skgepnmi.c 213 KB

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