skgepnmi.c 219 KB

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