7220-dpaa2-ethsw-Ethernet-Switch-driver.patch 195 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605
  1. From 8df017d70c54ceafc99b7904785603c678a2e5c1 Mon Sep 17 00:00:00 2001
  2. From: Razvan Stefanescu <razvan.stefanescu@freescale.com>
  3. Date: Tue, 22 Sep 2015 11:36:34 +0300
  4. Subject: [PATCH 220/226] dpaa2-ethsw: Ethernet Switch driver
  5. This is a commit of the cummulative, squashed dpaa2-l2switch patches.
  6. All the commit logs are preserved below.
  7. Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
  8. ---------------------------------------------------------------------
  9. dpaa2-ethsw: Ethernet Switch driver
  10. Initial support for DPAA2 L2 switch. The switch and all ports are
  11. presented as network interfaces in linux (swX and swXpY). I/O
  12. functionality is not available on these interfaces, they are exclusively
  13. for management.
  14. Configuration is done using bridge tool. Supported commands are:
  15. - fdb operations with unicast/multicast addresses
  16. - vlan configuration
  17. - setting STP state of ports
  18. - flooding, learning control
  19. Offers support for retrieving port statistics via ethtool (or similar
  20. applications).
  21. This patch contains the following patches squashed together:
  22. staging: fsl-dpaa2: ethsw: ethernet switch driver
  23. dpaa2-ethsw: Include by default in configuration
  24. staging: fsl-dpaa2: ethsw: Rebasing onto kernel 4.0
  25. staging: fsl-mc: migrated remaining flibs for MC fw 8.0.0
  26. dpaa2-ethsw: Prefix driver name with dpaa2-
  27. dpaa2-ethsw: Set carrier state on probe
  28. dpaa2-ethsw: Add support for link state update
  29. These patches were initally submitted by:
  30. Alex Marginean <alexandru.marginean@freescale.com>
  31. J. German Rivera <German.Rivera@freescale.com>
  32. Razvan Stefanescu <razvan.stefanescu@freescale.com>
  33. and reviewed by Stuart Yoder <stuart.yoder@freescale.com>
  34. Ported to linux-v4.1 by updating iflink usage and ndo_bridge_getlink()
  35. parameters list update.
  36. Signed-off-by: Razvan Stefanescu <razvan.stefanescu@freescale.com>
  37. [Stuart: resolved minor merge conflicts]
  38. Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
  39. dpaa2-ethsw: Update dpsw binary interface to 7.0
  40. This corresponds to MC release 0.8.0.
  41. Signed-off-by: Razvan Stefanescu <razvan.stefanescu@freescale.com>
  42. dpaa2-ethsw: Add object version check
  43. Abort probing if DPSW object version is smaller than required.
  44. Signed-off-by: Razvan Stefanescu <razvan.stefanescu@freescale.com>
  45. dpaa2-ethsw: Fix interrupt handling
  46. Mask only the events handled by the driver - DPSW_IRQ_EVENT_LINK_CHANGED.
  47. Use clear-on-read mechanism for the interrupt status and avoid calling
  48. dpsw_clear_irq_status(). Status contains the events handled (only link
  49. state change for the moment) and masks the first 16-bits, as they are used
  50. to store the interface ID that generated the event.
  51. Signed-off-by: Razvan Stefanescu <razvan.stefanescu@freescale.com>
  52. dpaa2-ethsw: resolve compile issues on uprev to 4.5
  53. -irq_number field no longer exists in fsl-mc interrupt
  54. struct
  55. -netdev_master_upper_dev_link() has 2 new parameters, which
  56. are set to NULL for now
  57. Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
  58. ---
  59. MAINTAINERS | 6 +
  60. drivers/staging/fsl-dpaa2/Kconfig | 1 +
  61. drivers/staging/fsl-dpaa2/Makefile | 1 +
  62. drivers/staging/fsl-dpaa2/ethsw/Kconfig | 7 +
  63. drivers/staging/fsl-dpaa2/ethsw/Makefile | 10 +
  64. drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 916 ++++++++++++
  65. drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 1639 +++++++++++++++++++++
  66. drivers/staging/fsl-dpaa2/ethsw/dpsw.h | 2164 ++++++++++++++++++++++++++++
  67. drivers/staging/fsl-dpaa2/ethsw/switch.c | 1711 ++++++++++++++++++++++
  68. drivers/staging/fsl-mc/include/net.h | 1 -
  69. 10 files changed, 6455 insertions(+), 1 deletion(-)
  70. create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Kconfig
  71. create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
  72. create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
  73. create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
  74. create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h
  75. create mode 100644 drivers/staging/fsl-dpaa2/ethsw/switch.c
  76. --- a/MAINTAINERS
  77. +++ b/MAINTAINERS
  78. @@ -4554,6 +4554,12 @@ S: Maintained
  79. F: drivers/staging/fsl-mc/bus/mc-ioctl.h
  80. F: drivers/staging/fsl-mc/bus/mc-restool.c
  81. +FREESCALE DPAA2 ETHERNET SWITCH DRIVER
  82. +M: Alex Marginean <Alexandru.Marginean@freescale.com>
  83. +L: linux-kernel@vger.kernel.org
  84. +S: Maintained
  85. +F: drivers/staging/fsl-dpaa2/ethsw/
  86. +
  87. FREESCALE DPAA2 MAC/PHY INTERFACE DRIVER
  88. M: Alex Marginean <Alexandru.Marginean@freescale.com>
  89. L: linux-kernel@vger.kernel.org
  90. --- a/drivers/staging/fsl-dpaa2/Kconfig
  91. +++ b/drivers/staging/fsl-dpaa2/Kconfig
  92. @@ -11,3 +11,4 @@ config FSL_DPAA2
  93. source "drivers/staging/fsl-dpaa2/ethernet/Kconfig"
  94. source "drivers/staging/fsl-dpaa2/mac/Kconfig"
  95. source "drivers/staging/fsl-dpaa2/evb/Kconfig"
  96. +source "drivers/staging/fsl-dpaa2/ethsw/Kconfig"
  97. --- a/drivers/staging/fsl-dpaa2/Makefile
  98. +++ b/drivers/staging/fsl-dpaa2/Makefile
  99. @@ -5,3 +5,4 @@
  100. obj-$(CONFIG_FSL_DPAA2_ETH) += ethernet/
  101. obj-$(CONFIG_FSL_DPAA2_MAC) += mac/
  102. obj-$(CONFIG_FSL_DPAA2_EVB) += evb/
  103. +obj-$(CONFIG_FSL_DPAA2_ETHSW) += ethsw/
  104. --- /dev/null
  105. +++ b/drivers/staging/fsl-dpaa2/ethsw/Kconfig
  106. @@ -0,0 +1,7 @@
  107. +config FSL_DPAA2_ETHSW
  108. + tristate "DPAA2 Ethernet Switch"
  109. + depends on FSL_MC_BUS && FSL_DPAA2 && FSL_DPAA2_ETH
  110. + select FSL_DPAA2_MAC
  111. + default y
  112. + ---help---
  113. + Prototype driver for DPAA2 Ethernet Switch.
  114. --- /dev/null
  115. +++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
  116. @@ -0,0 +1,10 @@
  117. +
  118. +obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
  119. +
  120. +dpaa2-ethsw-objs := switch.o dpsw.o
  121. +
  122. +all:
  123. + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
  124. +
  125. +clean:
  126. + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
  127. --- /dev/null
  128. +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
  129. @@ -0,0 +1,916 @@
  130. +/* Copyright 2013-2015 Freescale Semiconductor Inc.
  131. + *
  132. + * Redistribution and use in source and binary forms, with or without
  133. + * modification, are permitted provided that the following conditions are met:
  134. + * * Redistributions of source code must retain the above copyright
  135. + * notice, this list of conditions and the following disclaimer.
  136. + * * Redistributions in binary form must reproduce the above copyright
  137. + * notice, this list of conditions and the following disclaimer in the
  138. + * documentation and/or other materials provided with the distribution.
  139. + * * Neither the name of the above-listed copyright holders nor the
  140. + * names of any contributors may be used to endorse or promote products
  141. + * derived from this software without specific prior written permission.
  142. + *
  143. + *
  144. + * ALTERNATIVELY, this software may be distributed under the terms of the
  145. + * GNU General Public License ("GPL") as published by the Free Software
  146. + * Foundation, either version 2 of that License or (at your option) any
  147. + * later version.
  148. + *
  149. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  150. + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  151. + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  152. + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
  153. + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  154. + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  155. + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  156. + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  157. + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  158. + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  159. + * POSSIBILITY OF SUCH DAMAGE.
  160. + */
  161. +#ifndef __FSL_DPSW_CMD_H
  162. +#define __FSL_DPSW_CMD_H
  163. +
  164. +/* DPSW Version */
  165. +#define DPSW_VER_MAJOR 7
  166. +#define DPSW_VER_MINOR 0
  167. +
  168. +/* Command IDs */
  169. +#define DPSW_CMDID_CLOSE 0x800
  170. +#define DPSW_CMDID_OPEN 0x802
  171. +#define DPSW_CMDID_CREATE 0x902
  172. +#define DPSW_CMDID_DESTROY 0x900
  173. +
  174. +#define DPSW_CMDID_ENABLE 0x002
  175. +#define DPSW_CMDID_DISABLE 0x003
  176. +#define DPSW_CMDID_GET_ATTR 0x004
  177. +#define DPSW_CMDID_RESET 0x005
  178. +#define DPSW_CMDID_IS_ENABLED 0x006
  179. +
  180. +#define DPSW_CMDID_SET_IRQ 0x010
  181. +#define DPSW_CMDID_GET_IRQ 0x011
  182. +#define DPSW_CMDID_SET_IRQ_ENABLE 0x012
  183. +#define DPSW_CMDID_GET_IRQ_ENABLE 0x013
  184. +#define DPSW_CMDID_SET_IRQ_MASK 0x014
  185. +#define DPSW_CMDID_GET_IRQ_MASK 0x015
  186. +#define DPSW_CMDID_GET_IRQ_STATUS 0x016
  187. +#define DPSW_CMDID_CLEAR_IRQ_STATUS 0x017
  188. +
  189. +#define DPSW_CMDID_SET_REFLECTION_IF 0x022
  190. +
  191. +#define DPSW_CMDID_ADD_CUSTOM_TPID 0x024
  192. +
  193. +#define DPSW_CMDID_REMOVE_CUSTOM_TPID 0x026
  194. +
  195. +#define DPSW_CMDID_IF_SET_TCI 0x030
  196. +#define DPSW_CMDID_IF_SET_STP 0x031
  197. +#define DPSW_CMDID_IF_SET_ACCEPTED_FRAMES 0x032
  198. +#define DPSW_CMDID_SET_IF_ACCEPT_ALL_VLAN 0x033
  199. +#define DPSW_CMDID_IF_GET_COUNTER 0x034
  200. +#define DPSW_CMDID_IF_SET_COUNTER 0x035
  201. +#define DPSW_CMDID_IF_SET_TX_SELECTION 0x036
  202. +#define DPSW_CMDID_IF_ADD_REFLECTION 0x037
  203. +#define DPSW_CMDID_IF_REMOVE_REFLECTION 0x038
  204. +#define DPSW_CMDID_IF_SET_FLOODING_METERING 0x039
  205. +#define DPSW_CMDID_IF_SET_METERING 0x03A
  206. +#define DPSW_CMDID_IF_SET_EARLY_DROP 0x03B
  207. +
  208. +#define DPSW_CMDID_IF_ENABLE 0x03D
  209. +#define DPSW_CMDID_IF_DISABLE 0x03E
  210. +
  211. +#define DPSW_CMDID_IF_GET_ATTR 0x042
  212. +
  213. +#define DPSW_CMDID_IF_SET_MAX_FRAME_LENGTH 0x044
  214. +#define DPSW_CMDID_IF_GET_MAX_FRAME_LENGTH 0x045
  215. +#define DPSW_CMDID_IF_GET_LINK_STATE 0x046
  216. +#define DPSW_CMDID_IF_SET_FLOODING 0x047
  217. +#define DPSW_CMDID_IF_SET_BROADCAST 0x048
  218. +#define DPSW_CMDID_IF_SET_MULTICAST 0x049
  219. +#define DPSW_CMDID_IF_GET_TCI 0x04A
  220. +
  221. +#define DPSW_CMDID_IF_SET_LINK_CFG 0x04C
  222. +
  223. +#define DPSW_CMDID_VLAN_ADD 0x060
  224. +#define DPSW_CMDID_VLAN_ADD_IF 0x061
  225. +#define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED 0x062
  226. +#define DPSW_CMDID_VLAN_ADD_IF_FLOODING 0x063
  227. +#define DPSW_CMDID_VLAN_REMOVE_IF 0x064
  228. +#define DPSW_CMDID_VLAN_REMOVE_IF_UNTAGGED 0x065
  229. +#define DPSW_CMDID_VLAN_REMOVE_IF_FLOODING 0x066
  230. +#define DPSW_CMDID_VLAN_REMOVE 0x067
  231. +#define DPSW_CMDID_VLAN_GET_IF 0x068
  232. +#define DPSW_CMDID_VLAN_GET_IF_FLOODING 0x069
  233. +#define DPSW_CMDID_VLAN_GET_IF_UNTAGGED 0x06A
  234. +#define DPSW_CMDID_VLAN_GET_ATTRIBUTES 0x06B
  235. +
  236. +#define DPSW_CMDID_FDB_GET_MULTICAST 0x080
  237. +#define DPSW_CMDID_FDB_GET_UNICAST 0x081
  238. +#define DPSW_CMDID_FDB_ADD 0x082
  239. +#define DPSW_CMDID_FDB_REMOVE 0x083
  240. +#define DPSW_CMDID_FDB_ADD_UNICAST 0x084
  241. +#define DPSW_CMDID_FDB_REMOVE_UNICAST 0x085
  242. +#define DPSW_CMDID_FDB_ADD_MULTICAST 0x086
  243. +#define DPSW_CMDID_FDB_REMOVE_MULTICAST 0x087
  244. +#define DPSW_CMDID_FDB_SET_LEARNING_MODE 0x088
  245. +#define DPSW_CMDID_FDB_GET_ATTR 0x089
  246. +
  247. +#define DPSW_CMDID_ACL_ADD 0x090
  248. +#define DPSW_CMDID_ACL_REMOVE 0x091
  249. +#define DPSW_CMDID_ACL_ADD_ENTRY 0x092
  250. +#define DPSW_CMDID_ACL_REMOVE_ENTRY 0x093
  251. +#define DPSW_CMDID_ACL_ADD_IF 0x094
  252. +#define DPSW_CMDID_ACL_REMOVE_IF 0x095
  253. +#define DPSW_CMDID_ACL_GET_ATTR 0x096
  254. +
  255. +#define DPSW_CMDID_CTRL_IF_GET_ATTR 0x0A0
  256. +#define DPSW_CMDID_CTRL_IF_SET_POOLS 0x0A1
  257. +#define DPSW_CMDID_CTRL_IF_ENABLE 0x0A2
  258. +#define DPSW_CMDID_CTRL_IF_DISABLE 0x0A3
  259. +
  260. +/* cmd, param, offset, width, type, arg_name */
  261. +#define DPSW_CMD_OPEN(cmd, dpsw_id) \
  262. + MC_CMD_OP(cmd, 0, 0, 32, int, dpsw_id)
  263. +
  264. +/* cmd, param, offset, width, type, arg_name */
  265. +#define DPSW_CMD_CREATE(cmd, cfg) \
  266. +do { \
  267. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, cfg->num_ifs);\
  268. + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->adv.max_fdbs);\
  269. + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->adv.max_meters_per_if);\
  270. + MC_CMD_OP(cmd, 0, 32, 4, enum dpsw_component_type, \
  271. + cfg->adv.component_type);\
  272. + MC_CMD_OP(cmd, 1, 0, 16, uint16_t, cfg->adv.max_vlans);\
  273. + MC_CMD_OP(cmd, 1, 16, 16, uint16_t, cfg->adv.max_fdb_entries);\
  274. + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, cfg->adv.fdb_aging_time);\
  275. + MC_CMD_OP(cmd, 1, 48, 16, uint16_t, cfg->adv.max_fdb_mc_groups);\
  276. + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->adv.options);\
  277. +} while (0)
  278. +
  279. +/* cmd, param, offset, width, type, arg_name */
  280. +#define DPSW_RSP_IS_ENABLED(cmd, en) \
  281. + MC_RSP_OP(cmd, 0, 0, 1, int, en)
  282. +
  283. +/* cmd, param, offset, width, type, arg_name */
  284. +#define DPSW_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
  285. +do { \
  286. + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
  287. + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
  288. + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
  289. + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
  290. +} while (0)
  291. +
  292. +/* cmd, param, offset, width, type, arg_name */
  293. +#define DPSW_CMD_GET_IRQ(cmd, irq_index) \
  294. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
  295. +
  296. +/* cmd, param, offset, width, type, arg_name */
  297. +#define DPSW_RSP_GET_IRQ(cmd, type, irq_cfg) \
  298. +do { \
  299. + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
  300. + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
  301. + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
  302. + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
  303. +} while (0)
  304. +
  305. +/* cmd, param, offset, width, type, arg_name */
  306. +#define DPSW_CMD_SET_IRQ_ENABLE(cmd, irq_index, enable_state) \
  307. +do { \
  308. + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, enable_state); \
  309. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
  310. +} while (0)
  311. +
  312. +/* cmd, param, offset, width, type, arg_name */
  313. +#define DPSW_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
  314. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
  315. +
  316. +/* cmd, param, offset, width, type, arg_name */
  317. +#define DPSW_RSP_GET_IRQ_ENABLE(cmd, enable_state) \
  318. + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, enable_state)
  319. +
  320. +/* cmd, param, offset, width, type, arg_name */
  321. +#define DPSW_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
  322. +do { \
  323. + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
  324. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
  325. +} while (0)
  326. +
  327. +/* cmd, param, offset, width, type, arg_name */
  328. +#define DPSW_CMD_GET_IRQ_MASK(cmd, irq_index) \
  329. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
  330. +
  331. +/* cmd, param, offset, width, type, arg_name */
  332. +#define DPSW_RSP_GET_IRQ_MASK(cmd, mask) \
  333. + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
  334. +
  335. +/* cmd, param, offset, width, type, arg_name */
  336. +#define DPSW_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
  337. +do { \
  338. + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
  339. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
  340. +} while (0)
  341. +
  342. +/* cmd, param, offset, width, type, arg_name */
  343. +#define DPSW_RSP_GET_IRQ_STATUS(cmd, status) \
  344. + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
  345. +
  346. +/* cmd, param, offset, width, type, arg_name */
  347. +#define DPSW_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
  348. +do { \
  349. + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
  350. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
  351. +} while (0)
  352. +
  353. +/* cmd, param, offset, width, type, arg_name */
  354. +#define DPSW_RSP_GET_ATTR(cmd, attr) \
  355. +do { \
  356. + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, attr->num_ifs);\
  357. + MC_RSP_OP(cmd, 0, 16, 8, uint8_t, attr->max_fdbs);\
  358. + MC_RSP_OP(cmd, 0, 24, 8, uint8_t, attr->num_fdbs);\
  359. + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->max_vlans);\
  360. + MC_RSP_OP(cmd, 0, 48, 16, uint16_t, attr->num_vlans);\
  361. + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
  362. + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
  363. + MC_RSP_OP(cmd, 1, 32, 16, uint16_t, attr->max_fdb_entries);\
  364. + MC_RSP_OP(cmd, 1, 48, 16, uint16_t, attr->fdb_aging_time);\
  365. + MC_RSP_OP(cmd, 2, 0, 32, int, attr->id);\
  366. + MC_RSP_OP(cmd, 2, 32, 16, uint16_t, attr->mem_size);\
  367. + MC_RSP_OP(cmd, 2, 48, 16, uint16_t, attr->max_fdb_mc_groups);\
  368. + MC_RSP_OP(cmd, 3, 0, 64, uint64_t, attr->options);\
  369. + MC_RSP_OP(cmd, 4, 0, 8, uint8_t, attr->max_meters_per_if);\
  370. + MC_RSP_OP(cmd, 4, 8, 4, enum dpsw_component_type, \
  371. + attr->component_type);\
  372. +} while (0)
  373. +
  374. +/* cmd, param, offset, width, type, arg_name */
  375. +#define DPSW_CMD_SET_REFLECTION_IF(cmd, if_id) \
  376. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
  377. +
  378. +/* cmd, param, offset, width, type, arg_name */
  379. +#define DPSW_CMD_IF_SET_FLOODING(cmd, if_id, en) \
  380. +do { \
  381. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  382. + MC_CMD_OP(cmd, 0, 16, 1, int, en);\
  383. +} while (0)
  384. +
  385. +/* cmd, param, offset, width, type, arg_name */
  386. +#define DPSW_CMD_IF_SET_BROADCAST(cmd, if_id, en) \
  387. +do { \
  388. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  389. + MC_CMD_OP(cmd, 0, 16, 1, int, en);\
  390. +} while (0)
  391. +
  392. +/* cmd, param, offset, width, type, arg_name */
  393. +#define DPSW_CMD_IF_SET_MULTICAST(cmd, if_id, en) \
  394. +do { \
  395. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  396. + MC_CMD_OP(cmd, 0, 16, 1, int, en);\
  397. +} while (0)
  398. +
  399. +/* cmd, param, offset, width, type, arg_name */
  400. +#define DPSW_CMD_IF_SET_TCI(cmd, if_id, cfg) \
  401. +do { \
  402. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  403. + MC_CMD_OP(cmd, 0, 16, 12, uint16_t, cfg->vlan_id);\
  404. + MC_CMD_OP(cmd, 0, 28, 1, uint8_t, cfg->dei);\
  405. + MC_CMD_OP(cmd, 0, 29, 3, uint8_t, cfg->pcp);\
  406. +} while (0)
  407. +
  408. +/* cmd, param, offset, width, type, arg_name */
  409. +#define DPSW_CMD_IF_GET_TCI(cmd, if_id) \
  410. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
  411. +
  412. +/* cmd, param, offset, width, type, arg_name */
  413. +#define DPSW_RSP_IF_GET_TCI(cmd, cfg) \
  414. +do { \
  415. + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, cfg->vlan_id);\
  416. + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, cfg->dei);\
  417. + MC_RSP_OP(cmd, 0, 40, 8, uint8_t, cfg->pcp);\
  418. +} while (0)
  419. +
  420. +/* cmd, param, offset, width, type, arg_name */
  421. +#define DPSW_CMD_IF_SET_STP(cmd, if_id, cfg) \
  422. +do { \
  423. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  424. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->vlan_id);\
  425. + MC_CMD_OP(cmd, 0, 32, 4, enum dpsw_stp_state, cfg->state);\
  426. +} while (0)
  427. +
  428. +/* cmd, param, offset, width, type, arg_name */
  429. +#define DPSW_CMD_IF_SET_ACCEPTED_FRAMES(cmd, if_id, cfg) \
  430. +do { \
  431. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  432. + MC_CMD_OP(cmd, 0, 16, 4, enum dpsw_accepted_frames, cfg->type);\
  433. + MC_CMD_OP(cmd, 0, 20, 4, enum dpsw_action, cfg->unaccept_act);\
  434. +} while (0)
  435. +
  436. +/* cmd, param, offset, width, type, arg_name */
  437. +#define DPSW_CMD_IF_SET_ACCEPT_ALL_VLAN(cmd, if_id, accept_all) \
  438. +do { \
  439. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  440. + MC_CMD_OP(cmd, 0, 16, 1, int, accept_all);\
  441. +} while (0)
  442. +
  443. +/* cmd, param, offset, width, type, arg_name */
  444. +#define DPSW_CMD_IF_GET_COUNTER(cmd, if_id, type) \
  445. +do { \
  446. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  447. + MC_CMD_OP(cmd, 0, 16, 5, enum dpsw_counter, type);\
  448. +} while (0)
  449. +
  450. +/* cmd, param, offset, width, type, arg_name */
  451. +#define DPSW_RSP_IF_GET_COUNTER(cmd, counter) \
  452. + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, counter)
  453. +
  454. +/* cmd, param, offset, width, type, arg_name */
  455. +#define DPSW_CMD_IF_SET_COUNTER(cmd, if_id, type, counter) \
  456. +do { \
  457. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  458. + MC_CMD_OP(cmd, 0, 16, 5, enum dpsw_counter, type);\
  459. + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, counter);\
  460. +} while (0)
  461. +
  462. +/* cmd, param, offset, width, type, arg_name */
  463. +#define DPSW_CMD_IF_SET_TX_SELECTION(cmd, if_id, cfg) \
  464. +do { \
  465. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  466. + MC_CMD_OP(cmd, 0, 16, 3, enum dpsw_priority_selector, \
  467. + cfg->priority_selector);\
  468. + MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->tc_id[0]);\
  469. + MC_CMD_OP(cmd, 1, 8, 8, uint8_t, cfg->tc_id[1]);\
  470. + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->tc_id[2]);\
  471. + MC_CMD_OP(cmd, 1, 24, 8, uint8_t, cfg->tc_id[3]);\
  472. + MC_CMD_OP(cmd, 1, 32, 8, uint8_t, cfg->tc_id[4]);\
  473. + MC_CMD_OP(cmd, 1, 40, 8, uint8_t, cfg->tc_id[5]);\
  474. + MC_CMD_OP(cmd, 1, 48, 8, uint8_t, cfg->tc_id[6]);\
  475. + MC_CMD_OP(cmd, 1, 56, 8, uint8_t, cfg->tc_id[7]);\
  476. + MC_CMD_OP(cmd, 2, 0, 16, uint16_t, cfg->tc_sched[0].delta_bandwidth);\
  477. + MC_CMD_OP(cmd, 2, 16, 4, enum dpsw_schedule_mode, \
  478. + cfg->tc_sched[0].mode);\
  479. + MC_CMD_OP(cmd, 2, 32, 16, uint16_t, cfg->tc_sched[1].delta_bandwidth);\
  480. + MC_CMD_OP(cmd, 2, 48, 4, enum dpsw_schedule_mode, \
  481. + cfg->tc_sched[1].mode);\
  482. + MC_CMD_OP(cmd, 3, 0, 16, uint16_t, cfg->tc_sched[2].delta_bandwidth);\
  483. + MC_CMD_OP(cmd, 3, 16, 4, enum dpsw_schedule_mode, \
  484. + cfg->tc_sched[2].mode);\
  485. + MC_CMD_OP(cmd, 3, 32, 16, uint16_t, cfg->tc_sched[3].delta_bandwidth);\
  486. + MC_CMD_OP(cmd, 3, 48, 4, enum dpsw_schedule_mode, \
  487. + cfg->tc_sched[3].mode);\
  488. + MC_CMD_OP(cmd, 4, 0, 16, uint16_t, cfg->tc_sched[4].delta_bandwidth);\
  489. + MC_CMD_OP(cmd, 4, 16, 4, enum dpsw_schedule_mode, \
  490. + cfg->tc_sched[4].mode);\
  491. + MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->tc_sched[5].delta_bandwidth);\
  492. + MC_CMD_OP(cmd, 4, 48, 4, enum dpsw_schedule_mode, \
  493. + cfg->tc_sched[5].mode);\
  494. + MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->tc_sched[6].delta_bandwidth);\
  495. + MC_CMD_OP(cmd, 5, 16, 4, enum dpsw_schedule_mode, \
  496. + cfg->tc_sched[6].mode);\
  497. + MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->tc_sched[7].delta_bandwidth);\
  498. + MC_CMD_OP(cmd, 5, 48, 4, enum dpsw_schedule_mode, \
  499. + cfg->tc_sched[7].mode);\
  500. +} while (0)
  501. +
  502. +/* cmd, param, offset, width, type, arg_name */
  503. +#define DPSW_CMD_IF_ADD_REFLECTION(cmd, if_id, cfg) \
  504. +do { \
  505. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  506. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->vlan_id);\
  507. + MC_CMD_OP(cmd, 0, 32, 2, enum dpsw_reflection_filter, cfg->filter);\
  508. +} while (0)
  509. +
  510. +/* cmd, param, offset, width, type, arg_name */
  511. +#define DPSW_CMD_IF_REMOVE_REFLECTION(cmd, if_id, cfg) \
  512. +do { \
  513. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  514. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->vlan_id);\
  515. + MC_CMD_OP(cmd, 0, 32, 2, enum dpsw_reflection_filter, cfg->filter);\
  516. +} while (0)
  517. +
  518. +/* cmd, param, offset, width, type, arg_name */
  519. +#define DPSW_CMD_IF_SET_FLOODING_METERING(cmd, if_id, cfg) \
  520. +do { \
  521. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  522. + MC_CMD_OP(cmd, 0, 24, 4, enum dpsw_metering_mode, cfg->mode);\
  523. + MC_CMD_OP(cmd, 0, 28, 4, enum dpsw_metering_unit, cfg->units);\
  524. + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, cfg->cir);\
  525. + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->eir);\
  526. + MC_CMD_OP(cmd, 1, 32, 32, uint32_t, cfg->cbs);\
  527. + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->ebs);\
  528. +} while (0)
  529. +
  530. +/* cmd, param, offset, width, type, arg_name */
  531. +#define DPSW_CMD_IF_SET_METERING(cmd, if_id, tc_id, cfg) \
  532. +do { \
  533. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  534. + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id);\
  535. + MC_CMD_OP(cmd, 0, 24, 4, enum dpsw_metering_mode, cfg->mode);\
  536. + MC_CMD_OP(cmd, 0, 28, 4, enum dpsw_metering_unit, cfg->units);\
  537. + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, cfg->cir);\
  538. + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->eir);\
  539. + MC_CMD_OP(cmd, 1, 32, 32, uint32_t, cfg->cbs);\
  540. + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->ebs);\
  541. +} while (0)
  542. +
  543. +/* cmd, param, offset, width, type, arg_name */
  544. +#define DPSW_PREP_EARLY_DROP(ext, cfg) \
  545. +do { \
  546. + MC_PREP_OP(ext, 0, 0, 2, enum dpsw_early_drop_mode, cfg->drop_mode); \
  547. + MC_PREP_OP(ext, 0, 2, 2, \
  548. + enum dpsw_early_drop_unit, cfg->units); \
  549. + MC_PREP_OP(ext, 0, 32, 32, uint32_t, cfg->tail_drop_threshold); \
  550. + MC_PREP_OP(ext, 1, 0, 8, uint8_t, cfg->green.drop_probability); \
  551. + MC_PREP_OP(ext, 2, 0, 64, uint64_t, cfg->green.max_threshold); \
  552. + MC_PREP_OP(ext, 3, 0, 64, uint64_t, cfg->green.min_threshold); \
  553. + MC_PREP_OP(ext, 5, 0, 8, uint8_t, cfg->yellow.drop_probability);\
  554. + MC_PREP_OP(ext, 6, 0, 64, uint64_t, cfg->yellow.max_threshold); \
  555. + MC_PREP_OP(ext, 7, 0, 64, uint64_t, cfg->yellow.min_threshold); \
  556. +} while (0)
  557. +
  558. +/* cmd, param, offset, width, type, arg_name */
  559. +#define DPSW_EXT_EARLY_DROP(ext, cfg) \
  560. +do { \
  561. + MC_EXT_OP(ext, 0, 0, 2, enum dpsw_early_drop_mode, cfg->drop_mode); \
  562. + MC_EXT_OP(ext, 0, 2, 2, \
  563. + enum dpsw_early_drop_unit, cfg->units); \
  564. + MC_EXT_OP(ext, 0, 32, 32, uint32_t, cfg->tail_drop_threshold); \
  565. + MC_EXT_OP(ext, 1, 0, 8, uint8_t, cfg->green.drop_probability); \
  566. + MC_EXT_OP(ext, 2, 0, 64, uint64_t, cfg->green.max_threshold); \
  567. + MC_EXT_OP(ext, 3, 0, 64, uint64_t, cfg->green.min_threshold); \
  568. + MC_EXT_OP(ext, 5, 0, 8, uint8_t, cfg->yellow.drop_probability);\
  569. + MC_EXT_OP(ext, 6, 0, 64, uint64_t, cfg->yellow.max_threshold); \
  570. + MC_EXT_OP(ext, 7, 0, 64, uint64_t, cfg->yellow.min_threshold); \
  571. +} while (0)
  572. +
  573. +/* cmd, param, offset, width, type, arg_name */
  574. +#define DPSW_CMD_IF_SET_EARLY_DROP(cmd, if_id, tc_id, early_drop_iova) \
  575. +do { \
  576. + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc_id); \
  577. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, if_id); \
  578. + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, early_drop_iova); \
  579. +} while (0)
  580. +
  581. +/* cmd, param, offset, width, type, arg_name */
  582. +#define DPSW_CMD_ADD_CUSTOM_TPID(cmd, cfg) \
  583. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->tpid)
  584. +
  585. +/* cmd, param, offset, width, type, arg_name */
  586. +#define DPSW_CMD_REMOVE_CUSTOM_TPID(cmd, cfg) \
  587. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->tpid)
  588. +
  589. +/* cmd, param, offset, width, type, arg_name */
  590. +#define DPSW_CMD_IF_ENABLE(cmd, if_id) \
  591. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
  592. +
  593. +/* cmd, param, offset, width, type, arg_name */
  594. +#define DPSW_CMD_IF_DISABLE(cmd, if_id) \
  595. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
  596. +
  597. +/* cmd, param, offset, width, type, arg_name */
  598. +#define DPSW_CMD_IF_GET_ATTR(cmd, if_id) \
  599. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
  600. +
  601. +/* cmd, param, offset, width, type, arg_name */
  602. +#define DPSW_RSP_IF_GET_ATTR(cmd, attr) \
  603. +do { \
  604. + MC_RSP_OP(cmd, 0, 0, 4, enum dpsw_accepted_frames, \
  605. + attr->admit_untagged);\
  606. + MC_RSP_OP(cmd, 0, 5, 1, int, attr->enabled);\
  607. + MC_RSP_OP(cmd, 0, 6, 1, int, attr->accept_all_vlan);\
  608. + MC_RSP_OP(cmd, 0, 16, 8, uint8_t, attr->num_tcs);\
  609. + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qdid);\
  610. + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options);\
  611. + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->rate);\
  612. +} while (0)
  613. +
  614. +/* cmd, param, offset, width, type, arg_name */
  615. +#define DPSW_CMD_IF_SET_MAX_FRAME_LENGTH(cmd, if_id, frame_length) \
  616. +do { \
  617. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  618. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, frame_length);\
  619. +} while (0)
  620. +
  621. +/* cmd, param, offset, width, type, arg_name */
  622. +#define DPSW_CMD_IF_GET_MAX_FRAME_LENGTH(cmd, if_id) \
  623. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
  624. +
  625. +/* cmd, param, offset, width, type, arg_name */
  626. +#define DPSW_RSP_IF_GET_MAX_FRAME_LENGTH(cmd, frame_length) \
  627. + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, frame_length)
  628. +
  629. +/* cmd, param, offset, width, type, arg_name */
  630. +#define DPSW_CMD_IF_SET_LINK_CFG(cmd, if_id, cfg) \
  631. +do { \
  632. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
  633. + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\
  634. + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\
  635. +} while (0)
  636. +
  637. +/* cmd, param, offset, width, type, arg_name */
  638. +#define DPSW_CMD_IF_GET_LINK_STATE(cmd, if_id) \
  639. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
  640. +
  641. +/* cmd, param, offset, width, type, arg_name */
  642. +#define DPSW_RSP_IF_GET_LINK_STATE(cmd, state) \
  643. +do { \
  644. + MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\
  645. + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, state->rate);\
  646. + MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\
  647. +} while (0)
  648. +
  649. +/* cmd, param, offset, width, type, arg_name */
  650. +#define DPSW_CMD_VLAN_ADD(cmd, vlan_id, cfg) \
  651. +do { \
  652. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, cfg->fdb_id);\
  653. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id);\
  654. +} while (0)
  655. +
  656. +/* cmd, param, offset, width, type, arg_name */
  657. +#define DPSW_CMD_VLAN_ADD_IF(cmd, vlan_id) \
  658. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
  659. +
  660. +/* cmd, param, offset, width, type, arg_name */
  661. +#define DPSW_CMD_VLAN_ADD_IF_UNTAGGED(cmd, vlan_id) \
  662. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
  663. +
  664. +/* cmd, param, offset, width, type, arg_name */
  665. +#define DPSW_CMD_VLAN_ADD_IF_FLOODING(cmd, vlan_id) \
  666. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
  667. +
  668. +#define DPSW_CMD_VLAN_REMOVE_IF(cmd, vlan_id) \
  669. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
  670. +
  671. +/* cmd, param, offset, width, type, arg_name */
  672. +#define DPSW_CMD_VLAN_REMOVE_IF_UNTAGGED(cmd, vlan_id) \
  673. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
  674. +
  675. +/* cmd, param, offset, width, type, arg_name */
  676. +#define DPSW_CMD_VLAN_REMOVE_IF_FLOODING(cmd, vlan_id) \
  677. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
  678. +
  679. +/* cmd, param, offset, width, type, arg_name */
  680. +#define DPSW_CMD_VLAN_REMOVE(cmd, vlan_id) \
  681. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
  682. +
  683. +/* cmd, param, offset, width, type, arg_name */
  684. +#define DPSW_CMD_VLAN_GET_ATTR(cmd, vlan_id) \
  685. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, vlan_id)
  686. +
  687. +/* cmd, param, offset, width, type, arg_name */
  688. +#define DPSW_RSP_VLAN_GET_ATTR(cmd, attr) \
  689. +do { \
  690. + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->fdb_id); \
  691. + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->num_ifs); \
  692. + MC_RSP_OP(cmd, 1, 32, 16, uint16_t, attr->num_untagged_ifs); \
  693. + MC_RSP_OP(cmd, 1, 48, 16, uint16_t, attr->num_flooding_ifs); \
  694. +} while (0)
  695. +
  696. +/* cmd, param, offset, width, type, arg_name */
  697. +#define DPSW_CMD_VLAN_GET_IF(cmd, vlan_id) \
  698. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, vlan_id)
  699. +
  700. +/* cmd, param, offset, width, type, arg_name */
  701. +#define DPSW_RSP_VLAN_GET_IF(cmd, cfg) \
  702. + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs)
  703. +
  704. +/* cmd, param, offset, width, type, arg_name */
  705. +#define DPSW_CMD_VLAN_GET_IF_FLOODING(cmd, vlan_id) \
  706. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, vlan_id)
  707. +
  708. +/* cmd, param, offset, width, type, arg_name */
  709. +#define DPSW_RSP_VLAN_GET_IF_FLOODING(cmd, cfg) \
  710. + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs)
  711. +
  712. +/* cmd, param, offset, width, type, arg_name */
  713. +#define DPSW_CMD_VLAN_GET_IF_UNTAGGED(cmd, vlan_id) \
  714. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, vlan_id)
  715. +
  716. +/* cmd, param, offset, width, type, arg_name */
  717. +#define DPSW_RSP_VLAN_GET_IF_UNTAGGED(cmd, cfg) \
  718. + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs)
  719. +
  720. +/* param, offset, width, type, arg_name */
  721. +#define DPSW_CMD_FDB_ADD(cmd, cfg) \
  722. +do { \
  723. + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, cfg->fdb_aging_time);\
  724. + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, cfg->num_fdb_entries);\
  725. +} while (0)
  726. +
  727. +/* cmd, param, offset, width, type, arg_name */
  728. +#define DPSW_RSP_FDB_ADD(cmd, fdb_id) \
  729. + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, fdb_id)
  730. +
  731. +/* cmd, param, offset, width, type, arg_name */
  732. +#define DPSW_CMD_FDB_REMOVE(cmd, fdb_id) \
  733. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id)
  734. +
  735. +/* cmd, param, offset, width, type, arg_name */
  736. +#define DPSW_CMD_FDB_ADD_UNICAST(cmd, fdb_id, cfg) \
  737. +do { \
  738. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
  739. + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]);\
  740. + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]);\
  741. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]);\
  742. + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]);\
  743. + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]);\
  744. + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]);\
  745. + MC_CMD_OP(cmd, 1, 0, 8, uint16_t, cfg->if_egress);\
  746. + MC_CMD_OP(cmd, 1, 16, 4, enum dpsw_fdb_entry_type, cfg->type);\
  747. +} while (0)
  748. +
  749. +/* cmd, param, offset, width, type, arg_name */
  750. +#define DPSW_CMD_FDB_GET_UNICAST(cmd, fdb_id) \
  751. +do { \
  752. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
  753. + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]);\
  754. + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]);\
  755. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]);\
  756. + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]);\
  757. + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]);\
  758. + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]);\
  759. +} while (0)
  760. +
  761. +/* cmd, param, offset, width, type, arg_name */
  762. +#define DPSW_RSP_FDB_GET_UNICAST(cmd, cfg) \
  763. +do { \
  764. + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, cfg->if_egress);\
  765. + MC_RSP_OP(cmd, 1, 16, 4, enum dpsw_fdb_entry_type, cfg->type);\
  766. +} while (0)
  767. +
  768. +/* cmd, param, offset, width, type, arg_name */
  769. +#define DPSW_CMD_FDB_REMOVE_UNICAST(cmd, fdb_id, cfg) \
  770. +do { \
  771. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
  772. + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]);\
  773. + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]);\
  774. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]);\
  775. + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]);\
  776. + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]);\
  777. + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]);\
  778. + MC_CMD_OP(cmd, 1, 0, 16, uint16_t, cfg->if_egress);\
  779. + MC_CMD_OP(cmd, 1, 16, 4, enum dpsw_fdb_entry_type, cfg->type);\
  780. +} while (0)
  781. +
  782. +/* cmd, param, offset, width, type, arg_name */
  783. +#define DPSW_CMD_FDB_ADD_MULTICAST(cmd, fdb_id, cfg) \
  784. +do { \
  785. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
  786. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs);\
  787. + MC_CMD_OP(cmd, 0, 32, 4, enum dpsw_fdb_entry_type, cfg->type);\
  788. + MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->mac_addr[5]);\
  789. + MC_CMD_OP(cmd, 1, 8, 8, uint8_t, cfg->mac_addr[4]);\
  790. + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->mac_addr[3]);\
  791. + MC_CMD_OP(cmd, 1, 24, 8, uint8_t, cfg->mac_addr[2]);\
  792. + MC_CMD_OP(cmd, 1, 32, 8, uint8_t, cfg->mac_addr[1]);\
  793. + MC_CMD_OP(cmd, 1, 40, 8, uint8_t, cfg->mac_addr[0]);\
  794. +} while (0)
  795. +
  796. +/* cmd, param, offset, width, type, arg_name */
  797. +#define DPSW_CMD_FDB_GET_MULTICAST(cmd, fdb_id) \
  798. +do { \
  799. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
  800. + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]);\
  801. + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]);\
  802. + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]);\
  803. + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]);\
  804. + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]);\
  805. + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]);\
  806. +} while (0)
  807. +
  808. +/* cmd, param, offset, width, type, arg_name */
  809. +#define DPSW_RSP_FDB_GET_MULTICAST(cmd, cfg) \
  810. +do { \
  811. + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, cfg->num_ifs);\
  812. + MC_RSP_OP(cmd, 1, 16, 4, enum dpsw_fdb_entry_type, cfg->type);\
  813. +} while (0)
  814. +
  815. +/* cmd, param, offset, width, type, arg_name */
  816. +#define DPSW_CMD_FDB_REMOVE_MULTICAST(cmd, fdb_id, cfg) \
  817. +do { \
  818. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
  819. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs);\
  820. + MC_CMD_OP(cmd, 0, 32, 4, enum dpsw_fdb_entry_type, cfg->type);\
  821. + MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->mac_addr[5]);\
  822. + MC_CMD_OP(cmd, 1, 8, 8, uint8_t, cfg->mac_addr[4]);\
  823. + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->mac_addr[3]);\
  824. + MC_CMD_OP(cmd, 1, 24, 8, uint8_t, cfg->mac_addr[2]);\
  825. + MC_CMD_OP(cmd, 1, 32, 8, uint8_t, cfg->mac_addr[1]);\
  826. + MC_CMD_OP(cmd, 1, 40, 8, uint8_t, cfg->mac_addr[0]);\
  827. +} while (0)
  828. +
  829. +/* cmd, param, offset, width, type, arg_name */
  830. +#define DPSW_CMD_FDB_SET_LEARNING_MODE(cmd, fdb_id, mode) \
  831. +do { \
  832. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
  833. + MC_CMD_OP(cmd, 0, 16, 4, enum dpsw_fdb_learning_mode, mode);\
  834. +} while (0)
  835. +
  836. +/* cmd, param, offset, width, type, arg_name */
  837. +#define DPSW_CMD_FDB_GET_ATTR(cmd, fdb_id) \
  838. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id)
  839. +
  840. +/* cmd, param, offset, width, type, arg_name */
  841. +#define DPSW_RSP_FDB_GET_ATTR(cmd, attr) \
  842. +do { \
  843. + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->max_fdb_entries);\
  844. + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->fdb_aging_time);\
  845. + MC_RSP_OP(cmd, 0, 48, 16, uint16_t, attr->num_fdb_mc_groups);\
  846. + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->max_fdb_mc_groups);\
  847. + MC_RSP_OP(cmd, 1, 16, 4, enum dpsw_fdb_learning_mode, \
  848. + attr->learning_mode);\
  849. +} while (0)
  850. +
  851. +/* cmd, param, offset, width, type, arg_name */
  852. +#define DPSW_CMD_ACL_ADD(cmd, cfg) \
  853. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->max_entries)
  854. +
  855. +/* cmd, param, offset, width, type, arg_name */
  856. +#define DPSW_RSP_ACL_ADD(cmd, acl_id) \
  857. + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, acl_id)
  858. +
  859. +/* cmd, param, offset, width, type, arg_name */
  860. +#define DPSW_CMD_ACL_REMOVE(cmd, acl_id) \
  861. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id)
  862. +
  863. +/* cmd, param, offset, width, type, arg_name */
  864. +#define DPSW_PREP_ACL_ENTRY(ext, key) \
  865. +do { \
  866. + MC_PREP_OP(ext, 0, 0, 8, uint8_t, key->match.l2_dest_mac[5]);\
  867. + MC_PREP_OP(ext, 0, 8, 8, uint8_t, key->match.l2_dest_mac[4]);\
  868. + MC_PREP_OP(ext, 0, 16, 8, uint8_t, key->match.l2_dest_mac[3]);\
  869. + MC_PREP_OP(ext, 0, 24, 8, uint8_t, key->match.l2_dest_mac[2]);\
  870. + MC_PREP_OP(ext, 0, 32, 8, uint8_t, key->match.l2_dest_mac[1]);\
  871. + MC_PREP_OP(ext, 0, 40, 8, uint8_t, key->match.l2_dest_mac[0]);\
  872. + MC_PREP_OP(ext, 0, 48, 16, uint16_t, key->match.l2_tpid);\
  873. + MC_PREP_OP(ext, 1, 0, 8, uint8_t, key->match.l2_source_mac[5]);\
  874. + MC_PREP_OP(ext, 1, 8, 8, uint8_t, key->match.l2_source_mac[4]);\
  875. + MC_PREP_OP(ext, 1, 16, 8, uint8_t, key->match.l2_source_mac[3]);\
  876. + MC_PREP_OP(ext, 1, 24, 8, uint8_t, key->match.l2_source_mac[2]);\
  877. + MC_PREP_OP(ext, 1, 32, 8, uint8_t, key->match.l2_source_mac[1]);\
  878. + MC_PREP_OP(ext, 1, 40, 8, uint8_t, key->match.l2_source_mac[0]);\
  879. + MC_PREP_OP(ext, 1, 48, 16, uint16_t, key->match.l2_vlan_id);\
  880. + MC_PREP_OP(ext, 2, 0, 32, uint32_t, key->match.l3_dest_ip);\
  881. + MC_PREP_OP(ext, 2, 32, 32, uint32_t, key->match.l3_source_ip);\
  882. + MC_PREP_OP(ext, 3, 0, 16, uint16_t, key->match.l4_dest_port);\
  883. + MC_PREP_OP(ext, 3, 16, 16, uint16_t, key->match.l4_source_port);\
  884. + MC_PREP_OP(ext, 3, 32, 16, uint16_t, key->match.l2_ether_type);\
  885. + MC_PREP_OP(ext, 3, 48, 8, uint8_t, key->match.l2_pcp_dei);\
  886. + MC_PREP_OP(ext, 3, 56, 8, uint8_t, key->match.l3_dscp);\
  887. + MC_PREP_OP(ext, 4, 0, 8, uint8_t, key->mask.l2_dest_mac[5]);\
  888. + MC_PREP_OP(ext, 4, 8, 8, uint8_t, key->mask.l2_dest_mac[4]);\
  889. + MC_PREP_OP(ext, 4, 16, 8, uint8_t, key->mask.l2_dest_mac[3]);\
  890. + MC_PREP_OP(ext, 4, 24, 8, uint8_t, key->mask.l2_dest_mac[2]);\
  891. + MC_PREP_OP(ext, 4, 32, 8, uint8_t, key->mask.l2_dest_mac[1]);\
  892. + MC_PREP_OP(ext, 4, 40, 8, uint8_t, key->mask.l2_dest_mac[0]);\
  893. + MC_PREP_OP(ext, 4, 48, 16, uint16_t, key->mask.l2_tpid);\
  894. + MC_PREP_OP(ext, 5, 0, 8, uint8_t, key->mask.l2_source_mac[5]);\
  895. + MC_PREP_OP(ext, 5, 8, 8, uint8_t, key->mask.l2_source_mac[4]);\
  896. + MC_PREP_OP(ext, 5, 16, 8, uint8_t, key->mask.l2_source_mac[3]);\
  897. + MC_PREP_OP(ext, 5, 24, 8, uint8_t, key->mask.l2_source_mac[2]);\
  898. + MC_PREP_OP(ext, 5, 32, 8, uint8_t, key->mask.l2_source_mac[1]);\
  899. + MC_PREP_OP(ext, 5, 40, 8, uint8_t, key->mask.l2_source_mac[0]);\
  900. + MC_PREP_OP(ext, 5, 48, 16, uint16_t, key->mask.l2_vlan_id);\
  901. + MC_PREP_OP(ext, 6, 0, 32, uint32_t, key->mask.l3_dest_ip);\
  902. + MC_PREP_OP(ext, 6, 32, 32, uint32_t, key->mask.l3_source_ip);\
  903. + MC_PREP_OP(ext, 7, 0, 16, uint16_t, key->mask.l4_dest_port);\
  904. + MC_PREP_OP(ext, 7, 16, 16, uint16_t, key->mask.l4_source_port);\
  905. + MC_PREP_OP(ext, 7, 32, 16, uint16_t, key->mask.l2_ether_type);\
  906. + MC_PREP_OP(ext, 7, 48, 8, uint8_t, key->mask.l2_pcp_dei);\
  907. + MC_PREP_OP(ext, 7, 56, 8, uint8_t, key->mask.l3_dscp);\
  908. + MC_PREP_OP(ext, 8, 0, 8, uint8_t, key->match.l3_protocol);\
  909. + MC_PREP_OP(ext, 8, 8, 8, uint8_t, key->mask.l3_protocol);\
  910. +} while (0)
  911. +
  912. +/* cmd, param, offset, width, type, arg_name */
  913. +#define DPSW_EXT_ACL_ENTRY(ext, key) \
  914. +do { \
  915. + MC_EXT_OP(ext, 0, 0, 8, uint8_t, key->match.l2_dest_mac[5]);\
  916. + MC_EXT_OP(ext, 0, 8, 8, uint8_t, key->match.l2_dest_mac[4]);\
  917. + MC_EXT_OP(ext, 0, 16, 8, uint8_t, key->match.l2_dest_mac[3]);\
  918. + MC_EXT_OP(ext, 0, 24, 8, uint8_t, key->match.l2_dest_mac[2]);\
  919. + MC_EXT_OP(ext, 0, 32, 8, uint8_t, key->match.l2_dest_mac[1]);\
  920. + MC_EXT_OP(ext, 0, 40, 8, uint8_t, key->match.l2_dest_mac[0]);\
  921. + MC_EXT_OP(ext, 0, 48, 16, uint16_t, key->match.l2_tpid);\
  922. + MC_EXT_OP(ext, 1, 0, 8, uint8_t, key->match.l2_source_mac[5]);\
  923. + MC_EXT_OP(ext, 1, 8, 8, uint8_t, key->match.l2_source_mac[4]);\
  924. + MC_EXT_OP(ext, 1, 16, 8, uint8_t, key->match.l2_source_mac[3]);\
  925. + MC_EXT_OP(ext, 1, 24, 8, uint8_t, key->match.l2_source_mac[2]);\
  926. + MC_EXT_OP(ext, 1, 32, 8, uint8_t, key->match.l2_source_mac[1]);\
  927. + MC_EXT_OP(ext, 1, 40, 8, uint8_t, key->match.l2_source_mac[0]);\
  928. + MC_EXT_OP(ext, 1, 48, 16, uint16_t, key->match.l2_vlan_id);\
  929. + MC_EXT_OP(ext, 2, 0, 32, uint32_t, key->match.l3_dest_ip);\
  930. + MC_EXT_OP(ext, 2, 32, 32, uint32_t, key->match.l3_source_ip);\
  931. + MC_EXT_OP(ext, 3, 0, 16, uint16_t, key->match.l4_dest_port);\
  932. + MC_EXT_OP(ext, 3, 16, 16, uint16_t, key->match.l4_source_port);\
  933. + MC_EXT_OP(ext, 3, 32, 16, uint16_t, key->match.l2_ether_type);\
  934. + MC_EXT_OP(ext, 3, 48, 8, uint8_t, key->match.l2_pcp_dei);\
  935. + MC_EXT_OP(ext, 3, 56, 8, uint8_t, key->match.l3_dscp);\
  936. + MC_EXT_OP(ext, 4, 0, 8, uint8_t, key->mask.l2_dest_mac[5]);\
  937. + MC_EXT_OP(ext, 4, 8, 8, uint8_t, key->mask.l2_dest_mac[4]);\
  938. + MC_EXT_OP(ext, 4, 16, 8, uint8_t, key->mask.l2_dest_mac[3]);\
  939. + MC_EXT_OP(ext, 4, 24, 8, uint8_t, key->mask.l2_dest_mac[2]);\
  940. + MC_EXT_OP(ext, 4, 32, 8, uint8_t, key->mask.l2_dest_mac[1]);\
  941. + MC_EXT_OP(ext, 4, 40, 8, uint8_t, key->mask.l2_dest_mac[0]);\
  942. + MC_EXT_OP(ext, 4, 48, 16, uint16_t, key->mask.l2_tpid);\
  943. + MC_EXT_OP(ext, 5, 0, 8, uint8_t, key->mask.l2_source_mac[5]);\
  944. + MC_EXT_OP(ext, 5, 8, 8, uint8_t, key->mask.l2_source_mac[4]);\
  945. + MC_EXT_OP(ext, 5, 16, 8, uint8_t, key->mask.l2_source_mac[3]);\
  946. + MC_EXT_OP(ext, 5, 24, 8, uint8_t, key->mask.l2_source_mac[2]);\
  947. + MC_EXT_OP(ext, 5, 32, 8, uint8_t, key->mask.l2_source_mac[1]);\
  948. + MC_EXT_OP(ext, 5, 40, 8, uint8_t, key->mask.l2_source_mac[0]);\
  949. + MC_EXT_OP(ext, 5, 48, 16, uint16_t, key->mask.l2_vlan_id);\
  950. + MC_EXT_OP(ext, 6, 0, 32, uint32_t, key->mask.l3_dest_ip);\
  951. + MC_EXT_OP(ext, 6, 32, 32, uint32_t, key->mask.l3_source_ip);\
  952. + MC_EXT_OP(ext, 7, 0, 16, uint16_t, key->mask.l4_dest_port);\
  953. + MC_EXT_OP(ext, 7, 16, 16, uint16_t, key->mask.l4_source_port);\
  954. + MC_EXT_OP(ext, 7, 32, 16, uint16_t, key->mask.l2_ether_type);\
  955. + MC_EXT_OP(ext, 7, 48, 8, uint8_t, key->mask.l2_pcp_dei);\
  956. + MC_EXT_OP(ext, 7, 56, 8, uint8_t, key->mask.l3_dscp);\
  957. + MC_EXT_OP(ext, 8, 0, 8, uint8_t, key->match.l3_protocol);\
  958. + MC_EXT_OP(ext, 8, 8, 8, uint8_t, key->mask.l3_protocol);\
  959. +} while (0)
  960. +
  961. +/* cmd, param, offset, width, type, arg_name */
  962. +#define DPSW_CMD_ACL_ADD_ENTRY(cmd, acl_id, cfg) \
  963. +do { \
  964. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id);\
  965. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->result.if_id);\
  966. + MC_CMD_OP(cmd, 0, 32, 32, int, cfg->precedence);\
  967. + MC_CMD_OP(cmd, 1, 0, 4, enum dpsw_acl_action, cfg->result.action);\
  968. + MC_CMD_OP(cmd, 6, 0, 64, uint64_t, cfg->key_iova); \
  969. +} while (0)
  970. +
  971. +/* cmd, param, offset, width, type, arg_name */
  972. +#define DPSW_CMD_ACL_REMOVE_ENTRY(cmd, acl_id, cfg) \
  973. +do { \
  974. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id);\
  975. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->result.if_id);\
  976. + MC_CMD_OP(cmd, 0, 32, 32, int, cfg->precedence);\
  977. + MC_CMD_OP(cmd, 1, 0, 4, enum dpsw_acl_action, cfg->result.action);\
  978. + MC_CMD_OP(cmd, 6, 0, 64, uint64_t, cfg->key_iova); \
  979. +} while (0)
  980. +
  981. +/* cmd, param, offset, width, type, arg_name */
  982. +#define DPSW_CMD_ACL_ADD_IF(cmd, acl_id, cfg) \
  983. +do { \
  984. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id);\
  985. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs); \
  986. +} while (0)
  987. +
  988. +/* cmd, param, offset, width, type, arg_name */
  989. +#define DPSW_CMD_ACL_REMOVE_IF(cmd, acl_id, cfg) \
  990. +do { \
  991. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id);\
  992. + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs); \
  993. +} while (0)
  994. +
  995. +/* cmd, param, offset, width, type, arg_name */
  996. +#define DPSW_CMD_ACL_GET_ATTR(cmd, acl_id) \
  997. + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id)
  998. +
  999. +/* cmd, param, offset, width, type, arg_name */
  1000. +#define DPSW_RSP_ACL_GET_ATTR(cmd, attr) \
  1001. +do { \
  1002. + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->max_entries);\
  1003. + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->num_entries);\
  1004. + MC_RSP_OP(cmd, 1, 32, 16, uint16_t, attr->num_ifs);\
  1005. +} while (0)
  1006. +
  1007. +/* cmd, param, offset, width, type, arg_name */
  1008. +#define DPSW_RSP_CTRL_IF_GET_ATTR(cmd, attr) \
  1009. +do { \
  1010. + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->rx_fqid);\
  1011. + MC_RSP_OP(cmd, 1, 32, 32, uint32_t, attr->rx_err_fqid);\
  1012. + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->tx_err_conf_fqid);\
  1013. +} while (0)
  1014. +
  1015. +/* cmd, param, offset, width, type, arg_name */
  1016. +#define DPSW_CMD_CTRL_IF_SET_POOLS(cmd, cfg) \
  1017. +do { \
  1018. + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \
  1019. + MC_CMD_OP(cmd, 0, 8, 1, int, cfg->pools[0].backup_pool); \
  1020. + MC_CMD_OP(cmd, 0, 9, 1, int, cfg->pools[1].backup_pool); \
  1021. + MC_CMD_OP(cmd, 0, 10, 1, int, cfg->pools[2].backup_pool); \
  1022. + MC_CMD_OP(cmd, 0, 11, 1, int, cfg->pools[3].backup_pool); \
  1023. + MC_CMD_OP(cmd, 0, 12, 1, int, cfg->pools[4].backup_pool); \
  1024. + MC_CMD_OP(cmd, 0, 13, 1, int, cfg->pools[5].backup_pool); \
  1025. + MC_CMD_OP(cmd, 0, 14, 1, int, cfg->pools[6].backup_pool); \
  1026. + MC_CMD_OP(cmd, 0, 15, 1, int, cfg->pools[7].backup_pool); \
  1027. + MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \
  1028. + MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\
  1029. + MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \
  1030. + MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\
  1031. + MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \
  1032. + MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\
  1033. + MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \
  1034. + MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\
  1035. + MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \
  1036. + MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\
  1037. + MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \
  1038. + MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\
  1039. + MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \
  1040. + MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\
  1041. + MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \
  1042. + MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\
  1043. +} while (0)
  1044. +
  1045. +#endif /* __FSL_DPSW_CMD_H */
  1046. --- /dev/null
  1047. +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
  1048. @@ -0,0 +1,1639 @@
  1049. +/* Copyright 2013-2015 Freescale Semiconductor Inc.
  1050. + *
  1051. + * Redistribution and use in source and binary forms, with or without
  1052. + * modification, are permitted provided that the following conditions are met:
  1053. + * * Redistributions of source code must retain the above copyright
  1054. + * notice, this list of conditions and the following disclaimer.
  1055. + * * Redistributions in binary form must reproduce the above copyright
  1056. + * notice, this list of conditions and the following disclaimer in the
  1057. + * documentation and/or other materials provided with the distribution.
  1058. + * * Neither the name of the above-listed copyright holders nor the
  1059. + * names of any contributors may be used to endorse or promote products
  1060. + * derived from this software without specific prior written permission.
  1061. + *
  1062. + *
  1063. + * ALTERNATIVELY, this software may be distributed under the terms of the
  1064. + * GNU General Public License ("GPL") as published by the Free Software
  1065. + * Foundation, either version 2 of that License or (at your option) any
  1066. + * later version.
  1067. + *
  1068. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  1069. + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1070. + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1071. + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
  1072. + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  1073. + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  1074. + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  1075. + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  1076. + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  1077. + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  1078. + * POSSIBILITY OF SUCH DAMAGE.
  1079. + */
  1080. +#include "../../fsl-mc/include/mc-sys.h"
  1081. +#include "../../fsl-mc/include/mc-cmd.h"
  1082. +#include "dpsw.h"
  1083. +#include "dpsw-cmd.h"
  1084. +
  1085. +/* internal functions */
  1086. +static void build_if_id_bitmap(const uint16_t *if_id,
  1087. + const uint16_t num_ifs,
  1088. + struct mc_command *cmd,
  1089. + int start_param)
  1090. +{
  1091. + int i;
  1092. +
  1093. + for (i = 0; (i < num_ifs) && (i < DPSW_MAX_IF); i++)
  1094. + cmd->params[start_param + (if_id[i] / 64)] |= mc_enc(
  1095. + (if_id[i] % 64), 1, 1);
  1096. +}
  1097. +
  1098. +static int read_if_id_bitmap(uint16_t *if_id,
  1099. + uint16_t *num_ifs,
  1100. + struct mc_command *cmd,
  1101. + int start_param)
  1102. +{
  1103. + int bitmap[DPSW_MAX_IF] = { 0 };
  1104. + int i, j = 0;
  1105. + int count = 0;
  1106. +
  1107. + for (i = 0; i < DPSW_MAX_IF; i++) {
  1108. + bitmap[i] = (int)mc_dec(cmd->params[start_param + i / 64],
  1109. + i % 64, 1);
  1110. + count += bitmap[i];
  1111. + }
  1112. +
  1113. + *num_ifs = (uint16_t)count;
  1114. +
  1115. + for (i = 0; (i < DPSW_MAX_IF) && (j < count); i++) {
  1116. + if (bitmap[i]) {
  1117. + if_id[j] = (uint16_t)i;
  1118. + j++;
  1119. + }
  1120. + }
  1121. +
  1122. + return 0;
  1123. +}
  1124. +
  1125. +/* DPSW APIs */
  1126. +int dpsw_open(struct fsl_mc_io *mc_io,
  1127. + uint32_t cmd_flags,
  1128. + int dpsw_id,
  1129. + uint16_t *token)
  1130. +{
  1131. + struct mc_command cmd = { 0 };
  1132. + int err;
  1133. +
  1134. + /* prepare command */
  1135. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_OPEN,
  1136. + cmd_flags,
  1137. + 0);
  1138. + DPSW_CMD_OPEN(cmd, dpsw_id);
  1139. +
  1140. + /* send command to mc*/
  1141. + err = mc_send_command(mc_io, &cmd);
  1142. + if (err)
  1143. + return err;
  1144. +
  1145. + /* retrieve response parameters */
  1146. + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
  1147. +
  1148. + return 0;
  1149. +}
  1150. +
  1151. +int dpsw_close(struct fsl_mc_io *mc_io,
  1152. + uint32_t cmd_flags,
  1153. + uint16_t token)
  1154. +{
  1155. + struct mc_command cmd = { 0 };
  1156. +
  1157. + /* prepare command */
  1158. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CLOSE,
  1159. + cmd_flags,
  1160. + token);
  1161. +
  1162. + /* send command to mc*/
  1163. + return mc_send_command(mc_io, &cmd);
  1164. +}
  1165. +
  1166. +int dpsw_create(struct fsl_mc_io *mc_io,
  1167. + uint32_t cmd_flags,
  1168. + const struct dpsw_cfg *cfg,
  1169. + uint16_t *token)
  1170. +{
  1171. + struct mc_command cmd = { 0 };
  1172. + int err;
  1173. +
  1174. + /* prepare command */
  1175. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CREATE,
  1176. + cmd_flags,
  1177. + 0);
  1178. + DPSW_CMD_CREATE(cmd, cfg);
  1179. +
  1180. + /* send command to mc*/
  1181. + err = mc_send_command(mc_io, &cmd);
  1182. + if (err)
  1183. + return err;
  1184. +
  1185. + /* retrieve response parameters */
  1186. + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
  1187. +
  1188. + return 0;
  1189. +}
  1190. +
  1191. +int dpsw_destroy(struct fsl_mc_io *mc_io,
  1192. + uint32_t cmd_flags,
  1193. + uint16_t token)
  1194. +{
  1195. + struct mc_command cmd = { 0 };
  1196. +
  1197. + /* prepare command */
  1198. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_DESTROY,
  1199. + cmd_flags,
  1200. + token);
  1201. +
  1202. + /* send command to mc*/
  1203. + return mc_send_command(mc_io, &cmd);
  1204. +}
  1205. +
  1206. +int dpsw_enable(struct fsl_mc_io *mc_io,
  1207. + uint32_t cmd_flags,
  1208. + uint16_t token)
  1209. +{
  1210. + struct mc_command cmd = { 0 };
  1211. +
  1212. + /* prepare command */
  1213. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ENABLE,
  1214. + cmd_flags,
  1215. + token);
  1216. +
  1217. + /* send command to mc*/
  1218. + return mc_send_command(mc_io, &cmd);
  1219. +}
  1220. +
  1221. +int dpsw_disable(struct fsl_mc_io *mc_io,
  1222. + uint32_t cmd_flags,
  1223. + uint16_t token)
  1224. +{
  1225. + struct mc_command cmd = { 0 };
  1226. +
  1227. + /* prepare command */
  1228. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_DISABLE,
  1229. + cmd_flags,
  1230. + token);
  1231. +
  1232. + /* send command to mc*/
  1233. + return mc_send_command(mc_io, &cmd);
  1234. +}
  1235. +
  1236. +int dpsw_is_enabled(struct fsl_mc_io *mc_io,
  1237. + uint32_t cmd_flags,
  1238. + uint16_t token,
  1239. + int *en)
  1240. +{
  1241. + struct mc_command cmd = { 0 };
  1242. + int err;
  1243. +
  1244. + /* prepare command */
  1245. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IS_ENABLED, cmd_flags,
  1246. + token);
  1247. +
  1248. + /* send command to mc*/
  1249. + err = mc_send_command(mc_io, &cmd);
  1250. + if (err)
  1251. + return err;
  1252. +
  1253. + /* retrieve response parameters */
  1254. + DPSW_RSP_IS_ENABLED(cmd, *en);
  1255. +
  1256. + return 0;
  1257. +}
  1258. +
  1259. +int dpsw_reset(struct fsl_mc_io *mc_io,
  1260. + uint32_t cmd_flags,
  1261. + uint16_t token)
  1262. +{
  1263. + struct mc_command cmd = { 0 };
  1264. +
  1265. + /* prepare command */
  1266. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_RESET,
  1267. + cmd_flags,
  1268. + token);
  1269. +
  1270. + /* send command to mc*/
  1271. + return mc_send_command(mc_io, &cmd);
  1272. +}
  1273. +
  1274. +int dpsw_set_irq(struct fsl_mc_io *mc_io,
  1275. + uint32_t cmd_flags,
  1276. + uint16_t token,
  1277. + uint8_t irq_index,
  1278. + struct dpsw_irq_cfg *irq_cfg)
  1279. +{
  1280. + struct mc_command cmd = { 0 };
  1281. +
  1282. + /* prepare command */
  1283. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_SET_IRQ,
  1284. + cmd_flags,
  1285. + token);
  1286. + DPSW_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
  1287. +
  1288. + /* send command to mc*/
  1289. + return mc_send_command(mc_io, &cmd);
  1290. +}
  1291. +
  1292. +int dpsw_get_irq(struct fsl_mc_io *mc_io,
  1293. + uint32_t cmd_flags,
  1294. + uint16_t token,
  1295. + uint8_t irq_index,
  1296. + int *type,
  1297. + struct dpsw_irq_cfg *irq_cfg)
  1298. +{
  1299. + struct mc_command cmd = { 0 };
  1300. + int err;
  1301. +
  1302. + /* prepare command */
  1303. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_GET_IRQ,
  1304. + cmd_flags,
  1305. + token);
  1306. + DPSW_CMD_GET_IRQ(cmd, irq_index);
  1307. +
  1308. + /* send command to mc*/
  1309. + err = mc_send_command(mc_io, &cmd);
  1310. + if (err)
  1311. + return err;
  1312. +
  1313. + /* retrieve response parameters */
  1314. + DPSW_RSP_GET_IRQ(cmd, *type, irq_cfg);
  1315. +
  1316. + return 0;
  1317. +}
  1318. +
  1319. +int dpsw_set_irq_enable(struct fsl_mc_io *mc_io,
  1320. + uint32_t cmd_flags,
  1321. + uint16_t token,
  1322. + uint8_t irq_index,
  1323. + uint8_t en)
  1324. +{
  1325. + struct mc_command cmd = { 0 };
  1326. +
  1327. + /* prepare command */
  1328. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_SET_IRQ_ENABLE,
  1329. + cmd_flags,
  1330. + token);
  1331. + DPSW_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
  1332. +
  1333. + /* send command to mc*/
  1334. + return mc_send_command(mc_io, &cmd);
  1335. +}
  1336. +
  1337. +int dpsw_get_irq_enable(struct fsl_mc_io *mc_io,
  1338. + uint32_t cmd_flags,
  1339. + uint16_t token,
  1340. + uint8_t irq_index,
  1341. + uint8_t *en)
  1342. +{
  1343. + struct mc_command cmd = { 0 };
  1344. + int err;
  1345. +
  1346. + /* prepare command */
  1347. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_GET_IRQ_ENABLE,
  1348. + cmd_flags,
  1349. + token);
  1350. + DPSW_CMD_GET_IRQ_ENABLE(cmd, irq_index);
  1351. +
  1352. + /* send command to mc*/
  1353. + err = mc_send_command(mc_io, &cmd);
  1354. + if (err)
  1355. + return err;
  1356. +
  1357. + /* retrieve response parameters */
  1358. + DPSW_RSP_GET_IRQ_ENABLE(cmd, *en);
  1359. +
  1360. + return 0;
  1361. +}
  1362. +
  1363. +int dpsw_set_irq_mask(struct fsl_mc_io *mc_io,
  1364. + uint32_t cmd_flags,
  1365. + uint16_t token,
  1366. + uint8_t irq_index,
  1367. + uint32_t mask)
  1368. +{
  1369. + struct mc_command cmd = { 0 };
  1370. +
  1371. + /* prepare command */
  1372. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_SET_IRQ_MASK,
  1373. + cmd_flags,
  1374. + token);
  1375. + DPSW_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
  1376. +
  1377. + /* send command to mc*/
  1378. + return mc_send_command(mc_io, &cmd);
  1379. +}
  1380. +
  1381. +int dpsw_get_irq_mask(struct fsl_mc_io *mc_io,
  1382. + uint32_t cmd_flags,
  1383. + uint16_t token,
  1384. + uint8_t irq_index,
  1385. + uint32_t *mask)
  1386. +{
  1387. + struct mc_command cmd = { 0 };
  1388. + int err;
  1389. +
  1390. + /* prepare command */
  1391. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_GET_IRQ_MASK,
  1392. + cmd_flags,
  1393. + token);
  1394. + DPSW_CMD_GET_IRQ_MASK(cmd, irq_index);
  1395. +
  1396. + /* send command to mc*/
  1397. + err = mc_send_command(mc_io, &cmd);
  1398. + if (err)
  1399. + return err;
  1400. +
  1401. + /* retrieve response parameters */
  1402. + DPSW_RSP_GET_IRQ_MASK(cmd, *mask);
  1403. +
  1404. + return 0;
  1405. +}
  1406. +
  1407. +int dpsw_get_irq_status(struct fsl_mc_io *mc_io,
  1408. + uint32_t cmd_flags,
  1409. + uint16_t token,
  1410. + uint8_t irq_index,
  1411. + uint32_t *status)
  1412. +{
  1413. + struct mc_command cmd = { 0 };
  1414. + int err;
  1415. +
  1416. + /* prepare command */
  1417. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_GET_IRQ_STATUS,
  1418. + cmd_flags,
  1419. + token);
  1420. + DPSW_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
  1421. +
  1422. + /* send command to mc*/
  1423. + err = mc_send_command(mc_io, &cmd);
  1424. + if (err)
  1425. + return err;
  1426. +
  1427. + /* retrieve response parameters */
  1428. + DPSW_RSP_GET_IRQ_STATUS(cmd, *status);
  1429. +
  1430. + return 0;
  1431. +}
  1432. +
  1433. +int dpsw_clear_irq_status(struct fsl_mc_io *mc_io,
  1434. + uint32_t cmd_flags,
  1435. + uint16_t token,
  1436. + uint8_t irq_index,
  1437. + uint32_t status)
  1438. +{
  1439. + struct mc_command cmd = { 0 };
  1440. +
  1441. + /* prepare command */
  1442. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CLEAR_IRQ_STATUS,
  1443. + cmd_flags,
  1444. + token);
  1445. + DPSW_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
  1446. +
  1447. + /* send command to mc*/
  1448. + return mc_send_command(mc_io, &cmd);
  1449. +}
  1450. +
  1451. +int dpsw_get_attributes(struct fsl_mc_io *mc_io,
  1452. + uint32_t cmd_flags,
  1453. + uint16_t token,
  1454. + struct dpsw_attr *attr)
  1455. +{
  1456. + struct mc_command cmd = { 0 };
  1457. + int err;
  1458. +
  1459. + /* prepare command */
  1460. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_GET_ATTR,
  1461. + cmd_flags,
  1462. + token);
  1463. +
  1464. + /* send command to mc*/
  1465. + err = mc_send_command(mc_io, &cmd);
  1466. + if (err)
  1467. + return err;
  1468. +
  1469. + /* retrieve response parameters */
  1470. + DPSW_RSP_GET_ATTR(cmd, attr);
  1471. +
  1472. + return 0;
  1473. +}
  1474. +
  1475. +int dpsw_set_reflection_if(struct fsl_mc_io *mc_io,
  1476. + uint32_t cmd_flags,
  1477. + uint16_t token,
  1478. + uint16_t if_id)
  1479. +{
  1480. + struct mc_command cmd = { 0 };
  1481. +
  1482. + /* prepare command */
  1483. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_SET_REFLECTION_IF,
  1484. + cmd_flags,
  1485. + token);
  1486. + DPSW_CMD_SET_REFLECTION_IF(cmd, if_id);
  1487. +
  1488. + /* send command to mc*/
  1489. + return mc_send_command(mc_io, &cmd);
  1490. +}
  1491. +
  1492. +int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
  1493. + uint32_t cmd_flags,
  1494. + uint16_t token,
  1495. + uint16_t if_id,
  1496. + struct dpsw_link_cfg *cfg)
  1497. +{
  1498. + struct mc_command cmd = { 0 };
  1499. +
  1500. + /* prepare command */
  1501. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG,
  1502. + cmd_flags,
  1503. + token);
  1504. + DPSW_CMD_IF_SET_LINK_CFG(cmd, if_id, cfg);
  1505. +
  1506. + /* send command to mc*/
  1507. + return mc_send_command(mc_io, &cmd);
  1508. +}
  1509. +
  1510. +int dpsw_if_get_link_state(struct fsl_mc_io *mc_io,
  1511. + uint32_t cmd_flags,
  1512. + uint16_t token,
  1513. + uint16_t if_id,
  1514. + struct dpsw_link_state *state)
  1515. +{
  1516. + struct mc_command cmd = { 0 };
  1517. + int err;
  1518. +
  1519. + /* prepare command */
  1520. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_LINK_STATE,
  1521. + cmd_flags,
  1522. + token);
  1523. + DPSW_CMD_IF_GET_LINK_STATE(cmd, if_id);
  1524. +
  1525. + /* send command to mc*/
  1526. + err = mc_send_command(mc_io, &cmd);
  1527. + if (err)
  1528. + return err;
  1529. +
  1530. + /* retrieve response parameters */
  1531. + DPSW_RSP_IF_GET_LINK_STATE(cmd, state);
  1532. +
  1533. + return 0;
  1534. +}
  1535. +
  1536. +int dpsw_if_set_flooding(struct fsl_mc_io *mc_io,
  1537. + uint32_t cmd_flags,
  1538. + uint16_t token,
  1539. + uint16_t if_id,
  1540. + int en)
  1541. +{
  1542. + struct mc_command cmd = { 0 };
  1543. +
  1544. + /* prepare command */
  1545. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_FLOODING,
  1546. + cmd_flags,
  1547. + token);
  1548. + DPSW_CMD_IF_SET_FLOODING(cmd, if_id, en);
  1549. +
  1550. + /* send command to mc*/
  1551. + return mc_send_command(mc_io, &cmd);
  1552. +}
  1553. +
  1554. +int dpsw_if_set_broadcast(struct fsl_mc_io *mc_io,
  1555. + uint32_t cmd_flags,
  1556. + uint16_t token,
  1557. + uint16_t if_id,
  1558. + int en)
  1559. +{
  1560. + struct mc_command cmd = { 0 };
  1561. +
  1562. + /* prepare command */
  1563. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_BROADCAST,
  1564. + cmd_flags,
  1565. + token);
  1566. + DPSW_CMD_IF_SET_FLOODING(cmd, if_id, en);
  1567. +
  1568. + /* send command to mc*/
  1569. + return mc_send_command(mc_io, &cmd);
  1570. +}
  1571. +
  1572. +int dpsw_if_set_multicast(struct fsl_mc_io *mc_io,
  1573. + uint32_t cmd_flags,
  1574. + uint16_t token,
  1575. + uint16_t if_id,
  1576. + int en)
  1577. +{
  1578. + struct mc_command cmd = { 0 };
  1579. +
  1580. + /* prepare command */
  1581. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_MULTICAST,
  1582. + cmd_flags,
  1583. + token);
  1584. + DPSW_CMD_IF_SET_FLOODING(cmd, if_id, en);
  1585. +
  1586. + /* send command to mc*/
  1587. + return mc_send_command(mc_io, &cmd);
  1588. +}
  1589. +
  1590. +int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
  1591. + uint32_t cmd_flags,
  1592. + uint16_t token,
  1593. + uint16_t if_id,
  1594. + const struct dpsw_tci_cfg *cfg)
  1595. +{
  1596. + struct mc_command cmd = { 0 };
  1597. +
  1598. + /* prepare command */
  1599. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_TCI,
  1600. + cmd_flags,
  1601. + token);
  1602. + DPSW_CMD_IF_SET_TCI(cmd, if_id, cfg);
  1603. +
  1604. + /* send command to mc*/
  1605. + return mc_send_command(mc_io, &cmd);
  1606. +}
  1607. +
  1608. +int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
  1609. + uint32_t cmd_flags,
  1610. + uint16_t token,
  1611. + uint16_t if_id,
  1612. + struct dpsw_tci_cfg *cfg)
  1613. +{
  1614. + struct mc_command cmd = { 0 };
  1615. + int err = 0;
  1616. +
  1617. + /* prepare command */
  1618. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_TCI,
  1619. + cmd_flags,
  1620. + token);
  1621. + DPSW_CMD_IF_GET_TCI(cmd, if_id);
  1622. +
  1623. + /* send command to mc*/
  1624. + err = mc_send_command(mc_io, &cmd);
  1625. + if (err)
  1626. + return err;
  1627. +
  1628. + /* retrieve response parameters */
  1629. + DPSW_RSP_IF_GET_TCI(cmd, cfg);
  1630. +
  1631. + return 0;
  1632. +}
  1633. +
  1634. +int dpsw_if_set_stp(struct fsl_mc_io *mc_io,
  1635. + uint32_t cmd_flags,
  1636. + uint16_t token,
  1637. + uint16_t if_id,
  1638. + const struct dpsw_stp_cfg *cfg)
  1639. +{
  1640. + struct mc_command cmd = { 0 };
  1641. +
  1642. + /* prepare command */
  1643. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_STP,
  1644. + cmd_flags,
  1645. + token);
  1646. + DPSW_CMD_IF_SET_STP(cmd, if_id, cfg);
  1647. +
  1648. + /* send command to mc*/
  1649. + return mc_send_command(mc_io, &cmd);
  1650. +}
  1651. +
  1652. +int dpsw_if_set_accepted_frames(struct fsl_mc_io *mc_io,
  1653. + uint32_t cmd_flags,
  1654. + uint16_t token,
  1655. + uint16_t if_id,
  1656. + const struct dpsw_accepted_frames_cfg *cfg)
  1657. +{
  1658. + struct mc_command cmd = { 0 };
  1659. +
  1660. + /* prepare command */
  1661. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_ACCEPTED_FRAMES,
  1662. + cmd_flags,
  1663. + token);
  1664. + DPSW_CMD_IF_SET_ACCEPTED_FRAMES(cmd, if_id, cfg);
  1665. +
  1666. + /* send command to mc*/
  1667. + return mc_send_command(mc_io, &cmd);
  1668. +}
  1669. +
  1670. +int dpsw_if_set_accept_all_vlan(struct fsl_mc_io *mc_io,
  1671. + uint32_t cmd_flags,
  1672. + uint16_t token,
  1673. + uint16_t if_id,
  1674. + int accept_all)
  1675. +{
  1676. + struct mc_command cmd = { 0 };
  1677. +
  1678. + /* prepare command */
  1679. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_SET_IF_ACCEPT_ALL_VLAN,
  1680. + cmd_flags,
  1681. + token);
  1682. + DPSW_CMD_IF_SET_ACCEPT_ALL_VLAN(cmd, if_id, accept_all);
  1683. +
  1684. + /* send command to mc*/
  1685. + return mc_send_command(mc_io, &cmd);
  1686. +}
  1687. +
  1688. +int dpsw_if_get_counter(struct fsl_mc_io *mc_io,
  1689. + uint32_t cmd_flags,
  1690. + uint16_t token,
  1691. + uint16_t if_id,
  1692. + enum dpsw_counter type,
  1693. + uint64_t *counter)
  1694. +{
  1695. + struct mc_command cmd = { 0 };
  1696. + int err;
  1697. +
  1698. + /* prepare command */
  1699. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_COUNTER,
  1700. + cmd_flags,
  1701. + token);
  1702. + DPSW_CMD_IF_GET_COUNTER(cmd, if_id, type);
  1703. +
  1704. + /* send command to mc*/
  1705. + err = mc_send_command(mc_io, &cmd);
  1706. + if (err)
  1707. + return err;
  1708. +
  1709. + /* retrieve response parameters */
  1710. + DPSW_RSP_IF_GET_COUNTER(cmd, *counter);
  1711. +
  1712. + return 0;
  1713. +}
  1714. +
  1715. +int dpsw_if_set_counter(struct fsl_mc_io *mc_io,
  1716. + uint32_t cmd_flags,
  1717. + uint16_t token,
  1718. + uint16_t if_id,
  1719. + enum dpsw_counter type,
  1720. + uint64_t counter)
  1721. +{
  1722. + struct mc_command cmd = { 0 };
  1723. +
  1724. + /* prepare command */
  1725. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_COUNTER,
  1726. + cmd_flags,
  1727. + token);
  1728. + DPSW_CMD_IF_SET_COUNTER(cmd, if_id, type, counter);
  1729. +
  1730. + /* send command to mc*/
  1731. + return mc_send_command(mc_io, &cmd);
  1732. +}
  1733. +
  1734. +int dpsw_if_set_tx_selection(struct fsl_mc_io *mc_io,
  1735. + uint32_t cmd_flags,
  1736. + uint16_t token,
  1737. + uint16_t if_id,
  1738. + const struct dpsw_tx_selection_cfg *cfg)
  1739. +{
  1740. + struct mc_command cmd = { 0 };
  1741. +
  1742. + /* prepare command */
  1743. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_TX_SELECTION,
  1744. + cmd_flags,
  1745. + token);
  1746. + DPSW_CMD_IF_SET_TX_SELECTION(cmd, if_id, cfg);
  1747. +
  1748. + /* send command to mc*/
  1749. + return mc_send_command(mc_io, &cmd);
  1750. +}
  1751. +
  1752. +int dpsw_if_add_reflection(struct fsl_mc_io *mc_io,
  1753. + uint32_t cmd_flags,
  1754. + uint16_t token,
  1755. + uint16_t if_id,
  1756. + const struct dpsw_reflection_cfg *cfg)
  1757. +{
  1758. + struct mc_command cmd = { 0 };
  1759. +
  1760. + /* prepare command */
  1761. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_ADD_REFLECTION,
  1762. + cmd_flags,
  1763. + token);
  1764. + DPSW_CMD_IF_ADD_REFLECTION(cmd, if_id, cfg);
  1765. +
  1766. + /* send command to mc*/
  1767. + return mc_send_command(mc_io, &cmd);
  1768. +}
  1769. +
  1770. +int dpsw_if_remove_reflection(struct fsl_mc_io *mc_io,
  1771. + uint32_t cmd_flags,
  1772. + uint16_t token,
  1773. + uint16_t if_id,
  1774. + const struct dpsw_reflection_cfg *cfg)
  1775. +{
  1776. + struct mc_command cmd = { 0 };
  1777. +
  1778. + /* prepare command */
  1779. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_REMOVE_REFLECTION,
  1780. + cmd_flags,
  1781. + token);
  1782. + DPSW_CMD_IF_REMOVE_REFLECTION(cmd, if_id, cfg);
  1783. +
  1784. + /* send command to mc*/
  1785. + return mc_send_command(mc_io, &cmd);
  1786. +}
  1787. +
  1788. +int dpsw_if_set_flooding_metering(struct fsl_mc_io *mc_io,
  1789. + uint32_t cmd_flags,
  1790. + uint16_t token,
  1791. + uint16_t if_id,
  1792. + const struct dpsw_metering_cfg *cfg)
  1793. +{
  1794. + struct mc_command cmd = { 0 };
  1795. +
  1796. + /* prepare command */
  1797. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_FLOODING_METERING,
  1798. + cmd_flags,
  1799. + token);
  1800. + DPSW_CMD_IF_SET_FLOODING_METERING(cmd, if_id, cfg);
  1801. +
  1802. + /* send command to mc*/
  1803. + return mc_send_command(mc_io, &cmd);
  1804. +}
  1805. +
  1806. +int dpsw_if_set_metering(struct fsl_mc_io *mc_io,
  1807. + uint32_t cmd_flags,
  1808. + uint16_t token,
  1809. + uint16_t if_id,
  1810. + uint8_t tc_id,
  1811. + const struct dpsw_metering_cfg *cfg)
  1812. +{
  1813. + struct mc_command cmd = { 0 };
  1814. +
  1815. + /* prepare command */
  1816. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_METERING,
  1817. + cmd_flags,
  1818. + token);
  1819. + DPSW_CMD_IF_SET_METERING(cmd, if_id, tc_id, cfg);
  1820. +
  1821. + /* send command to mc*/
  1822. + return mc_send_command(mc_io, &cmd);
  1823. +}
  1824. +
  1825. +void dpsw_prepare_early_drop(const struct dpsw_early_drop_cfg *cfg,
  1826. + uint8_t *early_drop_buf)
  1827. +{
  1828. + uint64_t *ext_params = (uint64_t *)early_drop_buf;
  1829. +
  1830. + DPSW_PREP_EARLY_DROP(ext_params, cfg);
  1831. +}
  1832. +
  1833. +int dpsw_if_set_early_drop(struct fsl_mc_io *mc_io,
  1834. + uint32_t cmd_flags,
  1835. + uint16_t token,
  1836. + uint16_t if_id,
  1837. + uint8_t tc_id,
  1838. + uint64_t early_drop_iova)
  1839. +{
  1840. + struct mc_command cmd = { 0 };
  1841. +
  1842. + /* prepare command */
  1843. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_EARLY_DROP,
  1844. + cmd_flags,
  1845. + token);
  1846. + DPSW_CMD_IF_SET_EARLY_DROP(cmd, if_id, tc_id, early_drop_iova);
  1847. +
  1848. + /* send command to mc*/
  1849. + return mc_send_command(mc_io, &cmd);
  1850. +}
  1851. +
  1852. +int dpsw_add_custom_tpid(struct fsl_mc_io *mc_io,
  1853. + uint32_t cmd_flags,
  1854. + uint16_t token,
  1855. + const struct dpsw_custom_tpid_cfg *cfg)
  1856. +{
  1857. + struct mc_command cmd = { 0 };
  1858. +
  1859. + /* prepare command */
  1860. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ADD_CUSTOM_TPID,
  1861. + cmd_flags,
  1862. + token);
  1863. + DPSW_CMD_ADD_CUSTOM_TPID(cmd, cfg);
  1864. +
  1865. + /* send command to mc*/
  1866. + return mc_send_command(mc_io, &cmd);
  1867. +}
  1868. +
  1869. +int dpsw_remove_custom_tpid(struct fsl_mc_io *mc_io,
  1870. + uint32_t cmd_flags,
  1871. + uint16_t token,
  1872. + const struct dpsw_custom_tpid_cfg *cfg)
  1873. +{
  1874. + struct mc_command cmd = { 0 };
  1875. +
  1876. + /* prepare command */
  1877. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_REMOVE_CUSTOM_TPID,
  1878. + cmd_flags,
  1879. + token);
  1880. + DPSW_CMD_REMOVE_CUSTOM_TPID(cmd, cfg);
  1881. +
  1882. + /* send command to mc*/
  1883. + return mc_send_command(mc_io, &cmd);
  1884. +}
  1885. +
  1886. +int dpsw_if_enable(struct fsl_mc_io *mc_io,
  1887. + uint32_t cmd_flags,
  1888. + uint16_t token,
  1889. + uint16_t if_id)
  1890. +{
  1891. + struct mc_command cmd = { 0 };
  1892. +
  1893. + /* prepare command */
  1894. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_ENABLE,
  1895. + cmd_flags,
  1896. + token);
  1897. + DPSW_CMD_IF_ENABLE(cmd, if_id);
  1898. +
  1899. + /* send command to mc*/
  1900. + return mc_send_command(mc_io, &cmd);
  1901. +}
  1902. +
  1903. +int dpsw_if_disable(struct fsl_mc_io *mc_io,
  1904. + uint32_t cmd_flags,
  1905. + uint16_t token,
  1906. + uint16_t if_id)
  1907. +{
  1908. + struct mc_command cmd = { 0 };
  1909. +
  1910. + /* prepare command */
  1911. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_DISABLE,
  1912. + cmd_flags,
  1913. + token);
  1914. + DPSW_CMD_IF_DISABLE(cmd, if_id);
  1915. +
  1916. + /* send command to mc*/
  1917. + return mc_send_command(mc_io, &cmd);
  1918. +}
  1919. +
  1920. +int dpsw_if_get_attributes(struct fsl_mc_io *mc_io,
  1921. + uint32_t cmd_flags,
  1922. + uint16_t token,
  1923. + uint16_t if_id,
  1924. + struct dpsw_if_attr *attr)
  1925. +{
  1926. + struct mc_command cmd = { 0 };
  1927. + int err;
  1928. +
  1929. + /* prepare command */
  1930. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_ATTR,
  1931. + cmd_flags,
  1932. + token);
  1933. + DPSW_CMD_IF_GET_ATTR(cmd, if_id);
  1934. +
  1935. + /* send command to mc*/
  1936. + err = mc_send_command(mc_io, &cmd);
  1937. + if (err)
  1938. + return err;
  1939. +
  1940. + /* retrieve response parameters */
  1941. + DPSW_RSP_IF_GET_ATTR(cmd, attr);
  1942. +
  1943. + return 0;
  1944. +}
  1945. +
  1946. +int dpsw_if_set_max_frame_length(struct fsl_mc_io *mc_io,
  1947. + uint32_t cmd_flags,
  1948. + uint16_t token,
  1949. + uint16_t if_id,
  1950. + uint16_t frame_length)
  1951. +{
  1952. + struct mc_command cmd = { 0 };
  1953. +
  1954. + /* prepare command */
  1955. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_MAX_FRAME_LENGTH,
  1956. + cmd_flags,
  1957. + token);
  1958. + DPSW_CMD_IF_SET_MAX_FRAME_LENGTH(cmd, if_id, frame_length);
  1959. +
  1960. + /* send command to mc*/
  1961. + return mc_send_command(mc_io, &cmd);
  1962. +}
  1963. +
  1964. +int dpsw_if_get_max_frame_length(struct fsl_mc_io *mc_io,
  1965. + uint32_t cmd_flags,
  1966. + uint16_t token,
  1967. + uint16_t if_id,
  1968. + uint16_t *frame_length)
  1969. +{
  1970. + struct mc_command cmd = { 0 };
  1971. + int err;
  1972. +
  1973. + /* prepare command */
  1974. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_MAX_FRAME_LENGTH,
  1975. + cmd_flags,
  1976. + token);
  1977. + DPSW_CMD_IF_GET_MAX_FRAME_LENGTH(cmd, if_id);
  1978. +
  1979. + /* send command to mc*/
  1980. + err = mc_send_command(mc_io, &cmd);
  1981. + if (err)
  1982. + return err;
  1983. +
  1984. + DPSW_RSP_IF_GET_MAX_FRAME_LENGTH(cmd, *frame_length);
  1985. +
  1986. + return 0;
  1987. +}
  1988. +
  1989. +int dpsw_vlan_add(struct fsl_mc_io *mc_io,
  1990. + uint32_t cmd_flags,
  1991. + uint16_t token,
  1992. + uint16_t vlan_id,
  1993. + const struct dpsw_vlan_cfg *cfg)
  1994. +{
  1995. + struct mc_command cmd = { 0 };
  1996. +
  1997. + /* prepare command */
  1998. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_ADD,
  1999. + cmd_flags,
  2000. + token);
  2001. + DPSW_CMD_VLAN_ADD(cmd, vlan_id, cfg);
  2002. +
  2003. + /* send command to mc*/
  2004. + return mc_send_command(mc_io, &cmd);
  2005. +}
  2006. +
  2007. +int dpsw_vlan_add_if(struct fsl_mc_io *mc_io,
  2008. + uint32_t cmd_flags,
  2009. + uint16_t token,
  2010. + uint16_t vlan_id,
  2011. + const struct dpsw_vlan_if_cfg *cfg)
  2012. +{
  2013. + struct mc_command cmd = { 0 };
  2014. +
  2015. + /* prepare command */
  2016. + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
  2017. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_ADD_IF,
  2018. + cmd_flags,
  2019. + token);
  2020. + DPSW_CMD_VLAN_ADD_IF(cmd, vlan_id);
  2021. +
  2022. + /* send command to mc*/
  2023. + return mc_send_command(mc_io, &cmd);
  2024. +}
  2025. +
  2026. +int dpsw_vlan_add_if_untagged(struct fsl_mc_io *mc_io,
  2027. + uint32_t cmd_flags,
  2028. + uint16_t token,
  2029. + uint16_t vlan_id,
  2030. + const struct dpsw_vlan_if_cfg *cfg)
  2031. +{
  2032. + struct mc_command cmd = { 0 };
  2033. +
  2034. + /* prepare command */
  2035. + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
  2036. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_ADD_IF_UNTAGGED,
  2037. + cmd_flags,
  2038. + token);
  2039. + DPSW_CMD_VLAN_ADD_IF_UNTAGGED(cmd, vlan_id);
  2040. +
  2041. + /* send command to mc*/
  2042. + return mc_send_command(mc_io, &cmd);
  2043. +}
  2044. +
  2045. +int dpsw_vlan_add_if_flooding(struct fsl_mc_io *mc_io,
  2046. + uint32_t cmd_flags,
  2047. + uint16_t token,
  2048. + uint16_t vlan_id,
  2049. + const struct dpsw_vlan_if_cfg *cfg)
  2050. +{
  2051. + struct mc_command cmd = { 0 };
  2052. +
  2053. + /* prepare command */
  2054. + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
  2055. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_ADD_IF_FLOODING,
  2056. + cmd_flags,
  2057. + token);
  2058. + DPSW_CMD_VLAN_ADD_IF_FLOODING(cmd, vlan_id);
  2059. +
  2060. + /* send command to mc*/
  2061. + return mc_send_command(mc_io, &cmd);
  2062. +}
  2063. +
  2064. +int dpsw_vlan_remove_if(struct fsl_mc_io *mc_io,
  2065. + uint32_t cmd_flags,
  2066. + uint16_t token,
  2067. + uint16_t vlan_id,
  2068. + const struct dpsw_vlan_if_cfg *cfg)
  2069. +{
  2070. + struct mc_command cmd = { 0 };
  2071. +
  2072. + /* prepare command */
  2073. + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
  2074. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_REMOVE_IF,
  2075. + cmd_flags,
  2076. + token);
  2077. + DPSW_CMD_VLAN_REMOVE_IF(cmd, vlan_id);
  2078. +
  2079. + /* send command to mc*/
  2080. + return mc_send_command(mc_io, &cmd);
  2081. +}
  2082. +
  2083. +int dpsw_vlan_remove_if_untagged(struct fsl_mc_io *mc_io,
  2084. + uint32_t cmd_flags,
  2085. + uint16_t token,
  2086. + uint16_t vlan_id,
  2087. + const struct dpsw_vlan_if_cfg *cfg)
  2088. +{
  2089. + struct mc_command cmd = { 0 };
  2090. +
  2091. + /* prepare command */
  2092. + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
  2093. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_REMOVE_IF_UNTAGGED,
  2094. + cmd_flags,
  2095. + token);
  2096. + DPSW_CMD_VLAN_REMOVE_IF_UNTAGGED(cmd, vlan_id);
  2097. +
  2098. + /* send command to mc*/
  2099. + return mc_send_command(mc_io, &cmd);
  2100. +}
  2101. +
  2102. +int dpsw_vlan_remove_if_flooding(struct fsl_mc_io *mc_io,
  2103. + uint32_t cmd_flags,
  2104. + uint16_t token,
  2105. + uint16_t vlan_id,
  2106. + const struct dpsw_vlan_if_cfg *cfg)
  2107. +{
  2108. + struct mc_command cmd = { 0 };
  2109. +
  2110. + /* prepare command */
  2111. + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
  2112. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_REMOVE_IF_FLOODING,
  2113. + cmd_flags,
  2114. + token);
  2115. + DPSW_CMD_VLAN_REMOVE_IF_FLOODING(cmd, vlan_id);
  2116. +
  2117. + /* send command to mc*/
  2118. + return mc_send_command(mc_io, &cmd);
  2119. +}
  2120. +
  2121. +int dpsw_vlan_remove(struct fsl_mc_io *mc_io,
  2122. + uint32_t cmd_flags,
  2123. + uint16_t token,
  2124. + uint16_t vlan_id)
  2125. +{
  2126. + struct mc_command cmd = { 0 };
  2127. +
  2128. + /* prepare command */
  2129. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_REMOVE,
  2130. + cmd_flags,
  2131. + token);
  2132. + DPSW_CMD_VLAN_REMOVE(cmd, vlan_id);
  2133. +
  2134. + /* send command to mc*/
  2135. + return mc_send_command(mc_io, &cmd);
  2136. +}
  2137. +
  2138. +int dpsw_vlan_get_attributes(struct fsl_mc_io *mc_io,
  2139. + uint32_t cmd_flags,
  2140. + uint16_t token,
  2141. + uint16_t vlan_id,
  2142. + struct dpsw_vlan_attr *attr)
  2143. +{
  2144. + struct mc_command cmd = { 0 };
  2145. + int err;
  2146. +
  2147. + /* prepare command */
  2148. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_GET_ATTRIBUTES,
  2149. + cmd_flags,
  2150. + token);
  2151. + DPSW_CMD_VLAN_GET_ATTR(cmd, vlan_id);
  2152. +
  2153. + /* send command to mc*/
  2154. + err = mc_send_command(mc_io, &cmd);
  2155. + if (err)
  2156. + return err;
  2157. +
  2158. + /* retrieve response parameters */
  2159. + DPSW_RSP_VLAN_GET_ATTR(cmd, attr);
  2160. +
  2161. + return 0;
  2162. +}
  2163. +
  2164. +int dpsw_vlan_get_if(struct fsl_mc_io *mc_io,
  2165. + uint32_t cmd_flags,
  2166. + uint16_t token,
  2167. + uint16_t vlan_id,
  2168. + struct dpsw_vlan_if_cfg *cfg)
  2169. +{
  2170. + struct mc_command cmd = { 0 };
  2171. + int err;
  2172. +
  2173. + /* prepare command */
  2174. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_GET_IF,
  2175. + cmd_flags,
  2176. + token);
  2177. + DPSW_CMD_VLAN_GET_IF(cmd, vlan_id);
  2178. +
  2179. + /* send command to mc*/
  2180. + err = mc_send_command(mc_io, &cmd);
  2181. + if (err)
  2182. + return err;
  2183. +
  2184. + /* retrieve response parameters */
  2185. + DPSW_RSP_VLAN_GET_IF(cmd, cfg);
  2186. + read_if_id_bitmap(cfg->if_id, &cfg->num_ifs, &cmd, 1);
  2187. +
  2188. + return 0;
  2189. +}
  2190. +
  2191. +int dpsw_vlan_get_if_flooding(struct fsl_mc_io *mc_io,
  2192. + uint32_t cmd_flags,
  2193. + uint16_t token,
  2194. + uint16_t vlan_id,
  2195. + struct dpsw_vlan_if_cfg *cfg)
  2196. +{
  2197. + struct mc_command cmd = { 0 };
  2198. + int err;
  2199. +
  2200. + /* prepare command */
  2201. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_GET_IF_FLOODING,
  2202. + cmd_flags,
  2203. + token);
  2204. + DPSW_CMD_VLAN_GET_IF_FLOODING(cmd, vlan_id);
  2205. +
  2206. + /* send command to mc*/
  2207. + err = mc_send_command(mc_io, &cmd);
  2208. + if (err)
  2209. + return err;
  2210. +
  2211. + /* retrieve response parameters */
  2212. + DPSW_RSP_VLAN_GET_IF_FLOODING(cmd, cfg);
  2213. + read_if_id_bitmap(cfg->if_id, &cfg->num_ifs, &cmd, 1);
  2214. +
  2215. + return 0;
  2216. +}
  2217. +
  2218. +int dpsw_vlan_get_if_untagged(struct fsl_mc_io *mc_io,
  2219. + uint32_t cmd_flags,
  2220. + uint16_t token,
  2221. + uint16_t vlan_id,
  2222. + struct dpsw_vlan_if_cfg *cfg)
  2223. +{
  2224. + struct mc_command cmd = { 0 };
  2225. + int err;
  2226. +
  2227. + /* prepare command */
  2228. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_GET_IF_UNTAGGED,
  2229. + cmd_flags,
  2230. + token);
  2231. + DPSW_CMD_VLAN_GET_IF_UNTAGGED(cmd, vlan_id);
  2232. +
  2233. + /* send command to mc*/
  2234. + err = mc_send_command(mc_io, &cmd);
  2235. + if (err)
  2236. + return err;
  2237. +
  2238. + /* retrieve response parameters */
  2239. + DPSW_RSP_VLAN_GET_IF(cmd, cfg);
  2240. + read_if_id_bitmap(cfg->if_id, &cfg->num_ifs, &cmd, 1);
  2241. +
  2242. + return 0;
  2243. +}
  2244. +
  2245. +int dpsw_fdb_add(struct fsl_mc_io *mc_io,
  2246. + uint32_t cmd_flags,
  2247. + uint16_t token,
  2248. + uint16_t *fdb_id,
  2249. + const struct dpsw_fdb_cfg *cfg)
  2250. +{
  2251. + struct mc_command cmd = { 0 };
  2252. + int err;
  2253. +
  2254. + /* prepare command */
  2255. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_ADD,
  2256. + cmd_flags,
  2257. + token);
  2258. + DPSW_CMD_FDB_ADD(cmd, cfg);
  2259. +
  2260. + /* send command to mc*/
  2261. + err = mc_send_command(mc_io, &cmd);
  2262. + if (err)
  2263. + return err;
  2264. +
  2265. + /* retrieve response parameters */
  2266. + DPSW_RSP_FDB_ADD(cmd, *fdb_id);
  2267. +
  2268. + return 0;
  2269. +}
  2270. +
  2271. +int dpsw_fdb_remove(struct fsl_mc_io *mc_io,
  2272. + uint32_t cmd_flags,
  2273. + uint16_t token,
  2274. + uint16_t fdb_id)
  2275. +{
  2276. + struct mc_command cmd = { 0 };
  2277. +
  2278. + /* prepare command */
  2279. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_REMOVE,
  2280. + cmd_flags,
  2281. + token);
  2282. + DPSW_CMD_FDB_REMOVE(cmd, fdb_id);
  2283. +
  2284. + /* send command to mc*/
  2285. + return mc_send_command(mc_io, &cmd);
  2286. +}
  2287. +
  2288. +int dpsw_fdb_add_unicast(struct fsl_mc_io *mc_io,
  2289. + uint32_t cmd_flags,
  2290. + uint16_t token,
  2291. + uint16_t fdb_id,
  2292. + const struct dpsw_fdb_unicast_cfg *cfg)
  2293. +{
  2294. + struct mc_command cmd = { 0 };
  2295. +
  2296. + /* prepare command */
  2297. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_ADD_UNICAST,
  2298. + cmd_flags,
  2299. + token);
  2300. + DPSW_CMD_FDB_ADD_UNICAST(cmd, fdb_id, cfg);
  2301. +
  2302. + /* send command to mc*/
  2303. + return mc_send_command(mc_io, &cmd);
  2304. +}
  2305. +
  2306. +int dpsw_fdb_get_unicast(struct fsl_mc_io *mc_io,
  2307. + uint32_t cmd_flags,
  2308. + uint16_t token,
  2309. + uint16_t fdb_id,
  2310. + struct dpsw_fdb_unicast_cfg *cfg)
  2311. +{
  2312. + struct mc_command cmd = { 0 };
  2313. + int err;
  2314. +
  2315. + /* prepare command */
  2316. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_GET_UNICAST,
  2317. + cmd_flags,
  2318. + token);
  2319. + DPSW_CMD_FDB_GET_UNICAST(cmd, fdb_id);
  2320. +
  2321. + /* send command to mc*/
  2322. + err = mc_send_command(mc_io, &cmd);
  2323. + if (err)
  2324. + return err;
  2325. +
  2326. + /* retrieve response parameters */
  2327. + DPSW_RSP_FDB_GET_UNICAST(cmd, cfg);
  2328. +
  2329. + return 0;
  2330. +}
  2331. +
  2332. +int dpsw_fdb_remove_unicast(struct fsl_mc_io *mc_io,
  2333. + uint32_t cmd_flags,
  2334. + uint16_t token,
  2335. + uint16_t fdb_id,
  2336. + const struct dpsw_fdb_unicast_cfg *cfg)
  2337. +{
  2338. + struct mc_command cmd = { 0 };
  2339. +
  2340. + /* prepare command */
  2341. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_REMOVE_UNICAST,
  2342. + cmd_flags,
  2343. + token);
  2344. + DPSW_CMD_FDB_REMOVE_UNICAST(cmd, fdb_id, cfg);
  2345. +
  2346. + /* send command to mc*/
  2347. + return mc_send_command(mc_io, &cmd);
  2348. +}
  2349. +
  2350. +int dpsw_fdb_add_multicast(struct fsl_mc_io *mc_io,
  2351. + uint32_t cmd_flags,
  2352. + uint16_t token,
  2353. + uint16_t fdb_id,
  2354. + const struct dpsw_fdb_multicast_cfg *cfg)
  2355. +{
  2356. + struct mc_command cmd = { 0 };
  2357. +
  2358. + /* prepare command */
  2359. + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 2);
  2360. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_ADD_MULTICAST,
  2361. + cmd_flags,
  2362. + token);
  2363. + DPSW_CMD_FDB_ADD_MULTICAST(cmd, fdb_id, cfg);
  2364. +
  2365. + /* send command to mc*/
  2366. + return mc_send_command(mc_io, &cmd);
  2367. +}
  2368. +
  2369. +int dpsw_fdb_get_multicast(struct fsl_mc_io *mc_io,
  2370. + uint32_t cmd_flags,
  2371. + uint16_t token,
  2372. + uint16_t fdb_id,
  2373. + struct dpsw_fdb_multicast_cfg *cfg)
  2374. +{
  2375. + struct mc_command cmd = { 0 };
  2376. + int err;
  2377. +
  2378. + /* prepare command */
  2379. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_GET_MULTICAST,
  2380. + cmd_flags,
  2381. + token);
  2382. + DPSW_CMD_FDB_GET_MULTICAST(cmd, fdb_id);
  2383. +
  2384. + /* send command to mc*/
  2385. + err = mc_send_command(mc_io, &cmd);
  2386. + if (err)
  2387. + return err;
  2388. +
  2389. + /* retrieve response parameters */
  2390. + DPSW_RSP_FDB_GET_MULTICAST(cmd, cfg);
  2391. + read_if_id_bitmap(cfg->if_id, &cfg->num_ifs, &cmd, 2);
  2392. +
  2393. + return 0;
  2394. +}
  2395. +
  2396. +int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io,
  2397. + uint32_t cmd_flags,
  2398. + uint16_t token,
  2399. + uint16_t fdb_id,
  2400. + const struct dpsw_fdb_multicast_cfg *cfg)
  2401. +{
  2402. + struct mc_command cmd = { 0 };
  2403. +
  2404. + /* prepare command */
  2405. + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 2);
  2406. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_REMOVE_MULTICAST,
  2407. + cmd_flags,
  2408. + token);
  2409. + DPSW_CMD_FDB_REMOVE_MULTICAST(cmd, fdb_id, cfg);
  2410. +
  2411. + /* send command to mc*/
  2412. + return mc_send_command(mc_io, &cmd);
  2413. +}
  2414. +
  2415. +int dpsw_fdb_set_learning_mode(struct fsl_mc_io *mc_io,
  2416. + uint32_t cmd_flags,
  2417. + uint16_t token,
  2418. + uint16_t fdb_id,
  2419. + enum dpsw_fdb_learning_mode mode)
  2420. +{
  2421. + struct mc_command cmd = { 0 };
  2422. +
  2423. + /* prepare command */
  2424. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_SET_LEARNING_MODE,
  2425. + cmd_flags,
  2426. + token);
  2427. + DPSW_CMD_FDB_SET_LEARNING_MODE(cmd, fdb_id, mode);
  2428. +
  2429. + /* send command to mc*/
  2430. + return mc_send_command(mc_io, &cmd);
  2431. +}
  2432. +
  2433. +int dpsw_fdb_get_attributes(struct fsl_mc_io *mc_io,
  2434. + uint32_t cmd_flags,
  2435. + uint16_t token,
  2436. + uint16_t fdb_id,
  2437. + struct dpsw_fdb_attr *attr)
  2438. +{
  2439. + struct mc_command cmd = { 0 };
  2440. + int err;
  2441. +
  2442. + /* prepare command */
  2443. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_GET_ATTR,
  2444. + cmd_flags,
  2445. + token);
  2446. + DPSW_CMD_FDB_GET_ATTR(cmd, fdb_id);
  2447. +
  2448. + /* send command to mc*/
  2449. + err = mc_send_command(mc_io, &cmd);
  2450. + if (err)
  2451. + return err;
  2452. +
  2453. + /* retrieve response parameters */
  2454. + DPSW_RSP_FDB_GET_ATTR(cmd, attr);
  2455. +
  2456. + return 0;
  2457. +}
  2458. +
  2459. +int dpsw_acl_add(struct fsl_mc_io *mc_io,
  2460. + uint32_t cmd_flags,
  2461. + uint16_t token,
  2462. + uint16_t *acl_id,
  2463. + const struct dpsw_acl_cfg *cfg)
  2464. +{
  2465. + struct mc_command cmd = { 0 };
  2466. + int err;
  2467. +
  2468. + /* prepare command */
  2469. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_ADD,
  2470. + cmd_flags,
  2471. + token);
  2472. + DPSW_CMD_ACL_ADD(cmd, cfg);
  2473. +
  2474. + /* send command to mc*/
  2475. + err = mc_send_command(mc_io, &cmd);
  2476. + if (err)
  2477. + return err;
  2478. +
  2479. + /* retrieve response parameters */
  2480. + DPSW_RSP_ACL_ADD(cmd, *acl_id);
  2481. +
  2482. + return 0;
  2483. +}
  2484. +
  2485. +int dpsw_acl_remove(struct fsl_mc_io *mc_io,
  2486. + uint32_t cmd_flags,
  2487. + uint16_t token,
  2488. + uint16_t acl_id)
  2489. +{
  2490. + struct mc_command cmd = { 0 };
  2491. +
  2492. + /* prepare command */
  2493. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_REMOVE,
  2494. + cmd_flags,
  2495. + token);
  2496. + DPSW_CMD_ACL_REMOVE(cmd, acl_id);
  2497. +
  2498. + /* send command to mc*/
  2499. + return mc_send_command(mc_io, &cmd);
  2500. +}
  2501. +
  2502. +void dpsw_acl_prepare_entry_cfg(const struct dpsw_acl_key *key,
  2503. + uint8_t *entry_cfg_buf)
  2504. +{
  2505. + uint64_t *ext_params = (uint64_t *)entry_cfg_buf;
  2506. +
  2507. + DPSW_PREP_ACL_ENTRY(ext_params, key);
  2508. +}
  2509. +
  2510. +int dpsw_acl_add_entry(struct fsl_mc_io *mc_io,
  2511. + uint32_t cmd_flags,
  2512. + uint16_t token,
  2513. + uint16_t acl_id,
  2514. + const struct dpsw_acl_entry_cfg *cfg)
  2515. +{
  2516. + struct mc_command cmd = { 0 };
  2517. +
  2518. + /* prepare command */
  2519. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_ADD_ENTRY,
  2520. + cmd_flags,
  2521. + token);
  2522. + DPSW_CMD_ACL_ADD_ENTRY(cmd, acl_id, cfg);
  2523. +
  2524. + /* send command to mc*/
  2525. + return mc_send_command(mc_io, &cmd);
  2526. +}
  2527. +
  2528. +int dpsw_acl_remove_entry(struct fsl_mc_io *mc_io,
  2529. + uint32_t cmd_flags,
  2530. + uint16_t token,
  2531. + uint16_t acl_id,
  2532. + const struct dpsw_acl_entry_cfg *cfg)
  2533. +{
  2534. + struct mc_command cmd = { 0 };
  2535. +
  2536. + /* prepare command */
  2537. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_REMOVE_ENTRY,
  2538. + cmd_flags,
  2539. + token);
  2540. + DPSW_CMD_ACL_REMOVE_ENTRY(cmd, acl_id, cfg);
  2541. +
  2542. + /* send command to mc*/
  2543. + return mc_send_command(mc_io, &cmd);
  2544. +}
  2545. +
  2546. +int dpsw_acl_add_if(struct fsl_mc_io *mc_io,
  2547. + uint32_t cmd_flags,
  2548. + uint16_t token,
  2549. + uint16_t acl_id,
  2550. + const struct dpsw_acl_if_cfg *cfg)
  2551. +{
  2552. + struct mc_command cmd = { 0 };
  2553. +
  2554. + /* prepare command */
  2555. + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
  2556. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_ADD_IF,
  2557. + cmd_flags,
  2558. + token);
  2559. + DPSW_CMD_ACL_ADD_IF(cmd, acl_id, cfg);
  2560. +
  2561. + /* send command to mc*/
  2562. + return mc_send_command(mc_io, &cmd);
  2563. +}
  2564. +
  2565. +int dpsw_acl_remove_if(struct fsl_mc_io *mc_io,
  2566. + uint32_t cmd_flags,
  2567. + uint16_t token,
  2568. + uint16_t acl_id,
  2569. + const struct dpsw_acl_if_cfg *cfg)
  2570. +{
  2571. + struct mc_command cmd = { 0 };
  2572. +
  2573. + /* prepare command */
  2574. + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
  2575. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_REMOVE_IF,
  2576. + cmd_flags,
  2577. + token);
  2578. + DPSW_CMD_ACL_REMOVE_IF(cmd, acl_id, cfg);
  2579. +
  2580. + /* send command to mc*/
  2581. + return mc_send_command(mc_io, &cmd);
  2582. +}
  2583. +
  2584. +int dpsw_acl_get_attributes(struct fsl_mc_io *mc_io,
  2585. + uint32_t cmd_flags,
  2586. + uint16_t token,
  2587. + uint16_t acl_id,
  2588. + struct dpsw_acl_attr *attr)
  2589. +{
  2590. + struct mc_command cmd = { 0 };
  2591. + int err;
  2592. +
  2593. + /* prepare command */
  2594. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_GET_ATTR,
  2595. + cmd_flags,
  2596. + token);
  2597. + DPSW_CMD_ACL_GET_ATTR(cmd, acl_id);
  2598. +
  2599. + /* send command to mc*/
  2600. + err = mc_send_command(mc_io, &cmd);
  2601. + if (err)
  2602. + return err;
  2603. +
  2604. + /* retrieve response parameters */
  2605. + DPSW_RSP_ACL_GET_ATTR(cmd, attr);
  2606. +
  2607. + return 0;
  2608. +}
  2609. +
  2610. +int dpsw_ctrl_if_get_attributes(struct fsl_mc_io *mc_io,
  2611. + uint32_t cmd_flags,
  2612. + uint16_t token,
  2613. + struct dpsw_ctrl_if_attr *attr)
  2614. +{
  2615. + struct mc_command cmd = { 0 };
  2616. + int err;
  2617. +
  2618. + /* prepare command */
  2619. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CTRL_IF_GET_ATTR,
  2620. + cmd_flags,
  2621. + token);
  2622. +
  2623. + /* send command to mc*/
  2624. + err = mc_send_command(mc_io, &cmd);
  2625. + if (err)
  2626. + return err;
  2627. +
  2628. + /* retrieve response parameters */
  2629. + DPSW_RSP_CTRL_IF_GET_ATTR(cmd, attr);
  2630. +
  2631. + return 0;
  2632. +}
  2633. +
  2634. +int dpsw_ctrl_if_set_pools(struct fsl_mc_io *mc_io,
  2635. + uint32_t cmd_flags,
  2636. + uint16_t token,
  2637. + const struct dpsw_ctrl_if_pools_cfg *pools)
  2638. +{
  2639. + struct mc_command cmd = { 0 };
  2640. +
  2641. + /* prepare command */
  2642. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CTRL_IF_SET_POOLS,
  2643. + cmd_flags,
  2644. + token);
  2645. + DPSW_CMD_CTRL_IF_SET_POOLS(cmd, pools);
  2646. +
  2647. + /* send command to mc*/
  2648. + return mc_send_command(mc_io, &cmd);
  2649. +}
  2650. +
  2651. +int dpsw_ctrl_if_enable(struct fsl_mc_io *mc_io,
  2652. + uint32_t cmd_flags,
  2653. + uint16_t token)
  2654. +{
  2655. + struct mc_command cmd = { 0 };
  2656. +
  2657. + /* prepare command */
  2658. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CTRL_IF_ENABLE,
  2659. + cmd_flags,
  2660. + token);
  2661. +
  2662. + /* send command to mc*/
  2663. + return mc_send_command(mc_io, &cmd);
  2664. +}
  2665. +
  2666. +/**
  2667. +* @brief Function disables control interface
  2668. +* @mc_io: Pointer to MC portal's I/O object
  2669. +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2670. +* @token: Token of DPSW object
  2671. +*
  2672. +* Return: '0' on Success; Error code otherwise.
  2673. +*/
  2674. +int dpsw_ctrl_if_disable(struct fsl_mc_io *mc_io,
  2675. + uint32_t cmd_flags,
  2676. + uint16_t token)
  2677. +{
  2678. + struct mc_command cmd = { 0 };
  2679. +
  2680. + /* prepare command */
  2681. + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CTRL_IF_DISABLE,
  2682. + cmd_flags,
  2683. + token);
  2684. +
  2685. + /* send command to mc*/
  2686. + return mc_send_command(mc_io, &cmd);
  2687. +}
  2688. --- /dev/null
  2689. +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
  2690. @@ -0,0 +1,2164 @@
  2691. +/* Copyright 2013-2015 Freescale Semiconductor Inc.
  2692. + *
  2693. + * Redistribution and use in source and binary forms, with or without
  2694. + * modification, are permitted provided that the following conditions are met:
  2695. + * * Redistributions of source code must retain the above copyright
  2696. + * notice, this list of conditions and the following disclaimer.
  2697. + * * Redistributions in binary form must reproduce the above copyright
  2698. + * notice, this list of conditions and the following disclaimer in the
  2699. + * documentation and/or other materials provided with the distribution.
  2700. + * * Neither the name of the above-listed copyright holders nor the
  2701. + * names of any contributors may be used to endorse or promote products
  2702. + * derived from this software without specific prior written permission.
  2703. + *
  2704. + *
  2705. + * ALTERNATIVELY, this software may be distributed under the terms of the
  2706. + * GNU General Public License ("GPL") as published by the Free Software
  2707. + * Foundation, either version 2 of that License or (at your option) any
  2708. + * later version.
  2709. + *
  2710. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  2711. + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2712. + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2713. + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
  2714. + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  2715. + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  2716. + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  2717. + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  2718. + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  2719. + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  2720. + * POSSIBILITY OF SUCH DAMAGE.
  2721. + */
  2722. +#ifndef __FSL_DPSW_H
  2723. +#define __FSL_DPSW_H
  2724. +
  2725. +#include "../../fsl-mc/include/net.h"
  2726. +
  2727. +/* Data Path L2-Switch API
  2728. + * Contains API for handling DPSW topology and functionality
  2729. + */
  2730. +
  2731. +struct fsl_mc_io;
  2732. +
  2733. +/**
  2734. + * DPSW general definitions
  2735. + */
  2736. +
  2737. +/**
  2738. + * Maximum number of traffic class priorities
  2739. + */
  2740. +#define DPSW_MAX_PRIORITIES 8
  2741. +/**
  2742. + * Maximum number of interfaces
  2743. + */
  2744. +#define DPSW_MAX_IF 64
  2745. +
  2746. +/**
  2747. + * dpsw_open() - Open a control session for the specified object
  2748. + * @mc_io: Pointer to MC portal's I/O object
  2749. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2750. + * @dpsw_id: DPSW unique ID
  2751. + * @token: Returned token; use in subsequent API calls
  2752. + *
  2753. + * This function can be used to open a control session for an
  2754. + * already created object; an object may have been declared in
  2755. + * the DPL or by calling the dpsw_create() function.
  2756. + * This function returns a unique authentication token,
  2757. + * associated with the specific object ID and the specific MC
  2758. + * portal; this token must be used in all subsequent commands for
  2759. + * this specific object
  2760. + *
  2761. + * Return: '0' on Success; Error code otherwise.
  2762. + */
  2763. +int dpsw_open(struct fsl_mc_io *mc_io,
  2764. + uint32_t cmd_flags,
  2765. + int dpsw_id,
  2766. + uint16_t *token);
  2767. +
  2768. +/**
  2769. + * dpsw_close() - Close the control session of the object
  2770. + * @mc_io: Pointer to MC portal's I/O object
  2771. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2772. + * @token: Token of DPSW object
  2773. + *
  2774. + * After this function is called, no further operations are
  2775. + * allowed on the object without opening a new control session.
  2776. + *
  2777. + * Return: '0' on Success; Error code otherwise.
  2778. + */
  2779. +int dpsw_close(struct fsl_mc_io *mc_io,
  2780. + uint32_t cmd_flags,
  2781. + uint16_t token);
  2782. +
  2783. +/**
  2784. + * DPSW options
  2785. + */
  2786. +
  2787. +/**
  2788. + * Disable flooding
  2789. + */
  2790. +#define DPSW_OPT_FLOODING_DIS 0x0000000000000001ULL
  2791. +/**
  2792. + * Disable Multicast
  2793. + */
  2794. +#define DPSW_OPT_MULTICAST_DIS 0x0000000000000004ULL
  2795. +/**
  2796. + * Support control interface
  2797. + */
  2798. +#define DPSW_OPT_CTRL_IF_DIS 0x0000000000000010ULL
  2799. +/**
  2800. + * Disable flooding metering
  2801. + */
  2802. +#define DPSW_OPT_FLOODING_METERING_DIS 0x0000000000000020ULL
  2803. +/**
  2804. + * Enable metering
  2805. + */
  2806. +#define DPSW_OPT_METERING_EN 0x0000000000000040ULL
  2807. +
  2808. +/**
  2809. + * enum dpsw_component_type - component type of a bridge
  2810. + * @DPSW_COMPONENT_TYPE_C_VLAN: A C-VLAN component of an
  2811. + * enterprise VLAN bridge or of a Provider Bridge used
  2812. + * to process C-tagged frames
  2813. + * @DPSW_COMPONENT_TYPE_S_VLAN: An S-VLAN component of a
  2814. + * Provider Bridge
  2815. + *
  2816. + */
  2817. +enum dpsw_component_type {
  2818. + DPSW_COMPONENT_TYPE_C_VLAN = 0,
  2819. + DPSW_COMPONENT_TYPE_S_VLAN
  2820. +};
  2821. +
  2822. +/**
  2823. + * struct dpsw_cfg - DPSW configuration
  2824. + * @num_ifs: Number of external and internal interfaces
  2825. + * @adv: Advanced parameters; default is all zeros;
  2826. + * use this structure to change default settings
  2827. + */
  2828. +struct dpsw_cfg {
  2829. + uint16_t num_ifs;
  2830. + /**
  2831. + * struct adv - Advanced parameters
  2832. + * @options: Enable/Disable DPSW features (bitmap)
  2833. + * @max_vlans: Maximum Number of VLAN's; 0 - indicates default 16
  2834. + * @max_meters_per_if: Number of meters per interface
  2835. + * @max_fdbs: Maximum Number of FDB's; 0 - indicates default 16
  2836. + * @max_fdb_entries: Number of FDB entries for default FDB table;
  2837. + * 0 - indicates default 1024 entries.
  2838. + * @fdb_aging_time: Default FDB aging time for default FDB table;
  2839. + * 0 - indicates default 300 seconds
  2840. + * @max_fdb_mc_groups: Number of multicast groups in each FDB table;
  2841. + * 0 - indicates default 32
  2842. + * @component_type: Indicates the component type of this bridge
  2843. + */
  2844. + struct {
  2845. + uint64_t options;
  2846. + uint16_t max_vlans;
  2847. + uint8_t max_meters_per_if;
  2848. + uint8_t max_fdbs;
  2849. + uint16_t max_fdb_entries;
  2850. + uint16_t fdb_aging_time;
  2851. + uint16_t max_fdb_mc_groups;
  2852. + enum dpsw_component_type component_type;
  2853. + } adv;
  2854. +};
  2855. +
  2856. +/**
  2857. + * dpsw_create() - Create the DPSW object.
  2858. + * @mc_io: Pointer to MC portal's I/O object
  2859. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2860. + * @cfg: Configuration structure
  2861. + * @token: Returned token; use in subsequent API calls
  2862. + *
  2863. + * Create the DPSW object, allocate required resources and
  2864. + * perform required initialization.
  2865. + *
  2866. + * The object can be created either by declaring it in the
  2867. + * DPL file, or by calling this function.
  2868. + *
  2869. + * This function returns a unique authentication token,
  2870. + * associated with the specific object ID and the specific MC
  2871. + * portal; this token must be used in all subsequent calls to
  2872. + * this specific object. For objects that are created using the
  2873. + * DPL file, call dpsw_open() function to get an authentication
  2874. + * token first
  2875. + *
  2876. + * Return: '0' on Success; Error code otherwise.
  2877. + */
  2878. +int dpsw_create(struct fsl_mc_io *mc_io,
  2879. + uint32_t cmd_flags,
  2880. + const struct dpsw_cfg *cfg,
  2881. + uint16_t *token);
  2882. +
  2883. +/**
  2884. + * dpsw_destroy() - Destroy the DPSW object and release all its resources.
  2885. + * @mc_io: Pointer to MC portal's I/O object
  2886. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2887. + * @token: Token of DPSW object
  2888. + *
  2889. + * Return: '0' on Success; error code otherwise.
  2890. + */
  2891. +int dpsw_destroy(struct fsl_mc_io *mc_io,
  2892. + uint32_t cmd_flags,
  2893. + uint16_t token);
  2894. +
  2895. +/**
  2896. + * dpsw_enable() - Enable DPSW functionality
  2897. + * @mc_io: Pointer to MC portal's I/O object
  2898. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2899. + * @token: Token of DPSW object
  2900. + *
  2901. + * Return: Completion status. '0' on Success; Error code otherwise.
  2902. + */
  2903. +int dpsw_enable(struct fsl_mc_io *mc_io,
  2904. + uint32_t cmd_flags,
  2905. + uint16_t token);
  2906. +
  2907. +/**
  2908. + * dpsw_disable() - Disable DPSW functionality
  2909. + * @mc_io: Pointer to MC portal's I/O object
  2910. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2911. + * @token: Token of DPSW object
  2912. + *
  2913. + * Return: Completion status. '0' on Success; Error code otherwise.
  2914. + */
  2915. +int dpsw_disable(struct fsl_mc_io *mc_io,
  2916. + uint32_t cmd_flags,
  2917. + uint16_t token);
  2918. +
  2919. +/**
  2920. + * dpsw_is_enabled() - Check if the DPSW is enabled
  2921. + *
  2922. + * @mc_io: Pointer to MC portal's I/O object
  2923. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2924. + * @token: Token of DPSW object
  2925. + * @en: Returns '1' if object is enabled; '0' otherwise
  2926. + *
  2927. + * Return: '0' on Success; Error code otherwise
  2928. + */
  2929. +int dpsw_is_enabled(struct fsl_mc_io *mc_io,
  2930. + uint32_t cmd_flags,
  2931. + uint16_t token,
  2932. + int *en);
  2933. +
  2934. +/**
  2935. + * dpsw_reset() - Reset the DPSW, returns the object to initial state.
  2936. + * @mc_io: Pointer to MC portal's I/O object
  2937. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2938. + * @token: Token of DPSW object
  2939. + *
  2940. + * Return: '0' on Success; Error code otherwise.
  2941. + */
  2942. +int dpsw_reset(struct fsl_mc_io *mc_io,
  2943. + uint32_t cmd_flags,
  2944. + uint16_t token);
  2945. +
  2946. +/**
  2947. + * DPSW IRQ Index and Events
  2948. + */
  2949. +
  2950. +#define DPSW_IRQ_INDEX_IF 0x0000
  2951. +#define DPSW_IRQ_INDEX_L2SW 0x0001
  2952. +
  2953. +/**
  2954. + * IRQ event - Indicates that the link state changed
  2955. + */
  2956. +#define DPSW_IRQ_EVENT_LINK_CHANGED 0x0001
  2957. +
  2958. +/**
  2959. + * struct dpsw_irq_cfg - IRQ configuration
  2960. + * @addr: Address that must be written to signal a message-based interrupt
  2961. + * @val: Value to write into irq_addr address
  2962. + * @irq_num: A user defined number associated with this IRQ
  2963. + */
  2964. +struct dpsw_irq_cfg {
  2965. + uint64_t addr;
  2966. + uint32_t val;
  2967. + int irq_num;
  2968. +};
  2969. +
  2970. +/**
  2971. + * dpsw_set_irq() - Set IRQ information for the DPSW to trigger an interrupt.
  2972. + * @mc_io: Pointer to MC portal's I/O object
  2973. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2974. + * @token: Token of DPSW object
  2975. + * @irq_index: Identifies the interrupt index to configure
  2976. + * @irq_cfg: IRQ configuration
  2977. + *
  2978. + * Return: '0' on Success; Error code otherwise.
  2979. + */
  2980. +int dpsw_set_irq(struct fsl_mc_io *mc_io,
  2981. + uint32_t cmd_flags,
  2982. + uint16_t token,
  2983. + uint8_t irq_index,
  2984. + struct dpsw_irq_cfg *irq_cfg);
  2985. +
  2986. +/**
  2987. + * dpsw_get_irq() - Get IRQ information from the DPSW
  2988. + *
  2989. + * @mc_io: Pointer to MC portal's I/O object
  2990. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  2991. + * @token: Token of DPSW object
  2992. + * @irq_index: The interrupt index to configure
  2993. + * @type: Interrupt type: 0 represents message interrupt
  2994. + * type (both irq_addr and irq_val are valid)
  2995. + * @irq_cfg: IRQ attributes
  2996. + *
  2997. + * Return: '0' on Success; Error code otherwise.
  2998. + */
  2999. +int dpsw_get_irq(struct fsl_mc_io *mc_io,
  3000. + uint32_t cmd_flags,
  3001. + uint16_t token,
  3002. + uint8_t irq_index,
  3003. + int *type,
  3004. + struct dpsw_irq_cfg *irq_cfg);
  3005. +
  3006. +/**
  3007. + * dpsw_set_irq_enable() - Set overall interrupt state.
  3008. + * @mc_io: Pointer to MC portal's I/O object
  3009. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3010. + * @token: Token of DPCI object
  3011. + * @irq_index: The interrupt index to configure
  3012. + * @en: Interrupt state - enable = 1, disable = 0
  3013. + *
  3014. + * Allows GPP software to control when interrupts are generated.
  3015. + * Each interrupt can have up to 32 causes. The enable/disable control's the
  3016. + * overall interrupt state. if the interrupt is disabled no causes will cause
  3017. + * an interrupt
  3018. + *
  3019. + * Return: '0' on Success; Error code otherwise.
  3020. + */
  3021. +int dpsw_set_irq_enable(struct fsl_mc_io *mc_io,
  3022. + uint32_t cmd_flags,
  3023. + uint16_t token,
  3024. + uint8_t irq_index,
  3025. + uint8_t en);
  3026. +
  3027. +/**
  3028. + * dpsw_get_irq_enable() - Get overall interrupt state
  3029. + * @mc_io: Pointer to MC portal's I/O object
  3030. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3031. + * @token: Token of DPSW object
  3032. + * @irq_index: The interrupt index to configure
  3033. + * @en: Returned Interrupt state - enable = 1, disable = 0
  3034. + *
  3035. + * Return: '0' on Success; Error code otherwise.
  3036. + */
  3037. +int dpsw_get_irq_enable(struct fsl_mc_io *mc_io,
  3038. + uint32_t cmd_flags,
  3039. + uint16_t token,
  3040. + uint8_t irq_index,
  3041. + uint8_t *en);
  3042. +
  3043. +/**
  3044. + * dpsw_set_irq_mask() - Set interrupt mask.
  3045. + * @mc_io: Pointer to MC portal's I/O object
  3046. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3047. + * @token: Token of DPCI object
  3048. + * @irq_index: The interrupt index to configure
  3049. + * @mask: event mask to trigger interrupt;
  3050. + * each bit:
  3051. + * 0 = ignore event
  3052. + * 1 = consider event for asserting IRQ
  3053. + *
  3054. + * Every interrupt can have up to 32 causes and the interrupt model supports
  3055. + * masking/unmasking each cause independently
  3056. + *
  3057. + * Return: '0' on Success; Error code otherwise.
  3058. + */
  3059. +int dpsw_set_irq_mask(struct fsl_mc_io *mc_io,
  3060. + uint32_t cmd_flags,
  3061. + uint16_t token,
  3062. + uint8_t irq_index,
  3063. + uint32_t mask);
  3064. +
  3065. +/**
  3066. + * dpsw_get_irq_mask() - Get interrupt mask.
  3067. + * @mc_io: Pointer to MC portal's I/O object
  3068. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3069. + * @token: Token of DPSW object
  3070. + * @irq_index: The interrupt index to configure
  3071. + * @mask: Returned event mask to trigger interrupt
  3072. + *
  3073. + * Every interrupt can have up to 32 causes and the interrupt model supports
  3074. + * masking/unmasking each cause independently
  3075. + *
  3076. + * Return: '0' on Success; Error code otherwise.
  3077. + */
  3078. +int dpsw_get_irq_mask(struct fsl_mc_io *mc_io,
  3079. + uint32_t cmd_flags,
  3080. + uint16_t token,
  3081. + uint8_t irq_index,
  3082. + uint32_t *mask);
  3083. +
  3084. +/**
  3085. + * dpsw_get_irq_status() - Get the current status of any pending interrupts
  3086. + * @mc_io: Pointer to MC portal's I/O object
  3087. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3088. + * @token: Token of DPSW object
  3089. + * @irq_index: The interrupt index to configure
  3090. + * @status: Returned interrupts status - one bit per cause:
  3091. + * 0 = no interrupt pending
  3092. + * 1 = interrupt pending
  3093. + *
  3094. + * Return: '0' on Success; Error code otherwise.
  3095. + */
  3096. +int dpsw_get_irq_status(struct fsl_mc_io *mc_io,
  3097. + uint32_t cmd_flags,
  3098. + uint16_t token,
  3099. + uint8_t irq_index,
  3100. + uint32_t *status);
  3101. +
  3102. +/**
  3103. + * dpsw_clear_irq_status() - Clear a pending interrupt's status
  3104. + * @mc_io: Pointer to MC portal's I/O object
  3105. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3106. + * @token: Token of DPCI object
  3107. + * @irq_index: The interrupt index to configure
  3108. + * @status: bits to clear (W1C) - one bit per cause:
  3109. + * 0 = don't change
  3110. + * 1 = clear status bit
  3111. + *
  3112. + * Return: '0' on Success; Error code otherwise.
  3113. + */
  3114. +int dpsw_clear_irq_status(struct fsl_mc_io *mc_io,
  3115. + uint32_t cmd_flags,
  3116. + uint16_t token,
  3117. + uint8_t irq_index,
  3118. + uint32_t status);
  3119. +/**
  3120. + * struct dpsw_attr - Structure representing DPSW attributes
  3121. + * @id: DPSW object ID
  3122. + * @version: DPSW version
  3123. + * @options: Enable/Disable DPSW features
  3124. + * @max_vlans: Maximum Number of VLANs
  3125. + * @max_meters_per_if: Number of meters per interface
  3126. + * @max_fdbs: Maximum Number of FDBs
  3127. + * @max_fdb_entries: Number of FDB entries for default FDB table;
  3128. + * 0 - indicates default 1024 entries.
  3129. + * @fdb_aging_time: Default FDB aging time for default FDB table;
  3130. + * 0 - indicates default 300 seconds
  3131. + * @max_fdb_mc_groups: Number of multicast groups in each FDB table;
  3132. + * 0 - indicates default 32
  3133. + * @mem_size: DPSW frame storage memory size
  3134. + * @num_ifs: Number of interfaces
  3135. + * @num_vlans: Current number of VLANs
  3136. + * @num_fdbs: Current number of FDBs
  3137. + * @component_type: Component type of this bridge
  3138. + */
  3139. +struct dpsw_attr {
  3140. + int id;
  3141. + /**
  3142. + * struct version - DPSW version
  3143. + * @major: DPSW major version
  3144. + * @minor: DPSW minor version
  3145. + */
  3146. + struct {
  3147. + uint16_t major;
  3148. + uint16_t minor;
  3149. + } version;
  3150. + uint64_t options;
  3151. + uint16_t max_vlans;
  3152. + uint8_t max_meters_per_if;
  3153. + uint8_t max_fdbs;
  3154. + uint16_t max_fdb_entries;
  3155. + uint16_t fdb_aging_time;
  3156. + uint16_t max_fdb_mc_groups;
  3157. + uint16_t num_ifs;
  3158. + uint16_t mem_size;
  3159. + uint16_t num_vlans;
  3160. + uint8_t num_fdbs;
  3161. + enum dpsw_component_type component_type;
  3162. +};
  3163. +
  3164. +/**
  3165. + * dpsw_get_attributes() - Retrieve DPSW attributes
  3166. + * @mc_io: Pointer to MC portal's I/O object
  3167. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3168. + * @token: Token of DPSW object
  3169. + * @attr: Returned DPSW attributes
  3170. + *
  3171. + * Return: Completion status. '0' on Success; Error code otherwise.
  3172. + */
  3173. +int dpsw_get_attributes(struct fsl_mc_io *mc_io,
  3174. + uint32_t cmd_flags,
  3175. + uint16_t token,
  3176. + struct dpsw_attr *attr);
  3177. +
  3178. +/**
  3179. + * dpsw_set_reflection_if() - Set target interface for reflected interfaces.
  3180. + * @mc_io: Pointer to MC portal's I/O object
  3181. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3182. + * @token: Token of DPSW object
  3183. + * @if_id: Interface Id
  3184. + *
  3185. + * Only one reflection receive interface is allowed per switch
  3186. + *
  3187. + * Return: Completion status. '0' on Success; Error code otherwise.
  3188. + */
  3189. +int dpsw_set_reflection_if(struct fsl_mc_io *mc_io,
  3190. + uint32_t cmd_flags,
  3191. + uint16_t token,
  3192. + uint16_t if_id);
  3193. +
  3194. +/**
  3195. + * enum dpsw_action - Action selection for special/control frames
  3196. + * @DPSW_ACTION_DROP: Drop frame
  3197. + * @DPSW_ACTION_REDIRECT: Redirect frame to control port
  3198. + */
  3199. +enum dpsw_action {
  3200. + DPSW_ACTION_DROP = 0,
  3201. + DPSW_ACTION_REDIRECT = 1
  3202. +};
  3203. +
  3204. +/**
  3205. + * Enable auto-negotiation
  3206. + */
  3207. +#define DPSW_LINK_OPT_AUTONEG 0x0000000000000001ULL
  3208. +/**
  3209. + * Enable half-duplex mode
  3210. + */
  3211. +#define DPSW_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
  3212. +/**
  3213. + * Enable pause frames
  3214. + */
  3215. +#define DPSW_LINK_OPT_PAUSE 0x0000000000000004ULL
  3216. +/**
  3217. + * Enable a-symmetric pause frames
  3218. + */
  3219. +#define DPSW_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
  3220. +
  3221. +/**
  3222. + * struct dpsw_link_cfg - Structure representing DPSW link configuration
  3223. + * @rate: Rate
  3224. + * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
  3225. + */
  3226. +struct dpsw_link_cfg {
  3227. + uint32_t rate;
  3228. + uint64_t options;
  3229. +};
  3230. +
  3231. +/**
  3232. + * dpsw_if_set_link_cfg() - set the link configuration.
  3233. + * @mc_io: Pointer to MC portal's I/O object
  3234. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3235. + * @token: Token of DPSW object
  3236. + * @if_id: interface id
  3237. + * @cfg: Link configuration
  3238. + *
  3239. + * Return: '0' on Success; Error code otherwise.
  3240. + */
  3241. +int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
  3242. + uint32_t cmd_flags,
  3243. + uint16_t token,
  3244. + uint16_t if_id,
  3245. + struct dpsw_link_cfg *cfg);
  3246. +/**
  3247. + * struct dpsw_link_state - Structure representing DPSW link state
  3248. + * @rate: Rate
  3249. + * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
  3250. + * @up: 0 - covers two cases: down and disconnected, 1 - up
  3251. + */
  3252. +struct dpsw_link_state {
  3253. + uint32_t rate;
  3254. + uint64_t options;
  3255. + int up;
  3256. +};
  3257. +
  3258. +/**
  3259. + * dpsw_if_get_link_state - Return the link state
  3260. + * @mc_io: Pointer to MC portal's I/O object
  3261. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3262. + * @token: Token of DPSW object
  3263. + * @if_id: interface id
  3264. + * @state: link state 1 - linkup, 0 - link down or disconnected
  3265. + *
  3266. + * @returns '0' on Success; Error code otherwise.
  3267. + */
  3268. +int dpsw_if_get_link_state(struct fsl_mc_io *mc_io,
  3269. + uint32_t cmd_flags,
  3270. + uint16_t token,
  3271. + uint16_t if_id,
  3272. + struct dpsw_link_state *state);
  3273. +
  3274. +/**
  3275. + * dpsw_if_set_flooding() - Enable Disable flooding for particular interface
  3276. + * @mc_io: Pointer to MC portal's I/O object
  3277. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3278. + * @token: Token of DPSW object
  3279. + * @if_id: Interface Identifier
  3280. + * @en: 1 - enable, 0 - disable
  3281. + *
  3282. + * Return: Completion status. '0' on Success; Error code otherwise.
  3283. + */
  3284. +int dpsw_if_set_flooding(struct fsl_mc_io *mc_io,
  3285. + uint32_t cmd_flags,
  3286. + uint16_t token,
  3287. + uint16_t if_id,
  3288. + int en);
  3289. +
  3290. +/**
  3291. + * dpsw_if_set_broadcast() - Enable/disable broadcast for particular interface
  3292. + * @mc_io: Pointer to MC portal's I/O object
  3293. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3294. + * @token: Token of DPSW object
  3295. + * @if_id: Interface Identifier
  3296. + * @en: 1 - enable, 0 - disable
  3297. + *
  3298. + * Return: Completion status. '0' on Success; Error code otherwise.
  3299. + */
  3300. +int dpsw_if_set_broadcast(struct fsl_mc_io *mc_io,
  3301. + uint32_t cmd_flags,
  3302. + uint16_t token,
  3303. + uint16_t if_id,
  3304. + int en);
  3305. +
  3306. +/**
  3307. + * dpsw_if_set_multicast() - Enable/disable multicast for particular interface
  3308. + * @mc_io: Pointer to MC portal's I/O object
  3309. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3310. + * @token: Token of DPSW object
  3311. + * @if_id: Interface Identifier
  3312. + * @en: 1 - enable, 0 - disable
  3313. + *
  3314. + * Return: Completion status. '0' on Success; Error code otherwise.
  3315. + */
  3316. +int dpsw_if_set_multicast(struct fsl_mc_io *mc_io,
  3317. + uint32_t cmd_flags,
  3318. + uint16_t token,
  3319. + uint16_t if_id,
  3320. + int en);
  3321. +
  3322. +/**
  3323. + * struct dpsw_tci_cfg - Tag Contorl Information (TCI) configuration
  3324. + * @pcp: Priority Code Point (PCP): a 3-bit field which refers
  3325. + * to the IEEE 802.1p priority
  3326. + * @dei: Drop Eligible Indicator (DEI): a 1-bit field. May be used
  3327. + * separately or in conjunction with PCP to indicate frames
  3328. + * eligible to be dropped in the presence of congestion
  3329. + * @vlan_id: VLAN Identifier (VID): a 12-bit field specifying the VLAN
  3330. + * to which the frame belongs. The hexadecimal values
  3331. + * of 0x000 and 0xFFF are reserved;
  3332. + * all other values may be used as VLAN identifiers,
  3333. + * allowing up to 4,094 VLANs
  3334. + */
  3335. +struct dpsw_tci_cfg {
  3336. + uint8_t pcp;
  3337. + uint8_t dei;
  3338. + uint16_t vlan_id;
  3339. +};
  3340. +
  3341. +/**
  3342. + * dpsw_if_set_tci() - Set default VLAN Tag Control Information (TCI)
  3343. + * @mc_io: Pointer to MC portal's I/O object
  3344. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3345. + * @token: Token of DPSW object
  3346. + * @if_id: Interface Identifier
  3347. + * @cfg: Tag Control Information Configuration
  3348. + *
  3349. + * Return: Completion status. '0' on Success; Error code otherwise.
  3350. + */
  3351. +int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
  3352. + uint32_t cmd_flags,
  3353. + uint16_t token,
  3354. + uint16_t if_id,
  3355. + const struct dpsw_tci_cfg *cfg);
  3356. +
  3357. +/**
  3358. + * dpsw_if_get_tci() - Get default VLAN Tag Control Information (TCI)
  3359. + * @mc_io: Pointer to MC portal's I/O object
  3360. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3361. + * @token: Token of DPSW object
  3362. + * @if_id: Interface Identifier
  3363. + * @cfg: Tag Control Information Configuration
  3364. + *
  3365. + * Return: Completion status. '0' on Success; Error code otherwise.
  3366. + */
  3367. +int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
  3368. + uint32_t cmd_flags,
  3369. + uint16_t token,
  3370. + uint16_t if_id,
  3371. + struct dpsw_tci_cfg *cfg);
  3372. +
  3373. +/**
  3374. + * enum dpsw_stp_state - Spanning Tree Protocol (STP) states
  3375. + * @DPSW_STP_STATE_BLOCKING: Blocking state
  3376. + * @DPSW_STP_STATE_LISTENING: Listening state
  3377. + * @DPSW_STP_STATE_LEARNING: Learning state
  3378. + * @DPSW_STP_STATE_FORWARDING: Forwarding state
  3379. + *
  3380. + */
  3381. +enum dpsw_stp_state {
  3382. + DPSW_STP_STATE_BLOCKING = 0,
  3383. + DPSW_STP_STATE_LISTENING = 1,
  3384. + DPSW_STP_STATE_LEARNING = 2,
  3385. + DPSW_STP_STATE_FORWARDING = 3
  3386. +};
  3387. +
  3388. +/**
  3389. + * struct dpsw_stp_cfg - Spanning Tree Protocol (STP) Configuration
  3390. + * @vlan_id: VLAN ID STP state
  3391. + * @state: STP state
  3392. + */
  3393. +struct dpsw_stp_cfg {
  3394. + uint16_t vlan_id;
  3395. + enum dpsw_stp_state state;
  3396. +};
  3397. +
  3398. +/**
  3399. + * dpsw_if_set_stp() - Function sets Spanning Tree Protocol (STP) state.
  3400. + * @mc_io: Pointer to MC portal's I/O object
  3401. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3402. + * @token: Token of DPSW object
  3403. + * @if_id: Interface Identifier
  3404. + * @cfg: STP State configuration parameters
  3405. + *
  3406. + * The following STP states are supported -
  3407. + * blocking, listening, learning, forwarding and disabled.
  3408. + *
  3409. + * Return: Completion status. '0' on Success; Error code otherwise.
  3410. + */
  3411. +int dpsw_if_set_stp(struct fsl_mc_io *mc_io,
  3412. + uint32_t cmd_flags,
  3413. + uint16_t token,
  3414. + uint16_t if_id,
  3415. + const struct dpsw_stp_cfg *cfg);
  3416. +
  3417. +/**
  3418. + * enum dpsw_accepted_frames - Types of frames to accept
  3419. + * @DPSW_ADMIT_ALL: The device accepts VLAN tagged, untagged and
  3420. + * priority tagged frames
  3421. + * @DPSW_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
  3422. + * Priority-Tagged frames received on this interface.
  3423. + *
  3424. + */
  3425. +enum dpsw_accepted_frames {
  3426. + DPSW_ADMIT_ALL = 1,
  3427. + DPSW_ADMIT_ONLY_VLAN_TAGGED = 3
  3428. +};
  3429. +
  3430. +/**
  3431. + * struct dpsw_accepted_frames_cfg - Types of frames to accept configuration
  3432. + * @type: Defines ingress accepted frames
  3433. + * @unaccept_act: When a frame is not accepted, it may be discarded or
  3434. + * redirected to control interface depending on this mode
  3435. + */
  3436. +struct dpsw_accepted_frames_cfg {
  3437. + enum dpsw_accepted_frames type;
  3438. + enum dpsw_action unaccept_act;
  3439. +};
  3440. +
  3441. +/**
  3442. + * dpsw_if_set_accepted_frames()
  3443. + * @mc_io: Pointer to MC portal's I/O object
  3444. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3445. + * @token: Token of DPSW object
  3446. + * @if_id: Interface Identifier
  3447. + * @cfg: Frame types configuration
  3448. + *
  3449. + * When is admit_only_vlan_tagged- the device will discard untagged
  3450. + * frames or Priority-Tagged frames received on this interface.
  3451. + * When admit_only_untagged- untagged frames or Priority-Tagged
  3452. + * frames received on this interface will be accepted and assigned
  3453. + * to a VID based on the PVID and VID Set for this interface.
  3454. + * When admit_all - the device will accept VLAN tagged, untagged
  3455. + * and priority tagged frames.
  3456. + * The default is admit_all
  3457. + *
  3458. + * Return: Completion status. '0' on Success; Error code otherwise.
  3459. + */
  3460. +int dpsw_if_set_accepted_frames(struct fsl_mc_io *mc_io,
  3461. + uint32_t cmd_flags,
  3462. + uint16_t token,
  3463. + uint16_t if_id,
  3464. + const struct dpsw_accepted_frames_cfg *cfg);
  3465. +
  3466. +/**
  3467. + * dpsw_if_set_accept_all_vlan()
  3468. + * @mc_io: Pointer to MC portal's I/O object
  3469. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3470. + * @token: Token of DPSW object
  3471. + * @if_id: Interface Identifier
  3472. + * @accept_all: Accept or drop frames having different VLAN
  3473. + *
  3474. + * When this is accept (FALSE), the device will discard incoming
  3475. + * frames for VLANs that do not include this interface in its
  3476. + * Member set. When accept (TRUE), the interface will accept all incoming frames
  3477. + *
  3478. + * Return: Completion status. '0' on Success; Error code otherwise.
  3479. + */
  3480. +int dpsw_if_set_accept_all_vlan(struct fsl_mc_io *mc_io,
  3481. + uint32_t cmd_flags,
  3482. + uint16_t token,
  3483. + uint16_t if_id,
  3484. + int accept_all);
  3485. +
  3486. +/**
  3487. + * enum dpsw_counter - Counters types
  3488. + * @DPSW_CNT_ING_FRAME: Counts ingress frames
  3489. + * @DPSW_CNT_ING_BYTE: Counts ingress bytes
  3490. + * @DPSW_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
  3491. + * @DPSW_CNT_ING_FRAME_DISCARD: Counts discarded ingress frame
  3492. + * @DPSW_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
  3493. + * @DPSW_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
  3494. + * @DPSW_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
  3495. + * @DPSW_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
  3496. + * @DPSW_CNT_EGR_FRAME: Counts egress frames
  3497. + * @DPSW_CNT_EGR_BYTE: Counts eEgress bytes
  3498. + * @DPSW_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
  3499. + * @DPSW_CNT_EGR_STP_FRAME_DISCARD: Counts egress STP discarded frames
  3500. + */
  3501. +enum dpsw_counter {
  3502. + DPSW_CNT_ING_FRAME = 0x0,
  3503. + DPSW_CNT_ING_BYTE = 0x1,
  3504. + DPSW_CNT_ING_FLTR_FRAME = 0x2,
  3505. + DPSW_CNT_ING_FRAME_DISCARD = 0x3,
  3506. + DPSW_CNT_ING_MCAST_FRAME = 0x4,
  3507. + DPSW_CNT_ING_MCAST_BYTE = 0x5,
  3508. + DPSW_CNT_ING_BCAST_FRAME = 0x6,
  3509. + DPSW_CNT_ING_BCAST_BYTES = 0x7,
  3510. + DPSW_CNT_EGR_FRAME = 0x8,
  3511. + DPSW_CNT_EGR_BYTE = 0x9,
  3512. + DPSW_CNT_EGR_FRAME_DISCARD = 0xa,
  3513. + DPSW_CNT_EGR_STP_FRAME_DISCARD = 0xb
  3514. +};
  3515. +
  3516. +/**
  3517. + * dpsw_if_get_counter() - Get specific counter of particular interface
  3518. + * @mc_io: Pointer to MC portal's I/O object
  3519. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3520. + * @token: Token of DPSW object
  3521. + * @if_id: Interface Identifier
  3522. + * @type: Counter type
  3523. + * @counter: return value
  3524. + *
  3525. + * Return: Completion status. '0' on Success; Error code otherwise.
  3526. + */
  3527. +int dpsw_if_get_counter(struct fsl_mc_io *mc_io,
  3528. + uint32_t cmd_flags,
  3529. + uint16_t token,
  3530. + uint16_t if_id,
  3531. + enum dpsw_counter type,
  3532. + uint64_t *counter);
  3533. +
  3534. +/**
  3535. + * dpsw_if_set_counter() - Set specific counter of particular interface
  3536. + * @mc_io: Pointer to MC portal's I/O object
  3537. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3538. + * @token: Token of DPSW object
  3539. + * @if_id: Interface Identifier
  3540. + * @type: Counter type
  3541. + * @counter: New counter value
  3542. + *
  3543. + * Return: Completion status. '0' on Success; Error code otherwise.
  3544. + */
  3545. +int dpsw_if_set_counter(struct fsl_mc_io *mc_io,
  3546. + uint32_t cmd_flags,
  3547. + uint16_t token,
  3548. + uint16_t if_id,
  3549. + enum dpsw_counter type,
  3550. + uint64_t counter);
  3551. +
  3552. +/**
  3553. + * Maximum number of TC
  3554. + */
  3555. +#define DPSW_MAX_TC 8
  3556. +
  3557. +/**
  3558. + * enum dpsw_priority_selector - User priority
  3559. + * @DPSW_UP_PCP: Priority Code Point (PCP): a 3-bit field which
  3560. + * refers to the IEEE 802.1p priority.
  3561. + * @DPSW_UP_DSCP: Differentiated services Code Point (DSCP): 6 bit
  3562. + * field from IP header
  3563. + *
  3564. + */
  3565. +enum dpsw_priority_selector {
  3566. + DPSW_UP_PCP = 0,
  3567. + DPSW_UP_DSCP = 1
  3568. +};
  3569. +
  3570. +/**
  3571. + * enum dpsw_schedule_mode - Traffic classes scheduling
  3572. + * @DPSW_SCHED_STRICT_PRIORITY: schedule strict priority
  3573. + * @DPSW_SCHED_WEIGHTED: schedule based on token bucket created algorithm
  3574. + */
  3575. +enum dpsw_schedule_mode {
  3576. + DPSW_SCHED_STRICT_PRIORITY,
  3577. + DPSW_SCHED_WEIGHTED
  3578. +};
  3579. +
  3580. +/**
  3581. + * struct dpsw_tx_schedule_cfg - traffic class configuration
  3582. + * @mode: Strict or weight-based scheduling
  3583. + * @delta_bandwidth: weighted Bandwidth in range from 100 to 10000
  3584. + */
  3585. +struct dpsw_tx_schedule_cfg {
  3586. + enum dpsw_schedule_mode mode;
  3587. + uint16_t delta_bandwidth;
  3588. +};
  3589. +
  3590. +/**
  3591. + * struct dpsw_tx_selection_cfg - Mapping user priority into traffic
  3592. + * class configuration
  3593. + * @priority_selector: Source for user priority regeneration
  3594. + * @tc_id: The Regenerated User priority that the incoming
  3595. + * User Priority is mapped to for this interface
  3596. + * @tc_sched: Traffic classes configuration
  3597. + */
  3598. +struct dpsw_tx_selection_cfg {
  3599. + enum dpsw_priority_selector priority_selector;
  3600. + uint8_t tc_id[DPSW_MAX_PRIORITIES];
  3601. + struct dpsw_tx_schedule_cfg tc_sched[DPSW_MAX_TC];
  3602. +};
  3603. +
  3604. +/**
  3605. + * dpsw_if_set_tx_selection() - Function is used for mapping variety
  3606. + * of frame fields
  3607. + * @mc_io: Pointer to MC portal's I/O object
  3608. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3609. + * @token: Token of DPSW object
  3610. + * @if_id: Interface Identifier
  3611. + * @cfg: Traffic class mapping configuration
  3612. + *
  3613. + * Function is used for mapping variety of frame fields (DSCP, PCP)
  3614. + * to Traffic Class. Traffic class is a number
  3615. + * in the range from 0 to 7
  3616. + *
  3617. + * Return: Completion status. '0' on Success; Error code otherwise.
  3618. + */
  3619. +int dpsw_if_set_tx_selection(struct fsl_mc_io *mc_io,
  3620. + uint32_t cmd_flags,
  3621. + uint16_t token,
  3622. + uint16_t if_id,
  3623. + const struct dpsw_tx_selection_cfg *cfg);
  3624. +
  3625. +/**
  3626. + * enum dpsw_reflection_filter - Filter type for frames to reflect
  3627. + * @DPSW_REFLECTION_FILTER_INGRESS_ALL: Reflect all frames
  3628. + * @DPSW_REFLECTION_FILTER_INGRESS_VLAN: Reflect only frames belong to
  3629. + * particular VLAN defined by vid parameter
  3630. + *
  3631. + */
  3632. +enum dpsw_reflection_filter {
  3633. + DPSW_REFLECTION_FILTER_INGRESS_ALL = 0,
  3634. + DPSW_REFLECTION_FILTER_INGRESS_VLAN = 1
  3635. +};
  3636. +
  3637. +/**
  3638. + * struct dpsw_reflection_cfg - Structure representing reflection information
  3639. + * @filter: Filter type for frames to reflect
  3640. + * @vlan_id: Vlan Id to reflect; valid only when filter type is
  3641. + * DPSW_INGRESS_VLAN
  3642. + */
  3643. +struct dpsw_reflection_cfg {
  3644. + enum dpsw_reflection_filter filter;
  3645. + uint16_t vlan_id;
  3646. +};
  3647. +
  3648. +/**
  3649. + * dpsw_if_add_reflection() - Identify interface to be reflected or mirrored
  3650. + * @mc_io: Pointer to MC portal's I/O object
  3651. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3652. + * @token: Token of DPSW object
  3653. + * @if_id: Interface Identifier
  3654. + * @cfg: Reflection configuration
  3655. + *
  3656. + * Return: Completion status. '0' on Success; Error code otherwise.
  3657. + */
  3658. +int dpsw_if_add_reflection(struct fsl_mc_io *mc_io,
  3659. + uint32_t cmd_flags,
  3660. + uint16_t token,
  3661. + uint16_t if_id,
  3662. + const struct dpsw_reflection_cfg *cfg);
  3663. +
  3664. +/**
  3665. + * dpsw_if_remove_reflection() - Remove interface to be reflected or mirrored
  3666. + * @mc_io: Pointer to MC portal's I/O object
  3667. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3668. + * @token: Token of DPSW object
  3669. + * @if_id: Interface Identifier
  3670. + * @cfg: Reflection configuration
  3671. + *
  3672. + * Return: Completion status. '0' on Success; Error code otherwise.
  3673. + */
  3674. +int dpsw_if_remove_reflection(struct fsl_mc_io *mc_io,
  3675. + uint32_t cmd_flags,
  3676. + uint16_t token,
  3677. + uint16_t if_id,
  3678. + const struct dpsw_reflection_cfg *cfg);
  3679. +
  3680. +/**
  3681. + * enum dpsw_metering_mode - Metering modes
  3682. + * @DPSW_METERING_MODE_NONE: metering disabled
  3683. + * @DPSW_METERING_MODE_RFC2698: RFC 2698
  3684. + * @DPSW_METERING_MODE_RFC4115: RFC 4115
  3685. + */
  3686. +enum dpsw_metering_mode {
  3687. + DPSW_METERING_MODE_NONE = 0,
  3688. + DPSW_METERING_MODE_RFC2698,
  3689. + DPSW_METERING_MODE_RFC4115
  3690. +};
  3691. +
  3692. +/**
  3693. + * enum dpsw_metering_unit - Metering count
  3694. + * @DPSW_METERING_UNIT_BYTES: count bytes
  3695. + * @DPSW_METERING_UNIT_FRAMES: count frames
  3696. + */
  3697. +enum dpsw_metering_unit {
  3698. + DPSW_METERING_UNIT_BYTES = 0,
  3699. + DPSW_METERING_UNIT_FRAMES
  3700. +};
  3701. +
  3702. +/**
  3703. + * struct dpsw_metering_cfg - Metering configuration
  3704. + * @mode: metering modes
  3705. + * @units: Bytes or frame units
  3706. + * @cir: Committed information rate (CIR) in Kbits/s
  3707. + * @eir: Peak information rate (PIR) Kbit/s rfc2698
  3708. + * Excess information rate (EIR) Kbit/s rfc4115
  3709. + * @cbs: Committed burst size (CBS) in bytes
  3710. + * @ebs: Peak burst size (PBS) in bytes for rfc2698
  3711. + * Excess bust size (EBS) in bytes rfc4115
  3712. + *
  3713. + */
  3714. +struct dpsw_metering_cfg {
  3715. + enum dpsw_metering_mode mode;
  3716. + enum dpsw_metering_unit units;
  3717. + uint32_t cir;
  3718. + uint32_t eir;
  3719. + uint32_t cbs;
  3720. + uint32_t ebs;
  3721. +};
  3722. +
  3723. +/**
  3724. + * dpsw_if_set_flooding_metering() - Set flooding metering
  3725. + * @mc_io: Pointer to MC portal's I/O object
  3726. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3727. + * @token: Token of DPSW object
  3728. + * @if_id: Interface Identifier
  3729. + * @cfg: Metering parameters
  3730. + *
  3731. + * Return: Completion status. '0' on Success; Error code otherwise.
  3732. + */
  3733. +int dpsw_if_set_flooding_metering(struct fsl_mc_io *mc_io,
  3734. + uint32_t cmd_flags,
  3735. + uint16_t token,
  3736. + uint16_t if_id,
  3737. + const struct dpsw_metering_cfg *cfg);
  3738. +
  3739. +/**
  3740. + * dpsw_if_set_metering() - Set interface metering for flooding
  3741. + * @mc_io: Pointer to MC portal's I/O object
  3742. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3743. + * @token: Token of DPSW object
  3744. + * @if_id: Interface Identifier
  3745. + * @tc_id: Traffic class ID
  3746. + * @cfg: Metering parameters
  3747. + *
  3748. + * Return: Completion status. '0' on Success; Error code otherwise.
  3749. + */
  3750. +int dpsw_if_set_metering(struct fsl_mc_io *mc_io,
  3751. + uint32_t cmd_flags,
  3752. + uint16_t token,
  3753. + uint16_t if_id,
  3754. + uint8_t tc_id,
  3755. + const struct dpsw_metering_cfg *cfg);
  3756. +
  3757. +/**
  3758. + * enum dpsw_early_drop_unit - DPSW early drop unit
  3759. + * @DPSW_EARLY_DROP_UNIT_BYTE: count bytes
  3760. + * @DPSW_EARLY_DROP_UNIT_FRAMES: count frames
  3761. + */
  3762. +enum dpsw_early_drop_unit {
  3763. + DPSW_EARLY_DROP_UNIT_BYTE = 0,
  3764. + DPSW_EARLY_DROP_UNIT_FRAMES
  3765. +};
  3766. +
  3767. +/**
  3768. + * enum dpsw_early_drop_mode - DPSW early drop mode
  3769. + * @DPSW_EARLY_DROP_MODE_NONE: early drop is disabled
  3770. + * @DPSW_EARLY_DROP_MODE_TAIL: early drop in taildrop mode
  3771. + * @DPSW_EARLY_DROP_MODE_WRED: early drop in WRED mode
  3772. + */
  3773. +enum dpsw_early_drop_mode {
  3774. + DPSW_EARLY_DROP_MODE_NONE = 0,
  3775. + DPSW_EARLY_DROP_MODE_TAIL,
  3776. + DPSW_EARLY_DROP_MODE_WRED
  3777. +};
  3778. +
  3779. +/**
  3780. + * struct dpsw_wred_cfg - WRED configuration
  3781. + * @max_threshold: maximum threshold that packets may be discarded. Above this
  3782. + * threshold all packets are discarded; must be less than 2^39;
  3783. + * approximated to be expressed as (x+256)*2^(y-1) due to HW
  3784. + * implementation.
  3785. + * @min_threshold: minimum threshold that packets may be discarded at
  3786. + * @drop_probability: probability that a packet will be discarded (1-100,
  3787. + * associated with the maximum threshold)
  3788. + */
  3789. +struct dpsw_wred_cfg {
  3790. + uint64_t min_threshold;
  3791. + uint64_t max_threshold;
  3792. + uint8_t drop_probability;
  3793. +};
  3794. +
  3795. +/**
  3796. + * struct dpsw_early_drop_cfg - early-drop configuration
  3797. + * @drop_mode: drop mode
  3798. + * @units: count units
  3799. + * @yellow: WRED - 'yellow' configuration
  3800. + * @green: WRED - 'green' configuration
  3801. + * @tail_drop_threshold: tail drop threshold
  3802. + */
  3803. +struct dpsw_early_drop_cfg {
  3804. + enum dpsw_early_drop_mode drop_mode;
  3805. + enum dpsw_early_drop_unit units;
  3806. + struct dpsw_wred_cfg yellow;
  3807. + struct dpsw_wred_cfg green;
  3808. + uint32_t tail_drop_threshold;
  3809. +};
  3810. +
  3811. +/**
  3812. + * dpsw_prepare_early_drop() - Prepare an early drop for setting in to interface
  3813. + * @cfg: Early-drop configuration
  3814. + * @early_drop_buf: Zeroed 256 bytes of memory before mapping it to DMA
  3815. + *
  3816. + * This function has to be called before dpsw_if_tc_set_early_drop
  3817. + *
  3818. + */
  3819. +void dpsw_prepare_early_drop(const struct dpsw_early_drop_cfg *cfg,
  3820. + uint8_t *early_drop_buf);
  3821. +
  3822. +/**
  3823. + * dpsw_if_set_early_drop() - Set interface traffic class early-drop
  3824. + * configuration
  3825. + * @mc_io: Pointer to MC portal's I/O object
  3826. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3827. + * @token: Token of DPSW object
  3828. + * @if_id: Interface Identifier
  3829. + * @tc_id: Traffic class selection (0-7)
  3830. + * @early_drop_iova: I/O virtual address of 64 bytes;
  3831. + * Must be cacheline-aligned and DMA-able memory
  3832. + *
  3833. + * warning: Before calling this function, call dpsw_prepare_if_tc_early_drop()
  3834. + * to prepare the early_drop_iova parameter
  3835. + *
  3836. + * Return: '0' on Success; error code otherwise.
  3837. + */
  3838. +int dpsw_if_set_early_drop(struct fsl_mc_io *mc_io,
  3839. + uint32_t cmd_flags,
  3840. + uint16_t token,
  3841. + uint16_t if_id,
  3842. + uint8_t tc_id,
  3843. + uint64_t early_drop_iova);
  3844. +
  3845. +/**
  3846. + * struct dpsw_custom_tpid_cfg - Structure representing tag Protocol identifier
  3847. + * @tpid: An additional tag protocol identifier
  3848. + */
  3849. +struct dpsw_custom_tpid_cfg {
  3850. + uint16_t tpid;
  3851. +};
  3852. +
  3853. +/**
  3854. + * dpsw_add_custom_tpid() - API Configures a distinct Ethernet type value
  3855. + * @mc_io: Pointer to MC portal's I/O object
  3856. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3857. + * @token: Token of DPSW object
  3858. + * @cfg: Tag Protocol identifier
  3859. + *
  3860. + * API Configures a distinct Ethernet type value (or TPID value)
  3861. + * to indicate a VLAN tag in addition to the common
  3862. + * TPID values 0x8100 and 0x88A8.
  3863. + * Two additional TPID's are supported
  3864. + *
  3865. + * Return: Completion status. '0' on Success; Error code otherwise.
  3866. + */
  3867. +int dpsw_add_custom_tpid(struct fsl_mc_io *mc_io,
  3868. + uint32_t cmd_flags,
  3869. + uint16_t token,
  3870. + const struct dpsw_custom_tpid_cfg *cfg);
  3871. +
  3872. +/**
  3873. + * dpsw_remove_custom_tpid - API removes a distinct Ethernet type value
  3874. + * @mc_io: Pointer to MC portal's I/O object
  3875. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3876. + * @token: Token of DPSW object
  3877. + * @cfg: Tag Protocol identifier
  3878. + *
  3879. + * Return: Completion status. '0' on Success; Error code otherwise.
  3880. + */
  3881. +int dpsw_remove_custom_tpid(struct fsl_mc_io *mc_io,
  3882. + uint32_t cmd_flags,
  3883. + uint16_t token,
  3884. + const struct dpsw_custom_tpid_cfg *cfg);
  3885. +
  3886. +/**
  3887. + * dpsw_if_enable() - Enable Interface
  3888. + * @mc_io: Pointer to MC portal's I/O object
  3889. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3890. + * @token: Token of DPSW object
  3891. + * @if_id: Interface Identifier
  3892. + *
  3893. + * Return: Completion status. '0' on Success; Error code otherwise.
  3894. + */
  3895. +int dpsw_if_enable(struct fsl_mc_io *mc_io,
  3896. + uint32_t cmd_flags,
  3897. + uint16_t token,
  3898. + uint16_t if_id);
  3899. +
  3900. +/**
  3901. + * dpsw_if_disable() - Disable Interface
  3902. + * @mc_io: Pointer to MC portal's I/O object
  3903. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3904. + * @token: Token of DPSW object
  3905. + * @if_id: Interface Identifier
  3906. + *
  3907. + * Return: Completion status. '0' on Success; Error code otherwise.
  3908. + */
  3909. +int dpsw_if_disable(struct fsl_mc_io *mc_io,
  3910. + uint32_t cmd_flags,
  3911. + uint16_t token,
  3912. + uint16_t if_id);
  3913. +
  3914. +/**
  3915. + * struct dpsw_if_attr - Structure representing DPSW interface attributes
  3916. + * @num_tcs: Number of traffic classes
  3917. + * @rate: Transmit rate in bits per second
  3918. + * @options: Interface configuration options (bitmap)
  3919. + * @enabled: Indicates if interface is enabled
  3920. + * @accept_all_vlan: The device discards/accepts incoming frames
  3921. + * for VLANs that do not include this interface
  3922. + * @admit_untagged: When set to 'DPSW_ADMIT_ONLY_VLAN_TAGGED', the device
  3923. + * discards untagged frames or priority-tagged frames received on
  3924. + * this interface;
  3925. + * When set to 'DPSW_ADMIT_ALL', untagged frames or priority-
  3926. + * tagged frames received on this interface are accepted
  3927. + * @qdid: control frames transmit qdid
  3928. + */
  3929. +struct dpsw_if_attr {
  3930. + uint8_t num_tcs;
  3931. + uint32_t rate;
  3932. + uint32_t options;
  3933. + int enabled;
  3934. + int accept_all_vlan;
  3935. + enum dpsw_accepted_frames admit_untagged;
  3936. + uint16_t qdid;
  3937. +};
  3938. +
  3939. +/**
  3940. + * dpsw_if_get_attributes() - Function obtains attributes of interface
  3941. + * @mc_io: Pointer to MC portal's I/O object
  3942. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3943. + * @token: Token of DPSW object
  3944. + * @if_id: Interface Identifier
  3945. + * @attr: Returned interface attributes
  3946. + *
  3947. + * Return: Completion status. '0' on Success; Error code otherwise.
  3948. + */
  3949. +int dpsw_if_get_attributes(struct fsl_mc_io *mc_io,
  3950. + uint32_t cmd_flags,
  3951. + uint16_t token,
  3952. + uint16_t if_id,
  3953. + struct dpsw_if_attr *attr);
  3954. +
  3955. +/**
  3956. + * dpsw_if_set_max_frame_length() - Set Maximum Receive frame length.
  3957. + * @mc_io: Pointer to MC portal's I/O object
  3958. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3959. + * @token: Token of DPSW object
  3960. + * @if_id: Interface Identifier
  3961. + * @frame_length: Maximum Frame Length
  3962. + *
  3963. + * Return: Completion status. '0' on Success; Error code otherwise.
  3964. + */
  3965. +int dpsw_if_set_max_frame_length(struct fsl_mc_io *mc_io,
  3966. + uint32_t cmd_flags,
  3967. + uint16_t token,
  3968. + uint16_t if_id,
  3969. + uint16_t frame_length);
  3970. +
  3971. +/**
  3972. + * dpsw_if_get_max_frame_length() - Get Maximum Receive frame length.
  3973. + * @mc_io: Pointer to MC portal's I/O object
  3974. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3975. + * @token: Token of DPSW object
  3976. + * @if_id: Interface Identifier
  3977. + * @frame_length: Returned maximum Frame Length
  3978. + *
  3979. + * Return: Completion status. '0' on Success; Error code otherwise.
  3980. + */
  3981. +int dpsw_if_get_max_frame_length(struct fsl_mc_io *mc_io,
  3982. + uint32_t cmd_flags,
  3983. + uint16_t token,
  3984. + uint16_t if_id,
  3985. + uint16_t *frame_length);
  3986. +
  3987. +/**
  3988. + * struct dpsw_vlan_cfg - VLAN Configuration
  3989. + * @fdb_id: Forwarding Data Base
  3990. + */
  3991. +struct dpsw_vlan_cfg {
  3992. + uint16_t fdb_id;
  3993. +};
  3994. +
  3995. +/**
  3996. + * dpsw_vlan_add() - Adding new VLAN to DPSW.
  3997. + * @mc_io: Pointer to MC portal's I/O object
  3998. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  3999. + * @token: Token of DPSW object
  4000. + * @vlan_id: VLAN Identifier
  4001. + * @cfg: VLAN configuration
  4002. + *
  4003. + * Only VLAN ID and FDB ID are required parameters here.
  4004. + * 12 bit VLAN ID is defined in IEEE802.1Q.
  4005. + * Adding a duplicate VLAN ID is not allowed.
  4006. + * FDB ID can be shared across multiple VLANs. Shared learning
  4007. + * is obtained by calling dpsw_vlan_add for multiple VLAN IDs
  4008. + * with same fdb_id
  4009. + *
  4010. + * Return: Completion status. '0' on Success; Error code otherwise.
  4011. + */
  4012. +int dpsw_vlan_add(struct fsl_mc_io *mc_io,
  4013. + uint32_t cmd_flags,
  4014. + uint16_t token,
  4015. + uint16_t vlan_id,
  4016. + const struct dpsw_vlan_cfg *cfg);
  4017. +
  4018. +/**
  4019. + * struct dpsw_vlan_if_cfg - Set of VLAN Interfaces
  4020. + * @num_ifs: The number of interfaces that are assigned to the egress
  4021. + * list for this VLAN
  4022. + * @if_id: The set of interfaces that are
  4023. + * assigned to the egress list for this VLAN
  4024. + */
  4025. +struct dpsw_vlan_if_cfg {
  4026. + uint16_t num_ifs;
  4027. + uint16_t if_id[DPSW_MAX_IF];
  4028. +};
  4029. +
  4030. +/**
  4031. + * dpsw_vlan_add_if() - Adding a set of interfaces to an existing VLAN.
  4032. + * @mc_io: Pointer to MC portal's I/O object
  4033. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4034. + * @token: Token of DPSW object
  4035. + * @vlan_id: VLAN Identifier
  4036. + * @cfg: Set of interfaces to add
  4037. + *
  4038. + * It adds only interfaces not belonging to this VLAN yet,
  4039. + * otherwise an error is generated and an entire command is
  4040. + * ignored. This function can be called numerous times always
  4041. + * providing required interfaces delta.
  4042. + *
  4043. + * Return: Completion status. '0' on Success; Error code otherwise.
  4044. + */
  4045. +int dpsw_vlan_add_if(struct fsl_mc_io *mc_io,
  4046. + uint32_t cmd_flags,
  4047. + uint16_t token,
  4048. + uint16_t vlan_id,
  4049. + const struct dpsw_vlan_if_cfg *cfg);
  4050. +
  4051. +/**
  4052. + * dpsw_vlan_add_if_untagged() - Defining a set of interfaces that should be
  4053. + * transmitted as untagged.
  4054. + * @mc_io: Pointer to MC portal's I/O object
  4055. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4056. + * @token: Token of DPSW object
  4057. + * @vlan_id: VLAN Identifier
  4058. + * @cfg: set of interfaces that should be transmitted as untagged
  4059. + *
  4060. + * These interfaces should already belong to this VLAN.
  4061. + * By default all interfaces are transmitted as tagged.
  4062. + * Providing un-existing interface or untagged interface that is
  4063. + * configured untagged already generates an error and the entire
  4064. + * command is ignored.
  4065. + *
  4066. + * Return: Completion status. '0' on Success; Error code otherwise.
  4067. + */
  4068. +int dpsw_vlan_add_if_untagged(struct fsl_mc_io *mc_io,
  4069. + uint32_t cmd_flags,
  4070. + uint16_t token,
  4071. + uint16_t vlan_id,
  4072. + const struct dpsw_vlan_if_cfg *cfg);
  4073. +
  4074. +/**
  4075. + * dpsw_vlan_add_if_flooding() - Define a set of interfaces that should be
  4076. + * included in flooding when frame with unknown destination
  4077. + * unicast MAC arrived.
  4078. + * @mc_io: Pointer to MC portal's I/O object
  4079. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4080. + * @token: Token of DPSW object
  4081. + * @vlan_id: VLAN Identifier
  4082. + * @cfg: Set of interfaces that should be used for flooding
  4083. + *
  4084. + * These interfaces should belong to this VLAN. By default all
  4085. + * interfaces are included into flooding list. Providing
  4086. + * un-existing interface or an interface that already in the
  4087. + * flooding list generates an error and the entire command is
  4088. + * ignored.
  4089. + *
  4090. + * Return: Completion status. '0' on Success; Error code otherwise.
  4091. + */
  4092. +int dpsw_vlan_add_if_flooding(struct fsl_mc_io *mc_io,
  4093. + uint32_t cmd_flags,
  4094. + uint16_t token,
  4095. + uint16_t vlan_id,
  4096. + const struct dpsw_vlan_if_cfg *cfg);
  4097. +
  4098. +/**
  4099. + * dpsw_vlan_remove_if() - Remove interfaces from an existing VLAN.
  4100. + * @mc_io: Pointer to MC portal's I/O object
  4101. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4102. + * @token: Token of DPSW object
  4103. + * @vlan_id: VLAN Identifier
  4104. + * @cfg: Set of interfaces that should be removed
  4105. + *
  4106. + * Interfaces must belong to this VLAN, otherwise an error
  4107. + * is returned and an the command is ignored
  4108. + *
  4109. + * Return: Completion status. '0' on Success; Error code otherwise.
  4110. + */
  4111. +int dpsw_vlan_remove_if(struct fsl_mc_io *mc_io,
  4112. + uint32_t cmd_flags,
  4113. + uint16_t token,
  4114. + uint16_t vlan_id,
  4115. + const struct dpsw_vlan_if_cfg *cfg);
  4116. +
  4117. +/**
  4118. + * dpsw_vlan_remove_if_untagged() - Define a set of interfaces that should be
  4119. + * converted from transmitted as untagged to transmit as tagged.
  4120. + * @mc_io: Pointer to MC portal's I/O object
  4121. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4122. + * @token: Token of DPSW object
  4123. + * @vlan_id: VLAN Identifier
  4124. + * @cfg: set of interfaces that should be removed
  4125. + *
  4126. + * Interfaces provided by API have to belong to this VLAN and
  4127. + * configured untagged, otherwise an error is returned and the
  4128. + * command is ignored
  4129. + *
  4130. + * Return: Completion status. '0' on Success; Error code otherwise.
  4131. + */
  4132. +int dpsw_vlan_remove_if_untagged(struct fsl_mc_io *mc_io,
  4133. + uint32_t cmd_flags,
  4134. + uint16_t token,
  4135. + uint16_t vlan_id,
  4136. + const struct dpsw_vlan_if_cfg *cfg);
  4137. +
  4138. +/**
  4139. + * dpsw_vlan_remove_if_flooding() - Define a set of interfaces that should be
  4140. + * removed from the flooding list.
  4141. + * @mc_io: Pointer to MC portal's I/O object
  4142. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4143. + * @token: Token of DPSW object
  4144. + * @vlan_id: VLAN Identifier
  4145. + * @cfg: set of interfaces used for flooding
  4146. + *
  4147. + * Return: Completion status. '0' on Success; Error code otherwise.
  4148. + */
  4149. +int dpsw_vlan_remove_if_flooding(struct fsl_mc_io *mc_io,
  4150. + uint32_t cmd_flags,
  4151. + uint16_t token,
  4152. + uint16_t vlan_id,
  4153. + const struct dpsw_vlan_if_cfg *cfg);
  4154. +
  4155. +/**
  4156. + * dpsw_vlan_remove() - Remove an entire VLAN
  4157. + * @mc_io: Pointer to MC portal's I/O object
  4158. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4159. + * @token: Token of DPSW object
  4160. + * @vlan_id: VLAN Identifier
  4161. + *
  4162. + * Return: Completion status. '0' on Success; Error code otherwise.
  4163. + */
  4164. +int dpsw_vlan_remove(struct fsl_mc_io *mc_io,
  4165. + uint32_t cmd_flags,
  4166. + uint16_t token,
  4167. + uint16_t vlan_id);
  4168. +
  4169. +/**
  4170. + * struct dpsw_vlan_attr - VLAN attributes
  4171. + * @fdb_id: Associated FDB ID
  4172. + * @num_ifs: Number of interfaces
  4173. + * @num_untagged_ifs: Number of untagged interfaces
  4174. + * @num_flooding_ifs: Number of flooding interfaces
  4175. + */
  4176. +struct dpsw_vlan_attr {
  4177. + uint16_t fdb_id;
  4178. + uint16_t num_ifs;
  4179. + uint16_t num_untagged_ifs;
  4180. + uint16_t num_flooding_ifs;
  4181. +};
  4182. +
  4183. +/**
  4184. + * dpsw_vlan_get_attributes() - Get VLAN attributes
  4185. + * @mc_io: Pointer to MC portal's I/O object
  4186. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4187. + * @token: Token of DPSW object
  4188. + * @vlan_id: VLAN Identifier
  4189. + * @attr: Returned DPSW attributes
  4190. + *
  4191. + * Return: Completion status. '0' on Success; Error code otherwise.
  4192. + */
  4193. +int dpsw_vlan_get_attributes(struct fsl_mc_io *mc_io,
  4194. + uint32_t cmd_flags,
  4195. + uint16_t token,
  4196. + uint16_t vlan_id,
  4197. + struct dpsw_vlan_attr *attr);
  4198. +
  4199. +/**
  4200. + * dpsw_vlan_get_if() - Get interfaces belong to this VLAN
  4201. + * @mc_io: Pointer to MC portal's I/O object
  4202. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4203. + * @token: Token of DPSW object
  4204. + * @vlan_id: VLAN Identifier
  4205. + * @cfg: Returned set of interfaces belong to this VLAN
  4206. + *
  4207. + * Return: Completion status. '0' on Success; Error code otherwise.
  4208. + */
  4209. +int dpsw_vlan_get_if(struct fsl_mc_io *mc_io,
  4210. + uint32_t cmd_flags,
  4211. + uint16_t token,
  4212. + uint16_t vlan_id,
  4213. + struct dpsw_vlan_if_cfg *cfg);
  4214. +
  4215. +/**
  4216. + * dpsw_vlan_get_if_flooding() - Get interfaces used in flooding for this VLAN
  4217. + * @mc_io: Pointer to MC portal's I/O object
  4218. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4219. + * @token: Token of DPSW object
  4220. + * @vlan_id: VLAN Identifier
  4221. + * @cfg: Returned set of flooding interfaces
  4222. + *
  4223. + * Return: Completion status. '0' on Success; Error code otherwise.
  4224. + */
  4225. +int dpsw_vlan_get_if_flooding(struct fsl_mc_io *mc_io,
  4226. + uint32_t cmd_flags,
  4227. + uint16_t token,
  4228. + uint16_t vlan_id,
  4229. + struct dpsw_vlan_if_cfg *cfg);
  4230. +
  4231. +/**
  4232. + * dpsw_vlan_get_if_untagged() - Get interfaces that should be transmitted as
  4233. + * untagged
  4234. + * @mc_io: Pointer to MC portal's I/O object
  4235. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4236. + * @token: Token of DPSW object
  4237. + * @vlan_id: VLAN Identifier
  4238. + * @cfg: Returned set of untagged interfaces
  4239. + *
  4240. + * Return: Completion status. '0' on Success; Error code otherwise.
  4241. + */
  4242. +int dpsw_vlan_get_if_untagged(struct fsl_mc_io *mc_io,
  4243. + uint32_t cmd_flags,
  4244. + uint16_t token,
  4245. + uint16_t vlan_id,
  4246. + struct dpsw_vlan_if_cfg *cfg);
  4247. +
  4248. +/**
  4249. + * struct dpsw_fdb_cfg - FDB Configuration
  4250. + * @num_fdb_entries: Number of FDB entries
  4251. + * @fdb_aging_time: Aging time in seconds
  4252. + */
  4253. +struct dpsw_fdb_cfg {
  4254. + uint16_t num_fdb_entries;
  4255. + uint16_t fdb_aging_time;
  4256. +};
  4257. +
  4258. +/**
  4259. + * dpsw_fdb_add() - Add FDB to switch and Returns handle to FDB table for
  4260. + * the reference
  4261. + * @mc_io: Pointer to MC portal's I/O object
  4262. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4263. + * @token: Token of DPSW object
  4264. + * @fdb_id: Returned Forwarding Database Identifier
  4265. + * @cfg: FDB Configuration
  4266. + *
  4267. + * Return: Completion status. '0' on Success; Error code otherwise.
  4268. + */
  4269. +int dpsw_fdb_add(struct fsl_mc_io *mc_io,
  4270. + uint32_t cmd_flags,
  4271. + uint16_t token,
  4272. + uint16_t *fdb_id,
  4273. + const struct dpsw_fdb_cfg *cfg);
  4274. +
  4275. +/**
  4276. + * dpsw_fdb_remove() - Remove FDB from switch
  4277. + * @mc_io: Pointer to MC portal's I/O object
  4278. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4279. + * @token: Token of DPSW object
  4280. + * @fdb_id: Forwarding Database Identifier
  4281. + *
  4282. + * Return: Completion status. '0' on Success; Error code otherwise.
  4283. + */
  4284. +int dpsw_fdb_remove(struct fsl_mc_io *mc_io,
  4285. + uint32_t cmd_flags,
  4286. + uint16_t token,
  4287. + uint16_t fdb_id);
  4288. +
  4289. +/**
  4290. + * enum dpsw_fdb_entry_type - FDB Entry type - Static/Dynamic
  4291. + * @DPSW_FDB_ENTRY_STATIC: Static entry
  4292. + * @DPSW_FDB_ENTRY_DINAMIC: Dynamic entry
  4293. + */
  4294. +enum dpsw_fdb_entry_type {
  4295. + DPSW_FDB_ENTRY_STATIC = 0,
  4296. + DPSW_FDB_ENTRY_DINAMIC = 1
  4297. +};
  4298. +
  4299. +/**
  4300. + * struct dpsw_fdb_unicast_cfg - Unicast entry configuration
  4301. + * @type: Select static or dynamic entry
  4302. + * @mac_addr: MAC address
  4303. + * @if_egress: Egress interface ID
  4304. + */
  4305. +struct dpsw_fdb_unicast_cfg {
  4306. + enum dpsw_fdb_entry_type type;
  4307. + uint8_t mac_addr[6];
  4308. + uint16_t if_egress;
  4309. +};
  4310. +
  4311. +/**
  4312. + * dpsw_fdb_add_unicast() - Function adds an unicast entry into MAC lookup table
  4313. + * @mc_io: Pointer to MC portal's I/O object
  4314. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4315. + * @token: Token of DPSW object
  4316. + * @fdb_id: Forwarding Database Identifier
  4317. + * @cfg: Unicast entry configuration
  4318. + *
  4319. + * Return: Completion status. '0' on Success; Error code otherwise.
  4320. + */
  4321. +int dpsw_fdb_add_unicast(struct fsl_mc_io *mc_io,
  4322. + uint32_t cmd_flags,
  4323. + uint16_t token,
  4324. + uint16_t fdb_id,
  4325. + const struct dpsw_fdb_unicast_cfg *cfg);
  4326. +
  4327. +/**
  4328. + * dpsw_fdb_get_unicast() - Get unicast entry from MAC lookup table by
  4329. + * unicast Ethernet address
  4330. + * @mc_io: Pointer to MC portal's I/O object
  4331. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4332. + * @token: Token of DPSW object
  4333. + * @fdb_id: Forwarding Database Identifier
  4334. + * @cfg: Returned unicast entry configuration
  4335. + *
  4336. + * Return: Completion status. '0' on Success; Error code otherwise.
  4337. + */
  4338. +int dpsw_fdb_get_unicast(struct fsl_mc_io *mc_io,
  4339. + uint32_t cmd_flags,
  4340. + uint16_t token,
  4341. + uint16_t fdb_id,
  4342. + struct dpsw_fdb_unicast_cfg *cfg);
  4343. +
  4344. +/**
  4345. + * dpsw_fdb_remove_unicast() - removes an entry from MAC lookup table
  4346. + * @mc_io: Pointer to MC portal's I/O object
  4347. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4348. + * @token: Token of DPSW object
  4349. + * @fdb_id: Forwarding Database Identifier
  4350. + * @cfg: Unicast entry configuration
  4351. + *
  4352. + * Return: Completion status. '0' on Success; Error code otherwise.
  4353. + */
  4354. +int dpsw_fdb_remove_unicast(struct fsl_mc_io *mc_io,
  4355. + uint32_t cmd_flags,
  4356. + uint16_t token,
  4357. + uint16_t fdb_id,
  4358. + const struct dpsw_fdb_unicast_cfg *cfg);
  4359. +
  4360. +/**
  4361. + * struct dpsw_fdb_multicast_cfg - Multi-cast entry configuration
  4362. + * @type: Select static or dynamic entry
  4363. + * @mac_addr: MAC address
  4364. + * @num_ifs: Number of external and internal interfaces
  4365. + * @if_id: Egress interface IDs
  4366. + */
  4367. +struct dpsw_fdb_multicast_cfg {
  4368. + enum dpsw_fdb_entry_type type;
  4369. + uint8_t mac_addr[6];
  4370. + uint16_t num_ifs;
  4371. + uint16_t if_id[DPSW_MAX_IF];
  4372. +};
  4373. +
  4374. +/**
  4375. + * dpsw_fdb_add_multicast() - Add a set of egress interfaces to multi-cast group
  4376. + * @mc_io: Pointer to MC portal's I/O object
  4377. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4378. + * @token: Token of DPSW object
  4379. + * @fdb_id: Forwarding Database Identifier
  4380. + * @cfg: Multicast entry configuration
  4381. + *
  4382. + * If group doesn't exist, it will be created.
  4383. + * It adds only interfaces not belonging to this multicast group
  4384. + * yet, otherwise error will be generated and the command is
  4385. + * ignored.
  4386. + * This function may be called numerous times always providing
  4387. + * required interfaces delta.
  4388. + *
  4389. + * Return: Completion status. '0' on Success; Error code otherwise.
  4390. + */
  4391. +int dpsw_fdb_add_multicast(struct fsl_mc_io *mc_io,
  4392. + uint32_t cmd_flags,
  4393. + uint16_t token,
  4394. + uint16_t fdb_id,
  4395. + const struct dpsw_fdb_multicast_cfg *cfg);
  4396. +
  4397. +/**
  4398. + * dpsw_fdb_get_multicast() - Reading multi-cast group by multi-cast Ethernet
  4399. + * address.
  4400. + * @mc_io: Pointer to MC portal's I/O object
  4401. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4402. + * @token: Token of DPSW object
  4403. + * @fdb_id: Forwarding Database Identifier
  4404. + * @cfg: Returned multicast entry configuration
  4405. + *
  4406. + * Return: Completion status. '0' on Success; Error code otherwise.
  4407. + */
  4408. +int dpsw_fdb_get_multicast(struct fsl_mc_io *mc_io,
  4409. + uint32_t cmd_flags,
  4410. + uint16_t token,
  4411. + uint16_t fdb_id,
  4412. + struct dpsw_fdb_multicast_cfg *cfg);
  4413. +
  4414. +/**
  4415. + * dpsw_fdb_remove_multicast() - Removing interfaces from an existing multicast
  4416. + * group.
  4417. + * @mc_io: Pointer to MC portal's I/O object
  4418. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4419. + * @token: Token of DPSW object
  4420. + * @fdb_id: Forwarding Database Identifier
  4421. + * @cfg: Multicast entry configuration
  4422. + *
  4423. + * Interfaces provided by this API have to exist in the group,
  4424. + * otherwise an error will be returned and an entire command
  4425. + * ignored. If there is no interface left in the group,
  4426. + * an entire group is deleted
  4427. + *
  4428. + * Return: Completion status. '0' on Success; Error code otherwise.
  4429. + */
  4430. +int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io,
  4431. + uint32_t cmd_flags,
  4432. + uint16_t token,
  4433. + uint16_t fdb_id,
  4434. + const struct dpsw_fdb_multicast_cfg *cfg);
  4435. +
  4436. +/**
  4437. + * enum dpsw_fdb_learning_mode - Auto-learning modes
  4438. + * @DPSW_FDB_LEARNING_MODE_DIS: Disable Auto-learning
  4439. + * @DPSW_FDB_LEARNING_MODE_HW: Enable HW auto-Learning
  4440. + * @DPSW_FDB_LEARNING_MODE_NON_SECURE: Enable None secure learning by CPU
  4441. + * @DPSW_FDB_LEARNING_MODE_SECURE: Enable secure learning by CPU
  4442. + *
  4443. + * NONE - SECURE LEARNING
  4444. + * SMAC found DMAC found CTLU Action
  4445. + * v v Forward frame to
  4446. + * 1. DMAC destination
  4447. + * - v Forward frame to
  4448. + * 1. DMAC destination
  4449. + * 2. Control interface
  4450. + * v - Forward frame to
  4451. + * 1. Flooding list of interfaces
  4452. + * - - Forward frame to
  4453. + * 1. Flooding list of interfaces
  4454. + * 2. Control interface
  4455. + * SECURE LEARING
  4456. + * SMAC found DMAC found CTLU Action
  4457. + * v v Forward frame to
  4458. + * 1. DMAC destination
  4459. + * - v Forward frame to
  4460. + * 1. Control interface
  4461. + * v - Forward frame to
  4462. + * 1. Flooding list of interfaces
  4463. + * - - Forward frame to
  4464. + * 1. Control interface
  4465. + */
  4466. +enum dpsw_fdb_learning_mode {
  4467. + DPSW_FDB_LEARNING_MODE_DIS = 0,
  4468. + DPSW_FDB_LEARNING_MODE_HW = 1,
  4469. + DPSW_FDB_LEARNING_MODE_NON_SECURE = 2,
  4470. + DPSW_FDB_LEARNING_MODE_SECURE = 3
  4471. +};
  4472. +
  4473. +/**
  4474. + * dpsw_fdb_set_learning_mode() - Define FDB learning mode
  4475. + * @mc_io: Pointer to MC portal's I/O object
  4476. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4477. + * @token: Token of DPSW object
  4478. + * @fdb_id: Forwarding Database Identifier
  4479. + * @mode: learning mode
  4480. + *
  4481. + * Return: Completion status. '0' on Success; Error code otherwise.
  4482. + */
  4483. +int dpsw_fdb_set_learning_mode(struct fsl_mc_io *mc_io,
  4484. + uint32_t cmd_flags,
  4485. + uint16_t token,
  4486. + uint16_t fdb_id,
  4487. + enum dpsw_fdb_learning_mode mode);
  4488. +
  4489. +/**
  4490. + * struct dpsw_fdb_attr - FDB Attributes
  4491. + * @max_fdb_entries: Number of FDB entries
  4492. + * @fdb_aging_time: Aging time in seconds
  4493. + * @learning_mode: Learning mode
  4494. + * @num_fdb_mc_groups: Current number of multicast groups
  4495. + * @max_fdb_mc_groups: Maximum number of multicast groups
  4496. + */
  4497. +struct dpsw_fdb_attr {
  4498. + uint16_t max_fdb_entries;
  4499. + uint16_t fdb_aging_time;
  4500. + enum dpsw_fdb_learning_mode learning_mode;
  4501. + uint16_t num_fdb_mc_groups;
  4502. + uint16_t max_fdb_mc_groups;
  4503. +};
  4504. +
  4505. +/**
  4506. + * dpsw_fdb_get_attributes() - Get FDB attributes
  4507. + * @mc_io: Pointer to MC portal's I/O object
  4508. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4509. + * @token: Token of DPSW object
  4510. + * @fdb_id: Forwarding Database Identifier
  4511. + * @attr: Returned FDB attributes
  4512. + *
  4513. + * Return: Completion status. '0' on Success; Error code otherwise.
  4514. + */
  4515. +int dpsw_fdb_get_attributes(struct fsl_mc_io *mc_io,
  4516. + uint32_t cmd_flags,
  4517. + uint16_t token,
  4518. + uint16_t fdb_id,
  4519. + struct dpsw_fdb_attr *attr);
  4520. +
  4521. +/**
  4522. + * struct dpsw_acl_cfg - ACL Configuration
  4523. + * @max_entries: Number of FDB entries
  4524. + */
  4525. +struct dpsw_acl_cfg {
  4526. + uint16_t max_entries;
  4527. +};
  4528. +
  4529. +/**
  4530. + * struct dpsw_acl_fields - ACL fields.
  4531. + * @l2_dest_mac: Destination MAC address: BPDU, Multicast, Broadcast, Unicast,
  4532. + * slow protocols, MVRP, STP
  4533. + * @l2_source_mac: Source MAC address
  4534. + * @l2_tpid: Layer 2 (Ethernet) protocol type, used to identify the following
  4535. + * protocols: MPLS, PTP, PFC, ARP, Jumbo frames, LLDP, IEEE802.1ae,
  4536. + * Q-in-Q, IPv4, IPv6, PPPoE
  4537. + * @l2_pcp_dei: indicate which protocol is encapsulated in the payload
  4538. + * @l2_vlan_id: layer 2 VLAN ID
  4539. + * @l2_ether_type: layer 2 Ethernet type
  4540. + * @l3_dscp: Layer 3 differentiated services code point
  4541. + * @l3_protocol: Tells the Network layer at the destination host, to which
  4542. + * Protocol this packet belongs to. The following protocol are
  4543. + * supported: ICMP, IGMP, IPv4 (encapsulation), TCP, IPv6
  4544. + * (encapsulation), GRE, PTP
  4545. + * @l3_source_ip: Source IPv4 IP
  4546. + * @l3_dest_ip: Destination IPv4 IP
  4547. + * @l4_source_port: Source TCP/UDP Port
  4548. + * @l4_dest_port: Destination TCP/UDP Port
  4549. + */
  4550. +struct dpsw_acl_fields {
  4551. + uint8_t l2_dest_mac[6];
  4552. + uint8_t l2_source_mac[6];
  4553. + uint16_t l2_tpid;
  4554. + uint8_t l2_pcp_dei;
  4555. + uint16_t l2_vlan_id;
  4556. + uint16_t l2_ether_type;
  4557. + uint8_t l3_dscp;
  4558. + uint8_t l3_protocol;
  4559. + uint32_t l3_source_ip;
  4560. + uint32_t l3_dest_ip;
  4561. + uint16_t l4_source_port;
  4562. + uint16_t l4_dest_port;
  4563. +};
  4564. +
  4565. +/**
  4566. + * struct dpsw_acl_key - ACL key
  4567. + * @match: Match fields
  4568. + * @mask: Mask: b'1 - valid, b'0 don't care
  4569. + */
  4570. +struct dpsw_acl_key {
  4571. + struct dpsw_acl_fields match;
  4572. + struct dpsw_acl_fields mask;
  4573. +};
  4574. +
  4575. +/**
  4576. + * enum dpsw_acl_action
  4577. + * @DPSW_ACL_ACTION_DROP: Drop frame
  4578. + * @DPSW_ACL_ACTION_REDIRECT: Redirect to certain port
  4579. + * @DPSW_ACL_ACTION_ACCEPT: Accept frame
  4580. + * @DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF: Redirect to control interface
  4581. + */
  4582. +enum dpsw_acl_action {
  4583. + DPSW_ACL_ACTION_DROP,
  4584. + DPSW_ACL_ACTION_REDIRECT,
  4585. + DPSW_ACL_ACTION_ACCEPT,
  4586. + DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF
  4587. +};
  4588. +
  4589. +/**
  4590. + * struct dpsw_acl_result - ACL action
  4591. + * @action: Action should be taken when ACL entry hit
  4592. + * @if_id: Interface IDs to redirect frame. Valid only if redirect selected for
  4593. + * action
  4594. + */
  4595. +struct dpsw_acl_result {
  4596. + enum dpsw_acl_action action;
  4597. + uint16_t if_id;
  4598. +};
  4599. +
  4600. +/**
  4601. + * struct dpsw_acl_entry_cfg - ACL entry
  4602. + * @key_iova: I/O virtual address of DMA-able memory filled with key after call
  4603. + * to dpsw_acl_prepare_entry_cfg()
  4604. + * @result: Required action when entry hit occurs
  4605. + * @precedence: Precedence inside ACL 0 is lowest; This priority can not change
  4606. + * during the lifetime of a Policy. It is user responsibility to
  4607. + * space the priorities according to consequent rule additions.
  4608. + */
  4609. +struct dpsw_acl_entry_cfg {
  4610. + uint64_t key_iova;
  4611. + struct dpsw_acl_result result;
  4612. + int precedence;
  4613. +};
  4614. +
  4615. +/**
  4616. + * dpsw_acl_add() - Adds ACL to L2 switch.
  4617. + * @mc_io: Pointer to MC portal's I/O object
  4618. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4619. + * @token: Token of DPSW object
  4620. + * @acl_id: Returned ACL ID, for the future reference
  4621. + * @cfg: ACL configuration
  4622. + *
  4623. + * Create Access Control List. Multiple ACLs can be created and
  4624. + * co-exist in L2 switch
  4625. + *
  4626. + * Return: '0' on Success; Error code otherwise.
  4627. + */
  4628. +int dpsw_acl_add(struct fsl_mc_io *mc_io,
  4629. + uint32_t cmd_flags,
  4630. + uint16_t token,
  4631. + uint16_t *acl_id,
  4632. + const struct dpsw_acl_cfg *cfg);
  4633. +
  4634. +/**
  4635. + * dpsw_acl_remove() - Removes ACL from L2 switch.
  4636. + * @mc_io: Pointer to MC portal's I/O object
  4637. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4638. + * @token: Token of DPSW object
  4639. + * @acl_id: ACL ID
  4640. + *
  4641. + * Return: '0' on Success; Error code otherwise.
  4642. + */
  4643. +int dpsw_acl_remove(struct fsl_mc_io *mc_io,
  4644. + uint32_t cmd_flags,
  4645. + uint16_t token,
  4646. + uint16_t acl_id);
  4647. +
  4648. +/**
  4649. + * dpsw_acl_prepare_entry_cfg() - Set an entry to ACL.
  4650. + * @key: key
  4651. + * @entry_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
  4652. + *
  4653. + * This function has to be called before adding or removing acl_entry
  4654. + *
  4655. + */
  4656. +void dpsw_acl_prepare_entry_cfg(const struct dpsw_acl_key *key,
  4657. + uint8_t *entry_cfg_buf);
  4658. +
  4659. +/**
  4660. + * dpsw_acl_add_entry() - Adds an entry to ACL.
  4661. + * @mc_io: Pointer to MC portal's I/O object
  4662. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4663. + * @token: Token of DPSW object
  4664. + * @acl_id: ACL ID
  4665. + * @cfg: entry configuration
  4666. + *
  4667. + * warning: This function has to be called after dpsw_acl_set_entry_cfg()
  4668. + *
  4669. + * Return: '0' on Success; Error code otherwise.
  4670. + */
  4671. +int dpsw_acl_add_entry(struct fsl_mc_io *mc_io,
  4672. + uint32_t cmd_flags,
  4673. + uint16_t token,
  4674. + uint16_t acl_id,
  4675. + const struct dpsw_acl_entry_cfg *cfg);
  4676. +
  4677. +/**
  4678. + * dpsw_acl_remove_entry() - Removes an entry from ACL.
  4679. + * @mc_io: Pointer to MC portal's I/O object
  4680. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4681. + * @token: Token of DPSW object
  4682. + * @acl_id: ACL ID
  4683. + * @cfg: entry configuration
  4684. + *
  4685. + * warning: This function has to be called after dpsw_acl_set_entry_cfg()
  4686. + *
  4687. + * Return: '0' on Success; Error code otherwise.
  4688. + */
  4689. +int dpsw_acl_remove_entry(struct fsl_mc_io *mc_io,
  4690. + uint32_t cmd_flags,
  4691. + uint16_t token,
  4692. + uint16_t acl_id,
  4693. + const struct dpsw_acl_entry_cfg *cfg);
  4694. +
  4695. +/**
  4696. + * struct dpsw_acl_if_cfg - List of interfaces to Associate with ACL
  4697. + * @num_ifs: Number of interfaces
  4698. + * @if_id: List of interfaces
  4699. + */
  4700. +struct dpsw_acl_if_cfg {
  4701. + uint16_t num_ifs;
  4702. + uint16_t if_id[DPSW_MAX_IF];
  4703. +};
  4704. +
  4705. +/**
  4706. + * dpsw_acl_add_if() - Associate interface/interfaces with ACL.
  4707. + * @mc_io: Pointer to MC portal's I/O object
  4708. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4709. + * @token: Token of DPSW object
  4710. + * @acl_id: ACL ID
  4711. + * @cfg: interfaces list
  4712. + *
  4713. + * Return: '0' on Success; Error code otherwise.
  4714. + */
  4715. +int dpsw_acl_add_if(struct fsl_mc_io *mc_io,
  4716. + uint32_t cmd_flags,
  4717. + uint16_t token,
  4718. + uint16_t acl_id,
  4719. + const struct dpsw_acl_if_cfg *cfg);
  4720. +
  4721. +/**
  4722. + * dpsw_acl_remove_if() - De-associate interface/interfaces from ACL.
  4723. + * @mc_io: Pointer to MC portal's I/O object
  4724. + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4725. + * @token: Token of DPSW object
  4726. + * @acl_id: ACL ID
  4727. + * @cfg: interfaces list
  4728. + *
  4729. + * Return: '0' on Success; Error code otherwise.
  4730. + */
  4731. +int dpsw_acl_remove_if(struct fsl_mc_io *mc_io,
  4732. + uint32_t cmd_flags,
  4733. + uint16_t token,
  4734. + uint16_t acl_id,
  4735. + const struct dpsw_acl_if_cfg *cfg);
  4736. +
  4737. +/**
  4738. + * struct dpsw_acl_attr - ACL Attributes
  4739. + * @max_entries: Max number of ACL entries
  4740. + * @num_entries: Number of used ACL entries
  4741. + * @num_ifs: Number of interfaces associated with ACL
  4742. + */
  4743. +struct dpsw_acl_attr {
  4744. + uint16_t max_entries;
  4745. + uint16_t num_entries;
  4746. + uint16_t num_ifs;
  4747. +};
  4748. +
  4749. +/**
  4750. +* dpsw_acl_get_attributes() - Get specific counter of particular interface
  4751. +* @mc_io: Pointer to MC portal's I/O object
  4752. +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4753. +* @token: Token of DPSW object
  4754. +* @acl_id: ACL Identifier
  4755. +* @attr: Returned ACL attributes
  4756. +*
  4757. +* Return: '0' on Success; Error code otherwise.
  4758. +*/
  4759. +int dpsw_acl_get_attributes(struct fsl_mc_io *mc_io,
  4760. + uint32_t cmd_flags,
  4761. + uint16_t token,
  4762. + uint16_t acl_id,
  4763. + struct dpsw_acl_attr *attr);
  4764. +/**
  4765. +* struct dpsw_ctrl_if_attr - Control interface attributes
  4766. +* @rx_fqid: Receive FQID
  4767. +* @rx_err_fqid: Receive error FQID
  4768. +* @tx_err_conf_fqid: Transmit error and confirmation FQID
  4769. +*/
  4770. +struct dpsw_ctrl_if_attr {
  4771. + uint32_t rx_fqid;
  4772. + uint32_t rx_err_fqid;
  4773. + uint32_t tx_err_conf_fqid;
  4774. +};
  4775. +
  4776. +/**
  4777. +* dpsw_ctrl_if_get_attributes() - Obtain control interface attributes
  4778. +* @mc_io: Pointer to MC portal's I/O object
  4779. +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4780. +* @token: Token of DPSW object
  4781. +* @attr: Returned control interface attributes
  4782. +*
  4783. +* Return: '0' on Success; Error code otherwise.
  4784. +*/
  4785. +int dpsw_ctrl_if_get_attributes(struct fsl_mc_io *mc_io,
  4786. + uint32_t cmd_flags,
  4787. + uint16_t token,
  4788. + struct dpsw_ctrl_if_attr *attr);
  4789. +
  4790. +/**
  4791. + * Maximum number of DPBP
  4792. + */
  4793. +#define DPSW_MAX_DPBP 8
  4794. +
  4795. +/**
  4796. + * struct dpsw_ctrl_if_pools_cfg - Control interface buffer pools configuration
  4797. + * @num_dpbp: Number of DPBPs
  4798. + * @pools: Array of buffer pools parameters; The number of valid entries
  4799. + * must match 'num_dpbp' value
  4800. + */
  4801. +struct dpsw_ctrl_if_pools_cfg {
  4802. + uint8_t num_dpbp;
  4803. + /**
  4804. + * struct pools - Buffer pools parameters
  4805. + * @dpbp_id: DPBP object ID
  4806. + * @buffer_size: Buffer size
  4807. + * @backup_pool: Backup pool
  4808. + */
  4809. + struct {
  4810. + int dpbp_id;
  4811. + uint16_t buffer_size;
  4812. + int backup_pool;
  4813. + } pools[DPSW_MAX_DPBP];
  4814. +};
  4815. +
  4816. +/**
  4817. +* dpsw_ctrl_if_set_pools() - Set control interface buffer pools
  4818. +* @mc_io: Pointer to MC portal's I/O object
  4819. +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4820. +* @token: Token of DPSW object
  4821. +* @cfg: buffer pools configuration
  4822. +*
  4823. +* Return: '0' on Success; Error code otherwise.
  4824. +*/
  4825. +int dpsw_ctrl_if_set_pools(struct fsl_mc_io *mc_io,
  4826. + uint32_t cmd_flags,
  4827. + uint16_t token,
  4828. + const struct dpsw_ctrl_if_pools_cfg *cfg);
  4829. +
  4830. +/**
  4831. +* dpsw_ctrl_if_enable() - Enable control interface
  4832. +* @mc_io: Pointer to MC portal's I/O object
  4833. +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4834. +* @token: Token of DPSW object
  4835. +*
  4836. +* Return: '0' on Success; Error code otherwise.
  4837. +*/
  4838. +int dpsw_ctrl_if_enable(struct fsl_mc_io *mc_io,
  4839. + uint32_t cmd_flags,
  4840. + uint16_t token);
  4841. +
  4842. +/**
  4843. +* dpsw_ctrl_if_disable() - Function disables control interface
  4844. +* @mc_io: Pointer to MC portal's I/O object
  4845. +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  4846. +* @token: Token of DPSW object
  4847. +*
  4848. +* Return: '0' on Success; Error code otherwise.
  4849. +*/
  4850. +int dpsw_ctrl_if_disable(struct fsl_mc_io *mc_io,
  4851. + uint32_t cmd_flags,
  4852. + uint16_t token);
  4853. +
  4854. +#endif /* __FSL_DPSW_H */
  4855. --- /dev/null
  4856. +++ b/drivers/staging/fsl-dpaa2/ethsw/switch.c
  4857. @@ -0,0 +1,1711 @@
  4858. +/* Copyright 2014-2015 Freescale Semiconductor Inc.
  4859. + *
  4860. + * Redistribution and use in source and binary forms, with or without
  4861. + * modification, are permitted provided that the following conditions are met:
  4862. + * * Redistributions of source code must retain the above copyright
  4863. + * notice, this list of conditions and the following disclaimer.
  4864. + * * Redistributions in binary form must reproduce the above copyright
  4865. + * notice, this list of conditions and the following disclaimer in the
  4866. + * documentation and/or other materials provided with the distribution.
  4867. + * * Neither the name of Freescale Semiconductor nor the
  4868. + * names of its contributors may be used to endorse or promote products
  4869. + * derived from this software without specific prior written permission.
  4870. + *
  4871. + *
  4872. + * ALTERNATIVELY, this software may be distributed under the terms of the
  4873. + * GNU General Public License ("GPL") as published by the Free Software
  4874. + * Foundation, either version 2 of that License or (at your option) any
  4875. + * later version.
  4876. + *
  4877. + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
  4878. + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4879. + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  4880. + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
  4881. + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4882. + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4883. + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4884. + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4885. + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4886. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4887. + */
  4888. +
  4889. +#include <linux/module.h>
  4890. +
  4891. +#include <linux/netdevice.h>
  4892. +#include <linux/etherdevice.h>
  4893. +#include <linux/rtnetlink.h>
  4894. +#include <linux/if_vlan.h>
  4895. +#include <linux/interrupt.h>
  4896. +#include <linux/msi.h>
  4897. +
  4898. +#include <uapi/linux/if_bridge.h>
  4899. +#include <net/netlink.h>
  4900. +
  4901. +#include "../../fsl-mc/include/mc.h"
  4902. +#include "dpsw.h"
  4903. +#include "dpsw-cmd.h"
  4904. +
  4905. +/* Minimal supported DPSE version */
  4906. +#define DPSW_MIN_VER_MAJOR 7
  4907. +#define DPSW_MIN_VER_MINOR 0
  4908. +
  4909. +/* IRQ index */
  4910. +#define DPSW_MAX_IRQ_NUM 2
  4911. +
  4912. +#define ETHSW_VLAN_MEMBER 1
  4913. +#define ETHSW_VLAN_UNTAGGED 2
  4914. +#define ETHSW_VLAN_PVID 4
  4915. +#define ETHSW_VLAN_GLOBAL 8
  4916. +
  4917. +struct ethsw_port_priv {
  4918. + struct net_device *netdev;
  4919. + struct list_head list;
  4920. + u16 port_index;
  4921. + struct ethsw_dev_priv *ethsw_priv;
  4922. + u8 stp_state;
  4923. +
  4924. + char vlans[VLAN_VID_MASK+1];
  4925. +
  4926. +};
  4927. +
  4928. +struct ethsw_dev_priv {
  4929. + struct net_device *netdev;
  4930. + struct fsl_mc_io *mc_io;
  4931. + uint16_t dpsw_handle;
  4932. + struct dpsw_attr sw_attr;
  4933. + int dev_id;
  4934. + /*TODO: redundant, we can use the slave dev list */
  4935. + struct list_head port_list;
  4936. +
  4937. + bool flood;
  4938. + bool learning;
  4939. +
  4940. + char vlans[VLAN_VID_MASK+1];
  4941. +};
  4942. +
  4943. +static int ethsw_port_stop(struct net_device *netdev);
  4944. +static int ethsw_port_open(struct net_device *netdev);
  4945. +
  4946. +static inline void __get_priv(struct net_device *netdev,
  4947. + struct ethsw_dev_priv **priv,
  4948. + struct ethsw_port_priv **port_priv)
  4949. +{
  4950. + struct ethsw_dev_priv *_priv = NULL;
  4951. + struct ethsw_port_priv *_port_priv = NULL;
  4952. +
  4953. + if (netdev->flags & IFF_MASTER) {
  4954. + _priv = netdev_priv(netdev);
  4955. + } else {
  4956. + _port_priv = netdev_priv(netdev);
  4957. + _priv = _port_priv->ethsw_priv;
  4958. + }
  4959. +
  4960. + if (priv)
  4961. + *priv = _priv;
  4962. + if (port_priv)
  4963. + *port_priv = _port_priv;
  4964. +}
  4965. +
  4966. +/* -------------------------------------------------------------------------- */
  4967. +/* ethsw netdevice ops */
  4968. +
  4969. +static netdev_tx_t ethsw_dropframe(struct sk_buff *skb, struct net_device *dev)
  4970. +{
  4971. + /* we don't support I/O for now, drop the frame */
  4972. + dev_kfree_skb_any(skb);
  4973. + return NETDEV_TX_OK;
  4974. +}
  4975. +
  4976. +static int ethsw_open(struct net_device *netdev)
  4977. +{
  4978. + struct ethsw_dev_priv *priv = netdev_priv(netdev);
  4979. + struct list_head *pos;
  4980. + struct ethsw_port_priv *port_priv = NULL;
  4981. + int err;
  4982. +
  4983. + err = dpsw_enable(priv->mc_io, 0, priv->dpsw_handle);
  4984. + if (err) {
  4985. + netdev_err(netdev, "dpsw_enable err %d\n", err);
  4986. + return err;
  4987. + }
  4988. +
  4989. + list_for_each(pos, &priv->port_list) {
  4990. + port_priv = list_entry(pos, struct ethsw_port_priv, list);
  4991. + err = dev_open(port_priv->netdev);
  4992. + if (err)
  4993. + netdev_err(port_priv->netdev, "dev_open err %d\n", err);
  4994. + }
  4995. +
  4996. + return 0;
  4997. +}
  4998. +
  4999. +static int ethsw_stop(struct net_device *netdev)
  5000. +{
  5001. + struct ethsw_dev_priv *priv = netdev_priv(netdev);
  5002. + struct list_head *pos;
  5003. + struct ethsw_port_priv *port_priv = NULL;
  5004. + int err;
  5005. +
  5006. + err = dpsw_disable(priv->mc_io, 0, priv->dpsw_handle);
  5007. + if (err) {
  5008. + netdev_err(netdev, "dpsw_disable err %d\n", err);
  5009. + return err;
  5010. + }
  5011. +
  5012. + list_for_each(pos, &priv->port_list) {
  5013. + port_priv = list_entry(pos, struct ethsw_port_priv, list);
  5014. + err = dev_close(port_priv->netdev);
  5015. + if (err)
  5016. + netdev_err(port_priv->netdev,
  5017. + "dev_close err %d\n", err);
  5018. + }
  5019. +
  5020. + return 0;
  5021. +}
  5022. +
  5023. +static int ethsw_add_vlan(struct net_device *netdev, u16 vid)
  5024. +{
  5025. + struct ethsw_dev_priv *priv = netdev_priv(netdev);
  5026. + int err;
  5027. +
  5028. + struct dpsw_vlan_cfg vcfg = {
  5029. + /* TODO: add support for VLAN private FDBs */
  5030. + .fdb_id = 0,
  5031. + };
  5032. + if (priv->vlans[vid]) {
  5033. + netdev_err(netdev, "VLAN already configured\n");
  5034. + return -EEXIST;
  5035. + }
  5036. +
  5037. + err = dpsw_vlan_add(priv->mc_io, 0, priv->dpsw_handle, vid, &vcfg);
  5038. + if (err) {
  5039. + netdev_err(netdev, "dpsw_vlan_add err %d\n", err);
  5040. + return err;
  5041. + }
  5042. + priv->vlans[vid] = ETHSW_VLAN_MEMBER;
  5043. +
  5044. + return 0;
  5045. +}
  5046. +
  5047. +static int ethsw_port_add_vlan(struct net_device *netdev, u16 vid, u16 flags)
  5048. +{
  5049. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5050. + struct ethsw_dev_priv *priv = port_priv->ethsw_priv;
  5051. + int err;
  5052. +
  5053. + struct dpsw_vlan_if_cfg vcfg = {
  5054. + .num_ifs = 1,
  5055. + .if_id[0] = port_priv->port_index,
  5056. + };
  5057. +
  5058. + if (port_priv->vlans[vid]) {
  5059. + netdev_err(netdev, "VLAN already configured\n");
  5060. + return -EEXIST;
  5061. + }
  5062. +
  5063. + if (flags & BRIDGE_VLAN_INFO_PVID && netif_oper_up(netdev)) {
  5064. + netdev_err(netdev, "interface must be down to change PVID!\n");
  5065. + return -EBUSY;
  5066. + }
  5067. +
  5068. + err = dpsw_vlan_add_if(priv->mc_io, 0, priv->dpsw_handle, vid, &vcfg);
  5069. + if (err) {
  5070. + netdev_err(netdev, "dpsw_vlan_add_if err %d\n", err);
  5071. + return err;
  5072. + }
  5073. + port_priv->vlans[vid] = ETHSW_VLAN_MEMBER;
  5074. +
  5075. + if (flags & BRIDGE_VLAN_INFO_UNTAGGED) {
  5076. + err = dpsw_vlan_add_if_untagged(priv->mc_io, 0,
  5077. + priv->dpsw_handle, vid, &vcfg);
  5078. + if (err) {
  5079. + netdev_err(netdev, "dpsw_vlan_add_if_untagged err %d\n",
  5080. + err);
  5081. + return err;
  5082. + }
  5083. + port_priv->vlans[vid] |= ETHSW_VLAN_UNTAGGED;
  5084. + }
  5085. +
  5086. + if (flags & BRIDGE_VLAN_INFO_PVID) {
  5087. + struct dpsw_tci_cfg tci_cfg = {
  5088. + /* TODO: at least add better defaults if these cannot
  5089. + * be configured
  5090. + */
  5091. + .pcp = 0,
  5092. + .dei = 0,
  5093. + .vlan_id = vid,
  5094. + };
  5095. +
  5096. + err = dpsw_if_set_tci(priv->mc_io, 0, priv->dpsw_handle,
  5097. + port_priv->port_index, &tci_cfg);
  5098. + if (err) {
  5099. + netdev_err(netdev, "dpsw_if_set_tci err %d\n", err);
  5100. + return err;
  5101. + }
  5102. + port_priv->vlans[vid] |= ETHSW_VLAN_PVID;
  5103. + }
  5104. +
  5105. + return 0;
  5106. +}
  5107. +
  5108. +static const struct nla_policy ifla_br_policy[IFLA_MAX+1] = {
  5109. + [IFLA_BRIDGE_FLAGS] = { .type = NLA_U16 },
  5110. + [IFLA_BRIDGE_MODE] = { .type = NLA_U16 },
  5111. + [IFLA_BRIDGE_VLAN_INFO] = { .type = NLA_BINARY,
  5112. + .len = sizeof(struct bridge_vlan_info), },
  5113. +};
  5114. +
  5115. +static int ethsw_setlink_af_spec(struct net_device *netdev,
  5116. + struct nlattr **tb)
  5117. +{
  5118. + struct bridge_vlan_info *vinfo;
  5119. + struct ethsw_dev_priv *priv = NULL;
  5120. + struct ethsw_port_priv *port_priv = NULL;
  5121. + int err = 0;
  5122. +
  5123. + if (!tb[IFLA_BRIDGE_VLAN_INFO]) {
  5124. + netdev_err(netdev, "no VLAN INFO in nlmsg\n");
  5125. + return -EOPNOTSUPP;
  5126. + }
  5127. +
  5128. + vinfo = nla_data(tb[IFLA_BRIDGE_VLAN_INFO]);
  5129. +
  5130. + if (!vinfo->vid || vinfo->vid > VLAN_VID_MASK)
  5131. + return -EINVAL;
  5132. +
  5133. + __get_priv(netdev, &priv, &port_priv);
  5134. +
  5135. + if (!port_priv || !priv->vlans[vinfo->vid]) {
  5136. + /* command targets switch device or this is a new VLAN */
  5137. + err = ethsw_add_vlan(priv->netdev, vinfo->vid);
  5138. + if (err)
  5139. + return err;
  5140. +
  5141. + /* command targets switch device; mark it*/
  5142. + if (!port_priv)
  5143. + priv->vlans[vinfo->vid] |= ETHSW_VLAN_GLOBAL;
  5144. + }
  5145. +
  5146. + if (port_priv) {
  5147. + /* command targets switch port */
  5148. + err = ethsw_port_add_vlan(netdev, vinfo->vid, vinfo->flags);
  5149. + if (err)
  5150. + return err;
  5151. + }
  5152. +
  5153. + return 0;
  5154. +}
  5155. +
  5156. +static const struct nla_policy ifla_brport_policy[IFLA_BRPORT_MAX + 1] = {
  5157. + [IFLA_BRPORT_STATE] = { .type = NLA_U8 },
  5158. + [IFLA_BRPORT_COST] = { .type = NLA_U32 },
  5159. + [IFLA_BRPORT_PRIORITY] = { .type = NLA_U16 },
  5160. + [IFLA_BRPORT_MODE] = { .type = NLA_U8 },
  5161. + [IFLA_BRPORT_GUARD] = { .type = NLA_U8 },
  5162. + [IFLA_BRPORT_PROTECT] = { .type = NLA_U8 },
  5163. + [IFLA_BRPORT_LEARNING] = { .type = NLA_U8 },
  5164. + [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NLA_U8 },
  5165. +};
  5166. +
  5167. +static int ethsw_set_learning(struct net_device *netdev, u8 flag)
  5168. +{
  5169. + struct ethsw_dev_priv *priv = netdev_priv(netdev);
  5170. + enum dpsw_fdb_learning_mode learn_mode;
  5171. + int err;
  5172. +
  5173. + if (flag)
  5174. + learn_mode = DPSW_FDB_LEARNING_MODE_HW;
  5175. + else
  5176. + learn_mode = DPSW_FDB_LEARNING_MODE_DIS;
  5177. +
  5178. + err = dpsw_fdb_set_learning_mode(priv->mc_io, 0, priv->dpsw_handle,
  5179. + 0, learn_mode);
  5180. + if (err) {
  5181. + netdev_err(netdev, "dpsw_fdb_set_learning_mode err %d\n", err);
  5182. + return err;
  5183. + }
  5184. + priv->learning = !!flag;
  5185. +
  5186. + return 0;
  5187. +}
  5188. +
  5189. +static int ethsw_port_set_flood(struct net_device *netdev, u8 flag)
  5190. +{
  5191. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5192. + struct ethsw_dev_priv *priv = port_priv->ethsw_priv;
  5193. + int err;
  5194. +
  5195. + err = dpsw_if_set_flooding(priv->mc_io, 0, priv->dpsw_handle,
  5196. + port_priv->port_index, (int)flag);
  5197. + if (err) {
  5198. + netdev_err(netdev, "dpsw_fdb_set_learning_mode err %d\n", err);
  5199. + return err;
  5200. + }
  5201. + priv->flood = !!flag;
  5202. +
  5203. + return 0;
  5204. +}
  5205. +
  5206. +static int ethsw_port_set_state(struct net_device *netdev, u8 state)
  5207. +{
  5208. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5209. + struct ethsw_dev_priv *priv = port_priv->ethsw_priv;
  5210. + u8 old_state = port_priv->stp_state;
  5211. + int err;
  5212. +
  5213. + struct dpsw_stp_cfg stp_cfg = {
  5214. + .vlan_id = 1,
  5215. + .state = state,
  5216. + };
  5217. + /* TODO: check port state, interface may be down */
  5218. +
  5219. + if (state > BR_STATE_BLOCKING)
  5220. + return -EINVAL;
  5221. +
  5222. + if (state == port_priv->stp_state)
  5223. + return 0;
  5224. +
  5225. + if (state == BR_STATE_DISABLED) {
  5226. + port_priv->stp_state = state;
  5227. +
  5228. + err = ethsw_port_stop(netdev);
  5229. + if (err)
  5230. + goto error;
  5231. + } else {
  5232. + err = dpsw_if_set_stp(priv->mc_io, 0, priv->dpsw_handle,
  5233. + port_priv->port_index, &stp_cfg);
  5234. + if (err) {
  5235. + netdev_err(netdev, "dpsw_if_set_stp err %d\n", err);
  5236. + return err;
  5237. + }
  5238. +
  5239. + port_priv->stp_state = state;
  5240. +
  5241. + if (old_state == BR_STATE_DISABLED) {
  5242. + err = ethsw_port_open(netdev);
  5243. + if (err)
  5244. + goto error;
  5245. + }
  5246. + }
  5247. +
  5248. + return 0;
  5249. +error:
  5250. + port_priv->stp_state = old_state;
  5251. + return err;
  5252. +}
  5253. +
  5254. +static int ethsw_setlink_protinfo(struct net_device *netdev,
  5255. + struct nlattr **tb)
  5256. +{
  5257. + struct ethsw_dev_priv *priv;
  5258. + struct ethsw_port_priv *port_priv = NULL;
  5259. + int err = 0;
  5260. +
  5261. + __get_priv(netdev, &priv, &port_priv);
  5262. +
  5263. + if (tb[IFLA_BRPORT_LEARNING]) {
  5264. + u8 flag = nla_get_u8(tb[IFLA_BRPORT_LEARNING]);
  5265. +
  5266. + if (port_priv)
  5267. + netdev_warn(netdev,
  5268. + "learning set on whole switch dev\n");
  5269. +
  5270. + err = ethsw_set_learning(priv->netdev, flag);
  5271. + if (err)
  5272. + return err;
  5273. +
  5274. + } else if (tb[IFLA_BRPORT_UNICAST_FLOOD] && port_priv) {
  5275. + u8 flag = nla_get_u8(tb[IFLA_BRPORT_UNICAST_FLOOD]);
  5276. +
  5277. + err = ethsw_port_set_flood(port_priv->netdev, flag);
  5278. + if (err)
  5279. + return err;
  5280. +
  5281. + } else if (tb[IFLA_BRPORT_STATE] && port_priv) {
  5282. + u8 state = nla_get_u8(tb[IFLA_BRPORT_STATE]);
  5283. +
  5284. + err = ethsw_port_set_state(port_priv->netdev, state);
  5285. + if (err)
  5286. + return err;
  5287. +
  5288. + } else {
  5289. + return -EOPNOTSUPP;
  5290. + }
  5291. +
  5292. + return 0;
  5293. +}
  5294. +
  5295. +static int ethsw_setlink(struct net_device *netdev,
  5296. + struct nlmsghdr *nlh,
  5297. + u16 flags)
  5298. +{
  5299. + struct nlattr *attr;
  5300. + struct nlattr *tb[(IFLA_BRIDGE_MAX > IFLA_BRPORT_MAX) ?
  5301. + IFLA_BRIDGE_MAX : IFLA_BRPORT_MAX+1];
  5302. + int err = 0;
  5303. +
  5304. + attr = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
  5305. + if (attr) {
  5306. + err = nla_parse_nested(tb, IFLA_BRIDGE_MAX, attr,
  5307. + ifla_br_policy);
  5308. + if (err) {
  5309. + netdev_err(netdev,
  5310. + "nla_parse_nested for br_policy err %d\n",
  5311. + err);
  5312. + return err;
  5313. + }
  5314. +
  5315. + err = ethsw_setlink_af_spec(netdev, tb);
  5316. + return err;
  5317. + }
  5318. +
  5319. + attr = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_PROTINFO);
  5320. + if (attr) {
  5321. + err = nla_parse_nested(tb, IFLA_BRPORT_MAX, attr,
  5322. + ifla_brport_policy);
  5323. + if (err) {
  5324. + netdev_err(netdev,
  5325. + "nla_parse_nested for brport_policy err %d\n",
  5326. + err);
  5327. + return err;
  5328. + }
  5329. +
  5330. + err = ethsw_setlink_protinfo(netdev, tb);
  5331. + return err;
  5332. + }
  5333. +
  5334. + netdev_err(netdev, "nlmsg_find_attr found no AF_SPEC/PROTINFO\n");
  5335. + return -EOPNOTSUPP;
  5336. +}
  5337. +
  5338. +static int __nla_put_netdev(struct sk_buff *skb, struct net_device *netdev,
  5339. + struct ethsw_dev_priv *priv)
  5340. +{
  5341. + u8 operstate = netif_running(netdev) ? netdev->operstate : IF_OPER_DOWN;
  5342. + int iflink;
  5343. + int err;
  5344. +
  5345. + err = nla_put_string(skb, IFLA_IFNAME, netdev->name);
  5346. + if (err)
  5347. + goto nla_put_err;
  5348. + err = nla_put_u32(skb, IFLA_MASTER, priv->netdev->ifindex);
  5349. + if (err)
  5350. + goto nla_put_err;
  5351. + err = nla_put_u32(skb, IFLA_MTU, netdev->mtu);
  5352. + if (err)
  5353. + goto nla_put_err;
  5354. + err = nla_put_u8(skb, IFLA_OPERSTATE, operstate);
  5355. + if (err)
  5356. + goto nla_put_err;
  5357. + if (netdev->addr_len) {
  5358. + err = nla_put(skb, IFLA_ADDRESS, netdev->addr_len,
  5359. + netdev->dev_addr);
  5360. + if (err)
  5361. + goto nla_put_err;
  5362. + }
  5363. +
  5364. + iflink = dev_get_iflink(netdev);
  5365. + if (netdev->ifindex != iflink) {
  5366. + err = nla_put_u32(skb, IFLA_LINK, iflink);
  5367. + if (err)
  5368. + goto nla_put_err;
  5369. + }
  5370. +
  5371. + return 0;
  5372. +
  5373. +nla_put_err:
  5374. + netdev_err(netdev, "nla_put_ err %d\n", err);
  5375. + return err;
  5376. +}
  5377. +
  5378. +static int __nla_put_port(struct sk_buff *skb, struct net_device *netdev,
  5379. + struct ethsw_port_priv *port_priv)
  5380. +{
  5381. + struct nlattr *nest;
  5382. + int err;
  5383. +
  5384. + u8 stp_state = port_priv->stp_state;
  5385. +
  5386. + if (port_priv->stp_state == DPSW_STP_STATE_BLOCKING)
  5387. + stp_state = BR_STATE_BLOCKING;
  5388. +
  5389. + nest = nla_nest_start(skb, IFLA_PROTINFO | NLA_F_NESTED);
  5390. + if (!nest) {
  5391. + netdev_err(netdev, "nla_nest_start failed\n");
  5392. + return -ENOMEM;
  5393. + }
  5394. +
  5395. + err = nla_put_u8(skb, IFLA_BRPORT_STATE, stp_state);
  5396. + if (err)
  5397. + goto nla_put_err;
  5398. + err = nla_put_u16(skb, IFLA_BRPORT_PRIORITY, 0);
  5399. + if (err)
  5400. + goto nla_put_err;
  5401. + err = nla_put_u32(skb, IFLA_BRPORT_COST, 0);
  5402. + if (err)
  5403. + goto nla_put_err;
  5404. + err = nla_put_u8(skb, IFLA_BRPORT_MODE, 0);
  5405. + if (err)
  5406. + goto nla_put_err;
  5407. + err = nla_put_u8(skb, IFLA_BRPORT_GUARD, 0);
  5408. + if (err)
  5409. + goto nla_put_err;
  5410. + err = nla_put_u8(skb, IFLA_BRPORT_PROTECT, 0);
  5411. + if (err)
  5412. + goto nla_put_err;
  5413. + err = nla_put_u8(skb, IFLA_BRPORT_FAST_LEAVE, 0);
  5414. + if (err)
  5415. + goto nla_put_err;
  5416. + err = nla_put_u8(skb, IFLA_BRPORT_LEARNING,
  5417. + port_priv->ethsw_priv->learning);
  5418. + if (err)
  5419. + goto nla_put_err;
  5420. + err = nla_put_u8(skb, IFLA_BRPORT_UNICAST_FLOOD,
  5421. + port_priv->ethsw_priv->flood);
  5422. + if (err)
  5423. + goto nla_put_err;
  5424. + nla_nest_end(skb, nest);
  5425. +
  5426. + return 0;
  5427. +
  5428. +nla_put_err:
  5429. + netdev_err(netdev, "nla_put_ err %d\n", err);
  5430. + nla_nest_cancel(skb, nest);
  5431. + return err;
  5432. +}
  5433. +
  5434. +static int __nla_put_vlan(struct sk_buff *skb, struct net_device *netdev,
  5435. + struct ethsw_dev_priv *priv,
  5436. + struct ethsw_port_priv *port_priv)
  5437. +{
  5438. + struct nlattr *nest;
  5439. + struct bridge_vlan_info vinfo;
  5440. + const char *vlans;
  5441. + u16 i;
  5442. + int err;
  5443. +
  5444. + nest = nla_nest_start(skb, IFLA_AF_SPEC);
  5445. + if (!nest) {
  5446. + netdev_err(netdev, "nla_nest_start failed");
  5447. + return -ENOMEM;
  5448. + }
  5449. +
  5450. + if (port_priv)
  5451. + vlans = port_priv->vlans;
  5452. + else
  5453. + vlans = priv->vlans;
  5454. +
  5455. + for (i = 0; i < VLAN_VID_MASK+1; i++) {
  5456. + vinfo.flags = 0;
  5457. + vinfo.vid = i;
  5458. +
  5459. + if (vlans[i] & ETHSW_VLAN_UNTAGGED)
  5460. + vinfo.flags |= BRIDGE_VLAN_INFO_UNTAGGED;
  5461. +
  5462. + if (vlans[i] & ETHSW_VLAN_PVID)
  5463. + vinfo.flags |= BRIDGE_VLAN_INFO_PVID;
  5464. +
  5465. + if (vlans[i] & ETHSW_VLAN_MEMBER) {
  5466. + err = nla_put(skb, IFLA_BRIDGE_VLAN_INFO,
  5467. + sizeof(vinfo), &vinfo);
  5468. + if (err)
  5469. + goto nla_put_err;
  5470. + }
  5471. + }
  5472. +
  5473. + nla_nest_end(skb, nest);
  5474. +
  5475. + return 0;
  5476. +nla_put_err:
  5477. + netdev_err(netdev, "nla_put_ err %d\n", err);
  5478. + nla_nest_cancel(skb, nest);
  5479. + return err;
  5480. +}
  5481. +
  5482. +static int ethsw_getlink(struct sk_buff *skb, u32 pid, u32 seq,
  5483. + struct net_device *netdev, u32 filter_mask,
  5484. + int nlflags)
  5485. +{
  5486. + struct ethsw_dev_priv *priv;
  5487. + struct ethsw_port_priv *port_priv = NULL;
  5488. + struct ifinfomsg *hdr;
  5489. + struct nlmsghdr *nlh;
  5490. + int err;
  5491. +
  5492. + __get_priv(netdev, &priv, &port_priv);
  5493. +
  5494. + nlh = nlmsg_put(skb, pid, seq, RTM_NEWLINK, sizeof(*hdr), NLM_F_MULTI);
  5495. + if (!nlh)
  5496. + return -EMSGSIZE;
  5497. +
  5498. + hdr = nlmsg_data(nlh);
  5499. + memset(hdr, 0, sizeof(*hdr));
  5500. + hdr->ifi_family = AF_BRIDGE;
  5501. + hdr->ifi_type = netdev->type;
  5502. + hdr->ifi_index = netdev->ifindex;
  5503. + hdr->ifi_flags = dev_get_flags(netdev);
  5504. +
  5505. + err = __nla_put_netdev(skb, netdev, priv);
  5506. + if (err)
  5507. + goto nla_put_err;
  5508. +
  5509. + if (port_priv) {
  5510. + err = __nla_put_port(skb, netdev, port_priv);
  5511. + if (err)
  5512. + goto nla_put_err;
  5513. + }
  5514. +
  5515. + /* Check if the VID information is requested */
  5516. + if (filter_mask & RTEXT_FILTER_BRVLAN) {
  5517. + err = __nla_put_vlan(skb, netdev, priv, port_priv);
  5518. + if (err)
  5519. + goto nla_put_err;
  5520. + }
  5521. +
  5522. + nlmsg_end(skb, nlh);
  5523. + return skb->len;
  5524. +
  5525. +nla_put_err:
  5526. + nlmsg_cancel(skb, nlh);
  5527. + return -EMSGSIZE;
  5528. +}
  5529. +
  5530. +static int ethsw_dellink_switch(struct ethsw_dev_priv *priv, u16 vid)
  5531. +{
  5532. + struct list_head *pos;
  5533. + struct ethsw_port_priv *ppriv_local = NULL;
  5534. + int err = 0;
  5535. +
  5536. + if (!priv->vlans[vid])
  5537. + return -ENOENT;
  5538. +
  5539. + err = dpsw_vlan_remove(priv->mc_io, 0, priv->dpsw_handle, vid);
  5540. + if (err) {
  5541. + netdev_err(priv->netdev, "dpsw_vlan_remove err %d\n", err);
  5542. + return err;
  5543. + }
  5544. + priv->vlans[vid] = 0;
  5545. +
  5546. + list_for_each(pos, &priv->port_list) {
  5547. + ppriv_local = list_entry(pos, struct ethsw_port_priv,
  5548. + list);
  5549. + ppriv_local->vlans[vid] = 0;
  5550. + }
  5551. +
  5552. + return 0;
  5553. +}
  5554. +
  5555. +static int ethsw_dellink_port(struct ethsw_dev_priv *priv,
  5556. + struct ethsw_port_priv *port_priv,
  5557. + u16 vid)
  5558. +{
  5559. + struct list_head *pos;
  5560. + struct ethsw_port_priv *ppriv_local = NULL;
  5561. + struct dpsw_vlan_if_cfg vcfg = {
  5562. + .num_ifs = 1,
  5563. + .if_id[0] = port_priv->port_index,
  5564. + };
  5565. + unsigned int count = 0;
  5566. + int err = 0;
  5567. +
  5568. + if (!port_priv->vlans[vid])
  5569. + return -ENOENT;
  5570. +
  5571. + /* VLAN will be deleted from switch if global flag is not set
  5572. + * and is configured on only one port
  5573. + */
  5574. + if (!(priv->vlans[vid] & ETHSW_VLAN_GLOBAL)) {
  5575. + list_for_each(pos, &priv->port_list) {
  5576. + ppriv_local = list_entry(pos, struct ethsw_port_priv,
  5577. + list);
  5578. + if (ppriv_local->vlans[vid] & ETHSW_VLAN_MEMBER)
  5579. + count++;
  5580. + }
  5581. +
  5582. + if (count == 1)
  5583. + return ethsw_dellink_switch(priv, vid);
  5584. + }
  5585. +
  5586. + err = dpsw_vlan_remove_if(priv->mc_io, 0, priv->dpsw_handle,
  5587. + vid, &vcfg);
  5588. + if (err) {
  5589. + netdev_err(priv->netdev, "dpsw_vlan_remove_if err %d\n", err);
  5590. + return err;
  5591. + }
  5592. + port_priv->vlans[vid] = 0;
  5593. + return 0;
  5594. +}
  5595. +
  5596. +static int ethsw_dellink(struct net_device *netdev,
  5597. + struct nlmsghdr *nlh,
  5598. + u16 flags)
  5599. +{
  5600. + struct nlattr *tb[IFLA_BRIDGE_MAX+1];
  5601. + struct nlattr *spec;
  5602. + struct bridge_vlan_info *vinfo;
  5603. + struct ethsw_dev_priv *priv;
  5604. + struct ethsw_port_priv *port_priv = NULL;
  5605. + int err = 0;
  5606. +
  5607. + spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
  5608. + if (!spec)
  5609. + return 0;
  5610. +
  5611. + err = nla_parse_nested(tb, IFLA_BRIDGE_MAX, spec, ifla_br_policy);
  5612. + if (err)
  5613. + return err;
  5614. +
  5615. + if (!tb[IFLA_BRIDGE_VLAN_INFO])
  5616. + return -EOPNOTSUPP;
  5617. +
  5618. + vinfo = nla_data(tb[IFLA_BRIDGE_VLAN_INFO]);
  5619. +
  5620. + if (!vinfo->vid || vinfo->vid > VLAN_VID_MASK)
  5621. + return -EINVAL;
  5622. +
  5623. + __get_priv(netdev, &priv, &port_priv);
  5624. +
  5625. + /* decide if command targets switch device or port */
  5626. + if (!port_priv)
  5627. + err = ethsw_dellink_switch(priv, vinfo->vid);
  5628. + else
  5629. + err = ethsw_dellink_port(priv, port_priv, vinfo->vid);
  5630. +
  5631. + return err;
  5632. +}
  5633. +
  5634. +static const struct net_device_ops ethsw_ops = {
  5635. + .ndo_open = &ethsw_open,
  5636. + .ndo_stop = &ethsw_stop,
  5637. +
  5638. + .ndo_bridge_setlink = &ethsw_setlink,
  5639. + .ndo_bridge_getlink = &ethsw_getlink,
  5640. + .ndo_bridge_dellink = &ethsw_dellink,
  5641. +
  5642. + .ndo_start_xmit = &ethsw_dropframe,
  5643. +};
  5644. +
  5645. +/*--------------------------------------------------------------------------- */
  5646. +/* switch port netdevice ops */
  5647. +
  5648. +static int _ethsw_port_carrier_state_sync(struct net_device *netdev)
  5649. +{
  5650. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5651. + struct dpsw_link_state state;
  5652. + int err;
  5653. +
  5654. + err = dpsw_if_get_link_state(port_priv->ethsw_priv->mc_io, 0,
  5655. + port_priv->ethsw_priv->dpsw_handle,
  5656. + port_priv->port_index, &state);
  5657. + if (unlikely(err)) {
  5658. + netdev_err(netdev, "dpsw_if_get_link_state() err %d\n", err);
  5659. + return err;
  5660. + }
  5661. +
  5662. + WARN_ONCE(state.up > 1, "Garbage read into link_state");
  5663. +
  5664. + if (state.up)
  5665. + netif_carrier_on(port_priv->netdev);
  5666. + else
  5667. + netif_carrier_off(port_priv->netdev);
  5668. +
  5669. + return 0;
  5670. +}
  5671. +
  5672. +static int ethsw_port_open(struct net_device *netdev)
  5673. +{
  5674. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5675. + int err;
  5676. +
  5677. + if (!netif_oper_up(netdev) ||
  5678. + port_priv->stp_state == BR_STATE_DISABLED)
  5679. + return 0;
  5680. +
  5681. + err = dpsw_if_enable(port_priv->ethsw_priv->mc_io, 0,
  5682. + port_priv->ethsw_priv->dpsw_handle,
  5683. + port_priv->port_index);
  5684. + if (err) {
  5685. + netdev_err(netdev, "dpsw_if_enable err %d\n", err);
  5686. + return err;
  5687. + }
  5688. +
  5689. + return 0;
  5690. +}
  5691. +
  5692. +static int ethsw_port_stop(struct net_device *netdev)
  5693. +{
  5694. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5695. + int err;
  5696. +
  5697. + err = dpsw_if_disable(port_priv->ethsw_priv->mc_io, 0,
  5698. + port_priv->ethsw_priv->dpsw_handle,
  5699. + port_priv->port_index);
  5700. + if (err) {
  5701. + netdev_err(netdev, "dpsw_if_disable err %d\n", err);
  5702. + return err;
  5703. + }
  5704. +
  5705. + return 0;
  5706. +}
  5707. +
  5708. +static int ethsw_port_fdb_add_uc(struct net_device *netdev,
  5709. + const unsigned char *addr)
  5710. +{
  5711. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5712. + struct dpsw_fdb_unicast_cfg entry = {0};
  5713. + int err;
  5714. +
  5715. + entry.if_egress = port_priv->port_index;
  5716. + entry.type = DPSW_FDB_ENTRY_STATIC;
  5717. + ether_addr_copy(entry.mac_addr, addr);
  5718. +
  5719. + err = dpsw_fdb_add_unicast(port_priv->ethsw_priv->mc_io, 0,
  5720. + port_priv->ethsw_priv->dpsw_handle,
  5721. + 0, &entry);
  5722. + if (err)
  5723. + netdev_err(netdev, "dpsw_fdb_add_unicast err %d\n", err);
  5724. + return err;
  5725. +}
  5726. +
  5727. +static int ethsw_port_fdb_del_uc(struct net_device *netdev,
  5728. + const unsigned char *addr)
  5729. +{
  5730. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5731. + struct dpsw_fdb_unicast_cfg entry = {0};
  5732. + int err;
  5733. +
  5734. + entry.if_egress = port_priv->port_index;
  5735. + entry.type = DPSW_FDB_ENTRY_STATIC;
  5736. + ether_addr_copy(entry.mac_addr, addr);
  5737. +
  5738. + err = dpsw_fdb_remove_unicast(port_priv->ethsw_priv->mc_io, 0,
  5739. + port_priv->ethsw_priv->dpsw_handle,
  5740. + 0, &entry);
  5741. + if (err)
  5742. + netdev_err(netdev, "dpsw_fdb_remove_unicast err %d\n", err);
  5743. + return err;
  5744. +}
  5745. +
  5746. +static int ethsw_port_fdb_add_mc(struct net_device *netdev,
  5747. + const unsigned char *addr)
  5748. +{
  5749. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5750. + struct dpsw_fdb_multicast_cfg entry = {0};
  5751. + int err;
  5752. +
  5753. + ether_addr_copy(entry.mac_addr, addr);
  5754. + entry.type = DPSW_FDB_ENTRY_STATIC;
  5755. + entry.num_ifs = 1;
  5756. + entry.if_id[0] = port_priv->port_index;
  5757. +
  5758. + err = dpsw_fdb_add_multicast(port_priv->ethsw_priv->mc_io, 0,
  5759. + port_priv->ethsw_priv->dpsw_handle,
  5760. + 0, &entry);
  5761. + if (err)
  5762. + netdev_err(netdev, "dpsw_fdb_add_multicast err %d\n", err);
  5763. + return err;
  5764. +}
  5765. +
  5766. +static int ethsw_port_fdb_del_mc(struct net_device *netdev,
  5767. + const unsigned char *addr)
  5768. +{
  5769. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5770. + struct dpsw_fdb_multicast_cfg entry = {0};
  5771. + int err;
  5772. +
  5773. + ether_addr_copy(entry.mac_addr, addr);
  5774. + entry.type = DPSW_FDB_ENTRY_STATIC;
  5775. + entry.num_ifs = 1;
  5776. + entry.if_id[0] = port_priv->port_index;
  5777. +
  5778. + err = dpsw_fdb_remove_multicast(port_priv->ethsw_priv->mc_io, 0,
  5779. + port_priv->ethsw_priv->dpsw_handle,
  5780. + 0, &entry);
  5781. + if (err)
  5782. + netdev_err(netdev, "dpsw_fdb_remove_multicast err %d\n", err);
  5783. + return err;
  5784. +}
  5785. +
  5786. +static int _lookup_address(struct net_device *netdev, int is_uc,
  5787. + const unsigned char *addr)
  5788. +{
  5789. + struct netdev_hw_addr *ha;
  5790. + struct netdev_hw_addr_list *list = (is_uc) ? &netdev->uc : &netdev->mc;
  5791. +
  5792. + netif_addr_lock_bh(netdev);
  5793. + list_for_each_entry(ha, &list->list, list) {
  5794. + if (ether_addr_equal(ha->addr, addr)) {
  5795. + netif_addr_unlock_bh(netdev);
  5796. + return 1;
  5797. + }
  5798. + }
  5799. + netif_addr_unlock_bh(netdev);
  5800. + return 0;
  5801. +}
  5802. +
  5803. +static int ethsw_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
  5804. + struct net_device *netdev,
  5805. + const unsigned char *addr, u16 vid,
  5806. + u16 flags)
  5807. +{
  5808. + struct list_head *pos;
  5809. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5810. + struct ethsw_dev_priv *priv = port_priv->ethsw_priv;
  5811. + int err;
  5812. +
  5813. + /* TODO: add replace support when added to iproute bridge */
  5814. + if (!(flags & NLM_F_REQUEST)) {
  5815. + netdev_err(netdev,
  5816. + "ethsw_port_fdb_add unexpected flags value %08x\n",
  5817. + flags);
  5818. + return -EINVAL;
  5819. + }
  5820. +
  5821. + if (is_unicast_ether_addr(addr)) {
  5822. + /* if entry cannot be replaced, return error if exists */
  5823. + if (flags & NLM_F_EXCL || flags & NLM_F_APPEND) {
  5824. + list_for_each(pos, &priv->port_list) {
  5825. + port_priv = list_entry(pos,
  5826. + struct ethsw_port_priv,
  5827. + list);
  5828. + if (_lookup_address(port_priv->netdev,
  5829. + 1, addr))
  5830. + return -EEXIST;
  5831. + }
  5832. + }
  5833. +
  5834. + err = ethsw_port_fdb_add_uc(netdev, addr);
  5835. + if (err) {
  5836. + netdev_err(netdev, "ethsw_port_fdb_add_uc err %d\n",
  5837. + err);
  5838. + return err;
  5839. + }
  5840. +
  5841. + /* we might have replaced an existing entry for a different
  5842. + * switch port, make sure the address doesn't linger in any
  5843. + * port address list
  5844. + */
  5845. + list_for_each(pos, &priv->port_list) {
  5846. + port_priv = list_entry(pos, struct ethsw_port_priv,
  5847. + list);
  5848. + dev_uc_del(port_priv->netdev, addr);
  5849. + }
  5850. +
  5851. + err = dev_uc_add(netdev, addr);
  5852. + if (err) {
  5853. + netdev_err(netdev, "dev_uc_add err %d\n", err);
  5854. + return err;
  5855. + }
  5856. + } else {
  5857. + struct dpsw_fdb_multicast_cfg entry = {
  5858. + .type = DPSW_FDB_ENTRY_STATIC,
  5859. + .num_ifs = 0,
  5860. + };
  5861. +
  5862. + /* check if address is already set on this port */
  5863. + if (_lookup_address(netdev, 0, addr))
  5864. + return -EEXIST;
  5865. +
  5866. + /* check if the address exists on other port */
  5867. + ether_addr_copy(entry.mac_addr, addr);
  5868. + err = dpsw_fdb_get_multicast(priv->mc_io, 0, priv->dpsw_handle,
  5869. + 0, &entry);
  5870. + if (!err) {
  5871. + /* entry exists, can we replace it? */
  5872. + if (flags & NLM_F_EXCL)
  5873. + return -EEXIST;
  5874. + } else if (err != -ENAVAIL) {
  5875. + netdev_err(netdev, "dpsw_fdb_get_unicast err %d\n",
  5876. + err);
  5877. + return err;
  5878. + }
  5879. +
  5880. + err = ethsw_port_fdb_add_mc(netdev, addr);
  5881. + if (err) {
  5882. + netdev_err(netdev, "ethsw_port_fdb_add_mc err %d\n",
  5883. + err);
  5884. + return err;
  5885. + }
  5886. +
  5887. + err = dev_mc_add(netdev, addr);
  5888. + if (err) {
  5889. + netdev_err(netdev, "dev_mc_add err %d\n", err);
  5890. + return err;
  5891. + }
  5892. + }
  5893. +
  5894. + return 0;
  5895. +}
  5896. +
  5897. +static int ethsw_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
  5898. + struct net_device *netdev,
  5899. + const unsigned char *addr, u16 vid)
  5900. +{
  5901. + int err;
  5902. +
  5903. + if (is_unicast_ether_addr(addr)) {
  5904. + err = ethsw_port_fdb_del_uc(netdev, addr);
  5905. + if (err) {
  5906. + netdev_err(netdev, "ethsw_port_fdb_del_uc err %d\n",
  5907. + err);
  5908. + return err;
  5909. + }
  5910. +
  5911. + /* also delete if configured on port */
  5912. + err = dev_uc_del(netdev, addr);
  5913. + if (err && err != -ENOENT) {
  5914. + netdev_err(netdev, "dev_uc_del err %d\n", err);
  5915. + return err;
  5916. + }
  5917. + } else {
  5918. + if (!_lookup_address(netdev, 0, addr))
  5919. + return -ENOENT;
  5920. +
  5921. + err = dev_mc_del(netdev, addr);
  5922. + if (err) {
  5923. + netdev_err(netdev, "dev_mc_del err %d\n", err);
  5924. + return err;
  5925. + }
  5926. +
  5927. + err = ethsw_port_fdb_del_mc(netdev, addr);
  5928. + if (err) {
  5929. + netdev_err(netdev, "ethsw_port_fdb_del_mc err %d\n",
  5930. + err);
  5931. + return err;
  5932. + }
  5933. + }
  5934. +
  5935. + return 0;
  5936. +}
  5937. +
  5938. +static struct rtnl_link_stats64 *
  5939. +ethsw_port_get_stats(struct net_device *netdev,
  5940. + struct rtnl_link_stats64 *storage)
  5941. +{
  5942. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  5943. + u64 tmp;
  5944. + int err;
  5945. +
  5946. + err = dpsw_if_get_counter(port_priv->ethsw_priv->mc_io, 0,
  5947. + port_priv->ethsw_priv->dpsw_handle,
  5948. + port_priv->port_index,
  5949. + DPSW_CNT_ING_FRAME, &storage->rx_packets);
  5950. + if (err)
  5951. + goto error;
  5952. +
  5953. + err = dpsw_if_get_counter(port_priv->ethsw_priv->mc_io, 0,
  5954. + port_priv->ethsw_priv->dpsw_handle,
  5955. + port_priv->port_index,
  5956. + DPSW_CNT_EGR_FRAME, &storage->tx_packets);
  5957. + if (err)
  5958. + goto error;
  5959. +
  5960. + err = dpsw_if_get_counter(port_priv->ethsw_priv->mc_io, 0,
  5961. + port_priv->ethsw_priv->dpsw_handle,
  5962. + port_priv->port_index,
  5963. + DPSW_CNT_ING_BYTE, &storage->rx_bytes);
  5964. + if (err)
  5965. + goto error;
  5966. +
  5967. + err = dpsw_if_get_counter(port_priv->ethsw_priv->mc_io, 0,
  5968. + port_priv->ethsw_priv->dpsw_handle,
  5969. + port_priv->port_index,
  5970. + DPSW_CNT_EGR_BYTE, &storage->tx_bytes);
  5971. + if (err)
  5972. + goto error;
  5973. +
  5974. + err = dpsw_if_get_counter(port_priv->ethsw_priv->mc_io, 0,
  5975. + port_priv->ethsw_priv->dpsw_handle,
  5976. + port_priv->port_index,
  5977. + DPSW_CNT_ING_FRAME_DISCARD,
  5978. + &storage->rx_dropped);
  5979. + if (err)
  5980. + goto error;
  5981. +
  5982. + err = dpsw_if_get_counter(port_priv->ethsw_priv->mc_io, 0,
  5983. + port_priv->ethsw_priv->dpsw_handle,
  5984. + port_priv->port_index,
  5985. + DPSW_CNT_ING_FLTR_FRAME,
  5986. + &tmp);
  5987. + if (err)
  5988. + goto error;
  5989. + storage->rx_dropped += tmp;
  5990. +
  5991. + err = dpsw_if_get_counter(port_priv->ethsw_priv->mc_io, 0,
  5992. + port_priv->ethsw_priv->dpsw_handle,
  5993. + port_priv->port_index,
  5994. + DPSW_CNT_EGR_FRAME_DISCARD,
  5995. + &storage->tx_dropped);
  5996. + if (err)
  5997. + goto error;
  5998. +
  5999. + return storage;
  6000. +
  6001. +error:
  6002. + netdev_err(netdev, "dpsw_if_get_counter err %d\n", err);
  6003. + return storage;
  6004. +}
  6005. +
  6006. +static const struct net_device_ops ethsw_port_ops = {
  6007. + .ndo_open = &ethsw_port_open,
  6008. + .ndo_stop = &ethsw_port_stop,
  6009. +
  6010. + .ndo_fdb_add = &ethsw_port_fdb_add,
  6011. + .ndo_fdb_del = &ethsw_port_fdb_del,
  6012. + .ndo_fdb_dump = &ndo_dflt_fdb_dump,
  6013. +
  6014. + .ndo_get_stats64 = &ethsw_port_get_stats,
  6015. +
  6016. + .ndo_start_xmit = &ethsw_dropframe,
  6017. +};
  6018. +
  6019. +static struct {
  6020. + enum dpsw_counter id;
  6021. + char name[ETH_GSTRING_LEN];
  6022. +} ethsw_ethtool_counters[] = {
  6023. + {DPSW_CNT_ING_FRAME, "rx frames"},
  6024. + {DPSW_CNT_ING_BYTE, "rx bytes"},
  6025. + {DPSW_CNT_ING_FLTR_FRAME, "rx filtered frames"},
  6026. + {DPSW_CNT_ING_FRAME_DISCARD, "rx discarded frames"},
  6027. + {DPSW_CNT_ING_BCAST_FRAME, "rx b-cast frames"},
  6028. + {DPSW_CNT_ING_BCAST_BYTES, "rx b-cast bytes"},
  6029. + {DPSW_CNT_ING_MCAST_FRAME, "rx m-cast frames"},
  6030. + {DPSW_CNT_ING_MCAST_BYTE, "rx m-cast bytes"},
  6031. + {DPSW_CNT_EGR_FRAME, "tx frames"},
  6032. + {DPSW_CNT_EGR_BYTE, "tx bytes"},
  6033. + {DPSW_CNT_EGR_FRAME_DISCARD, "tx discarded frames"},
  6034. +
  6035. +};
  6036. +
  6037. +static int ethsw_ethtool_get_sset_count(struct net_device *dev, int sset)
  6038. +{
  6039. + switch (sset) {
  6040. + case ETH_SS_STATS:
  6041. + return ARRAY_SIZE(ethsw_ethtool_counters);
  6042. + default:
  6043. + return -EOPNOTSUPP;
  6044. + }
  6045. +}
  6046. +
  6047. +static void ethsw_ethtool_get_strings(struct net_device *netdev,
  6048. + u32 stringset, u8 *data)
  6049. +{
  6050. + int i;
  6051. +
  6052. + switch (stringset) {
  6053. + case ETH_SS_STATS:
  6054. + for (i = 0; i < ARRAY_SIZE(ethsw_ethtool_counters); i++)
  6055. + memcpy(data + i * ETH_GSTRING_LEN,
  6056. + ethsw_ethtool_counters[i].name, ETH_GSTRING_LEN);
  6057. + break;
  6058. + }
  6059. +}
  6060. +
  6061. +static void ethsw_ethtool_get_stats(struct net_device *netdev,
  6062. + struct ethtool_stats *stats,
  6063. + u64 *data)
  6064. +{
  6065. + struct ethsw_port_priv *port_priv = netdev_priv(netdev);
  6066. + int i;
  6067. + int err;
  6068. +
  6069. + for (i = 0; i < ARRAY_SIZE(ethsw_ethtool_counters); i++) {
  6070. + err = dpsw_if_get_counter(port_priv->ethsw_priv->mc_io, 0,
  6071. + port_priv->ethsw_priv->dpsw_handle,
  6072. + port_priv->port_index,
  6073. + ethsw_ethtool_counters[i].id,
  6074. + &data[i]);
  6075. + if (err)
  6076. + netdev_err(netdev, "dpsw_if_get_counter[%s] err %d\n",
  6077. + ethsw_ethtool_counters[i].name, err);
  6078. + }
  6079. +}
  6080. +
  6081. +static const struct ethtool_ops ethsw_port_ethtool_ops = {
  6082. + .get_strings = &ethsw_ethtool_get_strings,
  6083. + .get_ethtool_stats = &ethsw_ethtool_get_stats,
  6084. + .get_sset_count = &ethsw_ethtool_get_sset_count,
  6085. +};
  6086. +
  6087. +/* -------------------------------------------------------------------------- */
  6088. +/* ethsw driver functions */
  6089. +
  6090. +static int ethsw_links_state_update(struct ethsw_dev_priv *priv)
  6091. +{
  6092. + struct list_head *pos;
  6093. + struct ethsw_port_priv *port_priv;
  6094. + int err;
  6095. +
  6096. + list_for_each(pos, &priv->port_list) {
  6097. + port_priv = list_entry(pos, struct ethsw_port_priv,
  6098. + list);
  6099. +
  6100. + err = _ethsw_port_carrier_state_sync(port_priv->netdev);
  6101. + if (err)
  6102. + netdev_err(port_priv->netdev,
  6103. + "_ethsw_port_carrier_state_sync err %d\n",
  6104. + err);
  6105. + }
  6106. +
  6107. + return 0;
  6108. +}
  6109. +
  6110. +static irqreturn_t ethsw_irq0_handler(int irq_num, void *arg)
  6111. +{
  6112. + return IRQ_WAKE_THREAD;
  6113. +}
  6114. +
  6115. +static irqreturn_t _ethsw_irq0_handler_thread(int irq_num, void *arg)
  6116. +{
  6117. + struct device *dev = (struct device *)arg;
  6118. + struct fsl_mc_device *sw_dev = to_fsl_mc_device(dev);
  6119. + struct net_device *netdev = dev_get_drvdata(dev);
  6120. + struct ethsw_dev_priv *priv = netdev_priv(netdev);
  6121. +
  6122. + struct fsl_mc_io *io = priv->mc_io;
  6123. + uint16_t token = priv->dpsw_handle;
  6124. + int irq_index = DPSW_IRQ_INDEX_IF;
  6125. +
  6126. + /* Mask the events and the if_id reserved bits to be cleared on read */
  6127. + uint32_t status = DPSW_IRQ_EVENT_LINK_CHANGED | 0xFFFF0000;
  6128. + int err;
  6129. +
  6130. + /* Sanity check */
  6131. + if (WARN_ON(!sw_dev || !sw_dev->irqs || !sw_dev->irqs[irq_index]))
  6132. + goto out;
  6133. + if (WARN_ON(sw_dev->irqs[irq_index]->msi_desc->irq != irq_num))
  6134. + goto out;
  6135. +
  6136. + err = dpsw_get_irq_status(io, 0, token, irq_index, &status);
  6137. + if (unlikely(err)) {
  6138. + netdev_err(netdev, "Can't get irq status (err %d)", err);
  6139. +
  6140. + err = dpsw_clear_irq_status(io, 0, token, irq_index,
  6141. + 0xFFFFFFFF);
  6142. + if (unlikely(err))
  6143. + netdev_err(netdev, "Can't clear irq status (err %d)",
  6144. + err);
  6145. + goto out;
  6146. + }
  6147. +
  6148. + if (status & DPSW_IRQ_EVENT_LINK_CHANGED) {
  6149. + err = ethsw_links_state_update(priv);
  6150. + if (unlikely(err))
  6151. + goto out;
  6152. + }
  6153. +
  6154. +out:
  6155. + return IRQ_HANDLED;
  6156. +}
  6157. +
  6158. +static int ethsw_setup_irqs(struct fsl_mc_device *sw_dev)
  6159. +{
  6160. + struct device *dev = &sw_dev->dev;
  6161. + struct net_device *netdev = dev_get_drvdata(dev);
  6162. + struct ethsw_dev_priv *priv = netdev_priv(netdev);
  6163. + int err = 0;
  6164. + struct fsl_mc_device_irq *irq;
  6165. + const int irq_index = DPSW_IRQ_INDEX_IF;
  6166. + uint32_t mask = DPSW_IRQ_EVENT_LINK_CHANGED;
  6167. +
  6168. + err = fsl_mc_allocate_irqs(sw_dev);
  6169. + if (unlikely(err)) {
  6170. + dev_err(dev, "MC irqs allocation failed\n");
  6171. + return err;
  6172. + }
  6173. +
  6174. + if (WARN_ON(sw_dev->obj_desc.irq_count != DPSW_MAX_IRQ_NUM)) {
  6175. + err = -EINVAL;
  6176. + goto free_irq;
  6177. + }
  6178. +
  6179. + err = dpsw_set_irq_enable(priv->mc_io, 0, priv->dpsw_handle,
  6180. + irq_index, 0);
  6181. + if (unlikely(err)) {
  6182. + dev_err(dev, "dpsw_set_irq_enable err %d\n", err);
  6183. + goto free_irq;
  6184. + }
  6185. +
  6186. + irq = sw_dev->irqs[irq_index];
  6187. +
  6188. + err = devm_request_threaded_irq(dev, irq->msi_desc->irq,
  6189. + ethsw_irq0_handler,
  6190. + _ethsw_irq0_handler_thread,
  6191. + IRQF_NO_SUSPEND | IRQF_ONESHOT,
  6192. + dev_name(dev), dev);
  6193. + if (unlikely(err)) {
  6194. + dev_err(dev, "devm_request_threaded_irq(): %d", err);
  6195. + goto free_irq;
  6196. + }
  6197. +
  6198. + err = dpsw_set_irq_mask(priv->mc_io, 0, priv->dpsw_handle,
  6199. + irq_index, mask);
  6200. + if (unlikely(err)) {
  6201. + dev_err(dev, "dpsw_set_irq_mask(): %d", err);
  6202. + goto free_devm_irq;
  6203. + }
  6204. +
  6205. + err = dpsw_set_irq_enable(priv->mc_io, 0, priv->dpsw_handle,
  6206. + irq_index, 1);
  6207. + if (unlikely(err)) {
  6208. + dev_err(dev, "dpsw_set_irq_enable(): %d", err);
  6209. + goto free_devm_irq;
  6210. + }
  6211. +
  6212. + return 0;
  6213. +
  6214. +free_devm_irq:
  6215. + devm_free_irq(dev, irq->msi_desc->irq, dev);
  6216. +free_irq:
  6217. + fsl_mc_free_irqs(sw_dev);
  6218. + return err;
  6219. +}
  6220. +
  6221. +static void ethsw_teardown_irqs(struct fsl_mc_device *sw_dev)
  6222. +{
  6223. + struct device *dev = &sw_dev->dev;
  6224. + struct net_device *netdev = dev_get_drvdata(dev);
  6225. + struct ethsw_dev_priv *priv = netdev_priv(netdev);
  6226. +
  6227. + dpsw_set_irq_enable(priv->mc_io, 0, priv->dpsw_handle,
  6228. + DPSW_IRQ_INDEX_IF, 0);
  6229. + devm_free_irq(dev,
  6230. + sw_dev->irqs[DPSW_IRQ_INDEX_IF]->msi_desc->irq,
  6231. + dev);
  6232. + fsl_mc_free_irqs(sw_dev);
  6233. +}
  6234. +
  6235. +static int __cold
  6236. +ethsw_init(struct fsl_mc_device *sw_dev)
  6237. +{
  6238. + struct device *dev = &sw_dev->dev;
  6239. + struct ethsw_dev_priv *priv;
  6240. + struct net_device *netdev;
  6241. + int err = 0;
  6242. + u16 i;
  6243. + const struct dpsw_stp_cfg stp_cfg = {
  6244. + .vlan_id = 1,
  6245. + .state = DPSW_STP_STATE_FORWARDING,
  6246. + };
  6247. +
  6248. + netdev = dev_get_drvdata(dev);
  6249. + priv = netdev_priv(netdev);
  6250. +
  6251. + priv->dev_id = sw_dev->obj_desc.id;
  6252. +
  6253. + err = dpsw_open(priv->mc_io, 0, priv->dev_id, &priv->dpsw_handle);
  6254. + if (err) {
  6255. + dev_err(dev, "dpsw_open err %d\n", err);
  6256. + goto err_exit;
  6257. + }
  6258. + if (!priv->dpsw_handle) {
  6259. + dev_err(dev, "dpsw_open returned null handle but no error\n");
  6260. + err = -EFAULT;
  6261. + goto err_exit;
  6262. + }
  6263. +
  6264. + err = dpsw_get_attributes(priv->mc_io, 0, priv->dpsw_handle,
  6265. + &priv->sw_attr);
  6266. + if (err) {
  6267. + dev_err(dev, "dpsw_get_attributes err %d\n", err);
  6268. + goto err_close;
  6269. + }
  6270. +
  6271. + /* Minimum supported DPSW version check */
  6272. + if (priv->sw_attr.version.major < DPSW_MIN_VER_MAJOR ||
  6273. + (priv->sw_attr.version.major == DPSW_MIN_VER_MAJOR &&
  6274. + priv->sw_attr.version.minor < DPSW_MIN_VER_MINOR)) {
  6275. + dev_err(dev, "DPSW version %d:%d not supported. Use %d.%d or greater.\n",
  6276. + priv->sw_attr.version.major,
  6277. + priv->sw_attr.version.minor,
  6278. + DPSW_MIN_VER_MAJOR, DPSW_MIN_VER_MINOR);
  6279. + err = -ENOTSUPP;
  6280. + goto err_close;
  6281. + }
  6282. +
  6283. + err = dpsw_reset(priv->mc_io, 0, priv->dpsw_handle);
  6284. + if (err) {
  6285. + dev_err(dev, "dpsw_reset err %d\n", err);
  6286. + goto err_close;
  6287. + }
  6288. +
  6289. + err = dpsw_fdb_set_learning_mode(priv->mc_io, 0, priv->dpsw_handle, 0,
  6290. + DPSW_FDB_LEARNING_MODE_HW);
  6291. + if (err) {
  6292. + dev_err(dev, "dpsw_fdb_set_learning_mode err %d\n", err);
  6293. + goto err_close;
  6294. + }
  6295. +
  6296. + for (i = 0; i < priv->sw_attr.num_ifs; i++) {
  6297. + err = dpsw_if_set_stp(priv->mc_io, 0, priv->dpsw_handle, i,
  6298. + &stp_cfg);
  6299. + if (err) {
  6300. + dev_err(dev, "dpsw_if_set_stp err %d for port %d\n",
  6301. + err, i);
  6302. + goto err_close;
  6303. + }
  6304. +
  6305. + err = dpsw_if_set_broadcast(priv->mc_io, 0,
  6306. + priv->dpsw_handle, i, 1);
  6307. + if (err) {
  6308. + dev_err(dev,
  6309. + "dpsw_if_set_broadcast err %d for port %d\n",
  6310. + err, i);
  6311. + goto err_close;
  6312. + }
  6313. + }
  6314. +
  6315. + return 0;
  6316. +
  6317. +err_close:
  6318. + dpsw_close(priv->mc_io, 0, priv->dpsw_handle);
  6319. +err_exit:
  6320. + return err;
  6321. +}
  6322. +
  6323. +static int __cold
  6324. +ethsw_takedown(struct fsl_mc_device *sw_dev)
  6325. +{
  6326. + struct device *dev = &sw_dev->dev;
  6327. + struct net_device *netdev;
  6328. + struct ethsw_dev_priv *priv;
  6329. + int err;
  6330. +
  6331. + netdev = dev_get_drvdata(dev);
  6332. + priv = netdev_priv(netdev);
  6333. +
  6334. + err = dpsw_close(priv->mc_io, 0, priv->dpsw_handle);
  6335. + if (err)
  6336. + dev_warn(dev, "dpsw_close err %d\n", err);
  6337. +
  6338. + return 0;
  6339. +}
  6340. +
  6341. +static int __cold
  6342. +ethsw_remove(struct fsl_mc_device *sw_dev)
  6343. +{
  6344. + struct device *dev;
  6345. + struct net_device *netdev;
  6346. + struct ethsw_dev_priv *priv;
  6347. + struct ethsw_port_priv *port_priv;
  6348. + struct list_head *pos;
  6349. +
  6350. + dev = &sw_dev->dev;
  6351. + netdev = dev_get_drvdata(dev);
  6352. + priv = netdev_priv(netdev);
  6353. +
  6354. + list_for_each(pos, &priv->port_list) {
  6355. + port_priv = list_entry(pos, struct ethsw_port_priv, list);
  6356. +
  6357. + rtnl_lock();
  6358. + netdev_upper_dev_unlink(port_priv->netdev, netdev);
  6359. + rtnl_unlock();
  6360. +
  6361. + unregister_netdev(port_priv->netdev);
  6362. + free_netdev(port_priv->netdev);
  6363. + }
  6364. +
  6365. + ethsw_teardown_irqs(sw_dev);
  6366. +
  6367. + unregister_netdev(netdev);
  6368. +
  6369. + ethsw_takedown(sw_dev);
  6370. + fsl_mc_portal_free(priv->mc_io);
  6371. +
  6372. + dev_set_drvdata(dev, NULL);
  6373. + free_netdev(netdev);
  6374. +
  6375. + return 0;
  6376. +}
  6377. +
  6378. +static int __cold
  6379. +ethsw_probe(struct fsl_mc_device *sw_dev)
  6380. +{
  6381. + struct device *dev;
  6382. + struct net_device *netdev = NULL;
  6383. + struct ethsw_dev_priv *priv = NULL;
  6384. + int err = 0;
  6385. + u16 i;
  6386. + const char def_mcast[ETH_ALEN] = {
  6387. + 0x01, 0x00, 0x5e, 0x00, 0x00, 0x01,
  6388. + };
  6389. + char port_name[IFNAMSIZ];
  6390. +
  6391. + dev = &sw_dev->dev;
  6392. +
  6393. + /* register switch device, it's for management only - no I/O */
  6394. + netdev = alloc_etherdev(sizeof(*priv));
  6395. + if (!netdev) {
  6396. + dev_err(dev, "alloc_etherdev error\n");
  6397. + return -ENOMEM;
  6398. + }
  6399. + netdev->netdev_ops = &ethsw_ops;
  6400. +
  6401. + SET_NETDEV_DEV(netdev, dev);
  6402. + dev_set_drvdata(dev, netdev);
  6403. +
  6404. + priv = netdev_priv(netdev);
  6405. + priv->netdev = netdev;
  6406. +
  6407. + err = fsl_mc_portal_allocate(sw_dev, 0, &priv->mc_io);
  6408. + if (err) {
  6409. + dev_err(dev, "fsl_mc_portal_allocate err %d\n", err);
  6410. + goto err_free_netdev;
  6411. + }
  6412. + if (!priv->mc_io) {
  6413. + dev_err(dev, "fsl_mc_portal_allocate returned null handle but no error\n");
  6414. + err = -EFAULT;
  6415. + goto err_free_netdev;
  6416. + }
  6417. +
  6418. + err = ethsw_init(sw_dev);
  6419. + if (err) {
  6420. + dev_err(dev, "switch init err %d\n", err);
  6421. + goto err_free_cmdport;
  6422. + }
  6423. +
  6424. + netdev->flags = netdev->flags | IFF_PROMISC | IFF_MASTER;
  6425. +
  6426. + /* TODO: should we hold rtnl_lock here? We can't register_netdev under
  6427. + * lock
  6428. + */
  6429. + dev_alloc_name(netdev, "sw%d");
  6430. + err = register_netdev(netdev);
  6431. + if (err < 0) {
  6432. + dev_err(dev, "register_netdev error %d\n", err);
  6433. + goto err_takedown;
  6434. + }
  6435. + if (err)
  6436. + dev_info(dev, "register_netdev res %d\n", err);
  6437. +
  6438. + /* VLAN 1 is implicitly configured on the switch */
  6439. + priv->vlans[1] = ETHSW_VLAN_MEMBER;
  6440. + /* Flooding, learning are implicitly enabled */
  6441. + priv->learning = true;
  6442. + priv->flood = true;
  6443. +
  6444. + /* register switch ports */
  6445. + snprintf(port_name, IFNAMSIZ, "%sp%%d", netdev->name);
  6446. +
  6447. + INIT_LIST_HEAD(&priv->port_list);
  6448. + for (i = 0; i < priv->sw_attr.num_ifs; i++) {
  6449. + struct net_device *port_netdev;
  6450. + struct ethsw_port_priv *port_priv;
  6451. +
  6452. + port_netdev = alloc_etherdev(sizeof(struct ethsw_port_priv));
  6453. + if (!port_netdev) {
  6454. + dev_err(dev, "alloc_etherdev error\n");
  6455. + goto err_takedown;
  6456. + }
  6457. +
  6458. + port_priv = netdev_priv(port_netdev);
  6459. + port_priv->netdev = port_netdev;
  6460. + port_priv->ethsw_priv = priv;
  6461. +
  6462. + port_priv->port_index = i;
  6463. + port_priv->stp_state = BR_STATE_FORWARDING;
  6464. + /* VLAN 1 is configured by default on all switch ports */
  6465. + port_priv->vlans[1] = ETHSW_VLAN_MEMBER | ETHSW_VLAN_UNTAGGED |
  6466. + ETHSW_VLAN_PVID;
  6467. +
  6468. + SET_NETDEV_DEV(port_netdev, dev);
  6469. + port_netdev->netdev_ops = &ethsw_port_ops;
  6470. + port_netdev->ethtool_ops = &ethsw_port_ethtool_ops;
  6471. +
  6472. + port_netdev->flags = port_netdev->flags |
  6473. + IFF_PROMISC | IFF_SLAVE;
  6474. +
  6475. + dev_alloc_name(port_netdev, port_name);
  6476. + err = register_netdev(port_netdev);
  6477. + if (err < 0) {
  6478. + dev_err(dev, "register_netdev error %d\n", err);
  6479. + free_netdev(port_netdev);
  6480. + goto err_takedown;
  6481. + }
  6482. +
  6483. + rtnl_lock();
  6484. +
  6485. + err = netdev_master_upper_dev_link(port_netdev, netdev, NULL, NULL);
  6486. + if (err) {
  6487. + dev_err(dev, "netdev_master_upper_dev_link error %d\n",
  6488. + err);
  6489. + unregister_netdev(port_netdev);
  6490. + free_netdev(port_netdev);
  6491. + rtnl_unlock();
  6492. + goto err_takedown;
  6493. + }
  6494. +
  6495. + rtmsg_ifinfo(RTM_NEWLINK, port_netdev, IFF_SLAVE, GFP_KERNEL);
  6496. +
  6497. + rtnl_unlock();
  6498. +
  6499. + list_add(&port_priv->list, &priv->port_list);
  6500. +
  6501. + /* TODO: implmenet set_rm_mode instead of this */
  6502. + err = ethsw_port_fdb_add_mc(port_netdev, def_mcast);
  6503. + if (err)
  6504. + dev_warn(&netdev->dev,
  6505. + "ethsw_port_fdb_add_mc err %d\n", err);
  6506. +
  6507. +
  6508. + /* sync carrier state */
  6509. + err = _ethsw_port_carrier_state_sync(port_netdev);
  6510. + if (err)
  6511. + netdev_err(netdev,
  6512. + "_ethsw_port_carrier_state_sync err %d\n",
  6513. + err);
  6514. + }
  6515. +
  6516. + /* the switch starts up enabled */
  6517. + rtnl_lock();
  6518. + err = dev_open(netdev);
  6519. + rtnl_unlock();
  6520. + if (err)
  6521. + dev_warn(dev, "dev_open err %d\n", err);
  6522. +
  6523. + /* setup irqs */
  6524. + err = ethsw_setup_irqs(sw_dev);
  6525. + if (unlikely(err)) {
  6526. + dev_warn(dev, "ethsw_setup_irqs err %d\n", err);
  6527. + goto err_takedown;
  6528. + }
  6529. +
  6530. + dev_info(&netdev->dev,
  6531. + "probed %d port switch\n", priv->sw_attr.num_ifs);
  6532. + return 0;
  6533. +
  6534. +err_takedown:
  6535. + ethsw_remove(sw_dev);
  6536. +err_free_cmdport:
  6537. + fsl_mc_portal_free(priv->mc_io);
  6538. +err_free_netdev:
  6539. + dev_set_drvdata(dev, NULL);
  6540. + free_netdev(netdev);
  6541. +
  6542. + return err;
  6543. +}
  6544. +
  6545. +static const struct fsl_mc_device_match_id ethsw_match_id_table[] = {
  6546. + {
  6547. + .vendor = FSL_MC_VENDOR_FREESCALE,
  6548. + .obj_type = "dpsw",
  6549. + .ver_major = DPSW_VER_MAJOR,
  6550. + .ver_minor = DPSW_VER_MINOR,
  6551. + },
  6552. + {}
  6553. +};
  6554. +
  6555. +static struct fsl_mc_driver eth_sw_drv = {
  6556. + .driver = {
  6557. + .name = KBUILD_MODNAME,
  6558. + .owner = THIS_MODULE,
  6559. + },
  6560. + .probe = ethsw_probe,
  6561. + .remove = ethsw_remove,
  6562. + .match_id_table = ethsw_match_id_table,
  6563. +};
  6564. +
  6565. +module_fsl_mc_driver(eth_sw_drv);
  6566. +
  6567. +MODULE_LICENSE("GPL");
  6568. +MODULE_DESCRIPTION("DPAA2 Ethernet Switch Driver (prototype)");
  6569. --- a/drivers/staging/fsl-mc/include/net.h
  6570. +++ b/drivers/staging/fsl-mc/include/net.h
  6571. @@ -367,7 +367,6 @@
  6572. /*************************** GTP fields ************************************/
  6573. #define NH_FLD_GTP_TEID (1)
  6574. -
  6575. /* Protocol options */
  6576. /* Ethernet options */