skgepnmi.c 219 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310
  1. /*****************************************************************************
  2. *
  3. * Name: skgepnmi.c
  4. * Project: GEnesis, PCI Gigabit Ethernet Adapter
  5. * Version: $Revision: 1.102 $
  6. * Date: $Date: 2002/12/16 14:03:24 $
  7. * Purpose: Private Network Management Interface
  8. *
  9. ****************************************************************************/
  10. /******************************************************************************
  11. *
  12. * (C)Copyright 1998-2002 SysKonnect GmbH.
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * The information in this file is provided "AS IS" without warranty.
  20. *
  21. ******************************************************************************/
  22. /*****************************************************************************
  23. *
  24. * History:
  25. *
  26. * $Log: skgepnmi.c,v $
  27. * Revision 1.102 2002/12/16 14:03:24 tschilli
  28. * VCT code in Vct() changed.
  29. *
  30. * Revision 1.101 2002/12/16 09:04:10 tschilli
  31. * Code for VCT handling added.
  32. *
  33. * Revision 1.100 2002/09/26 14:28:13 tschilli
  34. * For XMAC the values in the SK_PNMI_PORT Port struct are copied to
  35. * the new SK_PNMI_PORT BufPort struct during a MacUpdate() call.
  36. * These values are used when GetPhysStatVal() is called. With this
  37. * mechanism you get the best results when software corrections for
  38. * counters are needed. Example: RX_LONGFRAMES.
  39. *
  40. * Revision 1.99 2002/09/17 12:31:19 tschilli
  41. * OID_SKGE_TX_HW_ERROR_CTS, OID_SKGE_OUT_ERROR_CTS, OID_GEN_XMIT_ERROR:
  42. * Double count of SK_PNMI_HTX_EXCESS_COL in function General() removed.
  43. * OID_PNP_CAPABILITIES: sizeof(SK_PM_WAKE_UP_CAPABILITIES) changed to
  44. * sizeof(SK_PNP_CAPABILITIES) in function PowerManagement().
  45. *
  46. * Revision 1.98 2002/09/10 09:00:03 rwahl
  47. * Adapted boolean definitions according sktypes.
  48. *
  49. * Revision 1.97 2002/09/05 15:07:03 rwahl
  50. * Editorial changes.
  51. *
  52. * Revision 1.96 2002/09/05 11:04:14 rwahl
  53. * - Rx/Tx packets statistics of virtual port were zero on link down (#10750)
  54. * - For GMAC the overflow IRQ for Rx longframe counter was not counted.
  55. * - Incorrect calculation for oids OID_SKGE_RX_HW_ERROR_CTS,
  56. * OID_SKGE_IN_ERRORS_CTS, OID_GEN_RCV_ERROR.
  57. * - Moved correction for OID_SKGE_STAT_RX_TOO_LONG to GetPhysStatVal().
  58. * - Editorial changes.
  59. *
  60. * Revision 1.95 2002/09/04 08:53:37 rwahl
  61. * - Incorrect statistics for Rx_too_long counter with jumbo frame (#10751)
  62. * - StatRxFrameTooLong & StatRxPMaccErr counters were not reset.
  63. * - Fixed compiler warning for debug msg arg types.
  64. *
  65. * Revision 1.94 2002/08/09 15:42:14 rwahl
  66. * - Fixed StatAddr table for GMAC.
  67. * - VirtualConf(): returned indeterminated status for speed oids if no
  68. * active port.
  69. *
  70. * Revision 1.93 2002/08/09 11:04:59 rwahl
  71. * Added handler for link speed caps.
  72. *
  73. * Revision 1.92 2002/08/09 09:43:03 rwahl
  74. * - Added handler for NDIS OID_PNP_xxx ids.
  75. *
  76. * Revision 1.91 2002/07/17 19:53:03 rwahl
  77. * - Added StatOvrflwBit table for XMAC & GMAC.
  78. * - Extended StatAddr table for GMAC. Added check of number of counters
  79. * in enumeration and size of StatAddr table on init level.
  80. * - Added use of GIFunc table.
  81. * - ChipSet is not static anymore,
  82. * - Extended SIRQ event handler for both mac types.
  83. * - Fixed rx short counter bug (#10620)
  84. * - Added handler for oids SKGE_SPEED_MODE & SKGE_SPEED_STATUS.
  85. * - Extendet GetPhysStatVal() for GMAC.
  86. * - Editorial changes.
  87. *
  88. * Revision 1.90 2002/05/22 08:56:25 rwahl
  89. * - Moved OID table to separate source file.
  90. * - Fix: TX_DEFFERAL counter incremented in full-duplex mode.
  91. * - Use string definitions for error msgs.
  92. *
  93. * Revision 1.89 2001/09/18 10:01:30 mkunz
  94. * some OID's fixed for dualnetmode
  95. *
  96. * Revision 1.88 2001/08/02 07:58:08 rwahl
  97. * - Fixed NetIndex to csum module at ResetCounter().
  98. *
  99. * Revision 1.87 2001/04/06 13:35:09 mkunz
  100. * -Bugs fixed in handling of OID_SKGE_MTU and the VPD OID's
  101. *
  102. * Revision 1.86 2001/03/09 09:18:03 mkunz
  103. * Changes in SK_DBG_MSG
  104. *
  105. * Revision 1.85 2001/03/08 09:37:31 mkunz
  106. * Bugfix in ResetCounter for Pnmi.Port structure
  107. *
  108. * Revision 1.84 2001/03/06 09:04:55 mkunz
  109. * Made some changes in instance calculation
  110. *
  111. * Revision 1.83 2001/02/15 09:15:32 mkunz
  112. * Necessary changes for dual net mode added
  113. *
  114. * Revision 1.82 2001/02/07 08:24:19 mkunz
  115. * -Made changes in handling of OID_SKGE_MTU
  116. *
  117. * Revision 1.81 2001/02/06 09:58:00 mkunz
  118. * -Vpd bug fixed
  119. * -OID_SKGE_MTU added
  120. * -pnmi support for dual net mode. Interface function and macros extended
  121. *
  122. * Revision 1.80 2001/01/22 13:41:35 rassmann
  123. * Supporting two nets on dual-port adapters.
  124. *
  125. * Revision 1.79 2000/12/05 14:57:40 cgoos
  126. * SetStruct failed before first Link Up (link mode of virtual
  127. * port "INDETERMINATED").
  128. *
  129. * Revision 1.78 2000/09/12 10:44:58 cgoos
  130. * Fixed SK_PNMI_STORE_U32 calls with typecasted argument.
  131. *
  132. * Revision 1.77 2000/09/07 08:10:19 rwahl
  133. * - Modified algorithm for 64bit NDIS statistic counters;
  134. * returns 64bit or 32bit value depending on passed buffer
  135. * size. Indicate capability for 64bit NDIS counter, if passed
  136. * buffer size is zero. OID_GEN_XMIT_ERROR, OID_GEN_RCV_ERROR,
  137. * and OID_GEN_RCV_NO_BUFFER handled as 64bit counter, too.
  138. * - corrected OID_SKGE_RLMT_PORT_PREFERRED.
  139. *
  140. * Revision 1.76 2000/08/03 15:23:39 rwahl
  141. * - Correction for FrameTooLong counter has to be moved to OID handling
  142. * routines (instead of statistic counter routine).
  143. * - Fix in XMAC Reset Event handling: Only offset counter for hardware
  144. * statistic registers are updated.
  145. *
  146. * Revision 1.75 2000/08/01 16:46:05 rwahl
  147. * - Added StatRxLongFrames counter and correction of FrameTooLong counter.
  148. * - Added directive to control width (default = 32bit) of NDIS statistic
  149. * counters (SK_NDIS_64BIT_CTR).
  150. *
  151. * Revision 1.74 2000/07/04 11:41:53 rwahl
  152. * - Added volition connector type.
  153. *
  154. * Revision 1.73 2000/03/15 16:33:10 rwahl
  155. * Fixed bug 10510; wrong reset of virtual port statistic counters.
  156. *
  157. * Revision 1.72 1999/12/06 16:15:53 rwahl
  158. * Fixed problem of instance range for current and factory MAC address.
  159. *
  160. * Revision 1.71 1999/12/06 10:14:20 rwahl
  161. * Fixed bug 10476; set operation for PHY_OPERATION_MODE.
  162. *
  163. * Revision 1.70 1999/11/22 13:33:34 cgoos
  164. * Changed license header to GPL.
  165. *
  166. * Revision 1.69 1999/10/18 11:42:15 rwahl
  167. * Added typecasts for checking event dependent param (debug only).
  168. *
  169. * Revision 1.68 1999/10/06 09:35:59 cgoos
  170. * Added state check to PHY_READ call (hanged if called during startup).
  171. *
  172. * Revision 1.67 1999/09/22 09:53:20 rwahl
  173. * - Read Broadcom register for updating fcs error counter (1000Base-T).
  174. *
  175. * Revision 1.66 1999/08/26 13:47:56 rwahl
  176. * Added SK_DRIVER_SENDEVENT when queueing RLMT_CHANGE_THRES trap.
  177. *
  178. * Revision 1.65 1999/07/26 07:49:35 cgoos
  179. * Added two typecasts to avoid compiler warnings.
  180. *
  181. * Revision 1.64 1999/05/20 09:24:12 cgoos
  182. * Changes for 1000Base-T (sensors, Master/Slave).
  183. *
  184. * Revision 1.63 1999/04/13 15:11:58 mhaveman
  185. * Moved include of rlmt.h to header skgepnmi.h because some macros
  186. * are needed there.
  187. *
  188. * Revision 1.62 1999/04/13 15:08:07 mhaveman
  189. * Replaced again SK_RLMT_CHECK_LINK with SK_PNMI_RLMT_MODE_CHK_LINK
  190. * to grant unified interface by only using the PNMI header file.
  191. * SK_PNMI_RLMT_MODE_CHK_LINK is defined the same as SK_RLMT_CHECK_LINK.
  192. *
  193. * Revision 1.61 1999/04/13 15:02:48 mhaveman
  194. * Changes caused by review:
  195. * -Changed some comments
  196. * -Removed redundant check for OID_SKGE_PHYS_FAC_ADDR
  197. * -Optimized PRESET check.
  198. * -Meaning of error SK_ADDR_DUPLICATE_ADDRESS changed. Set of same
  199. * address will now not cause this error. Removed corresponding check.
  200. *
  201. * Revision 1.60 1999/03/23 10:41:23 mhaveman
  202. * Added comments.
  203. *
  204. * Revision 1.59 1999/02/19 08:01:28 mhaveman
  205. * Fixed bug 10372 that after counter reset all ports were displayed
  206. * as inactive.
  207. *
  208. * Revision 1.58 1999/02/16 18:04:47 mhaveman
  209. * Fixed problem of twisted OIDs SENSOR_WAR_TIME and SENSOR_ERR_TIME.
  210. *
  211. * Revision 1.56 1999/01/27 12:29:11 mhaveman
  212. * SkTimerStart was called with time value in milli seconds but needs
  213. * micro seconds.
  214. *
  215. * Revision 1.55 1999/01/25 15:00:38 mhaveman
  216. * Added support to allow multiple ports to be active. If this feature in
  217. * future will be used, the Management Data Base variables PORT_ACTIVE
  218. * and PORT_PREFERED should be moved to the port specific part of RLMT.
  219. * Currently they return the values of the first active physical port
  220. * found. A set to the virtual port will actually change all active
  221. * physical ports. A get returns the melted values of all active physical
  222. * ports. If the port values differ a return value INDETERMINATED will
  223. * be returned. This effects especially the CONF group.
  224. *
  225. * Revision 1.54 1999/01/19 10:10:22 mhaveman
  226. * -Fixed bug 10354: Counter values of virtual port were wrong after port
  227. * switches
  228. * -Added check if a switch to the same port is notified.
  229. *
  230. * Revision 1.53 1999/01/07 09:25:21 mhaveman
  231. * Forgot to initialize a variable.
  232. *
  233. * Revision 1.52 1999/01/05 10:34:33 mhaveman
  234. * Fixed little error in RlmtChangeEstimate calculation.
  235. *
  236. * Revision 1.51 1999/01/05 09:59:07 mhaveman
  237. * -Moved timer start to init level 2
  238. * -Redesigned port switch average calculation to avoid 64bit
  239. * arithmetic.
  240. *
  241. * Revision 1.50 1998/12/10 15:13:59 mhaveman
  242. * -Fixed: PHYS_CUR_ADDR returned wrong addresses
  243. * -Fixed: RLMT_PORT_PREFERED and RLMT_CHANGE_THRES preset returned
  244. * always BAD_VALUE.
  245. * -Fixed: TRAP buffer seemed to sometimes suddenly empty
  246. *
  247. * Revision 1.49 1998/12/09 16:17:07 mhaveman
  248. * Fixed: Couldnot delete VPD keys on UNIX.
  249. *
  250. * Revision 1.48 1998/12/09 14:11:10 mhaveman
  251. * -Add: Debugmessage for XMAC_RESET supressed to minimize output.
  252. * -Fixed: RlmtChangeThreshold will now be initialized.
  253. * -Fixed: VPD_ENTRIES_LIST extended value with unnecessary space char.
  254. * -Fixed: On VPD key creation an invalid key name could be created
  255. * (e.g. A5)
  256. * -Some minor changes in comments and code.
  257. *
  258. * Revision 1.47 1998/12/08 16:00:31 mhaveman
  259. * -Fixed: For RLMT_PORT_ACTIVE will now be returned a 0 if no port
  260. * is active.
  261. * -Fixed: For the RLMT statistics group only the last value was
  262. * returned and the rest of the buffer was filled with 0xff
  263. * -Fixed: Mysteriously the preset on RLMT_MODE still returned
  264. * BAD_VALUE.
  265. * Revision 1.46 1998/12/08 10:04:56 mhaveman
  266. * -Fixed: Preset on RLMT_MODE returned always BAD_VALUE error.
  267. * -Fixed: Alignment error in GetStruct
  268. * -Fixed: If for Get/Preset/SetStruct the buffer size is equal or
  269. * larger than SK_PNMI_MIN_STRUCT_SIZE the return value is stored
  270. * to the buffer. In this case the caller should always return
  271. * ok to its upper routines. Only if the buffer size is less
  272. * than SK_PNMI_MIN_STRUCT_SIZE and the return value is unequal
  273. * to 0, an error should be returned by the caller.
  274. * -Fixed: Wrong number of instances with RLMT statistic.
  275. * -Fixed: Return now SK_LMODE_STAT_UNKNOWN if the LinkModeStatus is 0.
  276. *
  277. * Revision 1.45 1998/12/03 17:17:24 mhaveman
  278. * -Removed for VPD create action the buffer size limitation to 4 bytes.
  279. * -Pass now physical/active physical port to ADDR for CUR_ADDR set
  280. *
  281. * Revision 1.44 1998/12/03 15:14:35 mhaveman
  282. * Another change to Vpd instance evaluation.
  283. *
  284. * Revision 1.43 1998/12/03 14:18:10 mhaveman
  285. * -Fixed problem in PnmiSetStruct. It was impossible to set any value.
  286. * -Removed VPD key evaluation for VPD_FREE_BYTES and VPD_ACTION.
  287. *
  288. * Revision 1.42 1998/12/03 11:31:47 mhaveman
  289. * Inserted cast to satisfy lint.
  290. *
  291. * Revision 1.41 1998/12/03 11:28:16 mhaveman
  292. * Removed SK_PNMI_CHECKPTR
  293. *
  294. * Revision 1.40 1998/12/03 11:19:07 mhaveman
  295. * Fixed problems
  296. * -A set to virtual port will now be ignored. A set with broadcast
  297. * address to any port will be ignored.
  298. * -GetStruct function made VPD instance calculation wrong.
  299. * -Prefered port returned -1 instead of 0.
  300. *
  301. * Revision 1.39 1998/11/26 15:30:29 mhaveman
  302. * Added sense mode to link mode.
  303. *
  304. * Revision 1.38 1998/11/23 15:34:00 mhaveman
  305. * -Fixed bug for RX counters. On an RX overflow interrupt the high
  306. * words of all RX counters were incremented.
  307. * -SET operations on FLOWCTRL_MODE and LINK_MODE accept now the
  308. * value 0, which has no effect. It is usefull for multiple instance
  309. * SETs.
  310. *
  311. * Revision 1.37 1998/11/20 08:02:04 mhaveman
  312. * -Fixed: Ports were compared with MAX_SENSORS
  313. * -Fixed: Crash in GetTrapEntry with MEMSET macro
  314. * -Fixed: Conversions between physical, logical port index and instance
  315. *
  316. * Revision 1.36 1998/11/16 07:48:53 mhaveman
  317. * Casted SK_DRIVER_SENDEVENT with (void) to eleminate compiler warnings
  318. * on Solaris.
  319. *
  320. * Revision 1.35 1998/11/16 07:45:34 mhaveman
  321. * SkAddrOverride now returns value and will be checked.
  322. *
  323. * Revision 1.34 1998/11/10 13:40:37 mhaveman
  324. * Needed to change interface, because NT driver needs a return value
  325. * of needed buffer space on TOO_SHORT errors. Therefore all
  326. * SkPnmiGet/Preset/Set functions now have a pointer to the length
  327. * parameter, where the needed space on error is returned.
  328. *
  329. * Revision 1.33 1998/11/03 13:52:46 mhaveman
  330. * Made file lint conform.
  331. *
  332. * Revision 1.32 1998/11/03 13:19:07 mhaveman
  333. * The events SK_HWEV_SET_LMODE and SK_HWEV_SET_FLOWMODE pass now in
  334. * Para32[0] the physical MAC index and in Para32[1] the new mode.
  335. *
  336. * Revision 1.31 1998/11/03 12:30:40 gklug
  337. * fix: compiler warning memset
  338. *
  339. * Revision 1.30 1998/11/03 12:04:46 mhaveman
  340. * Fixed problem in SENSOR_VALUE, which wrote beyond the buffer end
  341. * Fixed alignment problem with CHIPSET.
  342. *
  343. * Revision 1.29 1998/11/02 11:23:54 mhaveman
  344. * Corrected SK_ERROR_LOG to SK_ERR_LOG. Sorry.
  345. *
  346. * Revision 1.28 1998/11/02 10:47:16 mhaveman
  347. * Added syslog messages for internal errors.
  348. *
  349. * Revision 1.27 1998/10/30 15:48:06 mhaveman
  350. * Fixed problems after simulation of SK_PNMI_EVT_CHG_EST_TIMER and
  351. * RlmtChangeThreshold calculation.
  352. *
  353. * Revision 1.26 1998/10/29 15:36:55 mhaveman
  354. * -Fixed bug in trap buffer handling.
  355. * -OID_SKGE_DRIVER_DESCR, OID_SKGE_DRIVER_VERSION, OID_SKGE_HW_DESCR,
  356. * OID_SKGE_HW_VERSION, OID_SKGE_VPD_ENTRIES_LIST, OID_SKGE_VPD_KEY,
  357. * OID_SKGE_VPD_VALUE, and OID_SKGE_SENSOR_DESCR return values with
  358. * a leading octet before each string storing the string length.
  359. * -Perform a RlmtUpdate during SK_PNMI_EVT_XMAC_RESET to minimize
  360. * RlmtUpdate calls in GetStatVal.
  361. * -Inserted SK_PNMI_CHECKFLAGS macro increase readability.
  362. *
  363. * Revision 1.25 1998/10/29 08:50:36 mhaveman
  364. * Fixed problems after second event simulation.
  365. *
  366. * Revision 1.24 1998/10/28 08:44:37 mhaveman
  367. * -Fixed alignment problem
  368. * -Fixed problems during event simulation
  369. * -Fixed sequence of error return code (INSTANCE -> ACCESS -> SHORT)
  370. * -Changed type of parameter Instance back to SK_U32 because of VPD
  371. * -Updated new VPD function calls
  372. *
  373. * Revision 1.23 1998/10/23 10:16:37 mhaveman
  374. * Fixed bugs after buffer test simulation.
  375. *
  376. * Revision 1.22 1998/10/21 13:23:52 mhaveman
  377. * -Call syntax of SkOsGetTime() changed to SkOsGetTime(pAc).
  378. * -Changed calculation of hundrets of seconds.
  379. *
  380. * Revision 1.20 1998/10/20 07:30:45 mhaveman
  381. * Made type changes to unsigned integer where possible.
  382. *
  383. * Revision 1.19 1998/10/19 10:51:30 mhaveman
  384. * -Made Bug fixes after simulation run
  385. * -Renamed RlmtMAC... to RlmtPort...
  386. * -Marked workarounds with Errata comments
  387. *
  388. * Revision 1.18 1998/10/14 07:50:08 mhaveman
  389. * -For OID_SKGE_LINK_STATUS the link down detection has moved from RLMT
  390. * to HWACCESS.
  391. * -Provided all MEMCPY/MEMSET macros with (char *) pointers, because
  392. * Solaris throwed warnings when mapping to bcopy/bset.
  393. *
  394. * Revision 1.17 1998/10/13 07:42:01 mhaveman
  395. * -Added OIDs OID_SKGE_TRAP_NUMBER and OID_SKGE_ALL_DATA
  396. * -Removed old cvs history entries
  397. * -Renamed MacNumber to PortNumber
  398. *
  399. * Revision 1.16 1998/10/07 10:52:49 mhaveman
  400. * -Inserted handling of some OID_GEN_ Ids for windows
  401. * -Fixed problem with 803.2 statistic.
  402. *
  403. * Revision 1.15 1998/10/01 09:16:29 mhaveman
  404. * Added Debug messages for function call and UpdateFlag tracing.
  405. *
  406. * Revision 1.14 1998/09/30 13:39:09 mhaveman
  407. * -Reduced namings of 'MAC' by replacing them with 'PORT'.
  408. * -Completed counting of OID_SKGE_RX_HW_ERROR_CTS,
  409. * OID_SKGE_TX_HW_ERROR_CTS,
  410. * OID_SKGE_IN_ERRORS_CTS, and OID_SKGE_OUT_ERROR_CTS.
  411. * -SET check for RlmtMode
  412. *
  413. * Revision 1.13 1998/09/28 13:13:08 mhaveman
  414. * Hide strcmp, strlen, and strncpy behind macros SK_STRCMP, SK_STRLEN,
  415. * and SK_STRNCPY. (Same reasons as for mem.. and MEM..)
  416. *
  417. * Revision 1.12 1998/09/16 08:18:36 cgoos
  418. * Fix: XM_INxx and XM_OUTxx called with different parameter order:
  419. * sometimes IoC,Mac,... sometimes Mac,IoC,... Now always first variant.
  420. * Fix: inserted "Pnmi." into some pAC->pDriverDescription / Version.
  421. * Change: memset, memcpy to makros SK_MEMSET, SK_MEMCPY
  422. *
  423. * Revision 1.11 1998/09/04 17:01:45 mhaveman
  424. * Added SyncCounter as macro and OID_SKGE_.._NO_DESCR_CTS to
  425. * OID_SKGE_RX_NO_BUF_CTS.
  426. *
  427. * Revision 1.10 1998/09/04 14:35:35 mhaveman
  428. * Added macro counters, that are counted by driver.
  429. *
  430. ****************************************************************************/
  431. #include <config.h>
  432. #ifdef CONFIG_SK98
  433. static const char SysKonnectFileId[] =
  434. "@(#) $Id: skgepnmi.c,v 1.102 2002/12/16 14:03:24 tschilli Exp $"
  435. " (C) SysKonnect.";
  436. #include "h/skdrv1st.h"
  437. #include "h/sktypes.h"
  438. #include "h/xmac_ii.h"
  439. #include "h/skdebug.h"
  440. #include "h/skqueue.h"
  441. #include "h/skgepnmi.h"
  442. #include "h/skgesirq.h"
  443. #include "h/skcsum.h"
  444. #include "h/skvpd.h"
  445. #include "h/skgehw.h"
  446. #include "h/skgeinit.h"
  447. #include "h/skdrv2nd.h"
  448. #include "h/skgepnm2.h"
  449. #ifdef SK_POWER_MGMT
  450. #include "h/skgepmgt.h"
  451. #endif
  452. /* defines *******************************************************************/
  453. #ifndef DEBUG
  454. #define PNMI_STATIC static
  455. #else /* DEBUG */
  456. #define PNMI_STATIC
  457. #endif /* DEBUG */
  458. /*
  459. * Public Function prototypes
  460. */
  461. int SkPnmiInit(SK_AC *pAC, SK_IOC IoC, int level);
  462. int SkPnmiGetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, void *pBuf,
  463. unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex);
  464. int SkPnmiPreSetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, void *pBuf,
  465. unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex);
  466. int SkPnmiSetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, void *pBuf,
  467. unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex);
  468. int SkPnmiGetStruct(SK_AC *pAC, SK_IOC IoC, void *pBuf,
  469. unsigned int *pLen, SK_U32 NetIndex);
  470. int SkPnmiPreSetStruct(SK_AC *pAC, SK_IOC IoC, void *pBuf,
  471. unsigned int *pLen, SK_U32 NetIndex);
  472. int SkPnmiSetStruct(SK_AC *pAC, SK_IOC IoC, void *pBuf,
  473. unsigned int *pLen, SK_U32 NetIndex);
  474. int SkPnmiEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Param);
  475. /*
  476. * Private Function prototypes
  477. */
  478. PNMI_STATIC SK_U8 CalculateLinkModeStatus(SK_AC *pAC, SK_IOC IoC, unsigned int
  479. PhysPortIndex);
  480. PNMI_STATIC SK_U8 CalculateLinkStatus(SK_AC *pAC, SK_IOC IoC, unsigned int
  481. PhysPortIndex);
  482. PNMI_STATIC void CopyMac(char *pDst, SK_MAC_ADDR *pMac);
  483. PNMI_STATIC void CopyTrapQueue(SK_AC *pAC, char *pDstBuf);
  484. PNMI_STATIC SK_U64 GetPhysStatVal(SK_AC *pAC, SK_IOC IoC,
  485. unsigned int PhysPortIndex, unsigned int StatIndex);
  486. PNMI_STATIC SK_U64 GetStatVal(SK_AC *pAC, SK_IOC IoC, unsigned int LogPortIndex,
  487. unsigned int StatIndex, SK_U32 NetIndex);
  488. PNMI_STATIC char* GetTrapEntry(SK_AC *pAC, SK_U32 TrapId, unsigned int Size);
  489. PNMI_STATIC void GetTrapQueueLen(SK_AC *pAC, unsigned int *pLen,
  490. unsigned int *pEntries);
  491. PNMI_STATIC int GetVpdKeyArr(SK_AC *pAC, SK_IOC IoC, char *pKeyArr,
  492. unsigned int KeyArrLen, unsigned int *pKeyNo);
  493. PNMI_STATIC int LookupId(SK_U32 Id);
  494. PNMI_STATIC int MacUpdate(SK_AC *pAC, SK_IOC IoC, unsigned int FirstMac,
  495. unsigned int LastMac);
  496. PNMI_STATIC int PnmiStruct(SK_AC *pAC, SK_IOC IoC, int Action, char *pBuf,
  497. unsigned int *pLen, SK_U32 NetIndex);
  498. PNMI_STATIC int PnmiVar(SK_AC *pAC, SK_IOC IoC, int Action, SK_U32 Id,
  499. char *pBuf, unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex);
  500. PNMI_STATIC void QueueRlmtNewMacTrap(SK_AC *pAC, unsigned int ActiveMac);
  501. PNMI_STATIC void QueueRlmtPortTrap(SK_AC *pAC, SK_U32 TrapId,
  502. unsigned int PortIndex);
  503. PNMI_STATIC void QueueSensorTrap(SK_AC *pAC, SK_U32 TrapId,
  504. unsigned int SensorIndex);
  505. PNMI_STATIC void QueueSimpleTrap(SK_AC *pAC, SK_U32 TrapId);
  506. PNMI_STATIC void ResetCounter(SK_AC *pAC, SK_IOC IoC, SK_U32 NetIndex);
  507. PNMI_STATIC int RlmtUpdate(SK_AC *pAC, SK_IOC IoC, SK_U32 NetIndex);
  508. PNMI_STATIC int SirqUpdate(SK_AC *pAC, SK_IOC IoC);
  509. PNMI_STATIC void VirtualConf(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, char *pBuf);
  510. PNMI_STATIC int Vct(SK_AC *pAC, SK_IOC IoC, int Action, SK_U32 Id, char *pBuf,
  511. unsigned int *pLen, SK_U32 Instance, unsigned int TableIndex, SK_U32 NetIndex);
  512. PNMI_STATIC void CheckVctStatus(SK_AC *, SK_IOC, char *, SK_U32, SK_U32);
  513. /*
  514. * Table to correlate OID with handler function and index to
  515. * hardware register stored in StatAddress if applicable.
  516. */
  517. #include "skgemib.c"
  518. /* global variables **********************************************************/
  519. /*
  520. * Overflow status register bit table and corresponding counter
  521. * dependent on MAC type - the number relates to the size of overflow
  522. * mask returned by the pFnMacOverflow function
  523. */
  524. PNMI_STATIC const SK_U16 StatOvrflwBit[][SK_PNMI_MAC_TYPES] = {
  525. /* Bit0 */ { SK_PNMI_HTX, SK_PNMI_HTX_UNICAST},
  526. /* Bit1 */ { SK_PNMI_HTX_OCTETHIGH, SK_PNMI_HTX_BROADCAST},
  527. /* Bit2 */ { SK_PNMI_HTX_OCTETLOW, SK_PNMI_HTX_PMACC},
  528. /* Bit3 */ { SK_PNMI_HTX_BROADCAST, SK_PNMI_HTX_MULTICAST},
  529. /* Bit4 */ { SK_PNMI_HTX_MULTICAST, SK_PNMI_HTX_OCTETLOW},
  530. /* Bit5 */ { SK_PNMI_HTX_UNICAST, SK_PNMI_HTX_OCTETHIGH},
  531. /* Bit6 */ { SK_PNMI_HTX_LONGFRAMES, SK_PNMI_HTX_64},
  532. /* Bit7 */ { SK_PNMI_HTX_BURST, SK_PNMI_HTX_127},
  533. /* Bit8 */ { SK_PNMI_HTX_PMACC, SK_PNMI_HTX_255},
  534. /* Bit9 */ { SK_PNMI_HTX_MACC, SK_PNMI_HTX_511},
  535. /* Bit10 */ { SK_PNMI_HTX_SINGLE_COL, SK_PNMI_HTX_1023},
  536. /* Bit11 */ { SK_PNMI_HTX_MULTI_COL, SK_PNMI_HTX_MAX},
  537. /* Bit12 */ { SK_PNMI_HTX_EXCESS_COL, SK_PNMI_HTX_LONGFRAMES},
  538. /* Bit13 */ { SK_PNMI_HTX_LATE_COL, SK_PNMI_HTX_RESERVED},
  539. /* Bit14 */ { SK_PNMI_HTX_DEFFERAL, SK_PNMI_HTX_COL},
  540. /* Bit15 */ { SK_PNMI_HTX_EXCESS_DEF, SK_PNMI_HTX_LATE_COL},
  541. /* Bit16 */ { SK_PNMI_HTX_UNDERRUN, SK_PNMI_HTX_EXCESS_COL},
  542. /* Bit17 */ { SK_PNMI_HTX_CARRIER, SK_PNMI_HTX_MULTI_COL},
  543. /* Bit18 */ { SK_PNMI_HTX_UTILUNDER, SK_PNMI_HTX_SINGLE_COL},
  544. /* Bit19 */ { SK_PNMI_HTX_UTILOVER, SK_PNMI_HTX_UNDERRUN},
  545. /* Bit20 */ { SK_PNMI_HTX_64, SK_PNMI_HTX_RESERVED},
  546. /* Bit21 */ { SK_PNMI_HTX_127, SK_PNMI_HTX_RESERVED},
  547. /* Bit22 */ { SK_PNMI_HTX_255, SK_PNMI_HTX_RESERVED},
  548. /* Bit23 */ { SK_PNMI_HTX_511, SK_PNMI_HTX_RESERVED},
  549. /* Bit24 */ { SK_PNMI_HTX_1023, SK_PNMI_HTX_RESERVED},
  550. /* Bit25 */ { SK_PNMI_HTX_MAX, SK_PNMI_HTX_RESERVED},
  551. /* Bit26 */ { SK_PNMI_HTX_RESERVED, SK_PNMI_HTX_RESERVED},
  552. /* Bit27 */ { SK_PNMI_HTX_RESERVED, SK_PNMI_HTX_RESERVED},
  553. /* Bit28 */ { SK_PNMI_HTX_RESERVED, SK_PNMI_HTX_RESERVED},
  554. /* Bit29 */ { SK_PNMI_HTX_RESERVED, SK_PNMI_HTX_RESERVED},
  555. /* Bit30 */ { SK_PNMI_HTX_RESERVED, SK_PNMI_HTX_RESERVED},
  556. /* Bit31 */ { SK_PNMI_HTX_RESERVED, SK_PNMI_HTX_RESERVED},
  557. /* Bit32 */ { SK_PNMI_HRX, SK_PNMI_HRX_UNICAST},
  558. /* Bit33 */ { SK_PNMI_HRX_OCTETHIGH, SK_PNMI_HRX_BROADCAST},
  559. /* Bit34 */ { SK_PNMI_HRX_OCTETLOW, SK_PNMI_HRX_PMACC},
  560. /* Bit35 */ { SK_PNMI_HRX_BROADCAST, SK_PNMI_HRX_MULTICAST},
  561. /* Bit36 */ { SK_PNMI_HRX_MULTICAST, SK_PNMI_HRX_FCS},
  562. /* Bit37 */ { SK_PNMI_HRX_UNICAST, SK_PNMI_HRX_RESERVED},
  563. /* Bit38 */ { SK_PNMI_HRX_PMACC, SK_PNMI_HRX_OCTETLOW},
  564. /* Bit39 */ { SK_PNMI_HRX_MACC, SK_PNMI_HRX_OCTETHIGH},
  565. /* Bit40 */ { SK_PNMI_HRX_PMACC_ERR, SK_PNMI_HRX_BADOCTETLOW},
  566. /* Bit41 */ { SK_PNMI_HRX_MACC_UNKWN, SK_PNMI_HRX_BADOCTETHIGH},
  567. /* Bit42 */ { SK_PNMI_HRX_BURST, SK_PNMI_HRX_UNDERSIZE},
  568. /* Bit43 */ { SK_PNMI_HRX_MISSED, SK_PNMI_HRX_RUNT},
  569. /* Bit44 */ { SK_PNMI_HRX_FRAMING, SK_PNMI_HRX_64},
  570. /* Bit45 */ { SK_PNMI_HRX_OVERFLOW, SK_PNMI_HRX_127},
  571. /* Bit46 */ { SK_PNMI_HRX_JABBER, SK_PNMI_HRX_255},
  572. /* Bit47 */ { SK_PNMI_HRX_CARRIER, SK_PNMI_HRX_511},
  573. /* Bit48 */ { SK_PNMI_HRX_IRLENGTH, SK_PNMI_HRX_1023},
  574. /* Bit49 */ { SK_PNMI_HRX_SYMBOL, SK_PNMI_HRX_MAX},
  575. /* Bit50 */ { SK_PNMI_HRX_SHORTS, SK_PNMI_HRX_LONGFRAMES},
  576. /* Bit51 */ { SK_PNMI_HRX_RUNT, SK_PNMI_HRX_TOO_LONG},
  577. /* Bit52 */ { SK_PNMI_HRX_TOO_LONG, SK_PNMI_HRX_JABBER},
  578. /* Bit53 */ { SK_PNMI_HRX_FCS, SK_PNMI_HRX_RESERVED},
  579. /* Bit54 */ { SK_PNMI_HRX_RESERVED, SK_PNMI_HRX_OVERFLOW},
  580. /* Bit55 */ { SK_PNMI_HRX_CEXT, SK_PNMI_HRX_RESERVED},
  581. /* Bit56 */ { SK_PNMI_HRX_UTILUNDER, SK_PNMI_HRX_RESERVED},
  582. /* Bit57 */ { SK_PNMI_HRX_UTILOVER, SK_PNMI_HRX_RESERVED},
  583. /* Bit58 */ { SK_PNMI_HRX_64, SK_PNMI_HRX_RESERVED},
  584. /* Bit59 */ { SK_PNMI_HRX_127, SK_PNMI_HRX_RESERVED},
  585. /* Bit60 */ { SK_PNMI_HRX_255, SK_PNMI_HRX_RESERVED},
  586. /* Bit61 */ { SK_PNMI_HRX_511, SK_PNMI_HRX_RESERVED},
  587. /* Bit62 */ { SK_PNMI_HRX_1023, SK_PNMI_HRX_RESERVED},
  588. /* Bit63 */ { SK_PNMI_HRX_MAX, SK_PNMI_HRX_RESERVED}
  589. };
  590. /*
  591. * Table for hardware register saving on resets and port switches
  592. */
  593. PNMI_STATIC const SK_PNMI_STATADDR StatAddr[SK_PNMI_MAX_IDX][SK_PNMI_MAC_TYPES] = {
  594. /* SK_PNMI_HTX */
  595. {{XM_TXF_OK, SK_TRUE}, {0, SK_FALSE}},
  596. /* SK_PNMI_HTX_OCTETHIGH */
  597. {{XM_TXO_OK_HI, SK_TRUE}, {GM_TXO_OK_HI, SK_TRUE}},
  598. /* SK_PNMI_HTX_OCTETLOW */
  599. {{XM_TXO_OK_LO, SK_FALSE}, {GM_TXO_OK_LO, SK_FALSE}},
  600. /* SK_PNMI_HTX_BROADCAST */
  601. {{XM_TXF_BC_OK, SK_TRUE}, {GM_TXF_BC_OK, SK_TRUE}},
  602. /* SK_PNMI_HTX_MULTICAST */
  603. {{XM_TXF_MC_OK, SK_TRUE}, {GM_TXF_MC_OK, SK_TRUE}},
  604. /* SK_PNMI_HTX_UNICAST */
  605. {{XM_TXF_UC_OK, SK_TRUE}, {GM_TXF_UC_OK, SK_TRUE}},
  606. /* SK_PNMI_HTX_BURST */
  607. {{XM_TXE_BURST, SK_TRUE}, {0, SK_FALSE}},
  608. /* SK_PNMI_HTX_PMACC */
  609. {{XM_TXF_MPAUSE, SK_TRUE}, {GM_TXF_MPAUSE, SK_TRUE}},
  610. /* SK_PNMI_HTX_MACC */
  611. {{XM_TXF_MCTRL, SK_TRUE}, {0, SK_FALSE}},
  612. /* SK_PNMI_HTX_COL */
  613. {{0, SK_FALSE}, {GM_TXF_COL, SK_TRUE}},
  614. /* SK_PNMI_HTX_SINGLE_COL */
  615. {{XM_TXF_SNG_COL, SK_TRUE}, {GM_TXF_SNG_COL, SK_TRUE}},
  616. /* SK_PNMI_HTX_MULTI_COL */
  617. {{XM_TXF_MUL_COL, SK_TRUE}, {GM_TXF_MUL_COL, SK_TRUE}},
  618. /* SK_PNMI_HTX_EXCESS_COL */
  619. {{XM_TXF_ABO_COL, SK_TRUE}, {GM_TXF_ABO_COL, SK_TRUE}},
  620. /* SK_PNMI_HTX_LATE_COL */
  621. {{XM_TXF_LAT_COL, SK_TRUE}, {GM_TXF_LAT_COL, SK_TRUE}},
  622. /* SK_PNMI_HTX_DEFFERAL */
  623. {{XM_TXF_DEF, SK_TRUE}, {0, SK_FALSE}},
  624. /* SK_PNMI_HTX_EXCESS_DEF */
  625. {{XM_TXF_EX_DEF, SK_TRUE}, {0, SK_FALSE}},
  626. /* SK_PNMI_HTX_UNDERRUN */
  627. {{XM_TXE_FIFO_UR, SK_TRUE}, {GM_TXE_FIFO_UR, SK_TRUE}},
  628. /* SK_PNMI_HTX_CARRIER */
  629. {{XM_TXE_CS_ERR, SK_TRUE}, {0, SK_FALSE}},
  630. /* SK_PNMI_HTX_UTILUNDER */
  631. {{0, SK_FALSE}, {0, SK_FALSE}},
  632. /* SK_PNMI_HTX_UTILOVER */
  633. {{0, SK_FALSE}, {0, SK_FALSE}},
  634. /* SK_PNMI_HTX_64 */
  635. {{XM_TXF_64B, SK_TRUE}, {GM_TXF_64B, SK_TRUE}},
  636. /* SK_PNMI_HTX_127 */
  637. {{XM_TXF_127B, SK_TRUE}, {GM_TXF_127B, SK_TRUE}},
  638. /* SK_PNMI_HTX_255 */
  639. {{XM_TXF_255B, SK_TRUE}, {GM_TXF_255B, SK_TRUE}},
  640. /* SK_PNMI_HTX_511 */
  641. {{XM_TXF_511B, SK_TRUE}, {GM_TXF_511B, SK_TRUE}},
  642. /* SK_PNMI_HTX_1023 */
  643. {{XM_TXF_1023B, SK_TRUE}, {GM_TXF_1023B, SK_TRUE}},
  644. /* SK_PNMI_HTX_MAX */
  645. {{XM_TXF_MAX_SZ, SK_TRUE}, {GM_TXF_1518B, SK_TRUE}},
  646. /* SK_PNMI_HTX_LONGFRAMES */
  647. {{XM_TXF_LONG, SK_TRUE}, {GM_TXF_MAX_SZ, SK_TRUE}},
  648. /* SK_PNMI_HTX_SYNC */
  649. {{0, SK_FALSE}, {0, SK_FALSE}},
  650. /* SK_PNMI_HTX_SYNC_OCTET */
  651. {{0, SK_FALSE}, {0, SK_FALSE}},
  652. /* SK_PNMI_HTX_RESERVED */
  653. {{0, SK_FALSE}, {0, SK_FALSE}},
  654. /* SK_PNMI_HRX */
  655. {{XM_RXF_OK, SK_TRUE}, {0, SK_FALSE}},
  656. /* SK_PNMI_HRX_OCTETHIGH */
  657. {{XM_RXO_OK_HI, SK_TRUE}, {GM_RXO_OK_HI, SK_TRUE}},
  658. /* SK_PNMI_HRX_OCTETLOW */
  659. {{XM_RXO_OK_LO, SK_FALSE}, {GM_RXO_OK_LO, SK_FALSE}},
  660. /* SK_PNMI_HRX_BADOCTETHIGH */
  661. {{0, SK_FALSE}, {GM_RXO_ERR_HI, SK_TRUE}},
  662. /* SK_PNMI_HRX_BADOCTETLOW */
  663. {{0, SK_FALSE}, {GM_RXO_ERR_LO, SK_TRUE}},
  664. /* SK_PNMI_HRX_BROADCAST */
  665. {{XM_RXF_BC_OK, SK_TRUE}, {GM_RXF_BC_OK, SK_TRUE}},
  666. /* SK_PNMI_HRX_MULTICAST */
  667. {{XM_RXF_MC_OK, SK_TRUE}, {GM_RXF_MC_OK, SK_TRUE}},
  668. /* SK_PNMI_HRX_UNICAST */
  669. {{XM_RXF_UC_OK, SK_TRUE}, {GM_RXF_UC_OK, SK_TRUE}},
  670. /* SK_PNMI_HRX_PMACC */
  671. {{XM_RXF_MPAUSE, SK_TRUE}, {GM_RXF_MPAUSE, SK_TRUE}},
  672. /* SK_PNMI_HRX_MACC */
  673. {{XM_RXF_MCTRL, SK_TRUE}, {0, SK_FALSE}},
  674. /* SK_PNMI_HRX_PMACC_ERR */
  675. {{XM_RXF_INV_MP, SK_TRUE}, {0, SK_FALSE}},
  676. /* SK_PNMI_HRX_MACC_UNKWN */
  677. {{XM_RXF_INV_MOC, SK_TRUE}, {0, SK_FALSE}},
  678. /* SK_PNMI_HRX_BURST */
  679. {{XM_RXE_BURST, SK_TRUE}, {0, SK_FALSE}},
  680. /* SK_PNMI_HRX_MISSED */
  681. {{XM_RXE_FMISS, SK_TRUE}, {0, SK_FALSE}},
  682. /* SK_PNMI_HRX_FRAMING */
  683. {{XM_RXF_FRA_ERR, SK_TRUE}, {0, SK_FALSE}},
  684. /* SK_PNMI_HRX_UNDERSIZE */
  685. {{0, SK_FALSE},{GM_RXF_SHT, SK_TRUE}},
  686. /* SK_PNMI_HRX_OVERFLOW */
  687. {{XM_RXE_FIFO_OV, SK_TRUE}, {GM_RXE_FIFO_OV, SK_TRUE}},
  688. /* SK_PNMI_HRX_JABBER */
  689. {{XM_RXF_JAB_PKT, SK_TRUE}, {GM_RXF_JAB_PKT, SK_TRUE}},
  690. /* SK_PNMI_HRX_CARRIER */
  691. {{XM_RXE_CAR_ERR, SK_TRUE}, {0, SK_FALSE}},
  692. /* SK_PNMI_HRX_IRLENGTH */
  693. {{XM_RXF_LEN_ERR, SK_TRUE}, {0, SK_FALSE}},
  694. /* SK_PNMI_HRX_SYMBOL */
  695. {{XM_RXE_SYM_ERR, SK_TRUE}, {0, SK_FALSE}},
  696. /* SK_PNMI_HRX_SHORTS */
  697. {{XM_RXE_SHT_ERR, SK_TRUE}, {0, SK_FALSE}},
  698. /* SK_PNMI_HRX_RUNT */
  699. {{XM_RXE_RUNT, SK_TRUE}, {GM_RXE_FRAG, SK_TRUE}},
  700. /* SK_PNMI_HRX_TOO_LONG */
  701. {{XM_RXF_LNG_ERR, SK_TRUE}, {GM_RXF_LNG_ERR, SK_TRUE}},
  702. /* SK_PNMI_HRX_FCS */
  703. {{XM_RXF_FCS_ERR, SK_TRUE}, {GM_RXF_FCS_ERR, SK_TRUE}},
  704. /* SK_PNMI_HRX_CEXT */
  705. {{XM_RXF_CEX_ERR, SK_TRUE}, {0, SK_FALSE}},
  706. /* SK_PNMI_HRX_UTILUNDER */
  707. {{0, SK_FALSE}, {0, SK_FALSE}},
  708. /* SK_PNMI_HRX_UTILOVER */
  709. {{0, SK_FALSE}, {0, SK_FALSE}},
  710. /* SK_PNMI_HRX_64 */
  711. {{XM_RXF_64B, SK_TRUE}, {GM_RXF_64B, SK_TRUE}},
  712. /* SK_PNMI_HRX_127 */
  713. {{XM_RXF_127B, SK_TRUE}, {GM_RXF_127B, SK_TRUE}},
  714. /* SK_PNMI_HRX_255 */
  715. {{XM_RXF_255B, SK_TRUE}, {GM_RXF_255B, SK_TRUE}},
  716. /* SK_PNMI_HRX_511 */
  717. {{XM_RXF_511B, SK_TRUE}, {GM_RXF_511B, SK_TRUE}},
  718. /* SK_PNMI_HRX_1023 */
  719. {{XM_RXF_1023B, SK_TRUE}, {GM_RXF_1023B, SK_TRUE}},
  720. /* SK_PNMI_HRX_MAX */
  721. {{XM_RXF_MAX_SZ, SK_TRUE}, {GM_RXF_1518B, SK_TRUE}},
  722. /* SK_PNMI_HRX_LONGFRAMES */
  723. {{0, SK_FALSE}, {GM_RXF_MAX_SZ, SK_TRUE}},
  724. /* SK_PNMI_HRX_RESERVED */
  725. {{0, SK_FALSE}, {0, SK_FALSE}}
  726. };
  727. /*****************************************************************************
  728. *
  729. * Public functions
  730. *
  731. */
  732. /*****************************************************************************
  733. *
  734. * SkPnmiInit - Init function of PNMI
  735. *
  736. * Description:
  737. * SK_INIT_DATA: Initialises the data structures
  738. * SK_INIT_IO: Resets the XMAC statistics, determines the device and
  739. * connector type.
  740. * SK_INIT_RUN: Starts a timer event for port switch per hour
  741. * calculation.
  742. *
  743. * Returns:
  744. * Always 0
  745. */
  746. int SkPnmiInit(
  747. SK_AC *pAC, /* Pointer to adapter context */
  748. SK_IOC IoC, /* IO context handle */
  749. int Level) /* Initialization level */
  750. {
  751. unsigned int PortMax; /* Number of ports */
  752. unsigned int PortIndex; /* Current port index in loop */
  753. SK_U16 Val16; /* Multiple purpose 16 bit variable */
  754. SK_U8 Val8; /* Mulitple purpose 8 bit variable */
  755. SK_EVPARA EventParam; /* Event struct for timer event */
  756. SK_GEPORT *pPrt;
  757. SK_PNMI_VCT *pVctBackupData;
  758. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  759. ("PNMI: SkPnmiInit: Called, level=%d\n", Level));
  760. switch (Level) {
  761. case SK_INIT_DATA:
  762. SK_MEMSET((char *)&pAC->Pnmi, 0, sizeof(pAC->Pnmi));
  763. pAC->Pnmi.TrapBufFree = SK_PNMI_TRAP_QUEUE_LEN;
  764. pAC->Pnmi.StartUpTime = SK_PNMI_HUNDREDS_SEC(SkOsGetTime(pAC));
  765. pAC->Pnmi.RlmtChangeThreshold = SK_PNMI_DEF_RLMT_CHG_THRES;
  766. for (PortIndex = 0; PortIndex < SK_MAX_MACS; PortIndex ++) {
  767. pAC->Pnmi.Port[PortIndex].ActiveFlag = SK_FALSE;
  768. pAC->Pnmi.DualNetActiveFlag = SK_FALSE;
  769. }
  770. #ifdef SK_PNMI_CHECK
  771. if (SK_PNMI_MAX_IDX != SK_PNMI_CNT_NO) {
  772. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR049, SK_PNMI_ERR049MSG);
  773. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_INIT | SK_DBGCAT_FATAL,
  774. ("CounterOffset struct size (%d) differs from"
  775. "SK_PNMI_MAX_IDX (%d)\n",
  776. SK_PNMI_CNT_NO, SK_PNMI_MAX_IDX));
  777. BRK;
  778. }
  779. if (SK_PNMI_MAX_IDX !=
  780. (sizeof(StatAddr) / (sizeof(SK_PNMI_STATADDR) * SK_PNMI_MAC_TYPES))) {
  781. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR050, SK_PNMI_ERR050MSG);
  782. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_INIT | SK_DBGCAT_FATAL,
  783. ("StatAddr table size (%d) differs from "
  784. "SK_PNMI_MAX_IDX (%d)\n",
  785. (sizeof(StatAddr) /
  786. (sizeof(SK_PNMI_STATADDR) * SK_PNMI_MAC_TYPES)),
  787. SK_PNMI_MAX_IDX));
  788. BRK;
  789. }
  790. #endif /* SK_PNMI_CHECK */
  791. break;
  792. case SK_INIT_IO:
  793. /*
  794. * Reset MAC counters
  795. */
  796. PortMax = pAC->GIni.GIMacsFound;
  797. for (PortIndex = 0; PortIndex < PortMax; PortIndex ++) {
  798. pAC->GIni.GIFunc.pFnMacResetCounter(pAC, IoC, PortIndex);
  799. }
  800. /* Initialize DSP variables for Vct() to 0xff => Never written! */
  801. for (PortIndex = 0; PortIndex < PortMax; PortIndex ++) {
  802. pPrt = &pAC->GIni.GP[PortIndex];
  803. pPrt->PCableLen =0xff;
  804. pVctBackupData = &pAC->Pnmi.VctBackup[PortIndex];
  805. pVctBackupData->PCableLen = 0xff;
  806. }
  807. /*
  808. * Get pci bus speed
  809. */
  810. SK_IN16(IoC, B0_CTST, &Val16);
  811. if ((Val16 & CS_BUS_CLOCK) == 0) {
  812. pAC->Pnmi.PciBusSpeed = 33;
  813. }
  814. else {
  815. pAC->Pnmi.PciBusSpeed = 66;
  816. }
  817. /*
  818. * Get pci bus width
  819. */
  820. SK_IN16(IoC, B0_CTST, &Val16);
  821. if ((Val16 & CS_BUS_SLOT_SZ) == 0) {
  822. pAC->Pnmi.PciBusWidth = 32;
  823. }
  824. else {
  825. pAC->Pnmi.PciBusWidth = 64;
  826. }
  827. /*
  828. * Get chipset
  829. */
  830. switch (pAC->GIni.GIChipId) {
  831. case CHIP_ID_GENESIS:
  832. pAC->Pnmi.Chipset = SK_PNMI_CHIPSET_XMAC;
  833. break;
  834. case CHIP_ID_YUKON:
  835. pAC->Pnmi.Chipset = SK_PNMI_CHIPSET_YUKON;
  836. break;
  837. default:
  838. break;
  839. }
  840. /*
  841. * Get PMD and DeviceType
  842. */
  843. SK_IN8(IoC, B2_PMD_TYP, &Val8);
  844. switch (Val8) {
  845. case 'S':
  846. pAC->Pnmi.PMD = 3;
  847. if (pAC->GIni.GIMacsFound > 1) {
  848. pAC->Pnmi.DeviceType = 0x00020002;
  849. }
  850. else {
  851. pAC->Pnmi.DeviceType = 0x00020001;
  852. }
  853. break;
  854. case 'L':
  855. pAC->Pnmi.PMD = 2;
  856. if (pAC->GIni.GIMacsFound > 1) {
  857. pAC->Pnmi.DeviceType = 0x00020004;
  858. }
  859. else {
  860. pAC->Pnmi.DeviceType = 0x00020003;
  861. }
  862. break;
  863. case 'C':
  864. pAC->Pnmi.PMD = 4;
  865. if (pAC->GIni.GIMacsFound > 1) {
  866. pAC->Pnmi.DeviceType = 0x00020006;
  867. }
  868. else {
  869. pAC->Pnmi.DeviceType = 0x00020005;
  870. }
  871. break;
  872. case 'T':
  873. pAC->Pnmi.PMD = 5;
  874. if (pAC->GIni.GIMacsFound > 1) {
  875. pAC->Pnmi.DeviceType = 0x00020008;
  876. }
  877. else {
  878. pAC->Pnmi.DeviceType = 0x00020007;
  879. }
  880. break;
  881. default :
  882. pAC->Pnmi.PMD = 1;
  883. pAC->Pnmi.DeviceType = 0;
  884. break;
  885. }
  886. /*
  887. * Get connector
  888. */
  889. SK_IN8(IoC, B2_CONN_TYP, &Val8);
  890. switch (Val8) {
  891. case 'C':
  892. pAC->Pnmi.Connector = 2;
  893. break;
  894. case 'D':
  895. pAC->Pnmi.Connector = 3;
  896. break;
  897. case 'F':
  898. pAC->Pnmi.Connector = 4;
  899. break;
  900. case 'J':
  901. pAC->Pnmi.Connector = 5;
  902. break;
  903. case 'V':
  904. pAC->Pnmi.Connector = 6;
  905. break;
  906. default:
  907. pAC->Pnmi.Connector = 1;
  908. break;
  909. }
  910. break;
  911. case SK_INIT_RUN:
  912. /*
  913. * Start timer for RLMT change counter
  914. */
  915. SK_MEMSET((char *) &EventParam, 0, sizeof(EventParam));
  916. SkTimerStart(pAC, IoC, &pAC->Pnmi.RlmtChangeEstimate.EstTimer,
  917. 28125000, SKGE_PNMI, SK_PNMI_EVT_CHG_EST_TIMER,
  918. EventParam);
  919. break;
  920. default:
  921. break; /* Nothing todo */
  922. }
  923. return (0);
  924. }
  925. /*****************************************************************************
  926. *
  927. * SkPnmiGetVar - Retrieves the value of a single OID
  928. *
  929. * Description:
  930. * Calls a general sub-function for all this stuff. If the instance
  931. * -1 is passed, the values of all instances are returned in an
  932. * array of values.
  933. *
  934. * Returns:
  935. * SK_PNMI_ERR_OK The request was successfully performed
  936. * SK_PNMI_ERR_GENERAL A general severe internal error occured
  937. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to take
  938. * the data.
  939. * SK_PNMI_ERR_UNKNOWN_OID The requested OID is unknown
  940. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  941. * exist (e.g. port instance 3 on a two port
  942. * adapter.
  943. */
  944. int SkPnmiGetVar(
  945. SK_AC *pAC, /* Pointer to adapter context */
  946. SK_IOC IoC, /* IO context handle */
  947. SK_U32 Id, /* Object ID that is to be processed */
  948. void *pBuf, /* Buffer to which to mgmt data will be retrieved */
  949. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  950. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  951. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  952. {
  953. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  954. ("PNMI: SkPnmiGetVar: Called, Id=0x%x, BufLen=%d, Instance=%d, NetIndex=%d\n",
  955. Id, *pLen, Instance, NetIndex));
  956. return (PnmiVar(pAC, IoC, SK_PNMI_GET, Id, (char *)pBuf, pLen,
  957. Instance, NetIndex));
  958. }
  959. /*****************************************************************************
  960. *
  961. * SkPnmiPreSetVar - Presets the value of a single OID
  962. *
  963. * Description:
  964. * Calls a general sub-function for all this stuff. The preset does
  965. * the same as a set, but returns just before finally setting the
  966. * new value. This is usefull to check if a set might be successfull.
  967. * If as instance a -1 is passed, an array of values is supposed and
  968. * all instance of the OID will be set.
  969. *
  970. * Returns:
  971. * SK_PNMI_ERR_OK The request was successfully performed.
  972. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  973. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  974. * the correct data (e.g. a 32bit value is
  975. * needed, but a 16 bit value was passed).
  976. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  977. * value range.
  978. * SK_PNMI_ERR_READ_ONLY The OID is read-only and cannot be set.
  979. * SK_PNMI_ERR_UNKNOWN_OID The requested OID is unknown.
  980. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  981. * exist (e.g. port instance 3 on a two port
  982. * adapter.
  983. */
  984. int SkPnmiPreSetVar(
  985. SK_AC *pAC, /* Pointer to adapter context */
  986. SK_IOC IoC, /* IO context handle */
  987. SK_U32 Id, /* Object ID that is to be processed */
  988. void *pBuf, /* Buffer which stores the mgmt data to be set */
  989. unsigned int *pLen, /* Total length of mgmt data */
  990. SK_U32 Instance, /* Instance (1..n) that is to be set or -1 */
  991. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  992. {
  993. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  994. ("PNMI: SkPnmiPreSetVar: Called, Id=0x%x, BufLen=%d, Instance=%d, NetIndex=%d\n",
  995. Id, *pLen, Instance, NetIndex));
  996. return (PnmiVar(pAC, IoC, SK_PNMI_PRESET, Id, (char *)pBuf, pLen,
  997. Instance, NetIndex));
  998. }
  999. /*****************************************************************************
  1000. *
  1001. * SkPnmiSetVar - Sets the value of a single OID
  1002. *
  1003. * Description:
  1004. * Calls a general sub-function for all this stuff. The preset does
  1005. * the same as a set, but returns just before finally setting the
  1006. * new value. This is usefull to check if a set might be successfull.
  1007. * If as instance a -1 is passed, an array of values is supposed and
  1008. * all instance of the OID will be set.
  1009. *
  1010. * Returns:
  1011. * SK_PNMI_ERR_OK The request was successfully performed.
  1012. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  1013. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  1014. * the correct data (e.g. a 32bit value is
  1015. * needed, but a 16 bit value was passed).
  1016. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  1017. * value range.
  1018. * SK_PNMI_ERR_READ_ONLY The OID is read-only and cannot be set.
  1019. * SK_PNMI_ERR_UNKNOWN_OID The requested OID is unknown.
  1020. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  1021. * exist (e.g. port instance 3 on a two port
  1022. * adapter.
  1023. */
  1024. int SkPnmiSetVar(
  1025. SK_AC *pAC, /* Pointer to adapter context */
  1026. SK_IOC IoC, /* IO context handle */
  1027. SK_U32 Id, /* Object ID that is to be processed */
  1028. void *pBuf, /* Buffer which stores the mgmt data to be set */
  1029. unsigned int *pLen, /* Total length of mgmt data */
  1030. SK_U32 Instance, /* Instance (1..n) that is to be set or -1 */
  1031. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  1032. {
  1033. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1034. ("PNMI: SkPnmiSetVar: Called, Id=0x%x, BufLen=%d, Instance=%d, NetIndex=%d\n",
  1035. Id, *pLen, Instance, NetIndex));
  1036. return (PnmiVar(pAC, IoC, SK_PNMI_SET, Id, (char *)pBuf, pLen,
  1037. Instance, NetIndex));
  1038. }
  1039. /*****************************************************************************
  1040. *
  1041. * SkPnmiGetStruct - Retrieves the management database in SK_PNMI_STRUCT_DATA
  1042. *
  1043. * Description:
  1044. * Runs through the IdTable, queries the single OIDs and stores the
  1045. * returned data into the management database structure
  1046. * SK_PNMI_STRUCT_DATA. The offset of the OID in the structure
  1047. * is stored in the IdTable. The return value of the function will also
  1048. * be stored in SK_PNMI_STRUCT_DATA if the passed buffer has the
  1049. * minimum size of SK_PNMI_MIN_STRUCT_SIZE.
  1050. *
  1051. * Returns:
  1052. * SK_PNMI_ERR_OK The request was successfully performed
  1053. * SK_PNMI_ERR_GENERAL A general severe internal error occured
  1054. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to take
  1055. * the data.
  1056. * SK_PNMI_ERR_UNKNOWN_NET The requested NetIndex doesn't exist
  1057. */
  1058. int SkPnmiGetStruct(
  1059. SK_AC *pAC, /* Pointer to adapter context */
  1060. SK_IOC IoC, /* IO context handle */
  1061. void *pBuf, /* Buffer which will store the retrieved data */
  1062. unsigned int *pLen, /* Length of buffer */
  1063. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  1064. {
  1065. int Ret;
  1066. unsigned int TableIndex;
  1067. unsigned int DstOffset;
  1068. unsigned int InstanceNo;
  1069. unsigned int InstanceCnt;
  1070. SK_U32 Instance;
  1071. unsigned int TmpLen;
  1072. char KeyArr[SK_PNMI_VPD_ENTRIES][SK_PNMI_VPD_KEY_SIZE];
  1073. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1074. ("PNMI: SkPnmiGetStruct: Called, BufLen=%d, NetIndex=%d\n",
  1075. *pLen, NetIndex));
  1076. if (*pLen < SK_PNMI_STRUCT_SIZE) {
  1077. if (*pLen >= SK_PNMI_MIN_STRUCT_SIZE) {
  1078. SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_TOO_SHORT,
  1079. (SK_U32)(-1));
  1080. }
  1081. *pLen = SK_PNMI_STRUCT_SIZE;
  1082. return (SK_PNMI_ERR_TOO_SHORT);
  1083. }
  1084. /*
  1085. * Check NetIndex
  1086. */
  1087. if (NetIndex >= pAC->Rlmt.NumNets) {
  1088. return (SK_PNMI_ERR_UNKNOWN_NET);
  1089. }
  1090. /* Update statistic */
  1091. SK_PNMI_CHECKFLAGS("SkPnmiGetStruct: On call");
  1092. if ((Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1)) !=
  1093. SK_PNMI_ERR_OK) {
  1094. SK_PNMI_SET_STAT(pBuf, Ret, (SK_U32)(-1));
  1095. *pLen = SK_PNMI_MIN_STRUCT_SIZE;
  1096. return (Ret);
  1097. }
  1098. if ((Ret = RlmtUpdate(pAC, IoC, NetIndex)) != SK_PNMI_ERR_OK) {
  1099. SK_PNMI_SET_STAT(pBuf, Ret, (SK_U32)(-1));
  1100. *pLen = SK_PNMI_MIN_STRUCT_SIZE;
  1101. return (Ret);
  1102. }
  1103. if ((Ret = SirqUpdate(pAC, IoC)) != SK_PNMI_ERR_OK) {
  1104. SK_PNMI_SET_STAT(pBuf, Ret, (SK_U32)(-1));
  1105. *pLen = SK_PNMI_MIN_STRUCT_SIZE;
  1106. return (Ret);
  1107. }
  1108. /*
  1109. * Increment semaphores to indicate that an update was
  1110. * already done
  1111. */
  1112. pAC->Pnmi.MacUpdatedFlag ++;
  1113. pAC->Pnmi.RlmtUpdatedFlag ++;
  1114. pAC->Pnmi.SirqUpdatedFlag ++;
  1115. /* Get vpd keys for instance calculation */
  1116. Ret = GetVpdKeyArr(pAC, IoC, &KeyArr[0][0], sizeof(KeyArr), &TmpLen);
  1117. if (Ret != SK_PNMI_ERR_OK) {
  1118. pAC->Pnmi.MacUpdatedFlag --;
  1119. pAC->Pnmi.RlmtUpdatedFlag --;
  1120. pAC->Pnmi.SirqUpdatedFlag --;
  1121. SK_PNMI_CHECKFLAGS("SkPnmiGetStruct: On return");
  1122. SK_PNMI_SET_STAT(pBuf, Ret, (SK_U32)(-1));
  1123. *pLen = SK_PNMI_MIN_STRUCT_SIZE;
  1124. return (SK_PNMI_ERR_GENERAL);
  1125. }
  1126. /* Retrieve values */
  1127. SK_MEMSET((char *)pBuf, 0, SK_PNMI_STRUCT_SIZE);
  1128. for (TableIndex = 0; TableIndex < ID_TABLE_SIZE; TableIndex ++) {
  1129. InstanceNo = IdTable[TableIndex].InstanceNo;
  1130. for (InstanceCnt = 1; InstanceCnt <= InstanceNo;
  1131. InstanceCnt ++) {
  1132. DstOffset = IdTable[TableIndex].Offset +
  1133. (InstanceCnt - 1) *
  1134. IdTable[TableIndex].StructSize;
  1135. /*
  1136. * For the VPD the instance is not an index number
  1137. * but the key itself. Determin with the instance
  1138. * counter the VPD key to be used.
  1139. */
  1140. if (IdTable[TableIndex].Id == OID_SKGE_VPD_KEY ||
  1141. IdTable[TableIndex].Id == OID_SKGE_VPD_VALUE ||
  1142. IdTable[TableIndex].Id == OID_SKGE_VPD_ACCESS ||
  1143. IdTable[TableIndex].Id == OID_SKGE_VPD_ACTION) {
  1144. SK_STRNCPY((char *)&Instance, KeyArr[InstanceCnt - 1], 4);
  1145. }
  1146. else {
  1147. Instance = (SK_U32)InstanceCnt;
  1148. }
  1149. TmpLen = *pLen - DstOffset;
  1150. Ret = IdTable[TableIndex].Func(pAC, IoC, SK_PNMI_GET,
  1151. IdTable[TableIndex].Id, (char *)pBuf +
  1152. DstOffset, &TmpLen, Instance, TableIndex, NetIndex);
  1153. /*
  1154. * An unknown instance error means that we reached
  1155. * the last instance of that variable. Proceed with
  1156. * the next OID in the table and ignore the return
  1157. * code.
  1158. */
  1159. if (Ret == SK_PNMI_ERR_UNKNOWN_INST) {
  1160. break;
  1161. }
  1162. if (Ret != SK_PNMI_ERR_OK) {
  1163. pAC->Pnmi.MacUpdatedFlag --;
  1164. pAC->Pnmi.RlmtUpdatedFlag --;
  1165. pAC->Pnmi.SirqUpdatedFlag --;
  1166. SK_PNMI_CHECKFLAGS("SkPnmiGetStruct: On return");
  1167. SK_PNMI_SET_STAT(pBuf, Ret, DstOffset);
  1168. *pLen = SK_PNMI_MIN_STRUCT_SIZE;
  1169. return (Ret);
  1170. }
  1171. }
  1172. }
  1173. pAC->Pnmi.MacUpdatedFlag --;
  1174. pAC->Pnmi.RlmtUpdatedFlag --;
  1175. pAC->Pnmi.SirqUpdatedFlag --;
  1176. *pLen = SK_PNMI_STRUCT_SIZE;
  1177. SK_PNMI_CHECKFLAGS("SkPnmiGetStruct: On return");
  1178. SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_OK, (SK_U32)(-1));
  1179. return (SK_PNMI_ERR_OK);
  1180. }
  1181. /*****************************************************************************
  1182. *
  1183. * SkPnmiPreSetStruct - Presets the management database in SK_PNMI_STRUCT_DATA
  1184. *
  1185. * Description:
  1186. * Calls a general sub-function for all this set stuff. The preset does
  1187. * the same as a set, but returns just before finally setting the
  1188. * new value. This is usefull to check if a set might be successfull.
  1189. * The sub-function runs through the IdTable, checks which OIDs are able
  1190. * to set, and calls the handler function of the OID to perform the
  1191. * preset. The return value of the function will also be stored in
  1192. * SK_PNMI_STRUCT_DATA if the passed buffer has the minimum size of
  1193. * SK_PNMI_MIN_STRUCT_SIZE.
  1194. *
  1195. * Returns:
  1196. * SK_PNMI_ERR_OK The request was successfully performed.
  1197. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  1198. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  1199. * the correct data (e.g. a 32bit value is
  1200. * needed, but a 16 bit value was passed).
  1201. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  1202. * value range.
  1203. */
  1204. int SkPnmiPreSetStruct(
  1205. SK_AC *pAC, /* Pointer to adapter context */
  1206. SK_IOC IoC, /* IO context handle */
  1207. void *pBuf, /* Buffer which contains the data to be set */
  1208. unsigned int *pLen, /* Length of buffer */
  1209. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  1210. {
  1211. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1212. ("PNMI: SkPnmiPreSetStruct: Called, BufLen=%d, NetIndex=%d\n",
  1213. *pLen, NetIndex));
  1214. return (PnmiStruct(pAC, IoC, SK_PNMI_PRESET, (char *)pBuf,
  1215. pLen, NetIndex));
  1216. }
  1217. /*****************************************************************************
  1218. *
  1219. * SkPnmiSetStruct - Sets the management database in SK_PNMI_STRUCT_DATA
  1220. *
  1221. * Description:
  1222. * Calls a general sub-function for all this set stuff. The return value
  1223. * of the function will also be stored in SK_PNMI_STRUCT_DATA if the
  1224. * passed buffer has the minimum size of SK_PNMI_MIN_STRUCT_SIZE.
  1225. * The sub-function runs through the IdTable, checks which OIDs are able
  1226. * to set, and calls the handler function of the OID to perform the
  1227. * set. The return value of the function will also be stored in
  1228. * SK_PNMI_STRUCT_DATA if the passed buffer has the minimum size of
  1229. * SK_PNMI_MIN_STRUCT_SIZE.
  1230. *
  1231. * Returns:
  1232. * SK_PNMI_ERR_OK The request was successfully performed.
  1233. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  1234. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  1235. * the correct data (e.g. a 32bit value is
  1236. * needed, but a 16 bit value was passed).
  1237. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  1238. * value range.
  1239. */
  1240. int SkPnmiSetStruct(
  1241. SK_AC *pAC, /* Pointer to adapter context */
  1242. SK_IOC IoC, /* IO context handle */
  1243. void *pBuf, /* Buffer which contains the data to be set */
  1244. unsigned int *pLen, /* Length of buffer */
  1245. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  1246. {
  1247. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1248. ("PNMI: SkPnmiSetStruct: Called, BufLen=%d, NetIndex=%d\n",
  1249. *pLen, NetIndex));
  1250. return (PnmiStruct(pAC, IoC, SK_PNMI_SET, (char *)pBuf,
  1251. pLen, NetIndex));
  1252. }
  1253. /*****************************************************************************
  1254. *
  1255. * SkPnmiEvent - Event handler
  1256. *
  1257. * Description:
  1258. * Handles the following events:
  1259. * SK_PNMI_EVT_SIRQ_OVERFLOW When a hardware counter overflows an
  1260. * interrupt will be generated which is
  1261. * first handled by SIRQ which generates a
  1262. * this event. The event increments the
  1263. * upper 32 bit of the 64 bit counter.
  1264. * SK_PNMI_EVT_SEN_XXX The event is generated by the I2C module
  1265. * when a sensor reports a warning or
  1266. * error. The event will store a trap
  1267. * message in the trap buffer.
  1268. * SK_PNMI_EVT_CHG_EST_TIMER The timer event was initiated by this
  1269. * module and is used to calculate the
  1270. * port switches per hour.
  1271. * SK_PNMI_EVT_CLEAR_COUNTER The event clears all counters and
  1272. * timestamps.
  1273. * SK_PNMI_EVT_XMAC_RESET The event is generated by the driver
  1274. * before a hard reset of the XMAC is
  1275. * performed. All counters will be saved
  1276. * and added to the hardware counter
  1277. * values after reset to grant continuous
  1278. * counter values.
  1279. * SK_PNMI_EVT_RLMT_PORT_UP Generated by RLMT to notify that a port
  1280. * went logically up. A trap message will
  1281. * be stored to the trap buffer.
  1282. * SK_PNMI_EVT_RLMT_PORT_DOWN Generated by RLMT to notify that a port
  1283. * went logically down. A trap message will
  1284. * be stored to the trap buffer.
  1285. * SK_PNMI_EVT_RLMT_SEGMENTATION Generated by RLMT to notify that two
  1286. * spanning tree root bridges were
  1287. * detected. A trap message will be stored
  1288. * to the trap buffer.
  1289. * SK_PNMI_EVT_RLMT_ACTIVE_DOWN Notifies PNMI that an active port went
  1290. * down. PNMI will not further add the
  1291. * statistic values to the virtual port.
  1292. * SK_PNMI_EVT_RLMT_ACTIVE_UP Notifies PNMI that a port went up and
  1293. * is now an active port. PNMI will now
  1294. * add the statistic data of this port to
  1295. * the virtual port.
  1296. * SK_PNMI_EVT_RLMT_SET_NETS Notifies PNMI about the net mode. The first Parameter
  1297. * contains the number of nets. 1 means single net, 2 means
  1298. * dual net. The second Parameter is -1
  1299. *
  1300. * Returns:
  1301. * Always 0
  1302. */
  1303. int SkPnmiEvent(
  1304. SK_AC *pAC, /* Pointer to adapter context */
  1305. SK_IOC IoC, /* IO context handle */
  1306. SK_U32 Event, /* Event-Id */
  1307. SK_EVPARA Param) /* Event dependent parameter */
  1308. {
  1309. unsigned int PhysPortIndex;
  1310. unsigned int MaxNetNumber;
  1311. int CounterIndex;
  1312. int Ret;
  1313. SK_U16 MacStatus;
  1314. SK_U64 OverflowStatus;
  1315. SK_U64 Mask;
  1316. int MacType;
  1317. SK_U64 Value;
  1318. SK_U32 Val32;
  1319. SK_U16 Register;
  1320. SK_EVPARA EventParam;
  1321. SK_U64 NewestValue;
  1322. SK_U64 OldestValue;
  1323. SK_U64 Delta;
  1324. SK_PNMI_ESTIMATE *pEst;
  1325. SK_U32 NetIndex;
  1326. SK_GEPORT *pPrt;
  1327. SK_PNMI_VCT *pVctBackupData;
  1328. SK_U32 RetCode;
  1329. int i;
  1330. SK_U32 CableLength;
  1331. #ifdef DEBUG
  1332. if (Event != SK_PNMI_EVT_XMAC_RESET) {
  1333. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1334. ("PNMI: SkPnmiEvent: Called, Event=0x%x, Param=0x%x\n",
  1335. (unsigned int)Event, (unsigned int)Param.Para64));
  1336. }
  1337. #endif
  1338. SK_PNMI_CHECKFLAGS("SkPnmiEvent: On call");
  1339. MacType = pAC->GIni.GIMacType;
  1340. switch (Event) {
  1341. case SK_PNMI_EVT_SIRQ_OVERFLOW:
  1342. PhysPortIndex = (int)Param.Para32[0];
  1343. MacStatus = (SK_U16)Param.Para32[1];
  1344. #ifdef DEBUG
  1345. if (PhysPortIndex >= SK_MAX_MACS) {
  1346. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1347. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_SIRQ_OVERFLOW parameter"
  1348. " wrong, PhysPortIndex=0x%x\n",
  1349. PhysPortIndex));
  1350. return (0);
  1351. }
  1352. #endif
  1353. OverflowStatus = 0;
  1354. /*
  1355. * Check which source caused an overflow interrupt.
  1356. */
  1357. if ((pAC->GIni.GIFunc.pFnMacOverflow(
  1358. pAC, IoC, PhysPortIndex, MacStatus, &OverflowStatus) != 0) ||
  1359. (OverflowStatus == 0)) {
  1360. SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return");
  1361. return (0);
  1362. }
  1363. /*
  1364. * Check the overflow status register and increment
  1365. * the upper dword of corresponding counter.
  1366. */
  1367. for (CounterIndex = 0; CounterIndex < sizeof(Mask) * 8;
  1368. CounterIndex ++) {
  1369. Mask = (SK_U64)1 << CounterIndex;
  1370. if ((OverflowStatus & Mask) == 0) {
  1371. continue;
  1372. }
  1373. switch (StatOvrflwBit[CounterIndex][MacType]) {
  1374. case SK_PNMI_HTX_UTILUNDER:
  1375. case SK_PNMI_HTX_UTILOVER:
  1376. XM_IN16(IoC, PhysPortIndex, XM_TX_CMD,
  1377. &Register);
  1378. Register |= XM_TX_SAM_LINE;
  1379. XM_OUT16(IoC, PhysPortIndex, XM_TX_CMD,
  1380. Register);
  1381. break;
  1382. case SK_PNMI_HRX_UTILUNDER:
  1383. case SK_PNMI_HRX_UTILOVER:
  1384. XM_IN16(IoC, PhysPortIndex, XM_RX_CMD,
  1385. &Register);
  1386. Register |= XM_RX_SAM_LINE;
  1387. XM_OUT16(IoC, PhysPortIndex, XM_RX_CMD,
  1388. Register);
  1389. break;
  1390. case SK_PNMI_HTX_OCTETHIGH:
  1391. case SK_PNMI_HTX_OCTETLOW:
  1392. case SK_PNMI_HTX_RESERVED:
  1393. case SK_PNMI_HRX_OCTETHIGH:
  1394. case SK_PNMI_HRX_OCTETLOW:
  1395. case SK_PNMI_HRX_IRLENGTH:
  1396. case SK_PNMI_HRX_RESERVED:
  1397. /*
  1398. * the following counters aren't be handled (id > 63)
  1399. */
  1400. case SK_PNMI_HTX_SYNC:
  1401. case SK_PNMI_HTX_SYNC_OCTET:
  1402. break;
  1403. case SK_PNMI_HRX_LONGFRAMES:
  1404. if (MacType == SK_MAC_GMAC) {
  1405. pAC->Pnmi.Port[PhysPortIndex].
  1406. CounterHigh[CounterIndex] ++;
  1407. }
  1408. break;
  1409. default:
  1410. pAC->Pnmi.Port[PhysPortIndex].
  1411. CounterHigh[CounterIndex] ++;
  1412. }
  1413. }
  1414. break;
  1415. case SK_PNMI_EVT_SEN_WAR_LOW:
  1416. #ifdef DEBUG
  1417. if ((unsigned int)Param.Para64 >= (unsigned int)pAC->I2c.MaxSens) {
  1418. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1419. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_SEN_WAR_LOW parameter wrong, SensorIndex=%d\n",
  1420. (unsigned int)Param.Para64));
  1421. return (0);
  1422. }
  1423. #endif
  1424. /*
  1425. * Store a trap message in the trap buffer and generate
  1426. * an event for user space applications with the
  1427. * SK_DRIVER_SENDEVENT macro.
  1428. */
  1429. QueueSensorTrap(pAC, OID_SKGE_TRAP_SEN_WAR_LOW,
  1430. (unsigned int)Param.Para64);
  1431. (void)SK_DRIVER_SENDEVENT(pAC, IoC);
  1432. break;
  1433. case SK_PNMI_EVT_SEN_WAR_UPP:
  1434. #ifdef DEBUG
  1435. if ((unsigned int)Param.Para64 >= (unsigned int)pAC->I2c.MaxSens) {
  1436. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1437. ("PNMI: ERR:SkPnmiEvent: SK_PNMI_EVT_SEN_WAR_UPP parameter wrong, SensorIndex=%d\n",
  1438. (unsigned int)Param.Para64));
  1439. return (0);
  1440. }
  1441. #endif
  1442. /*
  1443. * Store a trap message in the trap buffer and generate
  1444. * an event for user space applications with the
  1445. * SK_DRIVER_SENDEVENT macro.
  1446. */
  1447. QueueSensorTrap(pAC, OID_SKGE_TRAP_SEN_WAR_UPP,
  1448. (unsigned int)Param.Para64);
  1449. (void)SK_DRIVER_SENDEVENT(pAC, IoC);
  1450. break;
  1451. case SK_PNMI_EVT_SEN_ERR_LOW:
  1452. #ifdef DEBUG
  1453. if ((unsigned int)Param.Para64 >= (unsigned int)pAC->I2c.MaxSens) {
  1454. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1455. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_SEN_ERR_LOW parameter wrong, SensorIndex=%d\n",
  1456. (unsigned int)Param.Para64));
  1457. return (0);
  1458. }
  1459. #endif
  1460. /*
  1461. * Store a trap message in the trap buffer and generate
  1462. * an event for user space applications with the
  1463. * SK_DRIVER_SENDEVENT macro.
  1464. */
  1465. QueueSensorTrap(pAC, OID_SKGE_TRAP_SEN_ERR_LOW,
  1466. (unsigned int)Param.Para64);
  1467. (void)SK_DRIVER_SENDEVENT(pAC, IoC);
  1468. break;
  1469. case SK_PNMI_EVT_SEN_ERR_UPP:
  1470. #ifdef DEBUG
  1471. if ((unsigned int)Param.Para64 >= (unsigned int)pAC->I2c.MaxSens) {
  1472. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1473. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_SEN_ERR_UPP parameter wrong, SensorIndex=%d\n",
  1474. (unsigned int)Param.Para64));
  1475. return (0);
  1476. }
  1477. #endif
  1478. /*
  1479. * Store a trap message in the trap buffer and generate
  1480. * an event for user space applications with the
  1481. * SK_DRIVER_SENDEVENT macro.
  1482. */
  1483. QueueSensorTrap(pAC, OID_SKGE_TRAP_SEN_ERR_UPP,
  1484. (unsigned int)Param.Para64);
  1485. (void)SK_DRIVER_SENDEVENT(pAC, IoC);
  1486. break;
  1487. case SK_PNMI_EVT_CHG_EST_TIMER:
  1488. /*
  1489. * Calculate port switch average on a per hour basis
  1490. * Time interval for check : 28125 ms
  1491. * Number of values for average : 8
  1492. *
  1493. * Be careful in changing these values, on change check
  1494. * - typedef of SK_PNMI_ESTIMATE (Size of EstValue
  1495. * array one less than value number)
  1496. * - Timer initilization SkTimerStart() in SkPnmiInit
  1497. * - Delta value below must be multiplicated with
  1498. * power of 2
  1499. *
  1500. */
  1501. pEst = &pAC->Pnmi.RlmtChangeEstimate;
  1502. CounterIndex = pEst->EstValueIndex + 1;
  1503. if (CounterIndex == 7) {
  1504. CounterIndex = 0;
  1505. }
  1506. pEst->EstValueIndex = CounterIndex;
  1507. NewestValue = pAC->Pnmi.RlmtChangeCts;
  1508. OldestValue = pEst->EstValue[CounterIndex];
  1509. pEst->EstValue[CounterIndex] = NewestValue;
  1510. /*
  1511. * Calculate average. Delta stores the number of
  1512. * port switches per 28125 * 8 = 225000 ms
  1513. */
  1514. if (NewestValue >= OldestValue) {
  1515. Delta = NewestValue - OldestValue;
  1516. }
  1517. else {
  1518. /* Overflow situation */
  1519. Delta = (SK_U64)(0 - OldestValue) + NewestValue;
  1520. }
  1521. /*
  1522. * Extrapolate delta to port switches per hour.
  1523. * Estimate = Delta * (3600000 / 225000)
  1524. * = Delta * 16
  1525. * = Delta << 4
  1526. */
  1527. pAC->Pnmi.RlmtChangeEstimate.Estimate = Delta << 4;
  1528. /*
  1529. * Check if threshold is exceeded. If the threshold is
  1530. * permanently exceeded every 28125 ms an event will be
  1531. * generated to remind the user of this condition.
  1532. */
  1533. if ((pAC->Pnmi.RlmtChangeThreshold != 0) &&
  1534. (pAC->Pnmi.RlmtChangeEstimate.Estimate >=
  1535. pAC->Pnmi.RlmtChangeThreshold)) {
  1536. QueueSimpleTrap(pAC, OID_SKGE_TRAP_RLMT_CHANGE_THRES);
  1537. (void)SK_DRIVER_SENDEVENT(pAC, IoC);
  1538. }
  1539. SK_MEMSET((char *) &EventParam, 0, sizeof(EventParam));
  1540. SkTimerStart(pAC, IoC, &pAC->Pnmi.RlmtChangeEstimate.EstTimer,
  1541. 28125000, SKGE_PNMI, SK_PNMI_EVT_CHG_EST_TIMER,
  1542. EventParam);
  1543. break;
  1544. case SK_PNMI_EVT_CLEAR_COUNTER:
  1545. /*
  1546. * Param.Para32[0] contains the NetIndex (0 ..1).
  1547. * Param.Para32[1] is reserved, contains -1.
  1548. */
  1549. NetIndex = (SK_U32)Param.Para32[0];
  1550. #ifdef DEBUG
  1551. if (NetIndex >= pAC->Rlmt.NumNets) {
  1552. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1553. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_CLEAR_COUNTER parameter wrong, NetIndex=%d\n",
  1554. NetIndex));
  1555. return (0);
  1556. }
  1557. #endif
  1558. /*
  1559. * Set all counters and timestamps to zero
  1560. */
  1561. ResetCounter(pAC, IoC, NetIndex); /* the according NetIndex is required
  1562. as a Parameter of the Event */
  1563. break;
  1564. case SK_PNMI_EVT_XMAC_RESET:
  1565. /*
  1566. * To grant continuous counter values store the current
  1567. * XMAC statistic values to the entries 1..n of the
  1568. * CounterOffset array. XMAC Errata #2
  1569. */
  1570. #ifdef DEBUG
  1571. if ((unsigned int)Param.Para64 >= SK_MAX_MACS) {
  1572. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1573. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_XMAC_RESET parameter wrong, PhysPortIndex=%d\n",
  1574. (unsigned int)Param.Para64));
  1575. return (0);
  1576. }
  1577. #endif
  1578. PhysPortIndex = (unsigned int)Param.Para64;
  1579. /*
  1580. * Update XMAC statistic to get fresh values
  1581. */
  1582. Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1);
  1583. if (Ret != SK_PNMI_ERR_OK) {
  1584. SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return");
  1585. return (0);
  1586. }
  1587. /*
  1588. * Increment semaphore to indicate that an update was
  1589. * already done
  1590. */
  1591. pAC->Pnmi.MacUpdatedFlag ++;
  1592. for (CounterIndex = 0; CounterIndex < SK_PNMI_MAX_IDX;
  1593. CounterIndex ++) {
  1594. if (!StatAddr[CounterIndex][MacType].GetOffset) {
  1595. continue;
  1596. }
  1597. pAC->Pnmi.Port[PhysPortIndex].
  1598. CounterOffset[CounterIndex] = GetPhysStatVal(
  1599. pAC, IoC, PhysPortIndex, CounterIndex);
  1600. pAC->Pnmi.Port[PhysPortIndex].
  1601. CounterHigh[CounterIndex] = 0;
  1602. }
  1603. pAC->Pnmi.MacUpdatedFlag --;
  1604. break;
  1605. case SK_PNMI_EVT_RLMT_PORT_UP:
  1606. PhysPortIndex = (unsigned int)Param.Para32[0];
  1607. #ifdef DEBUG
  1608. if (PhysPortIndex >= SK_MAX_MACS) {
  1609. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1610. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_PORT_UP parameter"
  1611. " wrong, PhysPortIndex=%d\n", PhysPortIndex));
  1612. return (0);
  1613. }
  1614. #endif
  1615. /*
  1616. * Store a trap message in the trap buffer and generate an event for
  1617. * user space applications with the SK_DRIVER_SENDEVENT macro.
  1618. */
  1619. QueueRlmtPortTrap(pAC, OID_SKGE_TRAP_RLMT_PORT_UP, PhysPortIndex);
  1620. (void)SK_DRIVER_SENDEVENT(pAC, IoC);
  1621. /* Bugfix for XMAC errata (#10620)*/
  1622. if (pAC->GIni.GIMacType == SK_MAC_XMAC){
  1623. /* Add incremental difference to offset (#10620)*/
  1624. (void)pAC->GIni.GIFunc.pFnMacStatistic(pAC, IoC, PhysPortIndex,
  1625. XM_RXE_SHT_ERR, &Val32);
  1626. Value = (((SK_U64)pAC->Pnmi.Port[PhysPortIndex].
  1627. CounterHigh[SK_PNMI_HRX_SHORTS] << 32) | (SK_U64)Val32);
  1628. pAC->Pnmi.Port[PhysPortIndex].CounterOffset[SK_PNMI_HRX_SHORTS] +=
  1629. Value - pAC->Pnmi.Port[PhysPortIndex].RxShortZeroMark;
  1630. }
  1631. /* Tell VctStatus() that a link was up meanwhile. */
  1632. pAC->Pnmi.VctStatus[PhysPortIndex] |= SK_PNMI_VCT_LINK;
  1633. break;
  1634. case SK_PNMI_EVT_RLMT_PORT_DOWN:
  1635. PhysPortIndex = (unsigned int)Param.Para32[0];
  1636. #ifdef DEBUG
  1637. if (PhysPortIndex >= SK_MAX_MACS) {
  1638. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1639. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_PORT_DOWN parameter"
  1640. " wrong, PhysPortIndex=%d\n", PhysPortIndex));
  1641. return (0);
  1642. }
  1643. #endif
  1644. /*
  1645. * Store a trap message in the trap buffer and generate an event for
  1646. * user space applications with the SK_DRIVER_SENDEVENT macro.
  1647. */
  1648. QueueRlmtPortTrap(pAC, OID_SKGE_TRAP_RLMT_PORT_DOWN, PhysPortIndex);
  1649. (void)SK_DRIVER_SENDEVENT(pAC, IoC);
  1650. /* Bugfix #10620 - get zero level for incremental difference */
  1651. if ((pAC->GIni.GIMacType == SK_MAC_XMAC)) {
  1652. (void)pAC->GIni.GIFunc.pFnMacStatistic(pAC, IoC, PhysPortIndex,
  1653. XM_RXE_SHT_ERR, &Val32);
  1654. pAC->Pnmi.Port[PhysPortIndex].RxShortZeroMark =
  1655. (((SK_U64)pAC->Pnmi.Port[PhysPortIndex].
  1656. CounterHigh[SK_PNMI_HRX_SHORTS] << 32) | (SK_U64)Val32);
  1657. }
  1658. break;
  1659. case SK_PNMI_EVT_RLMT_ACTIVE_DOWN:
  1660. PhysPortIndex = (unsigned int)Param.Para32[0];
  1661. NetIndex = (SK_U32)Param.Para32[1];
  1662. #ifdef DEBUG
  1663. if (PhysPortIndex >= SK_MAX_MACS) {
  1664. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1665. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_ACTIVE_DOWN parameter too high, PhysPort=%d\n",
  1666. PhysPortIndex));
  1667. }
  1668. if (NetIndex >= pAC->Rlmt.NumNets) {
  1669. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1670. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_ACTIVE_DOWN parameter too high, NetIndex=%d\n",
  1671. NetIndex));
  1672. }
  1673. #endif
  1674. /*
  1675. * For now, ignore event if NetIndex != 0.
  1676. */
  1677. if (Param.Para32[1] != 0) {
  1678. return (0);
  1679. }
  1680. /*
  1681. * Nothing to do if port is already inactive
  1682. */
  1683. if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
  1684. return (0);
  1685. }
  1686. /*
  1687. * Update statistic counters to calculate new offset for the virtual
  1688. * port and increment semaphore to indicate that an update was already
  1689. * done.
  1690. */
  1691. if (MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1) !=
  1692. SK_PNMI_ERR_OK) {
  1693. SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return");
  1694. return (0);
  1695. }
  1696. pAC->Pnmi.MacUpdatedFlag ++;
  1697. /*
  1698. * Calculate new counter offset for virtual port to grant continous
  1699. * counting on port switches. The virtual port consists of all currently
  1700. * active ports. The port down event indicates that a port is removed
  1701. * from the virtual port. Therefore add the counter value of the removed
  1702. * port to the CounterOffset for the virtual port to grant the same
  1703. * counter value.
  1704. */
  1705. for (CounterIndex = 0; CounterIndex < SK_PNMI_MAX_IDX;
  1706. CounterIndex ++) {
  1707. if (!StatAddr[CounterIndex][MacType].GetOffset) {
  1708. continue;
  1709. }
  1710. Value = GetPhysStatVal(pAC, IoC, PhysPortIndex, CounterIndex);
  1711. pAC->Pnmi.VirtualCounterOffset[CounterIndex] += Value;
  1712. }
  1713. /*
  1714. * Set port to inactive
  1715. */
  1716. pAC->Pnmi.Port[PhysPortIndex].ActiveFlag = SK_FALSE;
  1717. pAC->Pnmi.MacUpdatedFlag --;
  1718. break;
  1719. case SK_PNMI_EVT_RLMT_ACTIVE_UP:
  1720. PhysPortIndex = (unsigned int)Param.Para32[0];
  1721. NetIndex = (SK_U32)Param.Para32[1];
  1722. #ifdef DEBUG
  1723. if (PhysPortIndex >= SK_MAX_MACS) {
  1724. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1725. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_ACTIVE_UP parameter too high, PhysPort=%d\n",
  1726. PhysPortIndex));
  1727. }
  1728. if (NetIndex >= pAC->Rlmt.NumNets) {
  1729. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,
  1730. ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_ACTIVE_UP parameter too high, NetIndex=%d\n",
  1731. NetIndex));
  1732. }
  1733. #endif
  1734. /*
  1735. * For now, ignore event if NetIndex != 0.
  1736. */
  1737. if (Param.Para32[1] != 0) {
  1738. return (0);
  1739. }
  1740. /*
  1741. * Nothing to do if port is already active
  1742. */
  1743. if (pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
  1744. return (0);
  1745. }
  1746. /*
  1747. * Statistic maintenance
  1748. */
  1749. pAC->Pnmi.RlmtChangeCts ++;
  1750. pAC->Pnmi.RlmtChangeTime = SK_PNMI_HUNDREDS_SEC(SkOsGetTime(pAC));
  1751. /*
  1752. * Store a trap message in the trap buffer and generate an event for
  1753. * user space applications with the SK_DRIVER_SENDEVENT macro.
  1754. */
  1755. QueueRlmtNewMacTrap(pAC, PhysPortIndex);
  1756. (void)SK_DRIVER_SENDEVENT(pAC, IoC);
  1757. /*
  1758. * Update statistic counters to calculate new offset for the virtual
  1759. * port and increment semaphore to indicate that an update was
  1760. * already done.
  1761. */
  1762. if (MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1) !=
  1763. SK_PNMI_ERR_OK) {
  1764. SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return");
  1765. return (0);
  1766. }
  1767. pAC->Pnmi.MacUpdatedFlag ++;
  1768. /*
  1769. * Calculate new counter offset for virtual port to grant continous
  1770. * counting on port switches. A new port is added to the virtual port.
  1771. * Therefore substract the counter value of the new port from the
  1772. * CounterOffset for the virtual port to grant the same value.
  1773. */
  1774. for (CounterIndex = 0; CounterIndex < SK_PNMI_MAX_IDX;
  1775. CounterIndex ++) {
  1776. if (!StatAddr[CounterIndex][MacType].GetOffset) {
  1777. continue;
  1778. }
  1779. Value = GetPhysStatVal(pAC, IoC, PhysPortIndex, CounterIndex);
  1780. pAC->Pnmi.VirtualCounterOffset[CounterIndex] -= Value;
  1781. }
  1782. /*
  1783. * Set port to active
  1784. */
  1785. pAC->Pnmi.Port[PhysPortIndex].ActiveFlag = SK_TRUE;
  1786. pAC->Pnmi.MacUpdatedFlag --;
  1787. break;
  1788. case SK_PNMI_EVT_RLMT_SEGMENTATION:
  1789. /*
  1790. * Para.Para32[0] contains the NetIndex.
  1791. */
  1792. /*
  1793. * Store a trap message in the trap buffer and generate an event for
  1794. * user space applications with the SK_DRIVER_SENDEVENT macro.
  1795. */
  1796. QueueSimpleTrap(pAC, OID_SKGE_TRAP_RLMT_SEGMENTATION);
  1797. (void)SK_DRIVER_SENDEVENT(pAC, IoC);
  1798. break;
  1799. case SK_PNMI_EVT_RLMT_SET_NETS:
  1800. /*
  1801. * Param.Para32[0] contains the number of Nets.
  1802. * Param.Para32[1] is reserved, contains -1.
  1803. */
  1804. /*
  1805. * Check number of nets
  1806. */
  1807. MaxNetNumber = pAC->GIni.GIMacsFound;
  1808. if (((unsigned int)Param.Para32[0] < 1)
  1809. || ((unsigned int)Param.Para32[0] > MaxNetNumber)) {
  1810. return (SK_PNMI_ERR_UNKNOWN_NET);
  1811. }
  1812. if ((unsigned int)Param.Para32[0] == 1) { /* single net mode */
  1813. pAC->Pnmi.DualNetActiveFlag = SK_FALSE;
  1814. }
  1815. else { /* dual net mode */
  1816. pAC->Pnmi.DualNetActiveFlag = SK_TRUE;
  1817. }
  1818. break;
  1819. case SK_PNMI_EVT_VCT_RESET:
  1820. PhysPortIndex = Param.Para32[0];
  1821. pPrt = &pAC->GIni.GP[PhysPortIndex];
  1822. pVctBackupData = &pAC->Pnmi.VctBackup[PhysPortIndex];
  1823. if (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_PENDING) {
  1824. RetCode = SkGmCableDiagStatus(pAC, IoC, PhysPortIndex, SK_FALSE);
  1825. if (RetCode == 2) {
  1826. /*
  1827. * VCT test is still running.
  1828. * Start VCT timer counter again.
  1829. */
  1830. SK_MEMSET((char *) &Param, 0, sizeof(Param));
  1831. Param.Para32[0] = PhysPortIndex;
  1832. Param.Para32[1] = -1;
  1833. SkTimerStart(pAC, IoC, &pAC->Pnmi.VctTimeout[PhysPortIndex].VctTimer,
  1834. 4000000, SKGE_PNMI, SK_PNMI_EVT_VCT_RESET, Param);
  1835. break;
  1836. }
  1837. pAC->Pnmi.VctStatus[PhysPortIndex] &= ~SK_PNMI_VCT_PENDING;
  1838. pAC->Pnmi.VctStatus[PhysPortIndex] |=
  1839. (SK_PNMI_VCT_NEW_VCT_DATA | SK_PNMI_VCT_TEST_DONE);
  1840. /* Copy results for later use to PNMI struct. */
  1841. for (i = 0; i < 4; i++) {
  1842. if (pPrt->PMdiPairLen[i] > 35) {
  1843. CableLength = 1000 * (((175 * pPrt->PMdiPairLen[i]) / 210) - 28);
  1844. }
  1845. else {
  1846. CableLength = 0;
  1847. }
  1848. pVctBackupData->PMdiPairLen[i] = CableLength;
  1849. pVctBackupData->PMdiPairSts[i] = pPrt->PMdiPairSts[i];
  1850. }
  1851. Param.Para32[0] = PhysPortIndex;
  1852. Param.Para32[1] = -1;
  1853. SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_RESET, Param);
  1854. SkEventDispatcher(pAC, IoC);
  1855. }
  1856. break;
  1857. default:
  1858. break;
  1859. }
  1860. SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return");
  1861. return (0);
  1862. }
  1863. /******************************************************************************
  1864. *
  1865. * Private functions
  1866. *
  1867. */
  1868. /*****************************************************************************
  1869. *
  1870. * PnmiVar - Gets, presets, and sets single OIDs
  1871. *
  1872. * Description:
  1873. * Looks up the requested OID, calls the corresponding handler
  1874. * function, and passes the parameters with the get, preset, or
  1875. * set command. The function is called by SkGePnmiGetVar,
  1876. * SkGePnmiPreSetVar, or SkGePnmiSetVar.
  1877. *
  1878. * Returns:
  1879. * SK_PNMI_ERR_XXX. For details have a look to the description of the
  1880. * calling functions.
  1881. * SK_PNMI_ERR_UNKNOWN_NET The requested NetIndex doesn't exist
  1882. */
  1883. PNMI_STATIC int PnmiVar(
  1884. SK_AC *pAC, /* Pointer to adapter context */
  1885. SK_IOC IoC, /* IO context handle */
  1886. int Action, /* Get/PreSet/Set action */
  1887. SK_U32 Id, /* Object ID that is to be processed */
  1888. char *pBuf, /* Buffer which stores the mgmt data to be set */
  1889. unsigned int *pLen, /* Total length of mgmt data */
  1890. SK_U32 Instance, /* Instance (1..n) that is to be set or -1 */
  1891. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  1892. {
  1893. unsigned int TableIndex;
  1894. int Ret;
  1895. if ((TableIndex = LookupId(Id)) == (unsigned int)(-1)) {
  1896. *pLen = 0;
  1897. return (SK_PNMI_ERR_UNKNOWN_OID);
  1898. }
  1899. /*
  1900. * Check NetIndex
  1901. */
  1902. if (NetIndex >= pAC->Rlmt.NumNets) {
  1903. return (SK_PNMI_ERR_UNKNOWN_NET);
  1904. }
  1905. SK_PNMI_CHECKFLAGS("PnmiVar: On call");
  1906. Ret = IdTable[TableIndex].Func(pAC, IoC, Action, Id, pBuf, pLen,
  1907. Instance, TableIndex, NetIndex);
  1908. SK_PNMI_CHECKFLAGS("PnmiVar: On return");
  1909. return (Ret);
  1910. }
  1911. /*****************************************************************************
  1912. *
  1913. * PnmiStruct - Presets and Sets data in structure SK_PNMI_STRUCT_DATA
  1914. *
  1915. * Description:
  1916. * The return value of the function will also be stored in
  1917. * SK_PNMI_STRUCT_DATA if the passed buffer has the minimum size of
  1918. * SK_PNMI_MIN_STRUCT_SIZE. The sub-function runs through the IdTable,
  1919. * checks which OIDs are able to set, and calls the handler function of
  1920. * the OID to perform the set. The return value of the function will
  1921. * also be stored in SK_PNMI_STRUCT_DATA if the passed buffer has the
  1922. * minimum size of SK_PNMI_MIN_STRUCT_SIZE. The function is called
  1923. * by SkGePnmiPreSetStruct and SkGePnmiSetStruct.
  1924. *
  1925. * Returns:
  1926. * SK_PNMI_ERR_XXX. The codes are described in the calling functions.
  1927. * SK_PNMI_ERR_UNKNOWN_NET The requested NetIndex doesn't exist
  1928. */
  1929. PNMI_STATIC int PnmiStruct(
  1930. SK_AC *pAC, /* Pointer to adapter context */
  1931. SK_IOC IoC, /* IO context handle */
  1932. int Action, /* Set action to be performed */
  1933. char *pBuf, /* Buffer which contains the data to be set */
  1934. unsigned int *pLen, /* Length of buffer */
  1935. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  1936. {
  1937. int Ret;
  1938. unsigned int TableIndex;
  1939. unsigned int DstOffset;
  1940. unsigned int Len;
  1941. unsigned int InstanceNo;
  1942. unsigned int InstanceCnt;
  1943. SK_U32 Instance;
  1944. SK_U32 Id;
  1945. /* Check if the passed buffer has the right size */
  1946. if (*pLen < SK_PNMI_STRUCT_SIZE) {
  1947. /* Check if we can return the error within the buffer */
  1948. if (*pLen >= SK_PNMI_MIN_STRUCT_SIZE) {
  1949. SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_TOO_SHORT,
  1950. (SK_U32)(-1));
  1951. }
  1952. *pLen = SK_PNMI_STRUCT_SIZE;
  1953. return (SK_PNMI_ERR_TOO_SHORT);
  1954. }
  1955. /*
  1956. * Check NetIndex
  1957. */
  1958. if (NetIndex >= pAC->Rlmt.NumNets) {
  1959. return (SK_PNMI_ERR_UNKNOWN_NET);
  1960. }
  1961. SK_PNMI_CHECKFLAGS("PnmiStruct: On call");
  1962. /*
  1963. * Update the values of RLMT and SIRQ and increment semaphores to
  1964. * indicate that an update was already done.
  1965. */
  1966. if ((Ret = RlmtUpdate(pAC, IoC, NetIndex)) != SK_PNMI_ERR_OK) {
  1967. SK_PNMI_SET_STAT(pBuf, Ret, (SK_U32)(-1));
  1968. *pLen = SK_PNMI_MIN_STRUCT_SIZE;
  1969. return (Ret);
  1970. }
  1971. if ((Ret = SirqUpdate(pAC, IoC)) != SK_PNMI_ERR_OK) {
  1972. SK_PNMI_SET_STAT(pBuf, Ret, (SK_U32)(-1));
  1973. *pLen = SK_PNMI_MIN_STRUCT_SIZE;
  1974. return (Ret);
  1975. }
  1976. pAC->Pnmi.RlmtUpdatedFlag ++;
  1977. pAC->Pnmi.SirqUpdatedFlag ++;
  1978. /* Preset/Set values */
  1979. for (TableIndex = 0; TableIndex < ID_TABLE_SIZE; TableIndex ++) {
  1980. if ((IdTable[TableIndex].Access != SK_PNMI_RW) &&
  1981. (IdTable[TableIndex].Access != SK_PNMI_WO)) {
  1982. continue;
  1983. }
  1984. InstanceNo = IdTable[TableIndex].InstanceNo;
  1985. Id = IdTable[TableIndex].Id;
  1986. for (InstanceCnt = 1; InstanceCnt <= InstanceNo;
  1987. InstanceCnt ++) {
  1988. DstOffset = IdTable[TableIndex].Offset +
  1989. (InstanceCnt - 1) *
  1990. IdTable[TableIndex].StructSize;
  1991. /*
  1992. * Because VPD multiple instance variables are
  1993. * not setable we do not need to evaluate VPD
  1994. * instances. Have a look to VPD instance
  1995. * calculation in SkPnmiGetStruct().
  1996. */
  1997. Instance = (SK_U32)InstanceCnt;
  1998. /*
  1999. * Evaluate needed buffer length
  2000. */
  2001. Len = 0;
  2002. Ret = IdTable[TableIndex].Func(pAC, IoC,
  2003. SK_PNMI_GET, IdTable[TableIndex].Id,
  2004. NULL, &Len, Instance, TableIndex, NetIndex);
  2005. if (Ret == SK_PNMI_ERR_UNKNOWN_INST) {
  2006. break;
  2007. }
  2008. if (Ret != SK_PNMI_ERR_TOO_SHORT) {
  2009. pAC->Pnmi.RlmtUpdatedFlag --;
  2010. pAC->Pnmi.SirqUpdatedFlag --;
  2011. SK_PNMI_CHECKFLAGS("PnmiStruct: On return");
  2012. SK_PNMI_SET_STAT(pBuf,
  2013. SK_PNMI_ERR_GENERAL, DstOffset);
  2014. *pLen = SK_PNMI_MIN_STRUCT_SIZE;
  2015. return (SK_PNMI_ERR_GENERAL);
  2016. }
  2017. if (Id == OID_SKGE_VPD_ACTION) {
  2018. switch (*(pBuf + DstOffset)) {
  2019. case SK_PNMI_VPD_CREATE:
  2020. Len = 3 + *(pBuf + DstOffset + 3);
  2021. break;
  2022. case SK_PNMI_VPD_DELETE:
  2023. Len = 3;
  2024. break;
  2025. default:
  2026. Len = 1;
  2027. break;
  2028. }
  2029. }
  2030. /* Call the OID handler function */
  2031. Ret = IdTable[TableIndex].Func(pAC, IoC, Action,
  2032. IdTable[TableIndex].Id, pBuf + DstOffset,
  2033. &Len, Instance, TableIndex, NetIndex);
  2034. if (Ret != SK_PNMI_ERR_OK) {
  2035. pAC->Pnmi.RlmtUpdatedFlag --;
  2036. pAC->Pnmi.SirqUpdatedFlag --;
  2037. SK_PNMI_CHECKFLAGS("PnmiStruct: On return");
  2038. SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_BAD_VALUE,
  2039. DstOffset);
  2040. *pLen = SK_PNMI_MIN_STRUCT_SIZE;
  2041. return (SK_PNMI_ERR_BAD_VALUE);
  2042. }
  2043. }
  2044. }
  2045. pAC->Pnmi.RlmtUpdatedFlag --;
  2046. pAC->Pnmi.SirqUpdatedFlag --;
  2047. SK_PNMI_CHECKFLAGS("PnmiStruct: On return");
  2048. SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_OK, (SK_U32)(-1));
  2049. return (SK_PNMI_ERR_OK);
  2050. }
  2051. /*****************************************************************************
  2052. *
  2053. * LookupId - Lookup an OID in the IdTable
  2054. *
  2055. * Description:
  2056. * Scans the IdTable to find the table entry of an OID.
  2057. *
  2058. * Returns:
  2059. * The table index or -1 if not found.
  2060. */
  2061. PNMI_STATIC int LookupId(
  2062. SK_U32 Id) /* Object identifier to be searched */
  2063. {
  2064. int i;
  2065. for (i = 0; i < ID_TABLE_SIZE; i++) {
  2066. if (IdTable[i].Id == Id) {
  2067. return i;
  2068. }
  2069. }
  2070. return (-1);
  2071. }
  2072. /*****************************************************************************
  2073. *
  2074. * OidStruct - Handler of OID_SKGE_ALL_DATA
  2075. *
  2076. * Description:
  2077. * This OID performs a Get/Preset/SetStruct call and returns all data
  2078. * in a SK_PNMI_STRUCT_DATA structure.
  2079. *
  2080. * Returns:
  2081. * SK_PNMI_ERR_OK The request was successfully performed.
  2082. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  2083. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  2084. * the correct data (e.g. a 32bit value is
  2085. * needed, but a 16 bit value was passed).
  2086. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  2087. * value range.
  2088. * SK_PNMI_ERR_READ_ONLY The OID is read-only and cannot be set.
  2089. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  2090. * exist (e.g. port instance 3 on a two port
  2091. * adapter.
  2092. */
  2093. PNMI_STATIC int OidStruct(
  2094. SK_AC *pAC, /* Pointer to adapter context */
  2095. SK_IOC IoC, /* IO context handle */
  2096. int Action, /* Get/PreSet/Set action */
  2097. SK_U32 Id, /* Object ID that is to be processed */
  2098. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  2099. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  2100. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  2101. unsigned int TableIndex, /* Index to the Id table */
  2102. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  2103. {
  2104. if (Id != OID_SKGE_ALL_DATA) {
  2105. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR003,
  2106. SK_PNMI_ERR003MSG);
  2107. *pLen = 0;
  2108. return (SK_PNMI_ERR_GENERAL);
  2109. }
  2110. /*
  2111. * Check instance. We only handle single instance variables
  2112. */
  2113. if (Instance != (SK_U32)(-1) && Instance != 1) {
  2114. *pLen = 0;
  2115. return (SK_PNMI_ERR_UNKNOWN_INST);
  2116. }
  2117. switch (Action) {
  2118. case SK_PNMI_GET:
  2119. return (SkPnmiGetStruct(pAC, IoC, pBuf, pLen, NetIndex));
  2120. case SK_PNMI_PRESET:
  2121. return (SkPnmiPreSetStruct(pAC, IoC, pBuf, pLen, NetIndex));
  2122. case SK_PNMI_SET:
  2123. return (SkPnmiSetStruct(pAC, IoC, pBuf, pLen, NetIndex));
  2124. }
  2125. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR004, SK_PNMI_ERR004MSG);
  2126. *pLen = 0;
  2127. return (SK_PNMI_ERR_GENERAL);
  2128. }
  2129. /*****************************************************************************
  2130. *
  2131. * Perform - OID handler of OID_SKGE_ACTION
  2132. *
  2133. * Description:
  2134. * None.
  2135. *
  2136. * Returns:
  2137. * SK_PNMI_ERR_OK The request was successfully performed.
  2138. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  2139. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  2140. * the correct data (e.g. a 32bit value is
  2141. * needed, but a 16 bit value was passed).
  2142. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  2143. * value range.
  2144. * SK_PNMI_ERR_READ_ONLY The OID is read-only and cannot be set.
  2145. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  2146. * exist (e.g. port instance 3 on a two port
  2147. * adapter.
  2148. */
  2149. PNMI_STATIC int Perform(
  2150. SK_AC *pAC, /* Pointer to adapter context */
  2151. SK_IOC IoC, /* IO context handle */
  2152. int Action, /* Get/PreSet/Set action */
  2153. SK_U32 Id, /* Object ID that is to be processed */
  2154. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  2155. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  2156. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  2157. unsigned int TableIndex, /* Index to the Id table */
  2158. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  2159. {
  2160. int Ret;
  2161. SK_U32 ActionOp;
  2162. /*
  2163. * Check instance. We only handle single instance variables
  2164. */
  2165. if (Instance != (SK_U32)(-1) && Instance != 1) {
  2166. *pLen = 0;
  2167. return (SK_PNMI_ERR_UNKNOWN_INST);
  2168. }
  2169. if (*pLen < sizeof(SK_U32)) {
  2170. *pLen = sizeof(SK_U32);
  2171. return (SK_PNMI_ERR_TOO_SHORT);
  2172. }
  2173. /* Check if a get should be performed */
  2174. if (Action == SK_PNMI_GET) {
  2175. /* A get is easy. We always return the same value */
  2176. ActionOp = (SK_U32)SK_PNMI_ACT_IDLE;
  2177. SK_PNMI_STORE_U32(pBuf, ActionOp);
  2178. *pLen = sizeof(SK_U32);
  2179. return (SK_PNMI_ERR_OK);
  2180. }
  2181. /* Continue with PRESET/SET action */
  2182. if (*pLen > sizeof(SK_U32)) {
  2183. return (SK_PNMI_ERR_BAD_VALUE);
  2184. }
  2185. /* Check if the command is a known one */
  2186. SK_PNMI_READ_U32(pBuf, ActionOp);
  2187. if (*pLen > sizeof(SK_U32) ||
  2188. (ActionOp != SK_PNMI_ACT_IDLE &&
  2189. ActionOp != SK_PNMI_ACT_RESET &&
  2190. ActionOp != SK_PNMI_ACT_SELFTEST &&
  2191. ActionOp != SK_PNMI_ACT_RESETCNT)) {
  2192. *pLen = 0;
  2193. return (SK_PNMI_ERR_BAD_VALUE);
  2194. }
  2195. /* A preset ends here */
  2196. if (Action == SK_PNMI_PRESET) {
  2197. return (SK_PNMI_ERR_OK);
  2198. }
  2199. switch (ActionOp) {
  2200. case SK_PNMI_ACT_IDLE:
  2201. /* Nothing to do */
  2202. break;
  2203. case SK_PNMI_ACT_RESET:
  2204. /*
  2205. * Perform a driver reset or something that comes near
  2206. * to this.
  2207. */
  2208. Ret = SK_DRIVER_RESET(pAC, IoC);
  2209. if (Ret != 0) {
  2210. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR005,
  2211. SK_PNMI_ERR005MSG);
  2212. return (SK_PNMI_ERR_GENERAL);
  2213. }
  2214. break;
  2215. case SK_PNMI_ACT_SELFTEST:
  2216. /*
  2217. * Perform a driver selftest or something similar to this.
  2218. * Currently this feature is not used and will probably
  2219. * implemented in another way.
  2220. */
  2221. Ret = SK_DRIVER_SELFTEST(pAC, IoC);
  2222. pAC->Pnmi.TestResult = Ret;
  2223. break;
  2224. case SK_PNMI_ACT_RESETCNT:
  2225. /* Set all counters and timestamps to zero */
  2226. ResetCounter(pAC, IoC, NetIndex);
  2227. break;
  2228. default:
  2229. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR006,
  2230. SK_PNMI_ERR006MSG);
  2231. return (SK_PNMI_ERR_GENERAL);
  2232. }
  2233. return (SK_PNMI_ERR_OK);
  2234. }
  2235. /*****************************************************************************
  2236. *
  2237. * Mac8023Stat - OID handler of OID_GEN_XXX and OID_802_3_XXX
  2238. *
  2239. * Description:
  2240. * Retrieves the statistic values of the virtual port (logical
  2241. * index 0). Only special OIDs of NDIS are handled which consist
  2242. * of a 32 bit instead of a 64 bit value. The OIDs are public
  2243. * because perhaps some other platform can use them too.
  2244. *
  2245. * Returns:
  2246. * SK_PNMI_ERR_OK The request was successfully performed.
  2247. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  2248. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  2249. * the correct data (e.g. a 32bit value is
  2250. * needed, but a 16 bit value was passed).
  2251. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  2252. * exist (e.g. port instance 3 on a two port
  2253. * adapter.
  2254. */
  2255. PNMI_STATIC int Mac8023Stat(
  2256. SK_AC *pAC, /* Pointer to adapter context */
  2257. SK_IOC IoC, /* IO context handle */
  2258. int Action, /* Get/PreSet/Set action */
  2259. SK_U32 Id, /* Object ID that is to be processed */
  2260. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  2261. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  2262. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  2263. unsigned int TableIndex, /* Index to the Id table */
  2264. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  2265. {
  2266. int Ret;
  2267. SK_U64 StatVal;
  2268. SK_U32 StatVal32;
  2269. SK_BOOL Is64BitReq = SK_FALSE;
  2270. /*
  2271. * Only the active Mac is returned
  2272. */
  2273. if (Instance != (SK_U32)(-1) && Instance != 1) {
  2274. *pLen = 0;
  2275. return (SK_PNMI_ERR_UNKNOWN_INST);
  2276. }
  2277. /*
  2278. * Check action type
  2279. */
  2280. if (Action != SK_PNMI_GET) {
  2281. *pLen = 0;
  2282. return (SK_PNMI_ERR_READ_ONLY);
  2283. }
  2284. /*
  2285. * Check length
  2286. */
  2287. switch (Id) {
  2288. case OID_802_3_PERMANENT_ADDRESS:
  2289. case OID_802_3_CURRENT_ADDRESS:
  2290. if (*pLen < sizeof(SK_MAC_ADDR)) {
  2291. *pLen = sizeof(SK_MAC_ADDR);
  2292. return (SK_PNMI_ERR_TOO_SHORT);
  2293. }
  2294. break;
  2295. default:
  2296. #ifndef SK_NDIS_64BIT_CTR
  2297. if (*pLen < sizeof(SK_U32)) {
  2298. *pLen = sizeof(SK_U32);
  2299. return (SK_PNMI_ERR_TOO_SHORT);
  2300. }
  2301. #else /* SK_NDIS_64BIT_CTR */
  2302. /*
  2303. * for compatibility, at least 32bit are required for oid
  2304. */
  2305. if (*pLen < sizeof(SK_U32)) {
  2306. /*
  2307. * but indicate handling for 64bit values,
  2308. * if insufficient space is provided
  2309. */
  2310. *pLen = sizeof(SK_U64);
  2311. return (SK_PNMI_ERR_TOO_SHORT);
  2312. }
  2313. Is64BitReq = (*pLen < sizeof(SK_U64)) ? SK_FALSE : SK_TRUE;
  2314. #endif /* SK_NDIS_64BIT_CTR */
  2315. break;
  2316. }
  2317. /*
  2318. * Update all statistics, because we retrieve virtual MAC, which
  2319. * consists of multiple physical statistics and increment semaphore
  2320. * to indicate that an update was already done.
  2321. */
  2322. Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1);
  2323. if ( Ret != SK_PNMI_ERR_OK) {
  2324. *pLen = 0;
  2325. return (Ret);
  2326. }
  2327. pAC->Pnmi.MacUpdatedFlag ++;
  2328. /*
  2329. * Get value (MAC Index 0 identifies the virtual MAC)
  2330. */
  2331. switch (Id) {
  2332. case OID_802_3_PERMANENT_ADDRESS:
  2333. CopyMac(pBuf, &pAC->Addr.Net[NetIndex].PermanentMacAddress);
  2334. *pLen = sizeof(SK_MAC_ADDR);
  2335. break;
  2336. case OID_802_3_CURRENT_ADDRESS:
  2337. CopyMac(pBuf, &pAC->Addr.Net[NetIndex].CurrentMacAddress);
  2338. *pLen = sizeof(SK_MAC_ADDR);
  2339. break;
  2340. default:
  2341. StatVal = GetStatVal(pAC, IoC, 0, IdTable[TableIndex].Param, NetIndex);
  2342. /*
  2343. * by default 32bit values are evaluated
  2344. */
  2345. if (!Is64BitReq) {
  2346. StatVal32 = (SK_U32)StatVal;
  2347. SK_PNMI_STORE_U32(pBuf, StatVal32);
  2348. *pLen = sizeof(SK_U32);
  2349. }
  2350. else {
  2351. SK_PNMI_STORE_U64(pBuf, StatVal);
  2352. *pLen = sizeof(SK_U64);
  2353. }
  2354. break;
  2355. }
  2356. pAC->Pnmi.MacUpdatedFlag --;
  2357. return (SK_PNMI_ERR_OK);
  2358. }
  2359. /*****************************************************************************
  2360. *
  2361. * MacPrivateStat - OID handler function of OID_SKGE_STAT_XXX
  2362. *
  2363. * Description:
  2364. * Retrieves the XMAC statistic data.
  2365. *
  2366. * Returns:
  2367. * SK_PNMI_ERR_OK The request was successfully performed.
  2368. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  2369. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  2370. * the correct data (e.g. a 32bit value is
  2371. * needed, but a 16 bit value was passed).
  2372. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  2373. * exist (e.g. port instance 3 on a two port
  2374. * adapter.
  2375. */
  2376. PNMI_STATIC int MacPrivateStat(
  2377. SK_AC *pAC, /* Pointer to adapter context */
  2378. SK_IOC IoC, /* IO context handle */
  2379. int Action, /* Get/PreSet/Set action */
  2380. SK_U32 Id, /* Object ID that is to be processed */
  2381. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  2382. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  2383. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  2384. unsigned int TableIndex, /* Index to the Id table */
  2385. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  2386. {
  2387. unsigned int LogPortMax;
  2388. unsigned int LogPortIndex;
  2389. unsigned int PhysPortMax;
  2390. unsigned int Limit;
  2391. unsigned int Offset;
  2392. int Ret;
  2393. SK_U64 StatVal;
  2394. /*
  2395. * Calculate instance if wished. MAC index 0 is the virtual
  2396. * MAC.
  2397. */
  2398. PhysPortMax = pAC->GIni.GIMacsFound;
  2399. LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
  2400. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) { /* Dual net mode */
  2401. LogPortMax--;
  2402. }
  2403. if ((Instance != (SK_U32)(-1))) { /* Only one specific instance is queried */
  2404. /* Check instance range */
  2405. if ((Instance < 1) || (Instance > LogPortMax)) {
  2406. *pLen = 0;
  2407. return (SK_PNMI_ERR_UNKNOWN_INST);
  2408. }
  2409. LogPortIndex = SK_PNMI_PORT_INST2LOG(Instance);
  2410. Limit = LogPortIndex + 1;
  2411. }
  2412. else { /* Instance == (SK_U32)(-1), get all Instances of that OID */
  2413. LogPortIndex = 0;
  2414. Limit = LogPortMax;
  2415. }
  2416. /*
  2417. * Check action
  2418. */
  2419. if (Action != SK_PNMI_GET) {
  2420. *pLen = 0;
  2421. return (SK_PNMI_ERR_READ_ONLY);
  2422. }
  2423. /*
  2424. * Check length
  2425. */
  2426. if (*pLen < (Limit - LogPortIndex) * sizeof(SK_U64)) {
  2427. *pLen = (Limit - LogPortIndex) * sizeof(SK_U64);
  2428. return (SK_PNMI_ERR_TOO_SHORT);
  2429. }
  2430. /*
  2431. * Update XMAC statistic and increment semaphore to indicate that
  2432. * an update was already done.
  2433. */
  2434. Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1);
  2435. if (Ret != SK_PNMI_ERR_OK) {
  2436. *pLen = 0;
  2437. return (Ret);
  2438. }
  2439. pAC->Pnmi.MacUpdatedFlag ++;
  2440. /*
  2441. * Get value
  2442. */
  2443. Offset = 0;
  2444. for (; LogPortIndex < Limit; LogPortIndex ++) {
  2445. switch (Id) {
  2446. /* XXX not yet implemented due to XMAC problems
  2447. case OID_SKGE_STAT_TX_UTIL:
  2448. return (SK_PNMI_ERR_GENERAL);
  2449. */
  2450. /* XXX not yet implemented due to XMAC problems
  2451. case OID_SKGE_STAT_RX_UTIL:
  2452. return (SK_PNMI_ERR_GENERAL);
  2453. */
  2454. case OID_SKGE_STAT_RX:
  2455. case OID_SKGE_STAT_TX:
  2456. switch (pAC->GIni.GIMacType) {
  2457. case SK_MAC_XMAC:
  2458. StatVal = GetStatVal(pAC, IoC, LogPortIndex,
  2459. IdTable[TableIndex].Param, NetIndex);
  2460. break;
  2461. case SK_MAC_GMAC:
  2462. if (Id == OID_SKGE_STAT_TX) {
  2463. StatVal =
  2464. GetStatVal(pAC, IoC, LogPortIndex,
  2465. SK_PNMI_HTX_BROADCAST, NetIndex) +
  2466. GetStatVal(pAC, IoC, LogPortIndex,
  2467. SK_PNMI_HTX_MULTICAST, NetIndex) +
  2468. GetStatVal(pAC, IoC, LogPortIndex,
  2469. SK_PNMI_HTX_UNICAST, NetIndex);
  2470. }
  2471. else {
  2472. StatVal =
  2473. GetStatVal(pAC, IoC, LogPortIndex,
  2474. SK_PNMI_HRX_BROADCAST, NetIndex) +
  2475. GetStatVal(pAC, IoC, LogPortIndex,
  2476. SK_PNMI_HRX_MULTICAST, NetIndex) +
  2477. GetStatVal(pAC, IoC, LogPortIndex,
  2478. SK_PNMI_HRX_UNICAST, NetIndex) +
  2479. GetStatVal(pAC, IoC, LogPortIndex,
  2480. SK_PNMI_HRX_UNDERSIZE, NetIndex);
  2481. }
  2482. break;
  2483. default:
  2484. StatVal = 0;
  2485. break;
  2486. }
  2487. SK_PNMI_STORE_U64(pBuf + Offset, StatVal);
  2488. break;
  2489. default:
  2490. StatVal = GetStatVal(pAC, IoC, LogPortIndex,
  2491. IdTable[TableIndex].Param, NetIndex);
  2492. SK_PNMI_STORE_U64(pBuf + Offset, StatVal);
  2493. break;
  2494. }
  2495. Offset += sizeof(SK_U64);
  2496. }
  2497. *pLen = Offset;
  2498. pAC->Pnmi.MacUpdatedFlag --;
  2499. return (SK_PNMI_ERR_OK);
  2500. }
  2501. /*****************************************************************************
  2502. *
  2503. * Addr - OID handler function of OID_SKGE_PHYS_CUR_ADDR and _FAC_ADDR
  2504. *
  2505. * Description:
  2506. * Get/Presets/Sets the current and factory MAC address. The MAC
  2507. * address of the virtual port, which is reported to the OS, may
  2508. * not be changed, but the physical ones. A set to the virtual port
  2509. * will be ignored. No error should be reported because otherwise
  2510. * a multiple instance set (-1) would always fail.
  2511. *
  2512. * Returns:
  2513. * SK_PNMI_ERR_OK The request was successfully performed.
  2514. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  2515. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  2516. * the correct data (e.g. a 32bit value is
  2517. * needed, but a 16 bit value was passed).
  2518. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  2519. * value range.
  2520. * SK_PNMI_ERR_READ_ONLY The OID is read-only and cannot be set.
  2521. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  2522. * exist (e.g. port instance 3 on a two port
  2523. * adapter.
  2524. */
  2525. PNMI_STATIC int Addr(
  2526. SK_AC *pAC, /* Pointer to adapter context */
  2527. SK_IOC IoC, /* IO context handle */
  2528. int Action, /* Get/PreSet/Set action */
  2529. SK_U32 Id, /* Object ID that is to be processed */
  2530. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  2531. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  2532. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  2533. unsigned int TableIndex, /* Index to the Id table */
  2534. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  2535. {
  2536. int Ret;
  2537. unsigned int LogPortMax;
  2538. unsigned int PhysPortMax;
  2539. unsigned int LogPortIndex;
  2540. unsigned int PhysPortIndex;
  2541. unsigned int Limit;
  2542. unsigned int Offset = 0;
  2543. /*
  2544. * Calculate instance if wished. MAC index 0 is the virtual
  2545. * MAC.
  2546. */
  2547. PhysPortMax = pAC->GIni.GIMacsFound;
  2548. LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
  2549. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) { /* Dual net mode */
  2550. LogPortMax--;
  2551. }
  2552. if ((Instance != (SK_U32)(-1))) { /* Only one specific instance is queried */
  2553. /* Check instance range */
  2554. if ((Instance < 1) || (Instance > LogPortMax)) {
  2555. *pLen = 0;
  2556. return (SK_PNMI_ERR_UNKNOWN_INST);
  2557. }
  2558. LogPortIndex = SK_PNMI_PORT_INST2LOG(Instance);
  2559. Limit = LogPortIndex + 1;
  2560. }
  2561. else { /* Instance == (SK_U32)(-1), get all Instances of that OID */
  2562. LogPortIndex = 0;
  2563. Limit = LogPortMax;
  2564. }
  2565. /*
  2566. * Perform Action
  2567. */
  2568. if (Action == SK_PNMI_GET) {
  2569. /*
  2570. * Check length
  2571. */
  2572. if (*pLen < (Limit - LogPortIndex) * 6) {
  2573. *pLen = (Limit - LogPortIndex) * 6;
  2574. return (SK_PNMI_ERR_TOO_SHORT);
  2575. }
  2576. /*
  2577. * Get value
  2578. */
  2579. for (; LogPortIndex < Limit; LogPortIndex ++) {
  2580. switch (Id) {
  2581. case OID_SKGE_PHYS_CUR_ADDR:
  2582. if (LogPortIndex == 0) {
  2583. CopyMac(pBuf + Offset, &pAC->Addr.Net[NetIndex].CurrentMacAddress);
  2584. }
  2585. else {
  2586. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
  2587. CopyMac(pBuf + Offset,
  2588. &pAC->Addr.Port[PhysPortIndex].CurrentMacAddress);
  2589. }
  2590. Offset += 6;
  2591. break;
  2592. case OID_SKGE_PHYS_FAC_ADDR:
  2593. if (LogPortIndex == 0) {
  2594. CopyMac(pBuf + Offset,
  2595. &pAC->Addr.Net[NetIndex].PermanentMacAddress);
  2596. }
  2597. else {
  2598. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  2599. pAC, LogPortIndex);
  2600. CopyMac(pBuf + Offset,
  2601. &pAC->Addr.Port[PhysPortIndex].PermanentMacAddress);
  2602. }
  2603. Offset += 6;
  2604. break;
  2605. default:
  2606. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR008,
  2607. SK_PNMI_ERR008MSG);
  2608. *pLen = 0;
  2609. return (SK_PNMI_ERR_GENERAL);
  2610. }
  2611. }
  2612. *pLen = Offset;
  2613. }
  2614. else {
  2615. /*
  2616. * The logical MAC address may not be changed only
  2617. * the physical ones
  2618. */
  2619. if (Id == OID_SKGE_PHYS_FAC_ADDR) {
  2620. *pLen = 0;
  2621. return (SK_PNMI_ERR_READ_ONLY);
  2622. }
  2623. /*
  2624. * Only the current address may be changed
  2625. */
  2626. if (Id != OID_SKGE_PHYS_CUR_ADDR) {
  2627. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR009,
  2628. SK_PNMI_ERR009MSG);
  2629. *pLen = 0;
  2630. return (SK_PNMI_ERR_GENERAL);
  2631. }
  2632. /*
  2633. * Check length
  2634. */
  2635. if (*pLen < (Limit - LogPortIndex) * 6) {
  2636. *pLen = (Limit - LogPortIndex) * 6;
  2637. return (SK_PNMI_ERR_TOO_SHORT);
  2638. }
  2639. if (*pLen > (Limit - LogPortIndex) * 6) {
  2640. *pLen = 0;
  2641. return (SK_PNMI_ERR_BAD_VALUE);
  2642. }
  2643. /*
  2644. * Check Action
  2645. */
  2646. if (Action == SK_PNMI_PRESET) {
  2647. *pLen = 0;
  2648. return (SK_PNMI_ERR_OK);
  2649. }
  2650. /*
  2651. * Set OID_SKGE_MAC_CUR_ADDR
  2652. */
  2653. for (; LogPortIndex < Limit; LogPortIndex ++, Offset += 6) {
  2654. /*
  2655. * A set to virtual port and set of broadcast
  2656. * address will be ignored
  2657. */
  2658. if (LogPortIndex == 0 || SK_MEMCMP(pBuf + Offset,
  2659. "\xff\xff\xff\xff\xff\xff", 6) == 0) {
  2660. continue;
  2661. }
  2662. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC,
  2663. LogPortIndex);
  2664. Ret = SkAddrOverride(pAC, IoC, PhysPortIndex,
  2665. (SK_MAC_ADDR *)(pBuf + Offset),
  2666. (LogPortIndex == 0 ? SK_ADDR_VIRTUAL_ADDRESS :
  2667. SK_ADDR_PHYSICAL_ADDRESS));
  2668. if (Ret != SK_ADDR_OVERRIDE_SUCCESS) {
  2669. return (SK_PNMI_ERR_GENERAL);
  2670. }
  2671. }
  2672. *pLen = Offset;
  2673. }
  2674. return (SK_PNMI_ERR_OK);
  2675. }
  2676. /*****************************************************************************
  2677. *
  2678. * CsumStat - OID handler function of OID_SKGE_CHKSM_XXX
  2679. *
  2680. * Description:
  2681. * Retrieves the statistic values of the CSUM module. The CSUM data
  2682. * structure must be available in the SK_AC even if the CSUM module
  2683. * is not included, because PNMI reads the statistic data from the
  2684. * CSUM part of SK_AC directly.
  2685. *
  2686. * Returns:
  2687. * SK_PNMI_ERR_OK The request was successfully performed.
  2688. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  2689. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  2690. * the correct data (e.g. a 32bit value is
  2691. * needed, but a 16 bit value was passed).
  2692. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  2693. * exist (e.g. port instance 3 on a two port
  2694. * adapter.
  2695. */
  2696. PNMI_STATIC int CsumStat(
  2697. SK_AC *pAC, /* Pointer to adapter context */
  2698. SK_IOC IoC, /* IO context handle */
  2699. int Action, /* Get/PreSet/Set action */
  2700. SK_U32 Id, /* Object ID that is to be processed */
  2701. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  2702. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  2703. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  2704. unsigned int TableIndex, /* Index to the Id table */
  2705. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  2706. {
  2707. unsigned int Index;
  2708. unsigned int Limit;
  2709. unsigned int Offset = 0;
  2710. SK_U64 StatVal;
  2711. /*
  2712. * Calculate instance if wished
  2713. */
  2714. if (Instance != (SK_U32)(-1)) {
  2715. if ((Instance < 1) || (Instance > SKCS_NUM_PROTOCOLS)) {
  2716. *pLen = 0;
  2717. return (SK_PNMI_ERR_UNKNOWN_INST);
  2718. }
  2719. Index = (unsigned int)Instance - 1;
  2720. Limit = Index + 1;
  2721. }
  2722. else {
  2723. Index = 0;
  2724. Limit = SKCS_NUM_PROTOCOLS;
  2725. }
  2726. /*
  2727. * Check action
  2728. */
  2729. if (Action != SK_PNMI_GET) {
  2730. *pLen = 0;
  2731. return (SK_PNMI_ERR_READ_ONLY);
  2732. }
  2733. /*
  2734. * Check length
  2735. */
  2736. if (*pLen < (Limit - Index) * sizeof(SK_U64)) {
  2737. *pLen = (Limit - Index) * sizeof(SK_U64);
  2738. return (SK_PNMI_ERR_TOO_SHORT);
  2739. }
  2740. /*
  2741. * Get value
  2742. */
  2743. for (; Index < Limit; Index ++) {
  2744. switch (Id) {
  2745. case OID_SKGE_CHKSM_RX_OK_CTS:
  2746. StatVal = pAC->Csum.ProtoStats[NetIndex][Index].RxOkCts;
  2747. break;
  2748. case OID_SKGE_CHKSM_RX_UNABLE_CTS:
  2749. StatVal = pAC->Csum.ProtoStats[NetIndex][Index].RxUnableCts;
  2750. break;
  2751. case OID_SKGE_CHKSM_RX_ERR_CTS:
  2752. StatVal = pAC->Csum.ProtoStats[NetIndex][Index].RxErrCts;
  2753. break;
  2754. case OID_SKGE_CHKSM_TX_OK_CTS:
  2755. StatVal = pAC->Csum.ProtoStats[NetIndex][Index].TxOkCts;
  2756. break;
  2757. case OID_SKGE_CHKSM_TX_UNABLE_CTS:
  2758. StatVal = pAC->Csum.ProtoStats[NetIndex][Index].TxUnableCts;
  2759. break;
  2760. default:
  2761. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR010,
  2762. SK_PNMI_ERR010MSG);
  2763. *pLen = 0;
  2764. return (SK_PNMI_ERR_GENERAL);
  2765. }
  2766. SK_PNMI_STORE_U64(pBuf + Offset, StatVal);
  2767. Offset += sizeof(SK_U64);
  2768. }
  2769. /*
  2770. * Store used buffer space
  2771. */
  2772. *pLen = Offset;
  2773. return (SK_PNMI_ERR_OK);
  2774. }
  2775. /*****************************************************************************
  2776. *
  2777. * SensorStat - OID handler function of OID_SKGE_SENSOR_XXX
  2778. *
  2779. * Description:
  2780. * Retrieves the statistic values of the I2C module, which handles
  2781. * the temperature and voltage sensors.
  2782. *
  2783. * Returns:
  2784. * SK_PNMI_ERR_OK The request was successfully performed.
  2785. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  2786. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  2787. * the correct data (e.g. a 32bit value is
  2788. * needed, but a 16 bit value was passed).
  2789. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  2790. * exist (e.g. port instance 3 on a two port
  2791. * adapter.
  2792. */
  2793. PNMI_STATIC int SensorStat(
  2794. SK_AC *pAC, /* Pointer to adapter context */
  2795. SK_IOC IoC, /* IO context handle */
  2796. int Action, /* Get/PreSet/Set action */
  2797. SK_U32 Id, /* Object ID that is to be processed */
  2798. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  2799. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  2800. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  2801. unsigned int TableIndex, /* Index to the Id table */
  2802. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  2803. {
  2804. unsigned int i;
  2805. unsigned int Index;
  2806. unsigned int Limit;
  2807. unsigned int Offset;
  2808. unsigned int Len;
  2809. SK_U32 Val32;
  2810. SK_U64 Val64;
  2811. /*
  2812. * Calculate instance if wished
  2813. */
  2814. if ((Instance != (SK_U32)(-1))) {
  2815. if ((Instance < 1) || (Instance > (SK_U32)pAC->I2c.MaxSens)) {
  2816. *pLen = 0;
  2817. return (SK_PNMI_ERR_UNKNOWN_INST);
  2818. }
  2819. Index = (unsigned int)Instance -1;
  2820. Limit = (unsigned int)Instance;
  2821. }
  2822. else {
  2823. Index = 0;
  2824. Limit = (unsigned int) pAC->I2c.MaxSens;
  2825. }
  2826. /*
  2827. * Check action
  2828. */
  2829. if (Action != SK_PNMI_GET) {
  2830. *pLen = 0;
  2831. return (SK_PNMI_ERR_READ_ONLY);
  2832. }
  2833. /*
  2834. * Check length
  2835. */
  2836. switch (Id) {
  2837. case OID_SKGE_SENSOR_VALUE:
  2838. case OID_SKGE_SENSOR_WAR_THRES_LOW:
  2839. case OID_SKGE_SENSOR_WAR_THRES_UPP:
  2840. case OID_SKGE_SENSOR_ERR_THRES_LOW:
  2841. case OID_SKGE_SENSOR_ERR_THRES_UPP:
  2842. if (*pLen < (Limit - Index) * sizeof(SK_U32)) {
  2843. *pLen = (Limit - Index) * sizeof(SK_U32);
  2844. return (SK_PNMI_ERR_TOO_SHORT);
  2845. }
  2846. break;
  2847. case OID_SKGE_SENSOR_DESCR:
  2848. for (Offset = 0, i = Index; i < Limit; i ++) {
  2849. Len = (unsigned int)
  2850. SK_STRLEN(pAC->I2c.SenTable[i].SenDesc) + 1;
  2851. if (Len >= SK_PNMI_STRINGLEN2) {
  2852. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR011,
  2853. SK_PNMI_ERR011MSG);
  2854. *pLen = 0;
  2855. return (SK_PNMI_ERR_GENERAL);
  2856. }
  2857. Offset += Len;
  2858. }
  2859. if (*pLen < Offset) {
  2860. *pLen = Offset;
  2861. return (SK_PNMI_ERR_TOO_SHORT);
  2862. }
  2863. break;
  2864. case OID_SKGE_SENSOR_INDEX:
  2865. case OID_SKGE_SENSOR_TYPE:
  2866. case OID_SKGE_SENSOR_STATUS:
  2867. if (*pLen < Limit - Index) {
  2868. *pLen = Limit - Index;
  2869. return (SK_PNMI_ERR_TOO_SHORT);
  2870. }
  2871. break;
  2872. case OID_SKGE_SENSOR_WAR_CTS:
  2873. case OID_SKGE_SENSOR_WAR_TIME:
  2874. case OID_SKGE_SENSOR_ERR_CTS:
  2875. case OID_SKGE_SENSOR_ERR_TIME:
  2876. if (*pLen < (Limit - Index) * sizeof(SK_U64)) {
  2877. *pLen = (Limit - Index) * sizeof(SK_U64);
  2878. return (SK_PNMI_ERR_TOO_SHORT);
  2879. }
  2880. break;
  2881. default:
  2882. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR012,
  2883. SK_PNMI_ERR012MSG);
  2884. *pLen = 0;
  2885. return (SK_PNMI_ERR_GENERAL);
  2886. }
  2887. /*
  2888. * Get value
  2889. */
  2890. for (Offset = 0; Index < Limit; Index ++) {
  2891. switch (Id) {
  2892. case OID_SKGE_SENSOR_INDEX:
  2893. *(pBuf + Offset) = (char)Index;
  2894. Offset += sizeof(char);
  2895. break;
  2896. case OID_SKGE_SENSOR_DESCR:
  2897. Len = SK_STRLEN(pAC->I2c.SenTable[Index].SenDesc);
  2898. SK_MEMCPY(pBuf + Offset + 1,
  2899. pAC->I2c.SenTable[Index].SenDesc, Len);
  2900. *(pBuf + Offset) = (char)Len;
  2901. Offset += Len + 1;
  2902. break;
  2903. case OID_SKGE_SENSOR_TYPE:
  2904. *(pBuf + Offset) =
  2905. (char)pAC->I2c.SenTable[Index].SenType;
  2906. Offset += sizeof(char);
  2907. break;
  2908. case OID_SKGE_SENSOR_VALUE:
  2909. Val32 = (SK_U32)pAC->I2c.SenTable[Index].SenValue;
  2910. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  2911. Offset += sizeof(SK_U32);
  2912. break;
  2913. case OID_SKGE_SENSOR_WAR_THRES_LOW:
  2914. Val32 = (SK_U32)pAC->I2c.SenTable[Index].
  2915. SenThreWarnLow;
  2916. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  2917. Offset += sizeof(SK_U32);
  2918. break;
  2919. case OID_SKGE_SENSOR_WAR_THRES_UPP:
  2920. Val32 = (SK_U32)pAC->I2c.SenTable[Index].
  2921. SenThreWarnHigh;
  2922. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  2923. Offset += sizeof(SK_U32);
  2924. break;
  2925. case OID_SKGE_SENSOR_ERR_THRES_LOW:
  2926. Val32 = (SK_U32)pAC->I2c.SenTable[Index].
  2927. SenThreErrLow;
  2928. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  2929. Offset += sizeof(SK_U32);
  2930. break;
  2931. case OID_SKGE_SENSOR_ERR_THRES_UPP:
  2932. Val32 = pAC->I2c.SenTable[Index].SenThreErrHigh;
  2933. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  2934. Offset += sizeof(SK_U32);
  2935. break;
  2936. case OID_SKGE_SENSOR_STATUS:
  2937. *(pBuf + Offset) =
  2938. (char)pAC->I2c.SenTable[Index].SenErrFlag;
  2939. Offset += sizeof(char);
  2940. break;
  2941. case OID_SKGE_SENSOR_WAR_CTS:
  2942. Val64 = pAC->I2c.SenTable[Index].SenWarnCts;
  2943. SK_PNMI_STORE_U64(pBuf + Offset, Val64);
  2944. Offset += sizeof(SK_U64);
  2945. break;
  2946. case OID_SKGE_SENSOR_ERR_CTS:
  2947. Val64 = pAC->I2c.SenTable[Index].SenErrCts;
  2948. SK_PNMI_STORE_U64(pBuf + Offset, Val64);
  2949. Offset += sizeof(SK_U64);
  2950. break;
  2951. case OID_SKGE_SENSOR_WAR_TIME:
  2952. Val64 = SK_PNMI_HUNDREDS_SEC(pAC->I2c.SenTable[Index].
  2953. SenBegWarnTS);
  2954. SK_PNMI_STORE_U64(pBuf + Offset, Val64);
  2955. Offset += sizeof(SK_U64);
  2956. break;
  2957. case OID_SKGE_SENSOR_ERR_TIME:
  2958. Val64 = SK_PNMI_HUNDREDS_SEC(pAC->I2c.SenTable[Index].
  2959. SenBegErrTS);
  2960. SK_PNMI_STORE_U64(pBuf + Offset, Val64);
  2961. Offset += sizeof(SK_U64);
  2962. break;
  2963. default:
  2964. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_ERR,
  2965. ("SensorStat: Unknown OID should be handled before"));
  2966. return (SK_PNMI_ERR_GENERAL);
  2967. }
  2968. }
  2969. /*
  2970. * Store used buffer space
  2971. */
  2972. *pLen = Offset;
  2973. return (SK_PNMI_ERR_OK);
  2974. }
  2975. /*****************************************************************************
  2976. *
  2977. * Vpd - OID handler function of OID_SKGE_VPD_XXX
  2978. *
  2979. * Description:
  2980. * Get/preset/set of VPD data. As instance the name of a VPD key
  2981. * can be passed. The Instance parameter is a SK_U32 and can be
  2982. * used as a string buffer for the VPD key, because their maximum
  2983. * length is 4 byte.
  2984. *
  2985. * Returns:
  2986. * SK_PNMI_ERR_OK The request was successfully performed.
  2987. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  2988. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  2989. * the correct data (e.g. a 32bit value is
  2990. * needed, but a 16 bit value was passed).
  2991. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  2992. * value range.
  2993. * SK_PNMI_ERR_READ_ONLY The OID is read-only and cannot be set.
  2994. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  2995. * exist (e.g. port instance 3 on a two port
  2996. * adapter.
  2997. */
  2998. PNMI_STATIC int Vpd(
  2999. SK_AC *pAC, /* Pointer to adapter context */
  3000. SK_IOC IoC, /* IO context handle */
  3001. int Action, /* Get/PreSet/Set action */
  3002. SK_U32 Id, /* Object ID that is to be processed */
  3003. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  3004. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  3005. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  3006. unsigned int TableIndex, /* Index to the Id table */
  3007. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  3008. {
  3009. SK_VPD_STATUS *pVpdStatus;
  3010. unsigned int BufLen;
  3011. char Buf[256];
  3012. char KeyArr[SK_PNMI_VPD_ENTRIES][SK_PNMI_VPD_KEY_SIZE];
  3013. char KeyStr[SK_PNMI_VPD_KEY_SIZE];
  3014. unsigned int KeyNo;
  3015. unsigned int Offset;
  3016. unsigned int Index;
  3017. unsigned int FirstIndex;
  3018. unsigned int LastIndex;
  3019. unsigned int Len;
  3020. int Ret;
  3021. SK_U32 Val32;
  3022. /*
  3023. * Get array of all currently stored VPD keys
  3024. */
  3025. Ret = GetVpdKeyArr(pAC, IoC, &KeyArr[0][0], sizeof(KeyArr),
  3026. &KeyNo);
  3027. if (Ret != SK_PNMI_ERR_OK) {
  3028. *pLen = 0;
  3029. return (Ret);
  3030. }
  3031. /*
  3032. * If instance is not -1, try to find the requested VPD key for
  3033. * the multiple instance variables. The other OIDs as for example
  3034. * OID VPD_ACTION are single instance variables and must be
  3035. * handled separatly.
  3036. */
  3037. FirstIndex = 0;
  3038. LastIndex = KeyNo;
  3039. if ((Instance != (SK_U32)(-1))) {
  3040. if (Id == OID_SKGE_VPD_KEY || Id == OID_SKGE_VPD_VALUE ||
  3041. Id == OID_SKGE_VPD_ACCESS) {
  3042. SK_STRNCPY(KeyStr, (char *)&Instance, 4);
  3043. KeyStr[4] = 0;
  3044. for (Index = 0; Index < KeyNo; Index ++) {
  3045. if (SK_STRCMP(KeyStr, KeyArr[Index]) == 0) {
  3046. FirstIndex = Index;
  3047. LastIndex = Index+1;
  3048. break;
  3049. }
  3050. }
  3051. if (Index == KeyNo) {
  3052. *pLen = 0;
  3053. return (SK_PNMI_ERR_UNKNOWN_INST);
  3054. }
  3055. }
  3056. else if (Instance != 1) {
  3057. *pLen = 0;
  3058. return (SK_PNMI_ERR_UNKNOWN_INST);
  3059. }
  3060. }
  3061. /*
  3062. * Get value, if a query should be performed
  3063. */
  3064. if (Action == SK_PNMI_GET) {
  3065. switch (Id) {
  3066. case OID_SKGE_VPD_FREE_BYTES:
  3067. /* Check length of buffer */
  3068. if (*pLen < sizeof(SK_U32)) {
  3069. *pLen = sizeof(SK_U32);
  3070. return (SK_PNMI_ERR_TOO_SHORT);
  3071. }
  3072. /* Get number of free bytes */
  3073. pVpdStatus = VpdStat(pAC, IoC);
  3074. if (pVpdStatus == NULL) {
  3075. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR017,
  3076. SK_PNMI_ERR017MSG);
  3077. *pLen = 0;
  3078. return (SK_PNMI_ERR_GENERAL);
  3079. }
  3080. if ((pVpdStatus->vpd_status & VPD_VALID) == 0) {
  3081. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR018,
  3082. SK_PNMI_ERR018MSG);
  3083. *pLen = 0;
  3084. return (SK_PNMI_ERR_GENERAL);
  3085. }
  3086. Val32 = (SK_U32)pVpdStatus->vpd_free_rw;
  3087. SK_PNMI_STORE_U32(pBuf, Val32);
  3088. *pLen = sizeof(SK_U32);
  3089. break;
  3090. case OID_SKGE_VPD_ENTRIES_LIST:
  3091. /* Check length */
  3092. for (Len = 0, Index = 0; Index < KeyNo; Index ++) {
  3093. Len += SK_STRLEN(KeyArr[Index]) + 1;
  3094. }
  3095. if (*pLen < Len) {
  3096. *pLen = Len;
  3097. return (SK_PNMI_ERR_TOO_SHORT);
  3098. }
  3099. /* Get value */
  3100. *(pBuf) = (char)Len - 1;
  3101. for (Offset = 1, Index = 0; Index < KeyNo; Index ++) {
  3102. Len = SK_STRLEN(KeyArr[Index]);
  3103. SK_MEMCPY(pBuf + Offset, KeyArr[Index], Len);
  3104. Offset += Len;
  3105. if (Index < KeyNo - 1) {
  3106. *(pBuf + Offset) = ' ';
  3107. Offset ++;
  3108. }
  3109. }
  3110. *pLen = Offset;
  3111. break;
  3112. case OID_SKGE_VPD_ENTRIES_NUMBER:
  3113. /* Check length */
  3114. if (*pLen < sizeof(SK_U32)) {
  3115. *pLen = sizeof(SK_U32);
  3116. return (SK_PNMI_ERR_TOO_SHORT);
  3117. }
  3118. Val32 = (SK_U32)KeyNo;
  3119. SK_PNMI_STORE_U32(pBuf, Val32);
  3120. *pLen = sizeof(SK_U32);
  3121. break;
  3122. case OID_SKGE_VPD_KEY:
  3123. /* Check buffer length, if it is large enough */
  3124. for (Len = 0, Index = FirstIndex;
  3125. Index < LastIndex; Index ++) {
  3126. Len += SK_STRLEN(KeyArr[Index]) + 1;
  3127. }
  3128. if (*pLen < Len) {
  3129. *pLen = Len;
  3130. return (SK_PNMI_ERR_TOO_SHORT);
  3131. }
  3132. /*
  3133. * Get the key to an intermediate buffer, because
  3134. * we have to prepend a length byte.
  3135. */
  3136. for (Offset = 0, Index = FirstIndex;
  3137. Index < LastIndex; Index ++) {
  3138. Len = SK_STRLEN(KeyArr[Index]);
  3139. *(pBuf + Offset) = (char)Len;
  3140. SK_MEMCPY(pBuf + Offset + 1, KeyArr[Index],
  3141. Len);
  3142. Offset += Len + 1;
  3143. }
  3144. *pLen = Offset;
  3145. break;
  3146. case OID_SKGE_VPD_VALUE:
  3147. /* Check the buffer length if it is large enough */
  3148. for (Offset = 0, Index = FirstIndex;
  3149. Index < LastIndex; Index ++) {
  3150. BufLen = 256;
  3151. if (VpdRead(pAC, IoC, KeyArr[Index], Buf,
  3152. (int *)&BufLen) > 0 ||
  3153. BufLen >= SK_PNMI_VPD_DATALEN) {
  3154. SK_ERR_LOG(pAC, SK_ERRCL_SW,
  3155. SK_PNMI_ERR021,
  3156. SK_PNMI_ERR021MSG);
  3157. return (SK_PNMI_ERR_GENERAL);
  3158. }
  3159. Offset += BufLen + 1;
  3160. }
  3161. if (*pLen < Offset) {
  3162. *pLen = Offset;
  3163. return (SK_PNMI_ERR_TOO_SHORT);
  3164. }
  3165. /*
  3166. * Get the value to an intermediate buffer, because
  3167. * we have to prepend a length byte.
  3168. */
  3169. for (Offset = 0, Index = FirstIndex;
  3170. Index < LastIndex; Index ++) {
  3171. BufLen = 256;
  3172. if (VpdRead(pAC, IoC, KeyArr[Index], Buf,
  3173. (int *)&BufLen) > 0 ||
  3174. BufLen >= SK_PNMI_VPD_DATALEN) {
  3175. SK_ERR_LOG(pAC, SK_ERRCL_SW,
  3176. SK_PNMI_ERR022,
  3177. SK_PNMI_ERR022MSG);
  3178. *pLen = 0;
  3179. return (SK_PNMI_ERR_GENERAL);
  3180. }
  3181. *(pBuf + Offset) = (char)BufLen;
  3182. SK_MEMCPY(pBuf + Offset + 1, Buf, BufLen);
  3183. Offset += BufLen + 1;
  3184. }
  3185. *pLen = Offset;
  3186. break;
  3187. case OID_SKGE_VPD_ACCESS:
  3188. if (*pLen < LastIndex - FirstIndex) {
  3189. *pLen = LastIndex - FirstIndex;
  3190. return (SK_PNMI_ERR_TOO_SHORT);
  3191. }
  3192. for (Offset = 0, Index = FirstIndex;
  3193. Index < LastIndex; Index ++) {
  3194. if (VpdMayWrite(KeyArr[Index])) {
  3195. *(pBuf + Offset) = SK_PNMI_VPD_RW;
  3196. }
  3197. else {
  3198. *(pBuf + Offset) = SK_PNMI_VPD_RO;
  3199. }
  3200. Offset ++;
  3201. }
  3202. *pLen = Offset;
  3203. break;
  3204. case OID_SKGE_VPD_ACTION:
  3205. Offset = LastIndex - FirstIndex;
  3206. if (*pLen < Offset) {
  3207. *pLen = Offset;
  3208. return (SK_PNMI_ERR_TOO_SHORT);
  3209. }
  3210. SK_MEMSET(pBuf, 0, Offset);
  3211. *pLen = Offset;
  3212. break;
  3213. default:
  3214. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR023,
  3215. SK_PNMI_ERR023MSG);
  3216. *pLen = 0;
  3217. return (SK_PNMI_ERR_GENERAL);
  3218. }
  3219. }
  3220. else {
  3221. /* The only OID which can be set is VPD_ACTION */
  3222. if (Id != OID_SKGE_VPD_ACTION) {
  3223. if (Id == OID_SKGE_VPD_FREE_BYTES ||
  3224. Id == OID_SKGE_VPD_ENTRIES_LIST ||
  3225. Id == OID_SKGE_VPD_ENTRIES_NUMBER ||
  3226. Id == OID_SKGE_VPD_KEY ||
  3227. Id == OID_SKGE_VPD_VALUE ||
  3228. Id == OID_SKGE_VPD_ACCESS) {
  3229. *pLen = 0;
  3230. return (SK_PNMI_ERR_READ_ONLY);
  3231. }
  3232. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR024,
  3233. SK_PNMI_ERR024MSG);
  3234. *pLen = 0;
  3235. return (SK_PNMI_ERR_GENERAL);
  3236. }
  3237. /*
  3238. * From this point we handle VPD_ACTION. Check the buffer
  3239. * length. It should at least have the size of one byte.
  3240. */
  3241. if (*pLen < 1) {
  3242. *pLen = 1;
  3243. return (SK_PNMI_ERR_TOO_SHORT);
  3244. }
  3245. /*
  3246. * The first byte contains the VPD action type we should
  3247. * perform.
  3248. */
  3249. switch (*pBuf) {
  3250. case SK_PNMI_VPD_IGNORE:
  3251. /* Nothing to do */
  3252. break;
  3253. case SK_PNMI_VPD_CREATE:
  3254. /*
  3255. * We have to create a new VPD entry or we modify
  3256. * an existing one. Check first the buffer length.
  3257. */
  3258. if (*pLen < 4) {
  3259. *pLen = 4;
  3260. return (SK_PNMI_ERR_TOO_SHORT);
  3261. }
  3262. KeyStr[0] = pBuf[1];
  3263. KeyStr[1] = pBuf[2];
  3264. KeyStr[2] = 0;
  3265. /*
  3266. * Is the entry writable or does it belong to the
  3267. * read-only area?
  3268. */
  3269. if (!VpdMayWrite(KeyStr)) {
  3270. *pLen = 0;
  3271. return (SK_PNMI_ERR_BAD_VALUE);
  3272. }
  3273. Offset = (int)pBuf[3] & 0xFF;
  3274. SK_MEMCPY(Buf, pBuf + 4, Offset);
  3275. Buf[Offset] = 0;
  3276. /* A preset ends here */
  3277. if (Action == SK_PNMI_PRESET) {
  3278. return (SK_PNMI_ERR_OK);
  3279. }
  3280. /* Write the new entry or modify an existing one */
  3281. Ret = VpdWrite(pAC, IoC, KeyStr, Buf);
  3282. if (Ret == SK_PNMI_VPD_NOWRITE ) {
  3283. *pLen = 0;
  3284. return (SK_PNMI_ERR_BAD_VALUE);
  3285. }
  3286. else if (Ret != SK_PNMI_VPD_OK) {
  3287. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR025,
  3288. SK_PNMI_ERR025MSG);
  3289. *pLen = 0;
  3290. return (SK_PNMI_ERR_GENERAL);
  3291. }
  3292. /*
  3293. * Perform an update of the VPD data. This is
  3294. * not mandantory, but just to be sure.
  3295. */
  3296. Ret = VpdUpdate(pAC, IoC);
  3297. if (Ret != SK_PNMI_VPD_OK) {
  3298. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR026,
  3299. SK_PNMI_ERR026MSG);
  3300. *pLen = 0;
  3301. return (SK_PNMI_ERR_GENERAL);
  3302. }
  3303. break;
  3304. case SK_PNMI_VPD_DELETE:
  3305. /* Check if the buffer size is plausible */
  3306. if (*pLen < 3) {
  3307. *pLen = 3;
  3308. return (SK_PNMI_ERR_TOO_SHORT);
  3309. }
  3310. if (*pLen > 3) {
  3311. *pLen = 0;
  3312. return (SK_PNMI_ERR_BAD_VALUE);
  3313. }
  3314. KeyStr[0] = pBuf[1];
  3315. KeyStr[1] = pBuf[2];
  3316. KeyStr[2] = 0;
  3317. /* Find the passed key in the array */
  3318. for (Index = 0; Index < KeyNo; Index ++) {
  3319. if (SK_STRCMP(KeyStr, KeyArr[Index]) == 0) {
  3320. break;
  3321. }
  3322. }
  3323. /*
  3324. * If we cannot find the key it is wrong, so we
  3325. * return an appropriate error value.
  3326. */
  3327. if (Index == KeyNo) {
  3328. *pLen = 0;
  3329. return (SK_PNMI_ERR_BAD_VALUE);
  3330. }
  3331. if (Action == SK_PNMI_PRESET) {
  3332. return (SK_PNMI_ERR_OK);
  3333. }
  3334. /* Ok, you wanted it and you will get it */
  3335. Ret = VpdDelete(pAC, IoC, KeyStr);
  3336. if (Ret != SK_PNMI_VPD_OK) {
  3337. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR027,
  3338. SK_PNMI_ERR027MSG);
  3339. *pLen = 0;
  3340. return (SK_PNMI_ERR_GENERAL);
  3341. }
  3342. /*
  3343. * Perform an update of the VPD data. This is
  3344. * not mandantory, but just to be sure.
  3345. */
  3346. Ret = VpdUpdate(pAC, IoC);
  3347. if (Ret != SK_PNMI_VPD_OK) {
  3348. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR028,
  3349. SK_PNMI_ERR028MSG);
  3350. *pLen = 0;
  3351. return (SK_PNMI_ERR_GENERAL);
  3352. }
  3353. break;
  3354. default:
  3355. *pLen = 0;
  3356. return (SK_PNMI_ERR_BAD_VALUE);
  3357. }
  3358. }
  3359. return (SK_PNMI_ERR_OK);
  3360. }
  3361. /*****************************************************************************
  3362. *
  3363. * General - OID handler function of various single instance OIDs
  3364. *
  3365. * Description:
  3366. * The code is simple. No description necessary.
  3367. *
  3368. * Returns:
  3369. * SK_PNMI_ERR_OK The request was successfully performed.
  3370. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  3371. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  3372. * the correct data (e.g. a 32bit value is
  3373. * needed, but a 16 bit value was passed).
  3374. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  3375. * exist (e.g. port instance 3 on a two port
  3376. * adapter.
  3377. */
  3378. PNMI_STATIC int General(
  3379. SK_AC *pAC, /* Pointer to adapter context */
  3380. SK_IOC IoC, /* IO context handle */
  3381. int Action, /* Get/PreSet/Set action */
  3382. SK_U32 Id, /* Object ID that is to be processed */
  3383. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  3384. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  3385. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  3386. unsigned int TableIndex, /* Index to the Id table */
  3387. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  3388. {
  3389. int Ret;
  3390. unsigned int Index;
  3391. unsigned int Len;
  3392. unsigned int Offset;
  3393. unsigned int Val;
  3394. SK_U8 Val8;
  3395. SK_U16 Val16;
  3396. SK_U32 Val32;
  3397. SK_U64 Val64;
  3398. SK_U64 Val64RxHwErrs = 0;
  3399. SK_U64 Val64TxHwErrs = 0;
  3400. SK_BOOL Is64BitReq = SK_FALSE;
  3401. char Buf[256];
  3402. int MacType;
  3403. /*
  3404. * Check instance. We only handle single instance variables
  3405. */
  3406. if (Instance != (SK_U32)(-1) && Instance != 1) {
  3407. *pLen = 0;
  3408. return (SK_PNMI_ERR_UNKNOWN_INST);
  3409. }
  3410. /*
  3411. * Check action. We only allow get requests.
  3412. */
  3413. if (Action != SK_PNMI_GET) {
  3414. *pLen = 0;
  3415. return (SK_PNMI_ERR_READ_ONLY);
  3416. }
  3417. MacType = pAC->GIni.GIMacType;
  3418. /*
  3419. * Check length for the various supported OIDs
  3420. */
  3421. switch (Id) {
  3422. case OID_GEN_XMIT_ERROR:
  3423. case OID_GEN_RCV_ERROR:
  3424. case OID_GEN_RCV_NO_BUFFER:
  3425. #ifndef SK_NDIS_64BIT_CTR
  3426. if (*pLen < sizeof(SK_U32)) {
  3427. *pLen = sizeof(SK_U32);
  3428. return (SK_PNMI_ERR_TOO_SHORT);
  3429. }
  3430. #else /* SK_NDIS_64BIT_CTR */
  3431. /*
  3432. * for compatibility, at least 32bit are required for oid
  3433. */
  3434. if (*pLen < sizeof(SK_U32)) {
  3435. /*
  3436. * but indicate handling for 64bit values,
  3437. * if insufficient space is provided
  3438. */
  3439. *pLen = sizeof(SK_U64);
  3440. return (SK_PNMI_ERR_TOO_SHORT);
  3441. }
  3442. Is64BitReq = (*pLen < sizeof(SK_U64)) ? SK_FALSE : SK_TRUE;
  3443. #endif /* SK_NDIS_64BIT_CTR */
  3444. break;
  3445. case OID_SKGE_PORT_NUMBER:
  3446. case OID_SKGE_DEVICE_TYPE:
  3447. case OID_SKGE_RESULT:
  3448. case OID_SKGE_RLMT_MONITOR_NUMBER:
  3449. case OID_GEN_TRANSMIT_QUEUE_LENGTH:
  3450. case OID_SKGE_TRAP_NUMBER:
  3451. case OID_SKGE_MDB_VERSION:
  3452. if (*pLen < sizeof(SK_U32)) {
  3453. *pLen = sizeof(SK_U32);
  3454. return (SK_PNMI_ERR_TOO_SHORT);
  3455. }
  3456. break;
  3457. case OID_SKGE_CHIPSET:
  3458. if (*pLen < sizeof(SK_U16)) {
  3459. *pLen = sizeof(SK_U16);
  3460. return (SK_PNMI_ERR_TOO_SHORT);
  3461. }
  3462. break;
  3463. case OID_SKGE_BUS_TYPE:
  3464. case OID_SKGE_BUS_SPEED:
  3465. case OID_SKGE_BUS_WIDTH:
  3466. case OID_SKGE_SENSOR_NUMBER:
  3467. case OID_SKGE_CHKSM_NUMBER:
  3468. if (*pLen < sizeof(SK_U8)) {
  3469. *pLen = sizeof(SK_U8);
  3470. return (SK_PNMI_ERR_TOO_SHORT);
  3471. }
  3472. break;
  3473. case OID_SKGE_TX_SW_QUEUE_LEN:
  3474. case OID_SKGE_TX_SW_QUEUE_MAX:
  3475. case OID_SKGE_TX_RETRY:
  3476. case OID_SKGE_RX_INTR_CTS:
  3477. case OID_SKGE_TX_INTR_CTS:
  3478. case OID_SKGE_RX_NO_BUF_CTS:
  3479. case OID_SKGE_TX_NO_BUF_CTS:
  3480. case OID_SKGE_TX_USED_DESCR_NO:
  3481. case OID_SKGE_RX_DELIVERED_CTS:
  3482. case OID_SKGE_RX_OCTETS_DELIV_CTS:
  3483. case OID_SKGE_RX_HW_ERROR_CTS:
  3484. case OID_SKGE_TX_HW_ERROR_CTS:
  3485. case OID_SKGE_IN_ERRORS_CTS:
  3486. case OID_SKGE_OUT_ERROR_CTS:
  3487. case OID_SKGE_ERR_RECOVERY_CTS:
  3488. case OID_SKGE_SYSUPTIME:
  3489. if (*pLen < sizeof(SK_U64)) {
  3490. *pLen = sizeof(SK_U64);
  3491. return (SK_PNMI_ERR_TOO_SHORT);
  3492. }
  3493. break;
  3494. default:
  3495. /* Checked later */
  3496. break;
  3497. }
  3498. /* Update statistic */
  3499. if (Id == OID_SKGE_RX_HW_ERROR_CTS ||
  3500. Id == OID_SKGE_TX_HW_ERROR_CTS ||
  3501. Id == OID_SKGE_IN_ERRORS_CTS ||
  3502. Id == OID_SKGE_OUT_ERROR_CTS ||
  3503. Id == OID_GEN_XMIT_ERROR ||
  3504. Id == OID_GEN_RCV_ERROR) {
  3505. /* Force the XMAC to update its statistic counters and
  3506. * Increment semaphore to indicate that an update was
  3507. * already done.
  3508. */
  3509. Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1);
  3510. if (Ret != SK_PNMI_ERR_OK) {
  3511. *pLen = 0;
  3512. return (Ret);
  3513. }
  3514. pAC->Pnmi.MacUpdatedFlag ++;
  3515. /*
  3516. * Some OIDs consist of multiple hardware counters. Those
  3517. * values which are contained in all of them will be added
  3518. * now.
  3519. */
  3520. switch (Id) {
  3521. case OID_SKGE_RX_HW_ERROR_CTS:
  3522. case OID_SKGE_IN_ERRORS_CTS:
  3523. case OID_GEN_RCV_ERROR:
  3524. Val64RxHwErrs =
  3525. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_MISSED, NetIndex) +
  3526. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_FRAMING, NetIndex) +
  3527. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_OVERFLOW, NetIndex)+
  3528. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_JABBER, NetIndex) +
  3529. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_CARRIER, NetIndex) +
  3530. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_IRLENGTH, NetIndex)+
  3531. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_SYMBOL, NetIndex) +
  3532. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_SHORTS, NetIndex) +
  3533. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_RUNT, NetIndex) +
  3534. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_TOO_LONG, NetIndex) +
  3535. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_FCS, NetIndex) +
  3536. GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_CEXT, NetIndex);
  3537. break;
  3538. case OID_SKGE_TX_HW_ERROR_CTS:
  3539. case OID_SKGE_OUT_ERROR_CTS:
  3540. case OID_GEN_XMIT_ERROR:
  3541. Val64TxHwErrs =
  3542. GetStatVal(pAC, IoC, 0, SK_PNMI_HTX_EXCESS_COL, NetIndex) +
  3543. GetStatVal(pAC, IoC, 0, SK_PNMI_HTX_LATE_COL, NetIndex)+
  3544. GetStatVal(pAC, IoC, 0, SK_PNMI_HTX_UNDERRUN, NetIndex)+
  3545. GetStatVal(pAC, IoC, 0, SK_PNMI_HTX_CARRIER, NetIndex);
  3546. break;
  3547. }
  3548. }
  3549. /*
  3550. * Retrieve value
  3551. */
  3552. switch (Id) {
  3553. case OID_SKGE_SUPPORTED_LIST:
  3554. Len = ID_TABLE_SIZE * sizeof(SK_U32);
  3555. if (*pLen < Len) {
  3556. *pLen = Len;
  3557. return (SK_PNMI_ERR_TOO_SHORT);
  3558. }
  3559. for (Offset = 0, Index = 0; Offset < Len;
  3560. Offset += sizeof(SK_U32), Index ++) {
  3561. Val32 = (SK_U32)IdTable[Index].Id;
  3562. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  3563. }
  3564. *pLen = Len;
  3565. break;
  3566. case OID_SKGE_PORT_NUMBER:
  3567. Val32 = (SK_U32)pAC->GIni.GIMacsFound;
  3568. SK_PNMI_STORE_U32(pBuf, Val32);
  3569. *pLen = sizeof(SK_U32);
  3570. break;
  3571. case OID_SKGE_DEVICE_TYPE:
  3572. Val32 = (SK_U32)pAC->Pnmi.DeviceType;
  3573. SK_PNMI_STORE_U32(pBuf, Val32);
  3574. *pLen = sizeof(SK_U32);
  3575. break;
  3576. case OID_SKGE_DRIVER_DESCR:
  3577. if (pAC->Pnmi.pDriverDescription == NULL) {
  3578. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR007,
  3579. SK_PNMI_ERR007MSG);
  3580. *pLen = 0;
  3581. return (SK_PNMI_ERR_GENERAL);
  3582. }
  3583. Len = SK_STRLEN(pAC->Pnmi.pDriverDescription) + 1;
  3584. if (Len > SK_PNMI_STRINGLEN1) {
  3585. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR029,
  3586. SK_PNMI_ERR029MSG);
  3587. *pLen = 0;
  3588. return (SK_PNMI_ERR_GENERAL);
  3589. }
  3590. if (*pLen < Len) {
  3591. *pLen = Len;
  3592. return (SK_PNMI_ERR_TOO_SHORT);
  3593. }
  3594. *pBuf = (char)(Len - 1);
  3595. SK_MEMCPY(pBuf + 1, pAC->Pnmi.pDriverDescription, Len - 1);
  3596. *pLen = Len;
  3597. break;
  3598. case OID_SKGE_DRIVER_VERSION:
  3599. if (pAC->Pnmi.pDriverVersion == NULL) {
  3600. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR030,
  3601. SK_PNMI_ERR030MSG);
  3602. *pLen = 0;
  3603. return (SK_PNMI_ERR_GENERAL);
  3604. }
  3605. Len = SK_STRLEN(pAC->Pnmi.pDriverVersion) + 1;
  3606. if (Len > SK_PNMI_STRINGLEN1) {
  3607. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR031,
  3608. SK_PNMI_ERR031MSG);
  3609. *pLen = 0;
  3610. return (SK_PNMI_ERR_GENERAL);
  3611. }
  3612. if (*pLen < Len) {
  3613. *pLen = Len;
  3614. return (SK_PNMI_ERR_TOO_SHORT);
  3615. }
  3616. *pBuf = (char)(Len - 1);
  3617. SK_MEMCPY(pBuf + 1, pAC->Pnmi.pDriverVersion, Len - 1);
  3618. *pLen = Len;
  3619. break;
  3620. case OID_SKGE_HW_DESCR:
  3621. /*
  3622. * The hardware description is located in the VPD. This
  3623. * query may move to the initialisation routine. But
  3624. * the VPD data is cached and therefore a call here
  3625. * will not make much difference.
  3626. */
  3627. Len = 256;
  3628. if (VpdRead(pAC, IoC, VPD_NAME, Buf, (int *)&Len) > 0) {
  3629. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR032,
  3630. SK_PNMI_ERR032MSG);
  3631. *pLen = 0;
  3632. return (SK_PNMI_ERR_GENERAL);
  3633. }
  3634. Len ++;
  3635. if (Len > SK_PNMI_STRINGLEN1) {
  3636. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR033,
  3637. SK_PNMI_ERR033MSG);
  3638. *pLen = 0;
  3639. return (SK_PNMI_ERR_GENERAL);
  3640. }
  3641. if (*pLen < Len) {
  3642. *pLen = Len;
  3643. return (SK_PNMI_ERR_TOO_SHORT);
  3644. }
  3645. *pBuf = (char)(Len - 1);
  3646. SK_MEMCPY(pBuf + 1, Buf, Len - 1);
  3647. *pLen = Len;
  3648. break;
  3649. case OID_SKGE_HW_VERSION:
  3650. /* Oh, I love to do some string manipulation */
  3651. if (*pLen < 5) {
  3652. *pLen = 5;
  3653. return (SK_PNMI_ERR_TOO_SHORT);
  3654. }
  3655. Val8 = (SK_U8)pAC->GIni.GIPciHwRev;
  3656. pBuf[0] = 4;
  3657. pBuf[1] = 'v';
  3658. pBuf[2] = (char)(0x30 | ((Val8 >> 4) & 0x0F));
  3659. pBuf[3] = '.';
  3660. pBuf[4] = (char)(0x30 | (Val8 & 0x0F));
  3661. *pLen = 5;
  3662. break;
  3663. case OID_SKGE_CHIPSET:
  3664. Val16 = pAC->Pnmi.Chipset;
  3665. SK_PNMI_STORE_U16(pBuf, Val16);
  3666. *pLen = sizeof(SK_U16);
  3667. break;
  3668. case OID_SKGE_BUS_TYPE:
  3669. *pBuf = (char)SK_PNMI_BUS_PCI;
  3670. *pLen = sizeof(char);
  3671. break;
  3672. case OID_SKGE_BUS_SPEED:
  3673. *pBuf = pAC->Pnmi.PciBusSpeed;
  3674. *pLen = sizeof(char);
  3675. break;
  3676. case OID_SKGE_BUS_WIDTH:
  3677. *pBuf = pAC->Pnmi.PciBusWidth;
  3678. *pLen = sizeof(char);
  3679. break;
  3680. case OID_SKGE_RESULT:
  3681. Val32 = pAC->Pnmi.TestResult;
  3682. SK_PNMI_STORE_U32(pBuf, Val32);
  3683. *pLen = sizeof(SK_U32);
  3684. break;
  3685. case OID_SKGE_SENSOR_NUMBER:
  3686. *pBuf = (char)pAC->I2c.MaxSens;
  3687. *pLen = sizeof(char);
  3688. break;
  3689. case OID_SKGE_CHKSM_NUMBER:
  3690. *pBuf = SKCS_NUM_PROTOCOLS;
  3691. *pLen = sizeof(char);
  3692. break;
  3693. case OID_SKGE_TRAP_NUMBER:
  3694. GetTrapQueueLen(pAC, &Len, &Val);
  3695. Val32 = (SK_U32)Val;
  3696. SK_PNMI_STORE_U32(pBuf, Val32);
  3697. *pLen = sizeof(SK_U32);
  3698. break;
  3699. case OID_SKGE_TRAP:
  3700. GetTrapQueueLen(pAC, &Len, &Val);
  3701. if (*pLen < Len) {
  3702. *pLen = Len;
  3703. return (SK_PNMI_ERR_TOO_SHORT);
  3704. }
  3705. CopyTrapQueue(pAC, pBuf);
  3706. *pLen = Len;
  3707. break;
  3708. case OID_SKGE_RLMT_MONITOR_NUMBER:
  3709. /* XXX Not yet implemented by RLMT therefore we return zero elements */
  3710. Val32 = 0;
  3711. SK_PNMI_STORE_U32(pBuf, Val32);
  3712. *pLen = sizeof(SK_U32);
  3713. break;
  3714. case OID_SKGE_TX_SW_QUEUE_LEN:
  3715. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3716. if (MacType == SK_MAC_XMAC) {
  3717. /* Dual net mode */
  3718. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3719. Val64 = pAC->Pnmi.BufPort[NetIndex].TxSwQueueLen;
  3720. }
  3721. /* Single net mode */
  3722. else {
  3723. Val64 = pAC->Pnmi.BufPort[0].TxSwQueueLen +
  3724. pAC->Pnmi.BufPort[1].TxSwQueueLen;
  3725. }
  3726. }
  3727. else {
  3728. /* Dual net mode */
  3729. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3730. Val64 = pAC->Pnmi.Port[NetIndex].TxSwQueueLen;
  3731. }
  3732. /* Single net mode */
  3733. else {
  3734. Val64 = pAC->Pnmi.Port[0].TxSwQueueLen +
  3735. pAC->Pnmi.Port[1].TxSwQueueLen;
  3736. }
  3737. }
  3738. SK_PNMI_STORE_U64(pBuf, Val64);
  3739. *pLen = sizeof(SK_U64);
  3740. break;
  3741. case OID_SKGE_TX_SW_QUEUE_MAX:
  3742. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3743. if (MacType == SK_MAC_XMAC) {
  3744. /* Dual net mode */
  3745. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3746. Val64 = pAC->Pnmi.BufPort[NetIndex].TxSwQueueMax;
  3747. }
  3748. /* Single net mode */
  3749. else {
  3750. Val64 = pAC->Pnmi.BufPort[0].TxSwQueueMax +
  3751. pAC->Pnmi.BufPort[1].TxSwQueueMax;
  3752. }
  3753. }
  3754. else {
  3755. /* Dual net mode */
  3756. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3757. Val64 = pAC->Pnmi.Port[NetIndex].TxSwQueueMax;
  3758. }
  3759. /* Single net mode */
  3760. else {
  3761. Val64 = pAC->Pnmi.Port[0].TxSwQueueMax +
  3762. pAC->Pnmi.Port[1].TxSwQueueMax;
  3763. }
  3764. }
  3765. SK_PNMI_STORE_U64(pBuf, Val64);
  3766. *pLen = sizeof(SK_U64);
  3767. break;
  3768. case OID_SKGE_TX_RETRY:
  3769. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3770. if (MacType == SK_MAC_XMAC) {
  3771. /* Dual net mode */
  3772. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3773. Val64 = pAC->Pnmi.BufPort[NetIndex].TxRetryCts;
  3774. }
  3775. /* Single net mode */
  3776. else {
  3777. Val64 = pAC->Pnmi.BufPort[0].TxRetryCts +
  3778. pAC->Pnmi.BufPort[1].TxRetryCts;
  3779. }
  3780. }
  3781. else {
  3782. /* Dual net mode */
  3783. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3784. Val64 = pAC->Pnmi.Port[NetIndex].TxRetryCts;
  3785. }
  3786. /* Single net mode */
  3787. else {
  3788. Val64 = pAC->Pnmi.Port[0].TxRetryCts +
  3789. pAC->Pnmi.Port[1].TxRetryCts;
  3790. }
  3791. }
  3792. SK_PNMI_STORE_U64(pBuf, Val64);
  3793. *pLen = sizeof(SK_U64);
  3794. break;
  3795. case OID_SKGE_RX_INTR_CTS:
  3796. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3797. if (MacType == SK_MAC_XMAC) {
  3798. /* Dual net mode */
  3799. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3800. Val64 = pAC->Pnmi.BufPort[NetIndex].RxIntrCts;
  3801. }
  3802. /* Single net mode */
  3803. else {
  3804. Val64 = pAC->Pnmi.BufPort[0].RxIntrCts +
  3805. pAC->Pnmi.BufPort[1].RxIntrCts;
  3806. }
  3807. }
  3808. else {
  3809. /* Dual net mode */
  3810. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3811. Val64 = pAC->Pnmi.Port[NetIndex].RxIntrCts;
  3812. }
  3813. /* Single net mode */
  3814. else {
  3815. Val64 = pAC->Pnmi.Port[0].RxIntrCts +
  3816. pAC->Pnmi.Port[1].RxIntrCts;
  3817. }
  3818. }
  3819. SK_PNMI_STORE_U64(pBuf, Val64);
  3820. *pLen = sizeof(SK_U64);
  3821. break;
  3822. case OID_SKGE_TX_INTR_CTS:
  3823. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3824. if (MacType == SK_MAC_XMAC) {
  3825. /* Dual net mode */
  3826. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3827. Val64 = pAC->Pnmi.BufPort[NetIndex].TxIntrCts;
  3828. }
  3829. /* Single net mode */
  3830. else {
  3831. Val64 = pAC->Pnmi.BufPort[0].TxIntrCts +
  3832. pAC->Pnmi.BufPort[1].TxIntrCts;
  3833. }
  3834. }
  3835. else {
  3836. /* Dual net mode */
  3837. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3838. Val64 = pAC->Pnmi.Port[NetIndex].TxIntrCts;
  3839. }
  3840. /* Single net mode */
  3841. else {
  3842. Val64 = pAC->Pnmi.Port[0].TxIntrCts +
  3843. pAC->Pnmi.Port[1].TxIntrCts;
  3844. }
  3845. }
  3846. SK_PNMI_STORE_U64(pBuf, Val64);
  3847. *pLen = sizeof(SK_U64);
  3848. break;
  3849. case OID_SKGE_RX_NO_BUF_CTS:
  3850. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3851. if (MacType == SK_MAC_XMAC) {
  3852. /* Dual net mode */
  3853. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3854. Val64 = pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
  3855. }
  3856. /* Single net mode */
  3857. else {
  3858. Val64 = pAC->Pnmi.BufPort[0].RxNoBufCts +
  3859. pAC->Pnmi.BufPort[1].RxNoBufCts;
  3860. }
  3861. }
  3862. else {
  3863. /* Dual net mode */
  3864. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3865. Val64 = pAC->Pnmi.Port[NetIndex].RxNoBufCts;
  3866. }
  3867. /* Single net mode */
  3868. else {
  3869. Val64 = pAC->Pnmi.Port[0].RxNoBufCts +
  3870. pAC->Pnmi.Port[1].RxNoBufCts;
  3871. }
  3872. }
  3873. SK_PNMI_STORE_U64(pBuf, Val64);
  3874. *pLen = sizeof(SK_U64);
  3875. break;
  3876. case OID_SKGE_TX_NO_BUF_CTS:
  3877. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3878. if (MacType == SK_MAC_XMAC) {
  3879. /* Dual net mode */
  3880. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3881. Val64 = pAC->Pnmi.BufPort[NetIndex].TxNoBufCts;
  3882. }
  3883. /* Single net mode */
  3884. else {
  3885. Val64 = pAC->Pnmi.BufPort[0].TxNoBufCts +
  3886. pAC->Pnmi.BufPort[1].TxNoBufCts;
  3887. }
  3888. }
  3889. else {
  3890. /* Dual net mode */
  3891. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3892. Val64 = pAC->Pnmi.Port[NetIndex].TxNoBufCts;
  3893. }
  3894. /* Single net mode */
  3895. else {
  3896. Val64 = pAC->Pnmi.Port[0].TxNoBufCts +
  3897. pAC->Pnmi.Port[1].TxNoBufCts;
  3898. }
  3899. }
  3900. SK_PNMI_STORE_U64(pBuf, Val64);
  3901. *pLen = sizeof(SK_U64);
  3902. break;
  3903. case OID_SKGE_TX_USED_DESCR_NO:
  3904. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3905. if (MacType == SK_MAC_XMAC) {
  3906. /* Dual net mode */
  3907. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3908. Val64 = pAC->Pnmi.BufPort[NetIndex].TxUsedDescrNo;
  3909. }
  3910. /* Single net mode */
  3911. else {
  3912. Val64 = pAC->Pnmi.BufPort[0].TxUsedDescrNo +
  3913. pAC->Pnmi.BufPort[1].TxUsedDescrNo;
  3914. }
  3915. }
  3916. else {
  3917. /* Dual net mode */
  3918. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3919. Val64 = pAC->Pnmi.Port[NetIndex].TxUsedDescrNo;
  3920. }
  3921. /* Single net mode */
  3922. else {
  3923. Val64 = pAC->Pnmi.Port[0].TxUsedDescrNo +
  3924. pAC->Pnmi.Port[1].TxUsedDescrNo;
  3925. }
  3926. }
  3927. SK_PNMI_STORE_U64(pBuf, Val64);
  3928. *pLen = sizeof(SK_U64);
  3929. break;
  3930. case OID_SKGE_RX_DELIVERED_CTS:
  3931. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3932. if (MacType == SK_MAC_XMAC) {
  3933. /* Dual net mode */
  3934. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3935. Val64 = pAC->Pnmi.BufPort[NetIndex].RxDeliveredCts;
  3936. }
  3937. /* Single net mode */
  3938. else {
  3939. Val64 = pAC->Pnmi.BufPort[0].RxDeliveredCts +
  3940. pAC->Pnmi.BufPort[1].RxDeliveredCts;
  3941. }
  3942. }
  3943. else {
  3944. /* Dual net mode */
  3945. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3946. Val64 = pAC->Pnmi.Port[NetIndex].RxDeliveredCts;
  3947. }
  3948. /* Single net mode */
  3949. else {
  3950. Val64 = pAC->Pnmi.Port[0].RxDeliveredCts +
  3951. pAC->Pnmi.Port[1].RxDeliveredCts;
  3952. }
  3953. }
  3954. SK_PNMI_STORE_U64(pBuf, Val64);
  3955. *pLen = sizeof(SK_U64);
  3956. break;
  3957. case OID_SKGE_RX_OCTETS_DELIV_CTS:
  3958. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3959. if (MacType == SK_MAC_XMAC) {
  3960. /* Dual net mode */
  3961. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3962. Val64 = pAC->Pnmi.BufPort[NetIndex].RxOctetsDeliveredCts;
  3963. }
  3964. /* Single net mode */
  3965. else {
  3966. Val64 = pAC->Pnmi.BufPort[0].RxOctetsDeliveredCts +
  3967. pAC->Pnmi.BufPort[1].RxOctetsDeliveredCts;
  3968. }
  3969. }
  3970. else {
  3971. /* Dual net mode */
  3972. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3973. Val64 = pAC->Pnmi.Port[NetIndex].RxOctetsDeliveredCts;
  3974. }
  3975. /* Single net mode */
  3976. else {
  3977. Val64 = pAC->Pnmi.Port[0].RxOctetsDeliveredCts +
  3978. pAC->Pnmi.Port[1].RxOctetsDeliveredCts;
  3979. }
  3980. }
  3981. SK_PNMI_STORE_U64(pBuf, Val64);
  3982. *pLen = sizeof(SK_U64);
  3983. break;
  3984. case OID_SKGE_RX_HW_ERROR_CTS:
  3985. SK_PNMI_STORE_U64(pBuf, Val64RxHwErrs);
  3986. *pLen = sizeof(SK_U64);
  3987. break;
  3988. case OID_SKGE_TX_HW_ERROR_CTS:
  3989. SK_PNMI_STORE_U64(pBuf, Val64TxHwErrs);
  3990. *pLen = sizeof(SK_U64);
  3991. break;
  3992. case OID_SKGE_IN_ERRORS_CTS:
  3993. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  3994. if (MacType == SK_MAC_XMAC) {
  3995. /* Dual net mode */
  3996. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  3997. Val64 = Val64RxHwErrs + pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
  3998. }
  3999. /* Single net mode */
  4000. else {
  4001. Val64 = Val64RxHwErrs +
  4002. pAC->Pnmi.BufPort[0].RxNoBufCts +
  4003. pAC->Pnmi.BufPort[1].RxNoBufCts;
  4004. }
  4005. }
  4006. else {
  4007. /* Dual net mode */
  4008. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  4009. Val64 = Val64RxHwErrs + pAC->Pnmi.Port[NetIndex].RxNoBufCts;
  4010. }
  4011. /* Single net mode */
  4012. else {
  4013. Val64 = Val64RxHwErrs +
  4014. pAC->Pnmi.Port[0].RxNoBufCts +
  4015. pAC->Pnmi.Port[1].RxNoBufCts;
  4016. }
  4017. }
  4018. SK_PNMI_STORE_U64(pBuf, Val64);
  4019. *pLen = sizeof(SK_U64);
  4020. break;
  4021. case OID_SKGE_OUT_ERROR_CTS:
  4022. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  4023. if (MacType == SK_MAC_XMAC) {
  4024. /* Dual net mode */
  4025. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  4026. Val64 = Val64TxHwErrs + pAC->Pnmi.BufPort[NetIndex].TxNoBufCts;
  4027. }
  4028. /* Single net mode */
  4029. else {
  4030. Val64 = Val64TxHwErrs +
  4031. pAC->Pnmi.BufPort[0].TxNoBufCts +
  4032. pAC->Pnmi.BufPort[1].TxNoBufCts;
  4033. }
  4034. }
  4035. else {
  4036. /* Dual net mode */
  4037. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  4038. Val64 = Val64TxHwErrs + pAC->Pnmi.Port[NetIndex].TxNoBufCts;
  4039. }
  4040. /* Single net mode */
  4041. else {
  4042. Val64 = Val64TxHwErrs +
  4043. pAC->Pnmi.Port[0].TxNoBufCts +
  4044. pAC->Pnmi.Port[1].TxNoBufCts;
  4045. }
  4046. }
  4047. SK_PNMI_STORE_U64(pBuf, Val64);
  4048. *pLen = sizeof(SK_U64);
  4049. break;
  4050. case OID_SKGE_ERR_RECOVERY_CTS:
  4051. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  4052. if (MacType == SK_MAC_XMAC) {
  4053. /* Dual net mode */
  4054. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  4055. Val64 = pAC->Pnmi.BufPort[NetIndex].ErrRecoveryCts;
  4056. }
  4057. /* Single net mode */
  4058. else {
  4059. Val64 = pAC->Pnmi.BufPort[0].ErrRecoveryCts +
  4060. pAC->Pnmi.BufPort[1].ErrRecoveryCts;
  4061. }
  4062. }
  4063. else {
  4064. /* Dual net mode */
  4065. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  4066. Val64 = pAC->Pnmi.Port[NetIndex].ErrRecoveryCts;
  4067. }
  4068. /* Single net mode */
  4069. else {
  4070. Val64 = pAC->Pnmi.Port[0].ErrRecoveryCts +
  4071. pAC->Pnmi.Port[1].ErrRecoveryCts;
  4072. }
  4073. }
  4074. SK_PNMI_STORE_U64(pBuf, Val64);
  4075. *pLen = sizeof(SK_U64);
  4076. break;
  4077. case OID_SKGE_SYSUPTIME:
  4078. Val64 = SK_PNMI_HUNDREDS_SEC(SkOsGetTime(pAC));
  4079. Val64 -= pAC->Pnmi.StartUpTime;
  4080. SK_PNMI_STORE_U64(pBuf, Val64);
  4081. *pLen = sizeof(SK_U64);
  4082. break;
  4083. case OID_SKGE_MDB_VERSION:
  4084. Val32 = SK_PNMI_MDB_VERSION;
  4085. SK_PNMI_STORE_U32(pBuf, Val32);
  4086. *pLen = sizeof(SK_U32);
  4087. break;
  4088. case OID_GEN_RCV_ERROR:
  4089. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  4090. if (MacType == SK_MAC_XMAC) {
  4091. Val64 = Val64RxHwErrs + pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
  4092. }
  4093. else {
  4094. Val64 = Val64RxHwErrs + pAC->Pnmi.Port[NetIndex].RxNoBufCts;
  4095. }
  4096. /*
  4097. * by default 32bit values are evaluated
  4098. */
  4099. if (!Is64BitReq) {
  4100. Val32 = (SK_U32)Val64;
  4101. SK_PNMI_STORE_U32(pBuf, Val32);
  4102. *pLen = sizeof(SK_U32);
  4103. }
  4104. else {
  4105. SK_PNMI_STORE_U64(pBuf, Val64);
  4106. *pLen = sizeof(SK_U64);
  4107. }
  4108. break;
  4109. case OID_GEN_XMIT_ERROR:
  4110. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  4111. if (MacType == SK_MAC_XMAC) {
  4112. Val64 = Val64TxHwErrs + pAC->Pnmi.BufPort[NetIndex].TxNoBufCts;
  4113. }
  4114. else {
  4115. Val64 = Val64TxHwErrs + pAC->Pnmi.Port[NetIndex].TxNoBufCts;
  4116. }
  4117. /*
  4118. * by default 32bit values are evaluated
  4119. */
  4120. if (!Is64BitReq) {
  4121. Val32 = (SK_U32)Val64;
  4122. SK_PNMI_STORE_U32(pBuf, Val32);
  4123. *pLen = sizeof(SK_U32);
  4124. }
  4125. else {
  4126. SK_PNMI_STORE_U64(pBuf, Val64);
  4127. *pLen = sizeof(SK_U64);
  4128. }
  4129. break;
  4130. case OID_GEN_RCV_NO_BUFFER:
  4131. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  4132. if (MacType == SK_MAC_XMAC) {
  4133. Val64 = pAC->Pnmi.BufPort[NetIndex].RxNoBufCts;
  4134. }
  4135. else {
  4136. Val64 = pAC->Pnmi.Port[NetIndex].RxNoBufCts;
  4137. }
  4138. /*
  4139. * by default 32bit values are evaluated
  4140. */
  4141. if (!Is64BitReq) {
  4142. Val32 = (SK_U32)Val64;
  4143. SK_PNMI_STORE_U32(pBuf, Val32);
  4144. *pLen = sizeof(SK_U32);
  4145. }
  4146. else {
  4147. SK_PNMI_STORE_U64(pBuf, Val64);
  4148. *pLen = sizeof(SK_U64);
  4149. }
  4150. break;
  4151. case OID_GEN_TRANSMIT_QUEUE_LENGTH:
  4152. Val32 = (SK_U32)pAC->Pnmi.Port[NetIndex].TxSwQueueLen;
  4153. SK_PNMI_STORE_U32(pBuf, Val32);
  4154. *pLen = sizeof(SK_U32);
  4155. break;
  4156. default:
  4157. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR034,
  4158. SK_PNMI_ERR034MSG);
  4159. *pLen = 0;
  4160. return (SK_PNMI_ERR_GENERAL);
  4161. }
  4162. if (Id == OID_SKGE_RX_HW_ERROR_CTS ||
  4163. Id == OID_SKGE_TX_HW_ERROR_CTS ||
  4164. Id == OID_SKGE_IN_ERRORS_CTS ||
  4165. Id == OID_SKGE_OUT_ERROR_CTS ||
  4166. Id == OID_GEN_XMIT_ERROR ||
  4167. Id == OID_GEN_RCV_ERROR) {
  4168. pAC->Pnmi.MacUpdatedFlag --;
  4169. }
  4170. return (SK_PNMI_ERR_OK);
  4171. }
  4172. /*****************************************************************************
  4173. *
  4174. * Rlmt - OID handler function of OID_SKGE_RLMT_XXX single instance.
  4175. *
  4176. * Description:
  4177. * Get/Presets/Sets the RLMT OIDs.
  4178. *
  4179. * Returns:
  4180. * SK_PNMI_ERR_OK The request was successfully performed.
  4181. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  4182. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  4183. * the correct data (e.g. a 32bit value is
  4184. * needed, but a 16 bit value was passed).
  4185. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  4186. * value range.
  4187. * SK_PNMI_ERR_READ_ONLY The OID is read-only and cannot be set.
  4188. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  4189. * exist (e.g. port instance 3 on a two port
  4190. * adapter.
  4191. */
  4192. PNMI_STATIC int Rlmt(
  4193. SK_AC *pAC, /* Pointer to adapter context */
  4194. SK_IOC IoC, /* IO context handle */
  4195. int Action, /* Get/PreSet/Set action */
  4196. SK_U32 Id, /* Object ID that is to be processed */
  4197. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  4198. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  4199. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  4200. unsigned int TableIndex, /* Index to the Id table */
  4201. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  4202. {
  4203. int Ret;
  4204. unsigned int PhysPortIndex;
  4205. unsigned int PhysPortMax;
  4206. SK_EVPARA EventParam;
  4207. SK_U32 Val32;
  4208. SK_U64 Val64;
  4209. /*
  4210. * Check instance. Only single instance OIDs are allowed here.
  4211. */
  4212. if (Instance != (SK_U32)(-1) && Instance != 1) {
  4213. *pLen = 0;
  4214. return (SK_PNMI_ERR_UNKNOWN_INST);
  4215. }
  4216. /*
  4217. * Perform the requested action
  4218. */
  4219. if (Action == SK_PNMI_GET) {
  4220. /*
  4221. * Check if the buffer length is large enough.
  4222. */
  4223. switch (Id) {
  4224. case OID_SKGE_RLMT_MODE:
  4225. case OID_SKGE_RLMT_PORT_ACTIVE:
  4226. case OID_SKGE_RLMT_PORT_PREFERRED:
  4227. if (*pLen < sizeof(SK_U8)) {
  4228. *pLen = sizeof(SK_U8);
  4229. return (SK_PNMI_ERR_TOO_SHORT);
  4230. }
  4231. break;
  4232. case OID_SKGE_RLMT_PORT_NUMBER:
  4233. if (*pLen < sizeof(SK_U32)) {
  4234. *pLen = sizeof(SK_U32);
  4235. return (SK_PNMI_ERR_TOO_SHORT);
  4236. }
  4237. break;
  4238. case OID_SKGE_RLMT_CHANGE_CTS:
  4239. case OID_SKGE_RLMT_CHANGE_TIME:
  4240. case OID_SKGE_RLMT_CHANGE_ESTIM:
  4241. case OID_SKGE_RLMT_CHANGE_THRES:
  4242. if (*pLen < sizeof(SK_U64)) {
  4243. *pLen = sizeof(SK_U64);
  4244. return (SK_PNMI_ERR_TOO_SHORT);
  4245. }
  4246. break;
  4247. default:
  4248. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR035,
  4249. SK_PNMI_ERR035MSG);
  4250. *pLen = 0;
  4251. return (SK_PNMI_ERR_GENERAL);
  4252. }
  4253. /*
  4254. * Update RLMT statistic and increment semaphores to indicate
  4255. * that an update was already done. Maybe RLMT will hold its
  4256. * statistic always up to date some time. Then we can
  4257. * remove this type of call.
  4258. */
  4259. if ((Ret = RlmtUpdate(pAC, IoC, NetIndex)) != SK_PNMI_ERR_OK) {
  4260. *pLen = 0;
  4261. return (Ret);
  4262. }
  4263. pAC->Pnmi.RlmtUpdatedFlag ++;
  4264. /*
  4265. * Retrieve Value
  4266. */
  4267. switch (Id) {
  4268. case OID_SKGE_RLMT_MODE:
  4269. *pBuf = (char)pAC->Rlmt.Net[0].RlmtMode;
  4270. *pLen = sizeof(char);
  4271. break;
  4272. case OID_SKGE_RLMT_PORT_NUMBER:
  4273. Val32 = (SK_U32)pAC->GIni.GIMacsFound;
  4274. SK_PNMI_STORE_U32(pBuf, Val32);
  4275. *pLen = sizeof(SK_U32);
  4276. break;
  4277. case OID_SKGE_RLMT_PORT_ACTIVE:
  4278. *pBuf = 0;
  4279. /*
  4280. * If multiple ports may become active this OID
  4281. * doesn't make sense any more. A new variable in
  4282. * the port structure should be created. However,
  4283. * for this variable the first active port is
  4284. * returned.
  4285. */
  4286. PhysPortMax = pAC->GIni.GIMacsFound;
  4287. for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax;
  4288. PhysPortIndex ++) {
  4289. if (pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
  4290. *pBuf = (char)SK_PNMI_PORT_PHYS2LOG(PhysPortIndex);
  4291. break;
  4292. }
  4293. }
  4294. *pLen = sizeof(char);
  4295. break;
  4296. case OID_SKGE_RLMT_PORT_PREFERRED:
  4297. *pBuf = (char)SK_PNMI_PORT_PHYS2LOG(pAC->Rlmt.Net[NetIndex].Preference);
  4298. *pLen = sizeof(char);
  4299. break;
  4300. case OID_SKGE_RLMT_CHANGE_CTS:
  4301. Val64 = pAC->Pnmi.RlmtChangeCts;
  4302. SK_PNMI_STORE_U64(pBuf, Val64);
  4303. *pLen = sizeof(SK_U64);
  4304. break;
  4305. case OID_SKGE_RLMT_CHANGE_TIME:
  4306. Val64 = pAC->Pnmi.RlmtChangeTime;
  4307. SK_PNMI_STORE_U64(pBuf, Val64);
  4308. *pLen = sizeof(SK_U64);
  4309. break;
  4310. case OID_SKGE_RLMT_CHANGE_ESTIM:
  4311. Val64 = pAC->Pnmi.RlmtChangeEstimate.Estimate;
  4312. SK_PNMI_STORE_U64(pBuf, Val64);
  4313. *pLen = sizeof(SK_U64);
  4314. break;
  4315. case OID_SKGE_RLMT_CHANGE_THRES:
  4316. Val64 = pAC->Pnmi.RlmtChangeThreshold;
  4317. SK_PNMI_STORE_U64(pBuf, Val64);
  4318. *pLen = sizeof(SK_U64);
  4319. break;
  4320. default:
  4321. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_ERR,
  4322. ("Rlmt: Unknown OID should be handled before"));
  4323. pAC->Pnmi.RlmtUpdatedFlag --;
  4324. *pLen = 0;
  4325. return (SK_PNMI_ERR_GENERAL);
  4326. }
  4327. pAC->Pnmi.RlmtUpdatedFlag --;
  4328. }
  4329. else {
  4330. /* Perform a preset or set */
  4331. switch (Id) {
  4332. case OID_SKGE_RLMT_MODE:
  4333. /* Check if the buffer length is plausible */
  4334. if (*pLen < sizeof(char)) {
  4335. *pLen = sizeof(char);
  4336. return (SK_PNMI_ERR_TOO_SHORT);
  4337. }
  4338. /* Check if the value range is correct */
  4339. if (*pLen != sizeof(char) ||
  4340. (*pBuf & SK_PNMI_RLMT_MODE_CHK_LINK) == 0 ||
  4341. *(SK_U8 *)pBuf > 15) {
  4342. *pLen = 0;
  4343. return (SK_PNMI_ERR_BAD_VALUE);
  4344. }
  4345. /* The preset ends here */
  4346. if (Action == SK_PNMI_PRESET) {
  4347. *pLen = 0;
  4348. return (SK_PNMI_ERR_OK);
  4349. }
  4350. /* Send an event to RLMT to change the mode */
  4351. SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
  4352. EventParam.Para32[0] |= (SK_U32)(*pBuf);
  4353. EventParam.Para32[1] = 0;
  4354. if (SkRlmtEvent(pAC, IoC, SK_RLMT_MODE_CHANGE,
  4355. EventParam) > 0) {
  4356. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR037,
  4357. SK_PNMI_ERR037MSG);
  4358. *pLen = 0;
  4359. return (SK_PNMI_ERR_GENERAL);
  4360. }
  4361. break;
  4362. case OID_SKGE_RLMT_PORT_PREFERRED:
  4363. /* Check if the buffer length is plausible */
  4364. if (*pLen < sizeof(char)) {
  4365. *pLen = sizeof(char);
  4366. return (SK_PNMI_ERR_TOO_SHORT);
  4367. }
  4368. /* Check if the value range is correct */
  4369. if (*pLen != sizeof(char) || *(SK_U8 *)pBuf >
  4370. (SK_U8)pAC->GIni.GIMacsFound) {
  4371. *pLen = 0;
  4372. return (SK_PNMI_ERR_BAD_VALUE);
  4373. }
  4374. /* The preset ends here */
  4375. if (Action == SK_PNMI_PRESET) {
  4376. *pLen = 0;
  4377. return (SK_PNMI_ERR_OK);
  4378. }
  4379. /*
  4380. * Send an event to RLMT change the preferred port.
  4381. * A param of -1 means automatic mode. RLMT will
  4382. * make the decision which is the preferred port.
  4383. */
  4384. SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
  4385. EventParam.Para32[0] = (SK_U32)(*pBuf) - 1;
  4386. EventParam.Para32[1] = NetIndex;
  4387. if (SkRlmtEvent(pAC, IoC, SK_RLMT_PREFPORT_CHANGE,
  4388. EventParam) > 0) {
  4389. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR038,
  4390. SK_PNMI_ERR038MSG);
  4391. *pLen = 0;
  4392. return (SK_PNMI_ERR_GENERAL);
  4393. }
  4394. break;
  4395. case OID_SKGE_RLMT_CHANGE_THRES:
  4396. /* Check if the buffer length is plausible */
  4397. if (*pLen < sizeof(SK_U64)) {
  4398. *pLen = sizeof(SK_U64);
  4399. return (SK_PNMI_ERR_TOO_SHORT);
  4400. }
  4401. /*
  4402. * There are not many restrictions to the
  4403. * value range.
  4404. */
  4405. if (*pLen != sizeof(SK_U64)) {
  4406. *pLen = 0;
  4407. return (SK_PNMI_ERR_BAD_VALUE);
  4408. }
  4409. /* A preset ends here */
  4410. if (Action == SK_PNMI_PRESET) {
  4411. *pLen = 0;
  4412. return (SK_PNMI_ERR_OK);
  4413. }
  4414. /*
  4415. * Store the new threshold, which will be taken
  4416. * on the next timer event.
  4417. */
  4418. SK_PNMI_READ_U64(pBuf, Val64);
  4419. pAC->Pnmi.RlmtChangeThreshold = Val64;
  4420. break;
  4421. default:
  4422. /* The other OIDs are not be able for set */
  4423. *pLen = 0;
  4424. return (SK_PNMI_ERR_READ_ONLY);
  4425. }
  4426. }
  4427. return (SK_PNMI_ERR_OK);
  4428. }
  4429. /*****************************************************************************
  4430. *
  4431. * RlmtStat - OID handler function of OID_SKGE_RLMT_XXX multiple instance.
  4432. *
  4433. * Description:
  4434. * Performs get requests on multiple instance variables.
  4435. *
  4436. * Returns:
  4437. * SK_PNMI_ERR_OK The request was successfully performed.
  4438. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  4439. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  4440. * the correct data (e.g. a 32bit value is
  4441. * needed, but a 16 bit value was passed).
  4442. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  4443. * exist (e.g. port instance 3 on a two port
  4444. * adapter.
  4445. */
  4446. PNMI_STATIC int RlmtStat(
  4447. SK_AC *pAC, /* Pointer to adapter context */
  4448. SK_IOC IoC, /* IO context handle */
  4449. int Action, /* Get/PreSet/Set action */
  4450. SK_U32 Id, /* Object ID that is to be processed */
  4451. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  4452. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  4453. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  4454. unsigned int TableIndex, /* Index to the Id table */
  4455. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  4456. {
  4457. unsigned int PhysPortMax;
  4458. unsigned int PhysPortIndex;
  4459. unsigned int Limit;
  4460. unsigned int Offset;
  4461. int Ret;
  4462. SK_U32 Val32;
  4463. SK_U64 Val64;
  4464. /*
  4465. * Calculate the port indexes from the instance
  4466. */
  4467. PhysPortMax = pAC->GIni.GIMacsFound;
  4468. if ((Instance != (SK_U32)(-1))) {
  4469. /* Check instance range */
  4470. if ((Instance < 1) || (Instance > PhysPortMax)) {
  4471. *pLen = 0;
  4472. return (SK_PNMI_ERR_UNKNOWN_INST);
  4473. }
  4474. /* Single net mode */
  4475. PhysPortIndex = Instance - 1;
  4476. /* Dual net mode */
  4477. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  4478. PhysPortIndex = NetIndex;
  4479. }
  4480. /* Both net modes */
  4481. Limit = PhysPortIndex + 1;
  4482. }
  4483. else {
  4484. /* Single net mode */
  4485. PhysPortIndex = 0;
  4486. Limit = PhysPortMax;
  4487. /* Dual net mode */
  4488. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  4489. PhysPortIndex = NetIndex;
  4490. Limit = PhysPortIndex + 1;
  4491. }
  4492. }
  4493. /*
  4494. * Currently only get requests are allowed.
  4495. */
  4496. if (Action != SK_PNMI_GET) {
  4497. *pLen = 0;
  4498. return (SK_PNMI_ERR_READ_ONLY);
  4499. }
  4500. /*
  4501. * Check if the buffer length is large enough.
  4502. */
  4503. switch (Id) {
  4504. case OID_SKGE_RLMT_PORT_INDEX:
  4505. case OID_SKGE_RLMT_STATUS:
  4506. if (*pLen < (Limit - PhysPortIndex) * sizeof(SK_U32)) {
  4507. *pLen = (Limit - PhysPortIndex) * sizeof(SK_U32);
  4508. return (SK_PNMI_ERR_TOO_SHORT);
  4509. }
  4510. break;
  4511. case OID_SKGE_RLMT_TX_HELLO_CTS:
  4512. case OID_SKGE_RLMT_RX_HELLO_CTS:
  4513. case OID_SKGE_RLMT_TX_SP_REQ_CTS:
  4514. case OID_SKGE_RLMT_RX_SP_CTS:
  4515. if (*pLen < (Limit - PhysPortIndex) * sizeof(SK_U64)) {
  4516. *pLen = (Limit - PhysPortIndex) * sizeof(SK_U64);
  4517. return (SK_PNMI_ERR_TOO_SHORT);
  4518. }
  4519. break;
  4520. default:
  4521. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR039,
  4522. SK_PNMI_ERR039MSG);
  4523. *pLen = 0;
  4524. return (SK_PNMI_ERR_GENERAL);
  4525. }
  4526. /*
  4527. * Update statistic and increment semaphores to indicate that
  4528. * an update was already done.
  4529. */
  4530. if ((Ret = RlmtUpdate(pAC, IoC, NetIndex)) != SK_PNMI_ERR_OK) {
  4531. *pLen = 0;
  4532. return (Ret);
  4533. }
  4534. pAC->Pnmi.RlmtUpdatedFlag ++;
  4535. /*
  4536. * Get value
  4537. */
  4538. Offset = 0;
  4539. for (; PhysPortIndex < Limit; PhysPortIndex ++) {
  4540. switch (Id) {
  4541. case OID_SKGE_RLMT_PORT_INDEX:
  4542. Val32 = PhysPortIndex;
  4543. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  4544. Offset += sizeof(SK_U32);
  4545. break;
  4546. case OID_SKGE_RLMT_STATUS:
  4547. if (pAC->Rlmt.Port[PhysPortIndex].PortState ==
  4548. SK_RLMT_PS_INIT ||
  4549. pAC->Rlmt.Port[PhysPortIndex].PortState ==
  4550. SK_RLMT_PS_DOWN) {
  4551. Val32 = SK_PNMI_RLMT_STATUS_ERROR;
  4552. }
  4553. else if (pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
  4554. Val32 = SK_PNMI_RLMT_STATUS_ACTIVE;
  4555. }
  4556. else {
  4557. Val32 = SK_PNMI_RLMT_STATUS_STANDBY;
  4558. }
  4559. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  4560. Offset += sizeof(SK_U32);
  4561. break;
  4562. case OID_SKGE_RLMT_TX_HELLO_CTS:
  4563. Val64 = pAC->Rlmt.Port[PhysPortIndex].TxHelloCts;
  4564. SK_PNMI_STORE_U64(pBuf + Offset, Val64);
  4565. Offset += sizeof(SK_U64);
  4566. break;
  4567. case OID_SKGE_RLMT_RX_HELLO_CTS:
  4568. Val64 = pAC->Rlmt.Port[PhysPortIndex].RxHelloCts;
  4569. SK_PNMI_STORE_U64(pBuf + Offset, Val64);
  4570. Offset += sizeof(SK_U64);
  4571. break;
  4572. case OID_SKGE_RLMT_TX_SP_REQ_CTS:
  4573. Val64 = pAC->Rlmt.Port[PhysPortIndex].TxSpHelloReqCts;
  4574. SK_PNMI_STORE_U64(pBuf + Offset, Val64);
  4575. Offset += sizeof(SK_U64);
  4576. break;
  4577. case OID_SKGE_RLMT_RX_SP_CTS:
  4578. Val64 = pAC->Rlmt.Port[PhysPortIndex].RxSpHelloCts;
  4579. SK_PNMI_STORE_U64(pBuf + Offset, Val64);
  4580. Offset += sizeof(SK_U64);
  4581. break;
  4582. default:
  4583. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_ERR,
  4584. ("RlmtStat: Unknown OID should be errored before"));
  4585. pAC->Pnmi.RlmtUpdatedFlag --;
  4586. *pLen = 0;
  4587. return (SK_PNMI_ERR_GENERAL);
  4588. }
  4589. }
  4590. *pLen = Offset;
  4591. pAC->Pnmi.RlmtUpdatedFlag --;
  4592. return (SK_PNMI_ERR_OK);
  4593. }
  4594. /*****************************************************************************
  4595. *
  4596. * MacPrivateConf - OID handler function of OIDs concerning the configuration
  4597. *
  4598. * Description:
  4599. * Get/Presets/Sets the OIDs concerning the configuration.
  4600. *
  4601. * Returns:
  4602. * SK_PNMI_ERR_OK The request was successfully performed.
  4603. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  4604. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  4605. * the correct data (e.g. a 32bit value is
  4606. * needed, but a 16 bit value was passed).
  4607. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  4608. * value range.
  4609. * SK_PNMI_ERR_READ_ONLY The OID is read-only and cannot be set.
  4610. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  4611. * exist (e.g. port instance 3 on a two port
  4612. * adapter.
  4613. */
  4614. PNMI_STATIC int MacPrivateConf(
  4615. SK_AC *pAC, /* Pointer to adapter context */
  4616. SK_IOC IoC, /* IO context handle */
  4617. int Action, /* Get/PreSet/Set action */
  4618. SK_U32 Id, /* Object ID that is to be processed */
  4619. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  4620. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  4621. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  4622. unsigned int TableIndex, /* Index to the Id table */
  4623. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  4624. {
  4625. unsigned int PhysPortMax;
  4626. unsigned int PhysPortIndex;
  4627. unsigned int LogPortMax;
  4628. unsigned int LogPortIndex;
  4629. unsigned int Limit;
  4630. unsigned int Offset;
  4631. char Val8;
  4632. int Ret;
  4633. SK_EVPARA EventParam;
  4634. SK_U32 Val32;
  4635. /*
  4636. * Calculate instance if wished. MAC index 0 is the virtual
  4637. * MAC.
  4638. */
  4639. PhysPortMax = pAC->GIni.GIMacsFound;
  4640. LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
  4641. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) { /* Dual net mode */
  4642. LogPortMax--;
  4643. }
  4644. if ((Instance != (SK_U32)(-1))) { /* Only one specific instance is queried */
  4645. /* Check instance range */
  4646. if ((Instance < 1) || (Instance > LogPortMax)) {
  4647. *pLen = 0;
  4648. return (SK_PNMI_ERR_UNKNOWN_INST);
  4649. }
  4650. LogPortIndex = SK_PNMI_PORT_INST2LOG(Instance);
  4651. Limit = LogPortIndex + 1;
  4652. }
  4653. else { /* Instance == (SK_U32)(-1), get all Instances of that OID */
  4654. LogPortIndex = 0;
  4655. Limit = LogPortMax;
  4656. }
  4657. /*
  4658. * Perform action
  4659. */
  4660. if (Action == SK_PNMI_GET) {
  4661. /*
  4662. * Check length
  4663. */
  4664. switch (Id) {
  4665. case OID_SKGE_PMD:
  4666. case OID_SKGE_CONNECTOR:
  4667. case OID_SKGE_LINK_CAP:
  4668. case OID_SKGE_LINK_MODE:
  4669. case OID_SKGE_LINK_MODE_STATUS:
  4670. case OID_SKGE_LINK_STATUS:
  4671. case OID_SKGE_FLOWCTRL_CAP:
  4672. case OID_SKGE_FLOWCTRL_MODE:
  4673. case OID_SKGE_FLOWCTRL_STATUS:
  4674. case OID_SKGE_PHY_OPERATION_CAP:
  4675. case OID_SKGE_PHY_OPERATION_MODE:
  4676. case OID_SKGE_PHY_OPERATION_STATUS:
  4677. case OID_SKGE_SPEED_CAP:
  4678. case OID_SKGE_SPEED_MODE:
  4679. case OID_SKGE_SPEED_STATUS:
  4680. if (*pLen < (Limit - LogPortIndex) * sizeof(SK_U8)) {
  4681. *pLen = (Limit - LogPortIndex) *
  4682. sizeof(SK_U8);
  4683. return (SK_PNMI_ERR_TOO_SHORT);
  4684. }
  4685. break;
  4686. case OID_SKGE_MTU:
  4687. if (*pLen < sizeof(SK_U32)) {
  4688. *pLen = sizeof(SK_U32);
  4689. return (SK_PNMI_ERR_TOO_SHORT);
  4690. }
  4691. break;
  4692. default:
  4693. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR041,
  4694. SK_PNMI_ERR041MSG);
  4695. *pLen = 0;
  4696. return (SK_PNMI_ERR_GENERAL);
  4697. }
  4698. /*
  4699. * Update statistic and increment semaphore to indicate
  4700. * that an update was already done.
  4701. */
  4702. if ((Ret = SirqUpdate(pAC, IoC)) != SK_PNMI_ERR_OK) {
  4703. *pLen = 0;
  4704. return (Ret);
  4705. }
  4706. pAC->Pnmi.SirqUpdatedFlag ++;
  4707. /*
  4708. * Get value
  4709. */
  4710. Offset = 0;
  4711. for (; LogPortIndex < Limit; LogPortIndex ++) {
  4712. switch (Id) {
  4713. case OID_SKGE_PMD:
  4714. *(pBuf + Offset) = pAC->Pnmi.PMD;
  4715. Offset += sizeof(char);
  4716. break;
  4717. case OID_SKGE_CONNECTOR:
  4718. *(pBuf + Offset) = pAC->Pnmi.Connector;
  4719. Offset += sizeof(char);
  4720. break;
  4721. case OID_SKGE_LINK_CAP:
  4722. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4723. if (LogPortIndex == 0) {
  4724. /* Get value for virtual port */
  4725. VirtualConf(pAC, IoC, Id, pBuf +
  4726. Offset);
  4727. }
  4728. else {
  4729. /* Get value for physical ports */
  4730. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4731. pAC, LogPortIndex);
  4732. *(pBuf + Offset) = pAC->GIni.GP[
  4733. PhysPortIndex].PLinkCap;
  4734. }
  4735. Offset += sizeof(char);
  4736. }
  4737. else { /* DualNetMode */
  4738. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PLinkCap;
  4739. Offset += sizeof(char);
  4740. }
  4741. break;
  4742. case OID_SKGE_LINK_MODE:
  4743. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4744. if (LogPortIndex == 0) {
  4745. /* Get value for virtual port */
  4746. VirtualConf(pAC, IoC, Id, pBuf +
  4747. Offset);
  4748. }
  4749. else {
  4750. /* Get value for physical ports */
  4751. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4752. pAC, LogPortIndex);
  4753. *(pBuf + Offset) = pAC->GIni.GP[
  4754. PhysPortIndex].PLinkModeConf;
  4755. }
  4756. Offset += sizeof(char);
  4757. }
  4758. else { /* DualNetMode */
  4759. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PLinkModeConf;
  4760. Offset += sizeof(char);
  4761. }
  4762. break;
  4763. case OID_SKGE_LINK_MODE_STATUS:
  4764. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4765. if (LogPortIndex == 0) {
  4766. /* Get value for virtual port */
  4767. VirtualConf(pAC, IoC, Id, pBuf +
  4768. Offset);
  4769. }
  4770. else {
  4771. /* Get value for physical port */
  4772. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4773. pAC, LogPortIndex);
  4774. *(pBuf + Offset) =
  4775. CalculateLinkModeStatus(pAC,
  4776. IoC, PhysPortIndex);
  4777. }
  4778. Offset += sizeof(char);
  4779. }
  4780. else { /* DualNetMode */
  4781. *(pBuf + Offset) = CalculateLinkModeStatus(pAC, IoC, NetIndex);
  4782. Offset += sizeof(char);
  4783. }
  4784. break;
  4785. case OID_SKGE_LINK_STATUS:
  4786. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4787. if (LogPortIndex == 0) {
  4788. /* Get value for virtual port */
  4789. VirtualConf(pAC, IoC, Id, pBuf +
  4790. Offset);
  4791. }
  4792. else {
  4793. /* Get value for physical ports */
  4794. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4795. pAC, LogPortIndex);
  4796. *(pBuf + Offset) =
  4797. CalculateLinkStatus(pAC,
  4798. IoC, PhysPortIndex);
  4799. }
  4800. Offset += sizeof(char);
  4801. }
  4802. else { /* DualNetMode */
  4803. *(pBuf + Offset) = CalculateLinkStatus(pAC, IoC, NetIndex);
  4804. Offset += sizeof(char);
  4805. }
  4806. break;
  4807. case OID_SKGE_FLOWCTRL_CAP:
  4808. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4809. if (LogPortIndex == 0) {
  4810. /* Get value for virtual port */
  4811. VirtualConf(pAC, IoC, Id, pBuf +
  4812. Offset);
  4813. }
  4814. else {
  4815. /* Get value for physical ports */
  4816. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4817. pAC, LogPortIndex);
  4818. *(pBuf + Offset) = pAC->GIni.GP[
  4819. PhysPortIndex].PFlowCtrlCap;
  4820. }
  4821. Offset += sizeof(char);
  4822. }
  4823. else { /* DualNetMode */
  4824. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PFlowCtrlCap;
  4825. Offset += sizeof(char);
  4826. }
  4827. break;
  4828. case OID_SKGE_FLOWCTRL_MODE:
  4829. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4830. if (LogPortIndex == 0) {
  4831. /* Get value for virtual port */
  4832. VirtualConf(pAC, IoC, Id, pBuf +
  4833. Offset);
  4834. }
  4835. else {
  4836. /* Get value for physical port */
  4837. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4838. pAC, LogPortIndex);
  4839. *(pBuf + Offset) = pAC->GIni.GP[
  4840. PhysPortIndex].PFlowCtrlMode;
  4841. }
  4842. Offset += sizeof(char);
  4843. }
  4844. else { /* DualNetMode */
  4845. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PFlowCtrlMode;
  4846. Offset += sizeof(char);
  4847. }
  4848. break;
  4849. case OID_SKGE_FLOWCTRL_STATUS:
  4850. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4851. if (LogPortIndex == 0) {
  4852. /* Get value for virtual port */
  4853. VirtualConf(pAC, IoC, Id, pBuf +
  4854. Offset);
  4855. }
  4856. else {
  4857. /* Get value for physical port */
  4858. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4859. pAC, LogPortIndex);
  4860. *(pBuf + Offset) = pAC->GIni.GP[
  4861. PhysPortIndex].PFlowCtrlStatus;
  4862. }
  4863. Offset += sizeof(char);
  4864. }
  4865. else { /* DualNetMode */
  4866. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PFlowCtrlStatus;
  4867. Offset += sizeof(char);
  4868. }
  4869. break;
  4870. case OID_SKGE_PHY_OPERATION_CAP:
  4871. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4872. if (LogPortIndex == 0) {
  4873. /* Get value for virtual port */
  4874. VirtualConf(pAC, IoC, Id, pBuf +
  4875. Offset);
  4876. }
  4877. else {
  4878. /* Get value for physical ports */
  4879. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4880. pAC, LogPortIndex);
  4881. *(pBuf + Offset) = pAC->GIni.GP[
  4882. PhysPortIndex].PMSCap;
  4883. }
  4884. Offset += sizeof(char);
  4885. }
  4886. else { /* DualNetMode */
  4887. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PMSCap;
  4888. Offset += sizeof(char);
  4889. }
  4890. break;
  4891. case OID_SKGE_PHY_OPERATION_MODE:
  4892. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4893. if (LogPortIndex == 0) {
  4894. /* Get value for virtual port */
  4895. VirtualConf(pAC, IoC, Id, pBuf + Offset);
  4896. }
  4897. else {
  4898. /* Get value for physical port */
  4899. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4900. pAC, LogPortIndex);
  4901. *(pBuf + Offset) = pAC->GIni.GP[
  4902. PhysPortIndex].PMSMode;
  4903. }
  4904. Offset += sizeof(char);
  4905. }
  4906. else { /* DualNetMode */
  4907. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PMSMode;
  4908. Offset += sizeof(char);
  4909. }
  4910. break;
  4911. case OID_SKGE_PHY_OPERATION_STATUS:
  4912. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4913. if (LogPortIndex == 0) {
  4914. /* Get value for virtual port */
  4915. VirtualConf(pAC, IoC, Id, pBuf + Offset);
  4916. }
  4917. else {
  4918. /* Get value for physical port */
  4919. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4920. pAC, LogPortIndex);
  4921. *(pBuf + Offset) = pAC->GIni.GP[
  4922. PhysPortIndex].PMSStatus;
  4923. }
  4924. Offset += sizeof(char);
  4925. }
  4926. else {
  4927. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PMSStatus;
  4928. Offset += sizeof(char);
  4929. }
  4930. break;
  4931. case OID_SKGE_SPEED_CAP:
  4932. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4933. if (LogPortIndex == 0) {
  4934. /* Get value for virtual port */
  4935. VirtualConf(pAC, IoC, Id, pBuf +
  4936. Offset);
  4937. }
  4938. else {
  4939. /* Get value for physical ports */
  4940. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4941. pAC, LogPortIndex);
  4942. *(pBuf + Offset) = pAC->GIni.GP[
  4943. PhysPortIndex].PLinkSpeedCap;
  4944. }
  4945. Offset += sizeof(char);
  4946. }
  4947. else { /* DualNetMode */
  4948. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PLinkSpeedCap;
  4949. Offset += sizeof(char);
  4950. }
  4951. break;
  4952. case OID_SKGE_SPEED_MODE:
  4953. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4954. if (LogPortIndex == 0) {
  4955. /* Get value for virtual port */
  4956. VirtualConf(pAC, IoC, Id, pBuf + Offset);
  4957. }
  4958. else {
  4959. /* Get value for physical port */
  4960. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4961. pAC, LogPortIndex);
  4962. *(pBuf + Offset) = pAC->GIni.GP[
  4963. PhysPortIndex].PLinkSpeed;
  4964. }
  4965. Offset += sizeof(char);
  4966. }
  4967. else { /* DualNetMode */
  4968. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PLinkSpeed;
  4969. Offset += sizeof(char);
  4970. }
  4971. break;
  4972. case OID_SKGE_SPEED_STATUS:
  4973. if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
  4974. if (LogPortIndex == 0) {
  4975. /* Get value for virtual port */
  4976. VirtualConf(pAC, IoC, Id, pBuf + Offset);
  4977. }
  4978. else {
  4979. /* Get value for physical port */
  4980. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
  4981. pAC, LogPortIndex);
  4982. *(pBuf + Offset) = pAC->GIni.GP[
  4983. PhysPortIndex].PLinkSpeedUsed;
  4984. }
  4985. Offset += sizeof(char);
  4986. }
  4987. else { /* DualNetMode */
  4988. *(pBuf + Offset) = pAC->GIni.GP[NetIndex].PLinkSpeedUsed;
  4989. Offset += sizeof(char);
  4990. }
  4991. break;
  4992. case OID_SKGE_MTU:
  4993. Val32 = SK_DRIVER_GET_MTU(pAC, IoC, NetIndex);
  4994. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  4995. Offset += sizeof(SK_U32);
  4996. break;
  4997. default:
  4998. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_ERR,
  4999. ("MacPrivateConf: Unknown OID should be handled before"));
  5000. pAC->Pnmi.SirqUpdatedFlag --;
  5001. return (SK_PNMI_ERR_GENERAL);
  5002. }
  5003. }
  5004. *pLen = Offset;
  5005. pAC->Pnmi.SirqUpdatedFlag --;
  5006. return (SK_PNMI_ERR_OK);
  5007. }
  5008. /*
  5009. * From here SET or PRESET action. Check if the passed
  5010. * buffer length is plausible.
  5011. */
  5012. switch (Id) {
  5013. case OID_SKGE_LINK_MODE:
  5014. case OID_SKGE_FLOWCTRL_MODE:
  5015. case OID_SKGE_PHY_OPERATION_MODE:
  5016. case OID_SKGE_SPEED_MODE:
  5017. if (*pLen < Limit - LogPortIndex) {
  5018. *pLen = Limit - LogPortIndex;
  5019. return (SK_PNMI_ERR_TOO_SHORT);
  5020. }
  5021. if (*pLen != Limit - LogPortIndex) {
  5022. *pLen = 0;
  5023. return (SK_PNMI_ERR_BAD_VALUE);
  5024. }
  5025. break;
  5026. case OID_SKGE_MTU:
  5027. if (*pLen < sizeof(SK_U32)) {
  5028. *pLen = sizeof(SK_U32);
  5029. return (SK_PNMI_ERR_TOO_SHORT);
  5030. }
  5031. if (*pLen != sizeof(SK_U32)) {
  5032. *pLen = 0;
  5033. return (SK_PNMI_ERR_BAD_VALUE);
  5034. }
  5035. break;
  5036. default:
  5037. *pLen = 0;
  5038. return (SK_PNMI_ERR_READ_ONLY);
  5039. }
  5040. /*
  5041. * Perform preset or set
  5042. */
  5043. Offset = 0;
  5044. for (; LogPortIndex < Limit; LogPortIndex ++) {
  5045. switch (Id) {
  5046. case OID_SKGE_LINK_MODE:
  5047. /* Check the value range */
  5048. Val8 = *(pBuf + Offset);
  5049. if (Val8 == 0) {
  5050. Offset += sizeof(char);
  5051. break;
  5052. }
  5053. if (Val8 < SK_LMODE_HALF ||
  5054. (LogPortIndex != 0 && Val8 > SK_LMODE_AUTOSENSE) ||
  5055. (LogPortIndex == 0 && Val8 > SK_LMODE_INDETERMINATED)) {
  5056. *pLen = 0;
  5057. return (SK_PNMI_ERR_BAD_VALUE);
  5058. }
  5059. /* The preset ends here */
  5060. if (Action == SK_PNMI_PRESET) {
  5061. return (SK_PNMI_ERR_OK);
  5062. }
  5063. if (LogPortIndex == 0) {
  5064. /*
  5065. * The virtual port consists of all currently
  5066. * active ports. Find them and send an event
  5067. * with the new link mode to SIRQ.
  5068. */
  5069. for (PhysPortIndex = 0;
  5070. PhysPortIndex < PhysPortMax;
  5071. PhysPortIndex ++) {
  5072. if (!pAC->Pnmi.Port[PhysPortIndex].
  5073. ActiveFlag) {
  5074. continue;
  5075. }
  5076. EventParam.Para32[0] = PhysPortIndex;
  5077. EventParam.Para32[1] = (SK_U32)Val8;
  5078. if (SkGeSirqEvent(pAC, IoC,
  5079. SK_HWEV_SET_LMODE,
  5080. EventParam) > 0) {
  5081. SK_ERR_LOG(pAC, SK_ERRCL_SW,
  5082. SK_PNMI_ERR043,
  5083. SK_PNMI_ERR043MSG);
  5084. *pLen = 0;
  5085. return (SK_PNMI_ERR_GENERAL);
  5086. }
  5087. }
  5088. }
  5089. else {
  5090. /*
  5091. * Send an event with the new link mode to
  5092. * the SIRQ module.
  5093. */
  5094. EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
  5095. pAC, LogPortIndex);
  5096. EventParam.Para32[1] = (SK_U32)Val8;
  5097. if (SkGeSirqEvent(pAC, IoC, SK_HWEV_SET_LMODE,
  5098. EventParam) > 0) {
  5099. SK_ERR_LOG(pAC, SK_ERRCL_SW,
  5100. SK_PNMI_ERR043,
  5101. SK_PNMI_ERR043MSG);
  5102. *pLen = 0;
  5103. return (SK_PNMI_ERR_GENERAL);
  5104. }
  5105. }
  5106. Offset += sizeof(char);
  5107. break;
  5108. case OID_SKGE_FLOWCTRL_MODE:
  5109. /* Check the value range */
  5110. Val8 = *(pBuf + Offset);
  5111. if (Val8 == 0) {
  5112. Offset += sizeof(char);
  5113. break;
  5114. }
  5115. if (Val8 < SK_FLOW_MODE_NONE ||
  5116. (LogPortIndex != 0 && Val8 > SK_FLOW_MODE_SYM_OR_REM) ||
  5117. (LogPortIndex == 0 && Val8 > SK_FLOW_MODE_INDETERMINATED)) {
  5118. *pLen = 0;
  5119. return (SK_PNMI_ERR_BAD_VALUE);
  5120. }
  5121. /* The preset ends here */
  5122. if (Action == SK_PNMI_PRESET) {
  5123. return (SK_PNMI_ERR_OK);
  5124. }
  5125. if (LogPortIndex == 0) {
  5126. /*
  5127. * The virtual port consists of all currently
  5128. * active ports. Find them and send an event
  5129. * with the new flow control mode to SIRQ.
  5130. */
  5131. for (PhysPortIndex = 0;
  5132. PhysPortIndex < PhysPortMax;
  5133. PhysPortIndex ++) {
  5134. if (!pAC->Pnmi.Port[PhysPortIndex].
  5135. ActiveFlag) {
  5136. continue;
  5137. }
  5138. EventParam.Para32[0] = PhysPortIndex;
  5139. EventParam.Para32[1] = (SK_U32)Val8;
  5140. if (SkGeSirqEvent(pAC, IoC,
  5141. SK_HWEV_SET_FLOWMODE,
  5142. EventParam) > 0) {
  5143. SK_ERR_LOG(pAC, SK_ERRCL_SW,
  5144. SK_PNMI_ERR044,
  5145. SK_PNMI_ERR044MSG);
  5146. *pLen = 0;
  5147. return (SK_PNMI_ERR_GENERAL);
  5148. }
  5149. }
  5150. }
  5151. else {
  5152. /*
  5153. * Send an event with the new flow control
  5154. * mode to the SIRQ module.
  5155. */
  5156. EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
  5157. pAC, LogPortIndex);
  5158. EventParam.Para32[1] = (SK_U32)Val8;
  5159. if (SkGeSirqEvent(pAC, IoC,
  5160. SK_HWEV_SET_FLOWMODE, EventParam)
  5161. > 0) {
  5162. SK_ERR_LOG(pAC, SK_ERRCL_SW,
  5163. SK_PNMI_ERR044,
  5164. SK_PNMI_ERR044MSG);
  5165. *pLen = 0;
  5166. return (SK_PNMI_ERR_GENERAL);
  5167. }
  5168. }
  5169. Offset += sizeof(char);
  5170. break;
  5171. case OID_SKGE_PHY_OPERATION_MODE :
  5172. /* Check the value range */
  5173. Val8 = *(pBuf + Offset);
  5174. if (Val8 == 0) {
  5175. /* mode of this port remains unchanged */
  5176. Offset += sizeof(char);
  5177. break;
  5178. }
  5179. if (Val8 < SK_MS_MODE_AUTO ||
  5180. (LogPortIndex != 0 && Val8 > SK_MS_MODE_SLAVE) ||
  5181. (LogPortIndex == 0 && Val8 > SK_MS_MODE_INDETERMINATED)) {
  5182. *pLen = 0;
  5183. return (SK_PNMI_ERR_BAD_VALUE);
  5184. }
  5185. /* The preset ends here */
  5186. if (Action == SK_PNMI_PRESET) {
  5187. return (SK_PNMI_ERR_OK);
  5188. }
  5189. if (LogPortIndex == 0) {
  5190. /*
  5191. * The virtual port consists of all currently
  5192. * active ports. Find them and send an event
  5193. * with new master/slave (role) mode to SIRQ.
  5194. */
  5195. for (PhysPortIndex = 0;
  5196. PhysPortIndex < PhysPortMax;
  5197. PhysPortIndex ++) {
  5198. if (!pAC->Pnmi.Port[PhysPortIndex].
  5199. ActiveFlag) {
  5200. continue;
  5201. }
  5202. EventParam.Para32[0] = PhysPortIndex;
  5203. EventParam.Para32[1] = (SK_U32)Val8;
  5204. if (SkGeSirqEvent(pAC, IoC,
  5205. SK_HWEV_SET_ROLE,
  5206. EventParam) > 0) {
  5207. SK_ERR_LOG(pAC, SK_ERRCL_SW,
  5208. SK_PNMI_ERR042,
  5209. SK_PNMI_ERR042MSG);
  5210. *pLen = 0;
  5211. return (SK_PNMI_ERR_GENERAL);
  5212. }
  5213. }
  5214. }
  5215. else {
  5216. /*
  5217. * Send an event with the new master/slave
  5218. * (role) mode to the SIRQ module.
  5219. */
  5220. EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
  5221. pAC, LogPortIndex);
  5222. EventParam.Para32[1] = (SK_U32)Val8;
  5223. if (SkGeSirqEvent(pAC, IoC,
  5224. SK_HWEV_SET_ROLE, EventParam) > 0) {
  5225. SK_ERR_LOG(pAC, SK_ERRCL_SW,
  5226. SK_PNMI_ERR042,
  5227. SK_PNMI_ERR042MSG);
  5228. *pLen = 0;
  5229. return (SK_PNMI_ERR_GENERAL);
  5230. }
  5231. }
  5232. Offset += sizeof(char);
  5233. break;
  5234. case OID_SKGE_SPEED_MODE:
  5235. /* Check the value range */
  5236. Val8 = *(pBuf + Offset);
  5237. if (Val8 == 0) {
  5238. Offset += sizeof(char);
  5239. break;
  5240. }
  5241. if (Val8 < (SK_LSPEED_AUTO) ||
  5242. (LogPortIndex != 0 && Val8 > (SK_LSPEED_1000MBPS)) ||
  5243. (LogPortIndex == 0 && Val8 > (SK_LSPEED_INDETERMINATED))) {
  5244. *pLen = 0;
  5245. return (SK_PNMI_ERR_BAD_VALUE);
  5246. }
  5247. /* The preset ends here */
  5248. if (Action == SK_PNMI_PRESET) {
  5249. return (SK_PNMI_ERR_OK);
  5250. }
  5251. if (LogPortIndex == 0) {
  5252. /*
  5253. * The virtual port consists of all currently
  5254. * active ports. Find them and send an event
  5255. * with the new flow control mode to SIRQ.
  5256. */
  5257. for (PhysPortIndex = 0;
  5258. PhysPortIndex < PhysPortMax;
  5259. PhysPortIndex ++) {
  5260. if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
  5261. continue;
  5262. }
  5263. EventParam.Para32[0] = PhysPortIndex;
  5264. EventParam.Para32[1] = (SK_U32)Val8;
  5265. if (SkGeSirqEvent(pAC, IoC,
  5266. SK_HWEV_SET_SPEED,
  5267. EventParam) > 0) {
  5268. SK_ERR_LOG(pAC, SK_ERRCL_SW,
  5269. SK_PNMI_ERR045,
  5270. SK_PNMI_ERR045MSG);
  5271. *pLen = 0;
  5272. return (SK_PNMI_ERR_GENERAL);
  5273. }
  5274. }
  5275. }
  5276. else {
  5277. /*
  5278. * Send an event with the new flow control
  5279. * mode to the SIRQ module.
  5280. */
  5281. EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS(
  5282. pAC, LogPortIndex);
  5283. EventParam.Para32[1] = (SK_U32)Val8;
  5284. if (SkGeSirqEvent(pAC, IoC,
  5285. SK_HWEV_SET_SPEED,
  5286. EventParam) > 0) {
  5287. SK_ERR_LOG(pAC, SK_ERRCL_SW,
  5288. SK_PNMI_ERR045,
  5289. SK_PNMI_ERR045MSG);
  5290. *pLen = 0;
  5291. return (SK_PNMI_ERR_GENERAL);
  5292. }
  5293. }
  5294. Offset += sizeof(char);
  5295. break;
  5296. case OID_SKGE_MTU :
  5297. /* Check the value range */
  5298. Val32 = *(SK_U32*)(pBuf + Offset);
  5299. if (Val32 == 0) {
  5300. /* mtu of this port remains unchanged */
  5301. Offset += sizeof(SK_U32);
  5302. break;
  5303. }
  5304. if (SK_DRIVER_PRESET_MTU(pAC, IoC, NetIndex, Val32) != 0) {
  5305. *pLen = 0;
  5306. return (SK_PNMI_ERR_BAD_VALUE);
  5307. }
  5308. /* The preset ends here */
  5309. if (Action == SK_PNMI_PRESET) {
  5310. return (SK_PNMI_ERR_OK);
  5311. }
  5312. if (SK_DRIVER_SET_MTU(pAC, IoC, NetIndex, Val32) != 0) {
  5313. return (SK_PNMI_ERR_GENERAL);
  5314. }
  5315. Offset += sizeof(SK_U32);
  5316. break;
  5317. default:
  5318. SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_ERR,
  5319. ("MacPrivateConf: Unknown OID should be handled before set"));
  5320. *pLen = 0;
  5321. return (SK_PNMI_ERR_GENERAL);
  5322. }
  5323. }
  5324. return (SK_PNMI_ERR_OK);
  5325. }
  5326. /*****************************************************************************
  5327. *
  5328. * Monitor - OID handler function for RLMT_MONITOR_XXX
  5329. *
  5330. * Description:
  5331. * Because RLMT currently does not support the monitoring of
  5332. * remote adapter cards, we return always an empty table.
  5333. *
  5334. * Returns:
  5335. * SK_PNMI_ERR_OK The request was successfully performed.
  5336. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  5337. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  5338. * the correct data (e.g. a 32bit value is
  5339. * needed, but a 16 bit value was passed).
  5340. * SK_PNMI_ERR_BAD_VALUE The passed value is not in the valid
  5341. * value range.
  5342. * SK_PNMI_ERR_READ_ONLY The OID is read-only and cannot be set.
  5343. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  5344. * exist (e.g. port instance 3 on a two port
  5345. * adapter.
  5346. */
  5347. PNMI_STATIC int Monitor(
  5348. SK_AC *pAC, /* Pointer to adapter context */
  5349. SK_IOC IoC, /* IO context handle */
  5350. int Action, /* Get/PreSet/Set action */
  5351. SK_U32 Id, /* Object ID that is to be processed */
  5352. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  5353. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  5354. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  5355. unsigned int TableIndex, /* Index to the Id table */
  5356. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  5357. {
  5358. unsigned int Index;
  5359. unsigned int Limit;
  5360. unsigned int Offset;
  5361. unsigned int Entries;
  5362. /*
  5363. * Calculate instance if wished.
  5364. */
  5365. /* XXX Not yet implemented. Return always an empty table. */
  5366. Entries = 0;
  5367. if ((Instance != (SK_U32)(-1))) {
  5368. if ((Instance < 1) || (Instance > Entries)) {
  5369. *pLen = 0;
  5370. return (SK_PNMI_ERR_UNKNOWN_INST);
  5371. }
  5372. Index = (unsigned int)Instance - 1;
  5373. Limit = (unsigned int)Instance;
  5374. }
  5375. else {
  5376. Index = 0;
  5377. Limit = Entries;
  5378. }
  5379. /*
  5380. * Get/Set value
  5381. */
  5382. if (Action == SK_PNMI_GET) {
  5383. for (Offset=0; Index < Limit; Index ++) {
  5384. switch (Id) {
  5385. case OID_SKGE_RLMT_MONITOR_INDEX:
  5386. case OID_SKGE_RLMT_MONITOR_ADDR:
  5387. case OID_SKGE_RLMT_MONITOR_ERRS:
  5388. case OID_SKGE_RLMT_MONITOR_TIMESTAMP:
  5389. case OID_SKGE_RLMT_MONITOR_ADMIN:
  5390. break;
  5391. default:
  5392. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR046,
  5393. SK_PNMI_ERR046MSG);
  5394. *pLen = 0;
  5395. return (SK_PNMI_ERR_GENERAL);
  5396. }
  5397. }
  5398. *pLen = Offset;
  5399. }
  5400. else {
  5401. /* Only MONITOR_ADMIN can be set */
  5402. if (Id != OID_SKGE_RLMT_MONITOR_ADMIN) {
  5403. *pLen = 0;
  5404. return (SK_PNMI_ERR_READ_ONLY);
  5405. }
  5406. /* Check if the length is plausible */
  5407. if (*pLen < (Limit - Index)) {
  5408. return (SK_PNMI_ERR_TOO_SHORT);
  5409. }
  5410. /* Okay, we have a wide value range */
  5411. if (*pLen != (Limit - Index)) {
  5412. *pLen = 0;
  5413. return (SK_PNMI_ERR_BAD_VALUE);
  5414. }
  5415. /*
  5416. for (Offset=0; Index < Limit; Index ++) {
  5417. }
  5418. */
  5419. /*
  5420. * XXX Not yet implemented. Return always BAD_VALUE, because the table
  5421. * is empty.
  5422. */
  5423. *pLen = 0;
  5424. return (SK_PNMI_ERR_BAD_VALUE);
  5425. }
  5426. return (SK_PNMI_ERR_OK);
  5427. }
  5428. /*****************************************************************************
  5429. *
  5430. * VirtualConf - Calculates the values of configuration OIDs for virtual port
  5431. *
  5432. * Description:
  5433. * We handle here the get of the configuration group OIDs, which are
  5434. * a little bit complicated. The virtual port consists of all currently
  5435. * active physical ports. If multiple ports are active and configured
  5436. * differently we get in some trouble to return a single value. So we
  5437. * get the value of the first active port and compare it with that of
  5438. * the other active ports. If they are not the same, we return a value
  5439. * that indicates that the state is indeterminated.
  5440. *
  5441. * Returns:
  5442. * Nothing
  5443. */
  5444. PNMI_STATIC void VirtualConf(
  5445. SK_AC *pAC, /* Pointer to adapter context */
  5446. SK_IOC IoC, /* IO context handle */
  5447. SK_U32 Id, /* Object ID that is to be processed */
  5448. char *pBuf) /* Buffer to which to mgmt data will be retrieved */
  5449. {
  5450. unsigned int PhysPortMax;
  5451. unsigned int PhysPortIndex;
  5452. SK_U8 Val8;
  5453. SK_BOOL PortActiveFlag;
  5454. *pBuf = 0;
  5455. PortActiveFlag = SK_FALSE;
  5456. PhysPortMax = pAC->GIni.GIMacsFound;
  5457. for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax;
  5458. PhysPortIndex ++) {
  5459. /* Check if the physical port is active */
  5460. if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
  5461. continue;
  5462. }
  5463. PortActiveFlag = SK_TRUE;
  5464. switch (Id) {
  5465. case OID_SKGE_LINK_CAP:
  5466. /*
  5467. * Different capabilities should not happen, but
  5468. * in the case of the cases OR them all together.
  5469. * From a curious point of view the virtual port
  5470. * is capable of all found capabilities.
  5471. */
  5472. *pBuf |= pAC->GIni.GP[PhysPortIndex].PLinkCap;
  5473. break;
  5474. case OID_SKGE_LINK_MODE:
  5475. /* Check if it is the first active port */
  5476. if (*pBuf == 0) {
  5477. *pBuf = pAC->GIni.GP[PhysPortIndex].PLinkModeConf;
  5478. continue;
  5479. }
  5480. /*
  5481. * If we find an active port with a different link
  5482. * mode than the first one we return a value that
  5483. * indicates that the link mode is indeterminated.
  5484. */
  5485. if (*pBuf != pAC->GIni.GP[PhysPortIndex].PLinkModeConf
  5486. ) {
  5487. *pBuf = SK_LMODE_INDETERMINATED;
  5488. }
  5489. break;
  5490. case OID_SKGE_LINK_MODE_STATUS:
  5491. /* Get the link mode of the physical port */
  5492. Val8 = CalculateLinkModeStatus(pAC, IoC, PhysPortIndex);
  5493. /* Check if it is the first active port */
  5494. if (*pBuf == 0) {
  5495. *pBuf = Val8;
  5496. continue;
  5497. }
  5498. /*
  5499. * If we find an active port with a different link
  5500. * mode status than the first one we return a value
  5501. * that indicates that the link mode status is
  5502. * indeterminated.
  5503. */
  5504. if (*pBuf != Val8) {
  5505. *pBuf = SK_LMODE_STAT_INDETERMINATED;
  5506. }
  5507. break;
  5508. case OID_SKGE_LINK_STATUS:
  5509. /* Get the link status of the physical port */
  5510. Val8 = CalculateLinkStatus(pAC, IoC, PhysPortIndex);
  5511. /* Check if it is the first active port */
  5512. if (*pBuf == 0) {
  5513. *pBuf = Val8;
  5514. continue;
  5515. }
  5516. /*
  5517. * If we find an active port with a different link
  5518. * status than the first one, we return a value
  5519. * that indicates that the link status is
  5520. * indeterminated.
  5521. */
  5522. if (*pBuf != Val8) {
  5523. *pBuf = SK_PNMI_RLMT_LSTAT_INDETERMINATED;
  5524. }
  5525. break;
  5526. case OID_SKGE_FLOWCTRL_CAP:
  5527. /* Check if it is the first active port */
  5528. if (*pBuf == 0) {
  5529. *pBuf = pAC->GIni.GP[PhysPortIndex].PFlowCtrlCap;
  5530. continue;
  5531. }
  5532. /*
  5533. * From a curious point of view the virtual port
  5534. * is capable of all found capabilities.
  5535. */
  5536. *pBuf |= pAC->GIni.GP[PhysPortIndex].PFlowCtrlCap;
  5537. break;
  5538. case OID_SKGE_FLOWCTRL_MODE:
  5539. /* Check if it is the first active port */
  5540. if (*pBuf == 0) {
  5541. *pBuf = pAC->GIni.GP[PhysPortIndex].PFlowCtrlMode;
  5542. continue;
  5543. }
  5544. /*
  5545. * If we find an active port with a different flow
  5546. * control mode than the first one, we return a value
  5547. * that indicates that the mode is indeterminated.
  5548. */
  5549. if (*pBuf != pAC->GIni.GP[PhysPortIndex].PFlowCtrlMode) {
  5550. *pBuf = SK_FLOW_MODE_INDETERMINATED;
  5551. }
  5552. break;
  5553. case OID_SKGE_FLOWCTRL_STATUS:
  5554. /* Check if it is the first active port */
  5555. if (*pBuf == 0) {
  5556. *pBuf = pAC->GIni.GP[PhysPortIndex].PFlowCtrlStatus;
  5557. continue;
  5558. }
  5559. /*
  5560. * If we find an active port with a different flow
  5561. * control status than the first one, we return a
  5562. * value that indicates that the status is
  5563. * indeterminated.
  5564. */
  5565. if (*pBuf != pAC->GIni.GP[PhysPortIndex].PFlowCtrlStatus) {
  5566. *pBuf = SK_FLOW_STAT_INDETERMINATED;
  5567. }
  5568. break;
  5569. case OID_SKGE_PHY_OPERATION_CAP:
  5570. /* Check if it is the first active port */
  5571. if (*pBuf == 0) {
  5572. *pBuf = pAC->GIni.GP[PhysPortIndex].PMSCap;
  5573. continue;
  5574. }
  5575. /*
  5576. * From a curious point of view the virtual port
  5577. * is capable of all found capabilities.
  5578. */
  5579. *pBuf |= pAC->GIni.GP[PhysPortIndex].PMSCap;
  5580. break;
  5581. case OID_SKGE_PHY_OPERATION_MODE:
  5582. /* Check if it is the first active port */
  5583. if (*pBuf == 0) {
  5584. *pBuf = pAC->GIni.GP[PhysPortIndex].PMSMode;
  5585. continue;
  5586. }
  5587. /*
  5588. * If we find an active port with a different master/
  5589. * slave mode than the first one, we return a value
  5590. * that indicates that the mode is indeterminated.
  5591. */
  5592. if (*pBuf != pAC->GIni.GP[PhysPortIndex].PMSMode) {
  5593. *pBuf = SK_MS_MODE_INDETERMINATED;
  5594. }
  5595. break;
  5596. case OID_SKGE_PHY_OPERATION_STATUS:
  5597. /* Check if it is the first active port */
  5598. if (*pBuf == 0) {
  5599. *pBuf = pAC->GIni.GP[PhysPortIndex].PMSStatus;
  5600. continue;
  5601. }
  5602. /*
  5603. * If we find an active port with a different master/
  5604. * slave status than the first one, we return a
  5605. * value that indicates that the status is
  5606. * indeterminated.
  5607. */
  5608. if (*pBuf != pAC->GIni.GP[PhysPortIndex].PMSStatus) {
  5609. *pBuf = SK_MS_STAT_INDETERMINATED;
  5610. }
  5611. break;
  5612. case OID_SKGE_SPEED_MODE:
  5613. /* Check if it is the first active port */
  5614. if (*pBuf == 0) {
  5615. *pBuf = pAC->GIni.GP[PhysPortIndex].PLinkSpeed;
  5616. continue;
  5617. }
  5618. /*
  5619. * If we find an active port with a different flow
  5620. * control mode than the first one, we return a value
  5621. * that indicates that the mode is indeterminated.
  5622. */
  5623. if (*pBuf != pAC->GIni.GP[PhysPortIndex].PLinkSpeed) {
  5624. *pBuf = SK_LSPEED_INDETERMINATED;
  5625. }
  5626. break;
  5627. case OID_SKGE_SPEED_STATUS:
  5628. /* Check if it is the first active port */
  5629. if (*pBuf == 0) {
  5630. *pBuf = pAC->GIni.GP[PhysPortIndex].PLinkSpeedUsed;
  5631. continue;
  5632. }
  5633. /*
  5634. * If we find an active port with a different flow
  5635. * control status than the first one, we return a
  5636. * value that indicates that the status is
  5637. * indeterminated.
  5638. */
  5639. if (*pBuf != pAC->GIni.GP[PhysPortIndex].PLinkSpeedUsed) {
  5640. *pBuf = SK_LSPEED_STAT_INDETERMINATED;
  5641. }
  5642. break;
  5643. }
  5644. }
  5645. /*
  5646. * If no port is active return an indeterminated answer
  5647. */
  5648. if (!PortActiveFlag) {
  5649. switch (Id) {
  5650. case OID_SKGE_LINK_CAP:
  5651. *pBuf = SK_LMODE_CAP_INDETERMINATED;
  5652. break;
  5653. case OID_SKGE_LINK_MODE:
  5654. *pBuf = SK_LMODE_INDETERMINATED;
  5655. break;
  5656. case OID_SKGE_LINK_MODE_STATUS:
  5657. *pBuf = SK_LMODE_STAT_INDETERMINATED;
  5658. break;
  5659. case OID_SKGE_LINK_STATUS:
  5660. *pBuf = SK_PNMI_RLMT_LSTAT_INDETERMINATED;
  5661. break;
  5662. case OID_SKGE_FLOWCTRL_CAP:
  5663. case OID_SKGE_FLOWCTRL_MODE:
  5664. *pBuf = SK_FLOW_MODE_INDETERMINATED;
  5665. break;
  5666. case OID_SKGE_FLOWCTRL_STATUS:
  5667. *pBuf = SK_FLOW_STAT_INDETERMINATED;
  5668. break;
  5669. case OID_SKGE_PHY_OPERATION_CAP:
  5670. *pBuf = SK_MS_CAP_INDETERMINATED;
  5671. break;
  5672. case OID_SKGE_PHY_OPERATION_MODE:
  5673. *pBuf = SK_MS_MODE_INDETERMINATED;
  5674. break;
  5675. case OID_SKGE_PHY_OPERATION_STATUS:
  5676. *pBuf = SK_MS_STAT_INDETERMINATED;
  5677. break;
  5678. case OID_SKGE_SPEED_CAP:
  5679. *pBuf = SK_LSPEED_CAP_INDETERMINATED;
  5680. break;
  5681. case OID_SKGE_SPEED_MODE:
  5682. *pBuf = SK_LSPEED_INDETERMINATED;
  5683. break;
  5684. case OID_SKGE_SPEED_STATUS:
  5685. *pBuf = SK_LSPEED_STAT_INDETERMINATED;
  5686. break;
  5687. }
  5688. }
  5689. }
  5690. /*****************************************************************************
  5691. *
  5692. * CalculateLinkStatus - Determins the link status of a physical port
  5693. *
  5694. * Description:
  5695. * Determins the link status the following way:
  5696. * LSTAT_PHY_DOWN: Link is down
  5697. * LSTAT_AUTONEG: Auto-negotiation failed
  5698. * LSTAT_LOG_DOWN: Link is up but RLMT did not yet put the port
  5699. * logically up.
  5700. * LSTAT_LOG_UP: RLMT marked the port as up
  5701. *
  5702. * Returns:
  5703. * Link status of physical port
  5704. */
  5705. PNMI_STATIC SK_U8 CalculateLinkStatus(
  5706. SK_AC *pAC, /* Pointer to adapter context */
  5707. SK_IOC IoC, /* IO context handle */
  5708. unsigned int PhysPortIndex) /* Physical port index */
  5709. {
  5710. SK_U8 Result;
  5711. if (!pAC->GIni.GP[PhysPortIndex].PHWLinkUp) {
  5712. Result = SK_PNMI_RLMT_LSTAT_PHY_DOWN;
  5713. }
  5714. else if (pAC->GIni.GP[PhysPortIndex].PAutoNegFail > 0) {
  5715. Result = SK_PNMI_RLMT_LSTAT_AUTONEG;
  5716. }
  5717. else if (!pAC->Rlmt.Port[PhysPortIndex].PortDown) {
  5718. Result = SK_PNMI_RLMT_LSTAT_LOG_UP;
  5719. }
  5720. else {
  5721. Result = SK_PNMI_RLMT_LSTAT_LOG_DOWN;
  5722. }
  5723. return (Result);
  5724. }
  5725. /*****************************************************************************
  5726. *
  5727. * CalculateLinkModeStatus - Determins the link mode status of a phys. port
  5728. *
  5729. * Description:
  5730. * The COMMON module only tells us if the mode is half or full duplex.
  5731. * But in the decade of auto sensing it is usefull for the user to
  5732. * know if the mode was negotiated or forced. Therefore we have a
  5733. * look to the mode, which was last used by the negotiation process.
  5734. *
  5735. * Returns:
  5736. * The link mode status
  5737. */
  5738. PNMI_STATIC SK_U8 CalculateLinkModeStatus(
  5739. SK_AC *pAC, /* Pointer to adapter context */
  5740. SK_IOC IoC, /* IO context handle */
  5741. unsigned int PhysPortIndex) /* Physical port index */
  5742. {
  5743. SK_U8 Result;
  5744. /* Get the current mode, which can be full or half duplex */
  5745. Result = pAC->GIni.GP[PhysPortIndex].PLinkModeStatus;
  5746. /* Check if no valid mode could be found (link is down) */
  5747. if (Result < SK_LMODE_STAT_HALF) {
  5748. Result = SK_LMODE_STAT_UNKNOWN;
  5749. }
  5750. else if (pAC->GIni.GP[PhysPortIndex].PLinkMode >= SK_LMODE_AUTOHALF) {
  5751. /*
  5752. * Auto-negotiation was used to bring up the link. Change
  5753. * the already found duplex status that it indicates
  5754. * auto-negotiation was involved.
  5755. */
  5756. if (Result == SK_LMODE_STAT_HALF) {
  5757. Result = SK_LMODE_STAT_AUTOHALF;
  5758. }
  5759. else if (Result == SK_LMODE_STAT_FULL) {
  5760. Result = SK_LMODE_STAT_AUTOFULL;
  5761. }
  5762. }
  5763. return (Result);
  5764. }
  5765. /*****************************************************************************
  5766. *
  5767. * GetVpdKeyArr - Obtain an array of VPD keys
  5768. *
  5769. * Description:
  5770. * Read the VPD keys and build an array of VPD keys, which are
  5771. * easy to access.
  5772. *
  5773. * Returns:
  5774. * SK_PNMI_ERR_OK Task successfully performed.
  5775. * SK_PNMI_ERR_GENERAL Something went wrong.
  5776. */
  5777. PNMI_STATIC int GetVpdKeyArr(
  5778. SK_AC *pAC, /* Pointer to adapter context */
  5779. SK_IOC IoC, /* IO context handle */
  5780. char *pKeyArr, /* Ptr KeyArray */
  5781. unsigned int KeyArrLen, /* Length of array in bytes */
  5782. unsigned int *pKeyNo) /* Number of keys */
  5783. {
  5784. unsigned int BufKeysLen = SK_PNMI_VPD_BUFSIZE;
  5785. char BufKeys[SK_PNMI_VPD_BUFSIZE];
  5786. unsigned int StartOffset;
  5787. unsigned int Offset;
  5788. int Index;
  5789. int Ret;
  5790. SK_MEMSET(pKeyArr, 0, KeyArrLen);
  5791. /*
  5792. * Get VPD key list
  5793. */
  5794. Ret = VpdKeys(pAC, IoC, (char *)&BufKeys, (int *)&BufKeysLen,
  5795. (int *)pKeyNo);
  5796. if (Ret > 0) {
  5797. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR014,
  5798. SK_PNMI_ERR014MSG);
  5799. return (SK_PNMI_ERR_GENERAL);
  5800. }
  5801. /* If no keys are available return now */
  5802. if (*pKeyNo == 0 || BufKeysLen == 0) {
  5803. return (SK_PNMI_ERR_OK);
  5804. }
  5805. /*
  5806. * If the key list is too long for us trunc it and give a
  5807. * errorlog notification. This case should not happen because
  5808. * the maximum number of keys is limited due to RAM limitations
  5809. */
  5810. if (*pKeyNo > SK_PNMI_VPD_ENTRIES) {
  5811. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR015,
  5812. SK_PNMI_ERR015MSG);
  5813. *pKeyNo = SK_PNMI_VPD_ENTRIES;
  5814. }
  5815. /*
  5816. * Now build an array of fixed string length size and copy
  5817. * the keys together.
  5818. */
  5819. for (Index = 0, StartOffset = 0, Offset = 0; Offset < BufKeysLen;
  5820. Offset ++) {
  5821. if (BufKeys[Offset] != 0) {
  5822. continue;
  5823. }
  5824. if (Offset - StartOffset > SK_PNMI_VPD_KEY_SIZE) {
  5825. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR016,
  5826. SK_PNMI_ERR016MSG);
  5827. return (SK_PNMI_ERR_GENERAL);
  5828. }
  5829. SK_STRNCPY(pKeyArr + Index * SK_PNMI_VPD_KEY_SIZE,
  5830. &BufKeys[StartOffset], SK_PNMI_VPD_KEY_SIZE);
  5831. Index ++;
  5832. StartOffset = Offset + 1;
  5833. }
  5834. /* Last key not zero terminated? Get it anyway */
  5835. if (StartOffset < Offset) {
  5836. SK_STRNCPY(pKeyArr + Index * SK_PNMI_VPD_KEY_SIZE,
  5837. &BufKeys[StartOffset], SK_PNMI_VPD_KEY_SIZE);
  5838. }
  5839. return (SK_PNMI_ERR_OK);
  5840. }
  5841. /*****************************************************************************
  5842. *
  5843. * SirqUpdate - Let the SIRQ update its internal values
  5844. *
  5845. * Description:
  5846. * Just to be sure that the SIRQ module holds its internal data
  5847. * structures up to date, we send an update event before we make
  5848. * any access.
  5849. *
  5850. * Returns:
  5851. * SK_PNMI_ERR_OK Task successfully performed.
  5852. * SK_PNMI_ERR_GENERAL Something went wrong.
  5853. */
  5854. PNMI_STATIC int SirqUpdate(
  5855. SK_AC *pAC, /* Pointer to adapter context */
  5856. SK_IOC IoC) /* IO context handle */
  5857. {
  5858. SK_EVPARA EventParam;
  5859. /* Was the module already updated during the current PNMI call? */
  5860. if (pAC->Pnmi.SirqUpdatedFlag > 0) {
  5861. return (SK_PNMI_ERR_OK);
  5862. }
  5863. /* Send an synchronuous update event to the module */
  5864. SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
  5865. if (SkGeSirqEvent(pAC, IoC, SK_HWEV_UPDATE_STAT, EventParam) > 0) {
  5866. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR047,
  5867. SK_PNMI_ERR047MSG);
  5868. return (SK_PNMI_ERR_GENERAL);
  5869. }
  5870. return (SK_PNMI_ERR_OK);
  5871. }
  5872. /*****************************************************************************
  5873. *
  5874. * RlmtUpdate - Let the RLMT update its internal values
  5875. *
  5876. * Description:
  5877. * Just to be sure that the RLMT module holds its internal data
  5878. * structures up to date, we send an update event before we make
  5879. * any access.
  5880. *
  5881. * Returns:
  5882. * SK_PNMI_ERR_OK Task successfully performed.
  5883. * SK_PNMI_ERR_GENERAL Something went wrong.
  5884. */
  5885. PNMI_STATIC int RlmtUpdate(
  5886. SK_AC *pAC, /* Pointer to adapter context */
  5887. SK_IOC IoC, /* IO context handle */
  5888. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  5889. {
  5890. SK_EVPARA EventParam;
  5891. /* Was the module already updated during the current PNMI call? */
  5892. if (pAC->Pnmi.RlmtUpdatedFlag > 0) {
  5893. return (SK_PNMI_ERR_OK);
  5894. }
  5895. /* Send an synchronuous update event to the module */
  5896. SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
  5897. EventParam.Para32[0] = NetIndex;
  5898. EventParam.Para32[1] = (SK_U32)-1;
  5899. if (SkRlmtEvent(pAC, IoC, SK_RLMT_STATS_UPDATE, EventParam) > 0) {
  5900. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR048,
  5901. SK_PNMI_ERR048MSG);
  5902. return (SK_PNMI_ERR_GENERAL);
  5903. }
  5904. return (SK_PNMI_ERR_OK);
  5905. }
  5906. /*****************************************************************************
  5907. *
  5908. * MacUpdate - Force the XMAC to output the current statistic
  5909. *
  5910. * Description:
  5911. * The XMAC holds its statistic internally. To obtain the current
  5912. * values we send a command so that the statistic data will
  5913. * be written to apredefined memory area on the adapter.
  5914. *
  5915. * Returns:
  5916. * SK_PNMI_ERR_OK Task successfully performed.
  5917. * SK_PNMI_ERR_GENERAL Something went wrong.
  5918. */
  5919. PNMI_STATIC int MacUpdate(
  5920. SK_AC *pAC, /* Pointer to adapter context */
  5921. SK_IOC IoC, /* IO context handle */
  5922. unsigned int FirstMac, /* Index of the first Mac to be updated */
  5923. unsigned int LastMac) /* Index of the last Mac to be updated */
  5924. {
  5925. unsigned int MacIndex;
  5926. /*
  5927. * Were the statistics already updated during the
  5928. * current PNMI call?
  5929. */
  5930. if (pAC->Pnmi.MacUpdatedFlag > 0) {
  5931. return (SK_PNMI_ERR_OK);
  5932. }
  5933. /* Send an update command to all MACs specified */
  5934. for (MacIndex = FirstMac; MacIndex <= LastMac; MacIndex ++) {
  5935. /*
  5936. * 2002-09-13 pweber: Freeze the current sw counters.
  5937. * (That should be done as close as
  5938. * possible to the update of the
  5939. * hw counters)
  5940. */
  5941. if (pAC->GIni.GIMacType == SK_MAC_XMAC) {
  5942. pAC->Pnmi.BufPort[MacIndex] = pAC->Pnmi.Port[MacIndex];
  5943. }
  5944. /* 2002-09-13 pweber: Update the hw counter */
  5945. if (pAC->GIni.GIFunc.pFnMacUpdateStats(pAC, IoC, MacIndex) != 0) {
  5946. return (SK_PNMI_ERR_GENERAL);
  5947. }
  5948. }
  5949. return (SK_PNMI_ERR_OK);
  5950. }
  5951. /*****************************************************************************
  5952. *
  5953. * GetStatVal - Retrieve an XMAC statistic counter
  5954. *
  5955. * Description:
  5956. * Retrieves the statistic counter of a virtual or physical port. The
  5957. * virtual port is identified by the index 0. It consists of all
  5958. * currently active ports. To obtain the counter value for this port
  5959. * we must add the statistic counter of all active ports. To grant
  5960. * continuous counter values for the virtual port even when port
  5961. * switches occur we must additionally add a delta value, which was
  5962. * calculated during a SK_PNMI_EVT_RLMT_ACTIVE_UP event.
  5963. *
  5964. * Returns:
  5965. * Requested statistic value
  5966. */
  5967. PNMI_STATIC SK_U64 GetStatVal(
  5968. SK_AC *pAC, /* Pointer to adapter context */
  5969. SK_IOC IoC, /* IO context handle */
  5970. unsigned int LogPortIndex, /* Index of the logical Port to be processed */
  5971. unsigned int StatIndex, /* Index to statistic value */
  5972. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  5973. {
  5974. unsigned int PhysPortIndex;
  5975. unsigned int PhysPortMax;
  5976. SK_U64 Val = 0;
  5977. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) { /* Dual net mode */
  5978. PhysPortIndex = NetIndex;
  5979. Val = GetPhysStatVal(pAC, IoC, PhysPortIndex, StatIndex);
  5980. }
  5981. else { /* Single Net mode */
  5982. if (LogPortIndex == 0) {
  5983. PhysPortMax = pAC->GIni.GIMacsFound;
  5984. /* Add counter of all active ports */
  5985. for (PhysPortIndex = 0; PhysPortIndex < PhysPortMax;
  5986. PhysPortIndex ++) {
  5987. if (pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) {
  5988. Val += GetPhysStatVal(pAC, IoC, PhysPortIndex,
  5989. StatIndex);
  5990. }
  5991. }
  5992. /* Correct value because of port switches */
  5993. Val += pAC->Pnmi.VirtualCounterOffset[StatIndex];
  5994. }
  5995. else {
  5996. /* Get counter value of physical port */
  5997. PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
  5998. Val = GetPhysStatVal(pAC, IoC, PhysPortIndex, StatIndex);
  5999. }
  6000. }
  6001. return (Val);
  6002. }
  6003. /*****************************************************************************
  6004. *
  6005. * GetPhysStatVal - Get counter value for physical port
  6006. *
  6007. * Description:
  6008. * Builds a 64bit counter value. Except for the octet counters
  6009. * the lower 32bit are counted in hardware and the upper 32bit
  6010. * in software by monitoring counter overflow interrupts in the
  6011. * event handler. To grant continous counter values during XMAC
  6012. * resets (caused by a workaround) we must add a delta value.
  6013. * The delta was calculated in the event handler when a
  6014. * SK_PNMI_EVT_XMAC_RESET was received.
  6015. *
  6016. * Returns:
  6017. * Counter value
  6018. */
  6019. PNMI_STATIC SK_U64 GetPhysStatVal(
  6020. SK_AC *pAC, /* Pointer to adapter context */
  6021. SK_IOC IoC, /* IO context handle */
  6022. unsigned int PhysPortIndex, /* Index of the logical Port to be processed */
  6023. unsigned int StatIndex) /* Index to statistic value */
  6024. {
  6025. SK_U64 Val = 0;
  6026. SK_U32 LowVal = 0;
  6027. SK_U32 HighVal = 0;
  6028. SK_U16 Word;
  6029. int MacType;
  6030. SK_PNMI_PORT *pPnmiPrt;
  6031. SK_GEMACFUNC *pFnMac;
  6032. MacType = pAC->GIni.GIMacType;
  6033. /* 2002-09-17 pweber: For XMAC, use the frozen sw counters (BufPort) */
  6034. if (pAC->GIni.GIMacType == SK_MAC_XMAC) {
  6035. pPnmiPrt = &pAC->Pnmi.BufPort[PhysPortIndex];
  6036. }
  6037. else {
  6038. pPnmiPrt = &pAC->Pnmi.Port[PhysPortIndex];
  6039. }
  6040. pFnMac = &pAC->GIni.GIFunc;
  6041. switch (StatIndex) {
  6042. case SK_PNMI_HTX:
  6043. case SK_PNMI_HRX:
  6044. /* Not supported by GMAC */
  6045. if (MacType == SK_MAC_GMAC) {
  6046. return (Val);
  6047. }
  6048. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6049. StatAddr[StatIndex][MacType].Reg,
  6050. &LowVal);
  6051. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6052. break;
  6053. case SK_PNMI_HTX_OCTET:
  6054. case SK_PNMI_HRX_OCTET:
  6055. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6056. StatAddr[StatIndex][MacType].Reg,
  6057. &HighVal);
  6058. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6059. StatAddr[StatIndex + 1][MacType].Reg,
  6060. &LowVal);
  6061. break;
  6062. case SK_PNMI_HTX_BURST:
  6063. case SK_PNMI_HTX_EXCESS_DEF:
  6064. case SK_PNMI_HTX_CARRIER:
  6065. /* Not supported by GMAC */
  6066. if (MacType == SK_MAC_GMAC) {
  6067. return (Val);
  6068. }
  6069. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6070. StatAddr[StatIndex][MacType].Reg,
  6071. &LowVal);
  6072. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6073. break;
  6074. case SK_PNMI_HTX_MACC:
  6075. /* GMAC only supports PAUSE MAC control frames */
  6076. if (MacType == SK_MAC_GMAC) {
  6077. Val = GetPhysStatVal(pAC, IoC, PhysPortIndex, SK_PNMI_HTX_PMACC);
  6078. return (Val);
  6079. }
  6080. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6081. StatAddr[StatIndex][MacType].Reg,
  6082. &LowVal);
  6083. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6084. break;
  6085. case SK_PNMI_HTX_COL:
  6086. case SK_PNMI_HRX_UNDERSIZE:
  6087. /* Not supported by XMAC */
  6088. if (MacType == SK_MAC_XMAC) {
  6089. return (Val);
  6090. }
  6091. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6092. StatAddr[StatIndex][MacType].Reg,
  6093. &LowVal);
  6094. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6095. break;
  6096. case SK_PNMI_HTX_DEFFERAL:
  6097. /* Not supported by GMAC */
  6098. if (MacType == SK_MAC_GMAC) {
  6099. return (Val);
  6100. }
  6101. /*
  6102. * XMAC counts frames with deferred transmission
  6103. * even in full-duplex mode.
  6104. *
  6105. * In full-duplex mode the counter remains constant!
  6106. */
  6107. if ((pAC->GIni.GP[PhysPortIndex].PLinkModeStatus == SK_LMODE_STAT_AUTOFULL) ||
  6108. (pAC->GIni.GP[PhysPortIndex].PLinkModeStatus == SK_LMODE_STAT_FULL)) {
  6109. LowVal = 0;
  6110. HighVal = 0;
  6111. }
  6112. else {
  6113. /* Otherwise get contents of hardware register. */
  6114. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6115. StatAddr[SK_PNMI_HTX_DEFFERAL][MacType].Reg,
  6116. &LowVal);
  6117. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6118. }
  6119. break;
  6120. case SK_PNMI_HRX_BADOCTET:
  6121. /* Not supported by XMAC */
  6122. if (MacType == SK_MAC_XMAC) {
  6123. return (Val);
  6124. }
  6125. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6126. StatAddr[StatIndex][MacType].Reg,
  6127. &HighVal);
  6128. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6129. StatAddr[StatIndex + 1][MacType].Reg,
  6130. &LowVal);
  6131. break;
  6132. case SK_PNMI_HTX_OCTETLOW:
  6133. case SK_PNMI_HRX_OCTETLOW:
  6134. case SK_PNMI_HRX_BADOCTETLOW:
  6135. return (Val);
  6136. case SK_PNMI_HRX_LONGFRAMES:
  6137. /* For XMAC the SW counter is managed by PNMI */
  6138. if (MacType == SK_MAC_XMAC) {
  6139. return (pPnmiPrt->StatRxLongFrameCts);
  6140. }
  6141. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6142. StatAddr[StatIndex][MacType].Reg,
  6143. &LowVal);
  6144. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6145. break;
  6146. case SK_PNMI_HRX_TOO_LONG:
  6147. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6148. StatAddr[StatIndex][MacType].Reg,
  6149. &LowVal);
  6150. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6151. Val = (((SK_U64)HighVal << 32) | (SK_U64)LowVal);
  6152. switch (MacType) {
  6153. case SK_MAC_GMAC:
  6154. /* For GMAC the SW counter is additionally managed by PNMI */
  6155. Val += pPnmiPrt->StatRxFrameTooLongCts;
  6156. break;
  6157. case SK_MAC_XMAC:
  6158. /*
  6159. * Frames longer than IEEE 802.3 frame max size are counted
  6160. * by XMAC in frame_too_long counter even reception of long
  6161. * frames was enabled and the frame was correct.
  6162. * So correct the value by subtracting RxLongFrame counter.
  6163. */
  6164. Val -= pPnmiPrt->StatRxLongFrameCts;
  6165. break;
  6166. default:
  6167. break;
  6168. }
  6169. LowVal = (SK_U32)Val;
  6170. HighVal = (SK_U32)(Val >> 32);
  6171. break;
  6172. case SK_PNMI_HRX_SHORTS:
  6173. /* Not supported by GMAC */
  6174. if (MacType == SK_MAC_GMAC) {
  6175. /* GM_RXE_FRAG?? */
  6176. return (Val);
  6177. }
  6178. /*
  6179. * XMAC counts short frame errors even if link down (#10620)
  6180. *
  6181. * If link-down the counter remains constant
  6182. */
  6183. if (pAC->GIni.GP[PhysPortIndex].PLinkModeStatus != SK_LMODE_STAT_UNKNOWN) {
  6184. /* Otherwise get incremental difference */
  6185. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6186. StatAddr[StatIndex][MacType].Reg,
  6187. &LowVal);
  6188. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6189. Val = (((SK_U64)HighVal << 32) | (SK_U64)LowVal);
  6190. Val -= pPnmiPrt->RxShortZeroMark;
  6191. LowVal = (SK_U32)Val;
  6192. HighVal = (SK_U32)(Val >> 32);
  6193. }
  6194. break;
  6195. case SK_PNMI_HRX_MACC:
  6196. case SK_PNMI_HRX_MACC_UNKWN:
  6197. case SK_PNMI_HRX_BURST:
  6198. case SK_PNMI_HRX_MISSED:
  6199. case SK_PNMI_HRX_FRAMING:
  6200. case SK_PNMI_HRX_CARRIER:
  6201. case SK_PNMI_HRX_IRLENGTH:
  6202. case SK_PNMI_HRX_SYMBOL:
  6203. case SK_PNMI_HRX_CEXT:
  6204. /* Not supported by GMAC */
  6205. if (MacType == SK_MAC_GMAC) {
  6206. /* GM_RXE_FRAG?? */
  6207. return (Val);
  6208. }
  6209. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6210. StatAddr[StatIndex][MacType].Reg,
  6211. &LowVal);
  6212. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6213. break;
  6214. case SK_PNMI_HRX_PMACC_ERR:
  6215. /* For GMAC the SW counter is managed by PNMI */
  6216. if (MacType == SK_MAC_GMAC) {
  6217. return (pPnmiPrt->StatRxPMaccErr);
  6218. }
  6219. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6220. StatAddr[StatIndex][MacType].Reg,
  6221. &LowVal);
  6222. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6223. break;
  6224. /* SW counter managed by PNMI */
  6225. case SK_PNMI_HTX_SYNC:
  6226. LowVal = (SK_U32)pPnmiPrt->StatSyncCts;
  6227. HighVal = (SK_U32)(pPnmiPrt->StatSyncCts >> 32);
  6228. break;
  6229. /* SW counter managed by PNMI */
  6230. case SK_PNMI_HTX_SYNC_OCTET:
  6231. LowVal = (SK_U32)pPnmiPrt->StatSyncOctetsCts;
  6232. HighVal = (SK_U32)(pPnmiPrt->StatSyncOctetsCts >> 32);
  6233. break;
  6234. case SK_PNMI_HRX_FCS:
  6235. /*
  6236. * Broadcom filters fcs errors and counts it in
  6237. * Receive Error Counter register
  6238. */
  6239. if (pAC->GIni.GP[PhysPortIndex].PhyType == SK_PHY_BCOM) {
  6240. /* do not read while not initialized (PHY_READ hangs!)*/
  6241. if (pAC->GIni.GP[PhysPortIndex].PState) {
  6242. PHY_READ(IoC, &pAC->GIni.GP[PhysPortIndex],
  6243. PhysPortIndex, PHY_BCOM_RE_CTR,
  6244. &Word);
  6245. LowVal = Word;
  6246. }
  6247. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6248. }
  6249. else {
  6250. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6251. StatAddr[StatIndex][MacType].Reg,
  6252. &LowVal);
  6253. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6254. }
  6255. break;
  6256. default:
  6257. (void)pFnMac->pFnMacStatistic(pAC, IoC, PhysPortIndex,
  6258. StatAddr[StatIndex][MacType].Reg,
  6259. &LowVal);
  6260. HighVal = pPnmiPrt->CounterHigh[StatIndex];
  6261. break;
  6262. }
  6263. Val = (((SK_U64)HighVal << 32) | (SK_U64)LowVal);
  6264. /* Correct value because of possible XMAC reset. XMAC Errata #2 */
  6265. Val += pPnmiPrt->CounterOffset[StatIndex];
  6266. return (Val);
  6267. }
  6268. /*****************************************************************************
  6269. *
  6270. * ResetCounter - Set all counters and timestamps to zero
  6271. *
  6272. * Description:
  6273. * Notifies other common modules which store statistic data to
  6274. * reset their counters and finally reset our own counters.
  6275. *
  6276. * Returns:
  6277. * Nothing
  6278. */
  6279. PNMI_STATIC void ResetCounter(
  6280. SK_AC *pAC, /* Pointer to adapter context */
  6281. SK_IOC IoC, /* IO context handle */
  6282. SK_U32 NetIndex)
  6283. {
  6284. unsigned int PhysPortIndex;
  6285. SK_EVPARA EventParam;
  6286. SK_MEMSET((char *)&EventParam, 0, sizeof(EventParam));
  6287. /* Notify sensor module */
  6288. SkEventQueue(pAC, SKGE_I2C, SK_I2CEV_CLEAR, EventParam);
  6289. /* Notify RLMT module */
  6290. EventParam.Para32[0] = NetIndex;
  6291. EventParam.Para32[1] = (SK_U32)-1;
  6292. SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STATS_CLEAR, EventParam);
  6293. EventParam.Para32[1] = 0;
  6294. /* Notify SIRQ module */
  6295. SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_CLEAR_STAT, EventParam);
  6296. /* Notify CSUM module */
  6297. #ifdef SK_USE_CSUM
  6298. EventParam.Para32[0] = NetIndex;
  6299. EventParam.Para32[1] = (SK_U32)-1;
  6300. SkEventQueue(pAC, SKGE_CSUM, SK_CSUM_EVENT_CLEAR_PROTO_STATS,
  6301. EventParam);
  6302. #endif
  6303. /* Clear XMAC statistic */
  6304. for (PhysPortIndex = 0; PhysPortIndex <
  6305. (unsigned int)pAC->GIni.GIMacsFound; PhysPortIndex ++) {
  6306. (void)pAC->GIni.GIFunc.pFnMacResetCounter(pAC, IoC, PhysPortIndex);
  6307. SK_MEMSET((char *)&pAC->Pnmi.Port[PhysPortIndex].CounterHigh,
  6308. 0, sizeof(pAC->Pnmi.Port[PhysPortIndex].CounterHigh));
  6309. SK_MEMSET((char *)&pAC->Pnmi.Port[PhysPortIndex].
  6310. CounterOffset, 0, sizeof(pAC->Pnmi.Port[
  6311. PhysPortIndex].CounterOffset));
  6312. SK_MEMSET((char *)&pAC->Pnmi.Port[PhysPortIndex].StatSyncCts,
  6313. 0, sizeof(pAC->Pnmi.Port[PhysPortIndex].StatSyncCts));
  6314. SK_MEMSET((char *)&pAC->Pnmi.Port[PhysPortIndex].
  6315. StatSyncOctetsCts, 0, sizeof(pAC->Pnmi.Port[
  6316. PhysPortIndex].StatSyncOctetsCts));
  6317. SK_MEMSET((char *)&pAC->Pnmi.Port[PhysPortIndex].
  6318. StatRxLongFrameCts, 0, sizeof(pAC->Pnmi.Port[
  6319. PhysPortIndex].StatRxLongFrameCts));
  6320. SK_MEMSET((char *)&pAC->Pnmi.Port[PhysPortIndex].
  6321. StatRxFrameTooLongCts, 0, sizeof(pAC->Pnmi.Port[
  6322. PhysPortIndex].StatRxFrameTooLongCts));
  6323. SK_MEMSET((char *)&pAC->Pnmi.Port[PhysPortIndex].
  6324. StatRxPMaccErr, 0, sizeof(pAC->Pnmi.Port[
  6325. PhysPortIndex].StatRxPMaccErr));
  6326. }
  6327. /*
  6328. * Clear local statistics
  6329. */
  6330. SK_MEMSET((char *)&pAC->Pnmi.VirtualCounterOffset, 0,
  6331. sizeof(pAC->Pnmi.VirtualCounterOffset));
  6332. pAC->Pnmi.RlmtChangeCts = 0;
  6333. pAC->Pnmi.RlmtChangeTime = 0;
  6334. SK_MEMSET((char *)&pAC->Pnmi.RlmtChangeEstimate.EstValue[0], 0,
  6335. sizeof(pAC->Pnmi.RlmtChangeEstimate.EstValue));
  6336. pAC->Pnmi.RlmtChangeEstimate.EstValueIndex = 0;
  6337. pAC->Pnmi.RlmtChangeEstimate.Estimate = 0;
  6338. pAC->Pnmi.Port[NetIndex].TxSwQueueMax = 0;
  6339. pAC->Pnmi.Port[NetIndex].TxRetryCts = 0;
  6340. pAC->Pnmi.Port[NetIndex].RxIntrCts = 0;
  6341. pAC->Pnmi.Port[NetIndex].TxIntrCts = 0;
  6342. pAC->Pnmi.Port[NetIndex].RxNoBufCts = 0;
  6343. pAC->Pnmi.Port[NetIndex].TxNoBufCts = 0;
  6344. pAC->Pnmi.Port[NetIndex].TxUsedDescrNo = 0;
  6345. pAC->Pnmi.Port[NetIndex].RxDeliveredCts = 0;
  6346. pAC->Pnmi.Port[NetIndex].RxOctetsDeliveredCts = 0;
  6347. pAC->Pnmi.Port[NetIndex].ErrRecoveryCts = 0;
  6348. }
  6349. /*****************************************************************************
  6350. *
  6351. * GetTrapEntry - Get an entry in the trap buffer
  6352. *
  6353. * Description:
  6354. * The trap buffer stores various events. A user application somehow
  6355. * gets notified that an event occured and retrieves the trap buffer
  6356. * contens (or simply polls the buffer). The buffer is organized as
  6357. * a ring which stores the newest traps at the beginning. The oldest
  6358. * traps are overwritten by the newest ones. Each trap entry has a
  6359. * unique number, so that applications may detect new trap entries.
  6360. *
  6361. * Returns:
  6362. * A pointer to the trap entry
  6363. */
  6364. PNMI_STATIC char* GetTrapEntry(
  6365. SK_AC *pAC, /* Pointer to adapter context */
  6366. SK_U32 TrapId, /* SNMP ID of the trap */
  6367. unsigned int Size) /* Space needed for trap entry */
  6368. {
  6369. unsigned int BufPad = pAC->Pnmi.TrapBufPad;
  6370. unsigned int BufFree = pAC->Pnmi.TrapBufFree;
  6371. unsigned int Beg = pAC->Pnmi.TrapQueueBeg;
  6372. unsigned int End = pAC->Pnmi.TrapQueueEnd;
  6373. char *pBuf = &pAC->Pnmi.TrapBuf[0];
  6374. int Wrap;
  6375. unsigned int NeededSpace;
  6376. unsigned int EntrySize;
  6377. SK_U32 Val32;
  6378. SK_U64 Val64;
  6379. /* Last byte of entry will get a copy of the entry length */
  6380. Size ++;
  6381. /*
  6382. * Calculate needed buffer space */
  6383. if (Beg >= Size) {
  6384. NeededSpace = Size;
  6385. Wrap = SK_FALSE;
  6386. }
  6387. else {
  6388. NeededSpace = Beg + Size;
  6389. Wrap = SK_TRUE;
  6390. }
  6391. /*
  6392. * Check if enough buffer space is provided. Otherwise
  6393. * free some entries. Leave one byte space between begin
  6394. * and end of buffer to make it possible to detect whether
  6395. * the buffer is full or empty
  6396. */
  6397. while (BufFree < NeededSpace + 1) {
  6398. if (End == 0) {
  6399. End = SK_PNMI_TRAP_QUEUE_LEN;
  6400. }
  6401. EntrySize = (unsigned int)*((unsigned char *)pBuf + End - 1);
  6402. BufFree += EntrySize;
  6403. End -= EntrySize;
  6404. #ifdef DEBUG
  6405. SK_MEMSET(pBuf + End, (char)(-1), EntrySize);
  6406. #endif
  6407. if (End == BufPad) {
  6408. #ifdef DEBUG
  6409. SK_MEMSET(pBuf, (char)(-1), End);
  6410. #endif
  6411. BufFree += End;
  6412. End = 0;
  6413. BufPad = 0;
  6414. }
  6415. }
  6416. /*
  6417. * Insert new entry as first entry. Newest entries are
  6418. * stored at the beginning of the queue.
  6419. */
  6420. if (Wrap) {
  6421. BufPad = Beg;
  6422. Beg = SK_PNMI_TRAP_QUEUE_LEN - Size;
  6423. }
  6424. else {
  6425. Beg = Beg - Size;
  6426. }
  6427. BufFree -= NeededSpace;
  6428. /* Save the current offsets */
  6429. pAC->Pnmi.TrapQueueBeg = Beg;
  6430. pAC->Pnmi.TrapQueueEnd = End;
  6431. pAC->Pnmi.TrapBufPad = BufPad;
  6432. pAC->Pnmi.TrapBufFree = BufFree;
  6433. /* Initialize the trap entry */
  6434. *(pBuf + Beg + Size - 1) = (char)Size;
  6435. *(pBuf + Beg) = (char)Size;
  6436. Val32 = (pAC->Pnmi.TrapUnique) ++;
  6437. SK_PNMI_STORE_U32(pBuf + Beg + 1, Val32);
  6438. SK_PNMI_STORE_U32(pBuf + Beg + 1 + sizeof(SK_U32), TrapId);
  6439. Val64 = SK_PNMI_HUNDREDS_SEC(SkOsGetTime(pAC));
  6440. SK_PNMI_STORE_U64(pBuf + Beg + 1 + 2 * sizeof(SK_U32), Val64);
  6441. return (pBuf + Beg);
  6442. }
  6443. /*****************************************************************************
  6444. *
  6445. * CopyTrapQueue - Copies the trap buffer for the TRAP OID
  6446. *
  6447. * Description:
  6448. * On a query of the TRAP OID the trap buffer contents will be
  6449. * copied continuously to the request buffer, which must be large
  6450. * enough. No length check is performed.
  6451. *
  6452. * Returns:
  6453. * Nothing
  6454. */
  6455. PNMI_STATIC void CopyTrapQueue(
  6456. SK_AC *pAC, /* Pointer to adapter context */
  6457. char *pDstBuf) /* Buffer to which the queued traps will be copied */
  6458. {
  6459. unsigned int BufPad = pAC->Pnmi.TrapBufPad;
  6460. unsigned int Trap = pAC->Pnmi.TrapQueueBeg;
  6461. unsigned int End = pAC->Pnmi.TrapQueueEnd;
  6462. char *pBuf = &pAC->Pnmi.TrapBuf[0];
  6463. unsigned int Len;
  6464. unsigned int DstOff = 0;
  6465. while (Trap != End) {
  6466. Len = (unsigned int)*(pBuf + Trap);
  6467. /*
  6468. * Last byte containing a copy of the length will
  6469. * not be copied.
  6470. */
  6471. *(pDstBuf + DstOff) = (char)(Len - 1);
  6472. SK_MEMCPY(pDstBuf + DstOff + 1, pBuf + Trap + 1, Len - 2);
  6473. DstOff += Len - 1;
  6474. Trap += Len;
  6475. if (Trap == SK_PNMI_TRAP_QUEUE_LEN) {
  6476. Trap = BufPad;
  6477. }
  6478. }
  6479. }
  6480. /*****************************************************************************
  6481. *
  6482. * GetTrapQueueLen - Get the length of the trap buffer
  6483. *
  6484. * Description:
  6485. * Evaluates the number of currently stored traps and the needed
  6486. * buffer size to retrieve them.
  6487. *
  6488. * Returns:
  6489. * Nothing
  6490. */
  6491. PNMI_STATIC void GetTrapQueueLen(
  6492. SK_AC *pAC, /* Pointer to adapter context */
  6493. unsigned int *pLen, /* Length in Bytes of all queued traps */
  6494. unsigned int *pEntries) /* Returns number of trapes stored in queue */
  6495. {
  6496. unsigned int BufPad = pAC->Pnmi.TrapBufPad;
  6497. unsigned int Trap = pAC->Pnmi.TrapQueueBeg;
  6498. unsigned int End = pAC->Pnmi.TrapQueueEnd;
  6499. char *pBuf = &pAC->Pnmi.TrapBuf[0];
  6500. unsigned int Len;
  6501. unsigned int Entries = 0;
  6502. unsigned int TotalLen = 0;
  6503. while (Trap != End) {
  6504. Len = (unsigned int)*(pBuf + Trap);
  6505. TotalLen += Len - 1;
  6506. Entries ++;
  6507. Trap += Len;
  6508. if (Trap == SK_PNMI_TRAP_QUEUE_LEN) {
  6509. Trap = BufPad;
  6510. }
  6511. }
  6512. *pEntries = Entries;
  6513. *pLen = TotalLen;
  6514. }
  6515. /*****************************************************************************
  6516. *
  6517. * QueueSimpleTrap - Store a simple trap to the trap buffer
  6518. *
  6519. * Description:
  6520. * A simple trap is a trap with now additional data. It consists
  6521. * simply of a trap code.
  6522. *
  6523. * Returns:
  6524. * Nothing
  6525. */
  6526. PNMI_STATIC void QueueSimpleTrap(
  6527. SK_AC *pAC, /* Pointer to adapter context */
  6528. SK_U32 TrapId) /* Type of sensor trap */
  6529. {
  6530. GetTrapEntry(pAC, TrapId, SK_PNMI_TRAP_SIMPLE_LEN);
  6531. }
  6532. /*****************************************************************************
  6533. *
  6534. * QueueSensorTrap - Stores a sensor trap in the trap buffer
  6535. *
  6536. * Description:
  6537. * Gets an entry in the trap buffer and fills it with sensor related
  6538. * data.
  6539. *
  6540. * Returns:
  6541. * Nothing
  6542. */
  6543. PNMI_STATIC void QueueSensorTrap(
  6544. SK_AC *pAC, /* Pointer to adapter context */
  6545. SK_U32 TrapId, /* Type of sensor trap */
  6546. unsigned int SensorIndex) /* Index of sensor which caused the trap */
  6547. {
  6548. char *pBuf;
  6549. unsigned int Offset;
  6550. unsigned int DescrLen;
  6551. SK_U32 Val32;
  6552. /* Get trap buffer entry */
  6553. DescrLen = SK_STRLEN(pAC->I2c.SenTable[SensorIndex].SenDesc);
  6554. pBuf = GetTrapEntry(pAC, TrapId,
  6555. SK_PNMI_TRAP_SENSOR_LEN_BASE + DescrLen);
  6556. Offset = SK_PNMI_TRAP_SIMPLE_LEN;
  6557. /* Store additionally sensor trap related data */
  6558. Val32 = OID_SKGE_SENSOR_INDEX;
  6559. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  6560. *(pBuf + Offset + 4) = 4;
  6561. Val32 = (SK_U32)SensorIndex;
  6562. SK_PNMI_STORE_U32(pBuf + Offset + 5, Val32);
  6563. Offset += 9;
  6564. Val32 = (SK_U32)OID_SKGE_SENSOR_DESCR;
  6565. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  6566. *(pBuf + Offset + 4) = (char)DescrLen;
  6567. SK_MEMCPY(pBuf + Offset + 5, pAC->I2c.SenTable[SensorIndex].SenDesc,
  6568. DescrLen);
  6569. Offset += DescrLen + 5;
  6570. Val32 = OID_SKGE_SENSOR_TYPE;
  6571. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  6572. *(pBuf + Offset + 4) = 1;
  6573. *(pBuf + Offset + 5) = (char)pAC->I2c.SenTable[SensorIndex].SenType;
  6574. Offset += 6;
  6575. Val32 = OID_SKGE_SENSOR_VALUE;
  6576. SK_PNMI_STORE_U32(pBuf + Offset, Val32);
  6577. *(pBuf + Offset + 4) = 4;
  6578. Val32 = (SK_U32)pAC->I2c.SenTable[SensorIndex].SenValue;
  6579. SK_PNMI_STORE_U32(pBuf + Offset + 5, Val32);
  6580. }
  6581. /*****************************************************************************
  6582. *
  6583. * QueueRlmtNewMacTrap - Store a port switch trap in the trap buffer
  6584. *
  6585. * Description:
  6586. * Nothing further to explain.
  6587. *
  6588. * Returns:
  6589. * Nothing
  6590. */
  6591. PNMI_STATIC void QueueRlmtNewMacTrap(
  6592. SK_AC *pAC, /* Pointer to adapter context */
  6593. unsigned int ActiveMac) /* Index (0..n) of the currently active port */
  6594. {
  6595. char *pBuf;
  6596. SK_U32 Val32;
  6597. pBuf = GetTrapEntry(pAC, OID_SKGE_TRAP_RLMT_CHANGE_PORT,
  6598. SK_PNMI_TRAP_RLMT_CHANGE_LEN);
  6599. Val32 = OID_SKGE_RLMT_PORT_ACTIVE;
  6600. SK_PNMI_STORE_U32(pBuf + SK_PNMI_TRAP_SIMPLE_LEN, Val32);
  6601. *(pBuf + SK_PNMI_TRAP_SIMPLE_LEN + 4) = 1;
  6602. *(pBuf + SK_PNMI_TRAP_SIMPLE_LEN + 5) = (char)ActiveMac;
  6603. }
  6604. /*****************************************************************************
  6605. *
  6606. * QueueRlmtPortTrap - Store port related RLMT trap to trap buffer
  6607. *
  6608. * Description:
  6609. * Nothing further to explain.
  6610. *
  6611. * Returns:
  6612. * Nothing
  6613. */
  6614. PNMI_STATIC void QueueRlmtPortTrap(
  6615. SK_AC *pAC, /* Pointer to adapter context */
  6616. SK_U32 TrapId, /* Type of RLMT port trap */
  6617. unsigned int PortIndex) /* Index of the port, which changed its state */
  6618. {
  6619. char *pBuf;
  6620. SK_U32 Val32;
  6621. pBuf = GetTrapEntry(pAC, TrapId, SK_PNMI_TRAP_RLMT_PORT_LEN);
  6622. Val32 = OID_SKGE_RLMT_PORT_INDEX;
  6623. SK_PNMI_STORE_U32(pBuf + SK_PNMI_TRAP_SIMPLE_LEN, Val32);
  6624. *(pBuf + SK_PNMI_TRAP_SIMPLE_LEN + 4) = 1;
  6625. *(pBuf + SK_PNMI_TRAP_SIMPLE_LEN + 5) = (char)PortIndex;
  6626. }
  6627. /*****************************************************************************
  6628. *
  6629. * CopyMac - Copies a MAC address
  6630. *
  6631. * Description:
  6632. * Nothing further to explain.
  6633. *
  6634. * Returns:
  6635. * Nothing
  6636. */
  6637. PNMI_STATIC void CopyMac(
  6638. char *pDst, /* Pointer to destination buffer */
  6639. SK_MAC_ADDR *pMac) /* Pointer of Source */
  6640. {
  6641. int i;
  6642. for (i = 0; i < sizeof(SK_MAC_ADDR); i ++) {
  6643. *(pDst + i) = pMac->a[i];
  6644. }
  6645. }
  6646. #ifdef SK_POWER_MGMT
  6647. /*****************************************************************************
  6648. *
  6649. * PowerManagement - OID handler function of PowerManagement OIDs
  6650. *
  6651. * Description:
  6652. * The code is simple. No description necessary.
  6653. *
  6654. * Returns:
  6655. * SK_PNMI_ERR_OK The request was successfully performed.
  6656. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  6657. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  6658. * the correct data (e.g. a 32bit value is
  6659. * needed, but a 16 bit value was passed).
  6660. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  6661. * exist (e.g. port instance 3 on a two port
  6662. * adapter.
  6663. */
  6664. PNMI_STATIC int PowerManagement(
  6665. SK_AC *pAC, /* Pointer to adapter context */
  6666. SK_IOC IoC, /* IO context handle */
  6667. int Action, /* Get/PreSet/Set action */
  6668. SK_U32 Id, /* Object ID that is to be processed */
  6669. char *pBuf, /* Buffer to which to mgmt data will be retrieved */
  6670. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  6671. SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */
  6672. unsigned int TableIndex, /* Index to the Id table */
  6673. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode allways zero */
  6674. {
  6675. SK_U32 RetCode = SK_PNMI_ERR_GENERAL;
  6676. /*
  6677. * Check instance. We only handle single instance variables
  6678. */
  6679. if (Instance != (SK_U32)(-1) && Instance != 1) {
  6680. *pLen = 0;
  6681. return (SK_PNMI_ERR_UNKNOWN_INST);
  6682. }
  6683. /*
  6684. * Perform action
  6685. */
  6686. if (Action == SK_PNMI_GET) {
  6687. /*
  6688. * Check length
  6689. */
  6690. switch (Id) {
  6691. case OID_PNP_CAPABILITIES:
  6692. if (*pLen < sizeof(SK_PNP_CAPABILITIES)) {
  6693. *pLen = sizeof(SK_PNP_CAPABILITIES);
  6694. return (SK_PNMI_ERR_TOO_SHORT);
  6695. }
  6696. break;
  6697. case OID_PNP_QUERY_POWER:
  6698. case OID_PNP_ENABLE_WAKE_UP:
  6699. if (*pLen < sizeof(SK_U32)) {
  6700. *pLen = sizeof(SK_U32);
  6701. return (SK_PNMI_ERR_TOO_SHORT);
  6702. }
  6703. break;
  6704. case OID_PNP_SET_POWER:
  6705. case OID_PNP_ADD_WAKE_UP_PATTERN:
  6706. case OID_PNP_REMOVE_WAKE_UP_PATTERN:
  6707. break;
  6708. default:
  6709. SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR040,
  6710. SK_PNMI_ERR040MSG);
  6711. *pLen = 0;
  6712. return (SK_PNMI_ERR_GENERAL);
  6713. }
  6714. /*
  6715. * Get value
  6716. */
  6717. switch (Id) {
  6718. case OID_PNP_CAPABILITIES:
  6719. RetCode = SkPowerQueryPnPCapabilities(pAC, IoC, pBuf, pLen);
  6720. break;
  6721. case OID_PNP_QUERY_POWER:
  6722. /* The Windows DDK describes: An OID_PNP_QUERY_POWER requests
  6723. the miniport to indicate whether it can transition its NIC
  6724. to the low-power state.
  6725. A miniport driver must always return NDIS_STATUS_SUCCESS
  6726. to a query of OID_PNP_QUERY_POWER. */
  6727. RetCode = SK_PNMI_ERR_OK;
  6728. break;
  6729. /* NDIS handles these OIDs as write-only.
  6730. * So in case of get action the buffer with written length = 0
  6731. * is returned
  6732. */
  6733. case OID_PNP_SET_POWER:
  6734. case OID_PNP_ADD_WAKE_UP_PATTERN:
  6735. case OID_PNP_REMOVE_WAKE_UP_PATTERN:
  6736. *pLen = 0;
  6737. RetCode = SK_PNMI_ERR_OK;
  6738. break;
  6739. case OID_PNP_ENABLE_WAKE_UP:
  6740. RetCode = SkPowerGetEnableWakeUp(pAC, IoC, pBuf, pLen);
  6741. break;
  6742. default:
  6743. RetCode = SK_PNMI_ERR_GENERAL;
  6744. break;
  6745. }
  6746. return (RetCode);
  6747. }
  6748. /*
  6749. * From here SET or PRESET action. Check if the passed
  6750. * buffer length is plausible.
  6751. */
  6752. switch (Id) {
  6753. case OID_PNP_SET_POWER:
  6754. case OID_PNP_ENABLE_WAKE_UP:
  6755. if (*pLen < sizeof(SK_U32)) {
  6756. *pLen = sizeof(SK_U32);
  6757. return (SK_PNMI_ERR_TOO_SHORT);
  6758. }
  6759. if (*pLen != sizeof(SK_U32)) {
  6760. *pLen = 0;
  6761. return (SK_PNMI_ERR_BAD_VALUE);
  6762. }
  6763. break;
  6764. case OID_PNP_ADD_WAKE_UP_PATTERN:
  6765. case OID_PNP_REMOVE_WAKE_UP_PATTERN:
  6766. if (*pLen < sizeof(SK_PM_PACKET_PATTERN)) {
  6767. *pLen = 0;
  6768. return (SK_PNMI_ERR_BAD_VALUE);
  6769. }
  6770. break;
  6771. default:
  6772. *pLen = 0;
  6773. return (SK_PNMI_ERR_READ_ONLY);
  6774. }
  6775. /*
  6776. * Perform preset or set
  6777. */
  6778. /* POWER module does not support PRESET action */
  6779. if (Action == SK_PNMI_PRESET) {
  6780. return (SK_PNMI_ERR_OK);
  6781. }
  6782. switch (Id) {
  6783. case OID_PNP_SET_POWER:
  6784. RetCode = SkPowerSetPower(pAC, IoC, pBuf, pLen);
  6785. break;
  6786. case OID_PNP_ADD_WAKE_UP_PATTERN:
  6787. RetCode = SkPowerAddWakeUpPattern(pAC, IoC, pBuf, pLen);
  6788. break;
  6789. case OID_PNP_REMOVE_WAKE_UP_PATTERN:
  6790. RetCode = SkPowerRemoveWakeUpPattern(pAC, IoC, pBuf, pLen);
  6791. break;
  6792. case OID_PNP_ENABLE_WAKE_UP:
  6793. RetCode = SkPowerSetEnableWakeUp(pAC, IoC, pBuf, pLen);
  6794. break;
  6795. default:
  6796. RetCode = SK_PNMI_ERR_GENERAL;
  6797. }
  6798. return (RetCode);
  6799. }
  6800. #endif /* SK_POWER_MGMT */
  6801. /*****************************************************************************
  6802. *
  6803. * Vct - OID handler function of OIDs
  6804. *
  6805. * Description:
  6806. * The code is simple. No description necessary.
  6807. *
  6808. * Returns:
  6809. * SK_PNMI_ERR_OK The request was performed successfully.
  6810. * SK_PNMI_ERR_GENERAL A general severe internal error occured.
  6811. * SK_PNMI_ERR_TOO_SHORT The passed buffer is too short to contain
  6812. * the correct data (e.g. a 32bit value is
  6813. * needed, but a 16 bit value was passed).
  6814. * SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't
  6815. * exist (e.g. port instance 3 on a two port
  6816. * adapter).
  6817. * SK_PNMI_ERR_READ_ONLY Only the Get action is allowed.
  6818. *
  6819. */
  6820. PNMI_STATIC int Vct(
  6821. SK_AC *pAC, /* Pointer to adapter context */
  6822. SK_IOC IoC, /* IO context handle */
  6823. int Action, /* Get/PreSet/Set action */
  6824. SK_U32 Id, /* Object ID that is to be processed */
  6825. char *pBuf, /* Buffer to which the mgmt data will be copied */
  6826. unsigned int *pLen, /* On call: buffer length. On return: used buffer */
  6827. SK_U32 Instance, /* Instance (-1,2..n) that is to be queried */
  6828. unsigned int TableIndex, /* Index to the Id table */
  6829. SK_U32 NetIndex) /* NetIndex (0..n), in single net mode always zero */
  6830. {
  6831. SK_GEPORT *pPrt;
  6832. SK_PNMI_VCT *pVctBackupData;
  6833. SK_U32 LogPortMax;
  6834. SK_U32 PhysPortMax;
  6835. SK_U32 PhysPortIndex;
  6836. SK_U32 Limit;
  6837. SK_U32 Offset;
  6838. SK_BOOL Link;
  6839. SK_U32 RetCode = SK_PNMI_ERR_GENERAL;
  6840. int i;
  6841. SK_EVPARA Para;
  6842. SK_U32 CableLength;
  6843. /*
  6844. * Calculate the port indexes from the instance.
  6845. */
  6846. PhysPortMax = pAC->GIni.GIMacsFound;
  6847. LogPortMax = SK_PNMI_PORT_PHYS2LOG(PhysPortMax);
  6848. /* Dual net mode? */
  6849. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  6850. LogPortMax--;
  6851. }
  6852. if ((Instance != (SK_U32) (-1))) {
  6853. /* Check instance range. */
  6854. if ((Instance < 2) || (Instance > LogPortMax)) {
  6855. *pLen = 0;
  6856. return (SK_PNMI_ERR_UNKNOWN_INST);
  6857. }
  6858. if (pAC->Pnmi.DualNetActiveFlag == SK_TRUE) {
  6859. PhysPortIndex = NetIndex;
  6860. }
  6861. else {
  6862. PhysPortIndex = Instance - 2;
  6863. }
  6864. Limit = PhysPortIndex + 1;
  6865. }
  6866. else { /*
  6867. * Instance == (SK_U32) (-1), get all Instances of that OID.
  6868. *
  6869. * Not implemented yet. May be used in future releases.
  6870. */
  6871. PhysPortIndex = 0;
  6872. Limit = PhysPortMax;
  6873. }
  6874. pPrt = &pAC->GIni.GP[PhysPortIndex];
  6875. if (pPrt->PHWLinkUp) {
  6876. Link = SK_TRUE;
  6877. }
  6878. else {
  6879. Link = SK_FALSE;
  6880. }
  6881. /*
  6882. * Check MAC type.
  6883. */
  6884. if (pPrt->PhyType != SK_PHY_MARV_COPPER) {
  6885. *pLen = 0;
  6886. return (SK_PNMI_ERR_GENERAL);
  6887. }
  6888. /* Initialize backup data pointer. */
  6889. pVctBackupData = &pAC->Pnmi.VctBackup[PhysPortIndex];
  6890. /*
  6891. * Check action type.
  6892. */
  6893. if (Action == SK_PNMI_GET) {
  6894. /*
  6895. * Check length.
  6896. */
  6897. switch (Id) {
  6898. case OID_SKGE_VCT_GET:
  6899. if (*pLen < (Limit - PhysPortIndex) * sizeof(SK_PNMI_VCT)) {
  6900. *pLen = (Limit - PhysPortIndex) * sizeof(SK_PNMI_VCT);
  6901. return (SK_PNMI_ERR_TOO_SHORT);
  6902. }
  6903. break;
  6904. case OID_SKGE_VCT_STATUS:
  6905. if (*pLen < (Limit - PhysPortIndex) * sizeof(SK_U8)) {
  6906. *pLen = (Limit - PhysPortIndex) * sizeof(SK_U8);
  6907. return (SK_PNMI_ERR_TOO_SHORT);
  6908. }
  6909. break;
  6910. default:
  6911. *pLen = 0;
  6912. return (SK_PNMI_ERR_GENERAL);
  6913. }
  6914. /*
  6915. * Get value.
  6916. */
  6917. Offset = 0;
  6918. for (; PhysPortIndex < Limit; PhysPortIndex++) {
  6919. switch (Id) {
  6920. case OID_SKGE_VCT_GET:
  6921. if ((Link == SK_FALSE) &&
  6922. (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_PENDING)) {
  6923. RetCode = SkGmCableDiagStatus(pAC, IoC, PhysPortIndex, SK_FALSE);
  6924. if (RetCode == 0) {
  6925. pAC->Pnmi.VctStatus[PhysPortIndex] &= ~SK_PNMI_VCT_PENDING;
  6926. pAC->Pnmi.VctStatus[PhysPortIndex] |=
  6927. (SK_PNMI_VCT_NEW_VCT_DATA | SK_PNMI_VCT_TEST_DONE);
  6928. /* Copy results for later use to PNMI struct. */
  6929. for (i = 0; i < 4; i++) {
  6930. if (pPrt->PMdiPairSts[i] == SK_PNMI_VCT_NORMAL_CABLE) {
  6931. if ((pPrt->PMdiPairLen[i] > 35) && (pPrt->PMdiPairLen[i] < 0xff)) {
  6932. pPrt->PMdiPairSts[i] = SK_PNMI_VCT_IMPEDANCE_MISMATCH;
  6933. }
  6934. }
  6935. if ((pPrt->PMdiPairLen[i] > 35) && (pPrt->PMdiPairLen[i] != 0xff)) {
  6936. CableLength = 1000 * (((175 * pPrt->PMdiPairLen[i]) / 210) - 28);
  6937. }
  6938. else {
  6939. CableLength = 0;
  6940. }
  6941. pVctBackupData->PMdiPairLen[i] = CableLength;
  6942. pVctBackupData->PMdiPairSts[i] = pPrt->PMdiPairSts[i];
  6943. }
  6944. Para.Para32[0] = PhysPortIndex;
  6945. Para.Para32[1] = -1;
  6946. SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_RESET, Para);
  6947. SkEventDispatcher(pAC, IoC);
  6948. }
  6949. else {
  6950. ; /* VCT test is running. */
  6951. }
  6952. }
  6953. /* Get all results. */
  6954. CheckVctStatus(pAC, IoC, pBuf, Offset, PhysPortIndex);
  6955. Offset += sizeof(SK_U8);
  6956. *(pBuf + Offset) = pPrt->PCableLen;
  6957. Offset += sizeof(SK_U8);
  6958. for (i = 0; i < 4; i++) {
  6959. SK_PNMI_STORE_U32((pBuf + Offset), pVctBackupData->PMdiPairLen[i]);
  6960. Offset += sizeof(SK_U32);
  6961. }
  6962. for (i = 0; i < 4; i++) {
  6963. *(pBuf + Offset) = pVctBackupData->PMdiPairSts[i];
  6964. Offset += sizeof(SK_U8);
  6965. }
  6966. RetCode = SK_PNMI_ERR_OK;
  6967. break;
  6968. case OID_SKGE_VCT_STATUS:
  6969. CheckVctStatus(pAC, IoC, pBuf, Offset, PhysPortIndex);
  6970. Offset += sizeof(SK_U8);
  6971. RetCode = SK_PNMI_ERR_OK;
  6972. break;
  6973. default:
  6974. *pLen = 0;
  6975. return (SK_PNMI_ERR_GENERAL);
  6976. }
  6977. } /* for */
  6978. *pLen = Offset;
  6979. return (RetCode);
  6980. } /* if SK_PNMI_GET */
  6981. /*
  6982. * From here SET or PRESET action. Check if the passed
  6983. * buffer length is plausible.
  6984. */
  6985. /*
  6986. * Check length.
  6987. */
  6988. switch (Id) {
  6989. case OID_SKGE_VCT_SET:
  6990. if (*pLen < (Limit - PhysPortIndex) * sizeof(SK_U32)) {
  6991. *pLen = (Limit - PhysPortIndex) * sizeof(SK_U32);
  6992. return (SK_PNMI_ERR_TOO_SHORT);
  6993. }
  6994. break;
  6995. default:
  6996. *pLen = 0;
  6997. return (SK_PNMI_ERR_GENERAL);
  6998. }
  6999. /*
  7000. * Perform preset or set.
  7001. */
  7002. /* VCT does not support PRESET action. */
  7003. if (Action == SK_PNMI_PRESET) {
  7004. return (SK_PNMI_ERR_OK);
  7005. }
  7006. Offset = 0;
  7007. for (; PhysPortIndex < Limit; PhysPortIndex++) {
  7008. switch (Id) {
  7009. case OID_SKGE_VCT_SET: /* Start VCT test. */
  7010. if (Link == SK_FALSE) {
  7011. SkGeStopPort(pAC, IoC, PhysPortIndex, SK_STOP_ALL, SK_SOFT_RST);
  7012. RetCode = SkGmCableDiagStatus(pAC, IoC, PhysPortIndex, SK_TRUE);
  7013. if (RetCode == 0) { /* RetCode: 0 => Start! */
  7014. pAC->Pnmi.VctStatus[PhysPortIndex] |= SK_PNMI_VCT_PENDING;
  7015. pAC->Pnmi.VctStatus[PhysPortIndex] &= ~SK_PNMI_VCT_NEW_VCT_DATA;
  7016. pAC->Pnmi.VctStatus[PhysPortIndex] &= ~SK_PNMI_VCT_LINK;
  7017. /*
  7018. * Start VCT timer counter.
  7019. */
  7020. SK_MEMSET((char *) &Para, 0, sizeof(Para));
  7021. Para.Para32[0] = PhysPortIndex;
  7022. Para.Para32[1] = -1;
  7023. SkTimerStart(pAC, IoC, &pAC->Pnmi.VctTimeout[PhysPortIndex].VctTimer,
  7024. 4000000, SKGE_PNMI, SK_PNMI_EVT_VCT_RESET, Para);
  7025. SK_PNMI_STORE_U32((pBuf + Offset), RetCode);
  7026. RetCode = SK_PNMI_ERR_OK;
  7027. }
  7028. else { /* RetCode: 2 => Running! */
  7029. SK_PNMI_STORE_U32((pBuf + Offset), RetCode);
  7030. RetCode = SK_PNMI_ERR_OK;
  7031. }
  7032. }
  7033. else { /* RetCode: 4 => Link! */
  7034. RetCode = 4;
  7035. SK_PNMI_STORE_U32((pBuf + Offset), RetCode);
  7036. RetCode = SK_PNMI_ERR_OK;
  7037. }
  7038. Offset += sizeof(SK_U32);
  7039. break;
  7040. default:
  7041. *pLen = 0;
  7042. return (SK_PNMI_ERR_GENERAL);
  7043. }
  7044. } /* for */
  7045. *pLen = Offset;
  7046. return (RetCode);
  7047. } /* Vct */
  7048. PNMI_STATIC void CheckVctStatus(
  7049. SK_AC *pAC,
  7050. SK_IOC IoC,
  7051. char *pBuf,
  7052. SK_U32 Offset,
  7053. SK_U32 PhysPortIndex)
  7054. {
  7055. SK_GEPORT *pPrt;
  7056. SK_PNMI_VCT *pVctData;
  7057. SK_U32 RetCode;
  7058. SK_U8 LinkSpeedUsed;
  7059. pPrt = &pAC->GIni.GP[PhysPortIndex];
  7060. pVctData = (SK_PNMI_VCT *) (pBuf + Offset);
  7061. pVctData->VctStatus = SK_PNMI_VCT_NONE;
  7062. if (!pPrt->PHWLinkUp) {
  7063. /* Was a VCT test ever made before? */
  7064. if (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_TEST_DONE) {
  7065. if ((pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_LINK)) {
  7066. pVctData->VctStatus |= SK_PNMI_VCT_OLD_VCT_DATA;
  7067. }
  7068. else {
  7069. pVctData->VctStatus |= SK_PNMI_VCT_NEW_VCT_DATA;
  7070. }
  7071. }
  7072. /* Check VCT test status. */
  7073. RetCode = SkGmCableDiagStatus(pAC,IoC, PhysPortIndex, SK_FALSE);
  7074. if (RetCode == 2) { /* VCT test is running. */
  7075. pVctData->VctStatus |= SK_PNMI_VCT_RUNNING;
  7076. }
  7077. else { /* VCT data was copied to pAC here. Check PENDING state. */
  7078. if (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_PENDING) {
  7079. pVctData->VctStatus |= SK_PNMI_VCT_NEW_VCT_DATA;
  7080. }
  7081. }
  7082. if (pPrt->PCableLen != 0xff) { /* Old DSP value. */
  7083. pVctData->VctStatus |= SK_PNMI_VCT_OLD_DSP_DATA;
  7084. }
  7085. }
  7086. else {
  7087. /* Was a VCT test ever made before? */
  7088. if (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_TEST_DONE) {
  7089. pVctData->VctStatus &= ~SK_PNMI_VCT_NEW_VCT_DATA;
  7090. pVctData->VctStatus |= SK_PNMI_VCT_OLD_VCT_DATA;
  7091. }
  7092. /* DSP only valid in 100/1000 modes. */
  7093. LinkSpeedUsed = pAC->GIni.GP[PhysPortIndex].PLinkSpeedUsed;
  7094. if (LinkSpeedUsed != SK_LSPEED_STAT_10MBPS) {
  7095. pVctData->VctStatus |= SK_PNMI_VCT_NEW_DSP_DATA;
  7096. }
  7097. }
  7098. } /* CheckVctStatus */
  7099. #endif /* CONFIG_SK98 */