skgepnmi.c 212 KB

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