?? skgepnmi.c
字號:
case SK_PNMI_EVT_SEN_WAR_LOW:#ifdef DEBUG if ((unsigned int)Param.Para64 >= (unsigned int)pAC->I2c.MaxSens) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_SEN_WAR_LOW parameter wrong, SensorIndex=%d\n", (unsigned int)Param.Para64)); return (0); }#endif /* * Store a trap message in the trap buffer and generate * an event for user space applications with the * SK_DRIVER_SENDEVENT macro. */ QueueSensorTrap(pAC, OID_SKGE_TRAP_SEN_WAR_LOW, (unsigned int)Param.Para64); (void)SK_DRIVER_SENDEVENT(pAC, IoC); break; case SK_PNMI_EVT_SEN_WAR_UPP:#ifdef DEBUG if ((unsigned int)Param.Para64 >= (unsigned int)pAC->I2c.MaxSens) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR:SkPnmiEvent: SK_PNMI_EVT_SEN_WAR_UPP parameter wrong, SensorIndex=%d\n", (unsigned int)Param.Para64)); return (0); }#endif /* * Store a trap message in the trap buffer and generate * an event for user space applications with the * SK_DRIVER_SENDEVENT macro. */ QueueSensorTrap(pAC, OID_SKGE_TRAP_SEN_WAR_UPP, (unsigned int)Param.Para64); (void)SK_DRIVER_SENDEVENT(pAC, IoC); break; case SK_PNMI_EVT_SEN_ERR_LOW:#ifdef DEBUG if ((unsigned int)Param.Para64 >= (unsigned int)pAC->I2c.MaxSens) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_SEN_ERR_LOW parameter wrong, SensorIndex=%d\n", (unsigned int)Param.Para64)); return (0); }#endif /* * Store a trap message in the trap buffer and generate * an event for user space applications with the * SK_DRIVER_SENDEVENT macro. */ QueueSensorTrap(pAC, OID_SKGE_TRAP_SEN_ERR_LOW, (unsigned int)Param.Para64); (void)SK_DRIVER_SENDEVENT(pAC, IoC); break; case SK_PNMI_EVT_SEN_ERR_UPP:#ifdef DEBUG if ((unsigned int)Param.Para64 >= (unsigned int)pAC->I2c.MaxSens) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_SEN_ERR_UPP parameter wrong, SensorIndex=%d\n", (unsigned int)Param.Para64)); return (0); }#endif /* * Store a trap message in the trap buffer and generate * an event for user space applications with the * SK_DRIVER_SENDEVENT macro. */ QueueSensorTrap(pAC, OID_SKGE_TRAP_SEN_ERR_UPP, (unsigned int)Param.Para64); (void)SK_DRIVER_SENDEVENT(pAC, IoC); break; case SK_PNMI_EVT_CHG_EST_TIMER: /* * Calculate port switch average on a per hour basis * Time interval for check : 28125 ms * Number of values for average : 8 * * Be careful in changing these values, on change check * - typedef of SK_PNMI_ESTIMATE (Size of EstValue * array one less than value number) * - Timer initilization SkTimerStart() in SkPnmiInit * - Delta value below must be multiplicated with * power of 2 * */ pEst = &pAC->Pnmi.RlmtChangeEstimate; CounterIndex = pEst->EstValueIndex + 1; if (CounterIndex == 7) { CounterIndex = 0; } pEst->EstValueIndex = CounterIndex; NewestValue = pAC->Pnmi.RlmtChangeCts; OldestValue = pEst->EstValue[CounterIndex]; pEst->EstValue[CounterIndex] = NewestValue; /* * Calculate average. Delta stores the number of * port switches per 28125 * 8 = 225000 ms */ if (NewestValue >= OldestValue) { Delta = NewestValue - OldestValue; } else { /* Overflow situation */ Delta = (SK_U64)(0 - OldestValue) + NewestValue; } /* * Extrapolate delta to port switches per hour. * Estimate = Delta * (3600000 / 225000) * = Delta * 16 * = Delta << 4 */ pAC->Pnmi.RlmtChangeEstimate.Estimate = Delta << 4; /* * Check if threshold is exceeded. If the threshold is * permanently exceeded every 28125 ms an event will be * generated to remind the user of this condition. */ if ((pAC->Pnmi.RlmtChangeThreshold != 0) && (pAC->Pnmi.RlmtChangeEstimate.Estimate >= pAC->Pnmi.RlmtChangeThreshold)) { QueueSimpleTrap(pAC, OID_SKGE_TRAP_RLMT_CHANGE_THRES); (void)SK_DRIVER_SENDEVENT(pAC, IoC); } SK_MEMSET((char *) &EventParam, 0, sizeof(EventParam)); SkTimerStart(pAC, IoC, &pAC->Pnmi.RlmtChangeEstimate.EstTimer, 28125000, SKGE_PNMI, SK_PNMI_EVT_CHG_EST_TIMER, EventParam); break; case SK_PNMI_EVT_CLEAR_COUNTER: /* * Param.Para32[0] contains the NetIndex (0 ..1). * Param.Para32[1] is reserved, contains -1. */ NetIndex = (SK_U32)Param.Para32[0];#ifdef DEBUG if (NetIndex >= pAC->Rlmt.NumNets) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_CLEAR_COUNTER parameter wrong, NetIndex=%d\n", NetIndex)); return (0); }#endif /* * Set all counters and timestamps to zero */ ResetCounter(pAC, IoC, NetIndex); /* the according NetIndex is required as a Parameter of the Event */ break; case SK_PNMI_EVT_XMAC_RESET: /* * To grant continuous counter values store the current * XMAC statistic values to the entries 1..n of the * CounterOffset array. XMAC Errata #2 */#ifdef DEBUG if ((unsigned int)Param.Para64 >= SK_MAX_MACS) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_XMAC_RESET parameter wrong, PhysPortIndex=%d\n", (unsigned int)Param.Para64)); return (0); }#endif PhysPortIndex = (unsigned int)Param.Para64; /* * Update XMAC statistic to get fresh values */ Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1); if (Ret != SK_PNMI_ERR_OK) { SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return"); return (0); } /* * Increment semaphore to indicate that an update was * already done */ pAC->Pnmi.MacUpdatedFlag ++; for (CounterIndex = 0; CounterIndex < SK_PNMI_MAX_IDX; CounterIndex ++) { if (!StatAddr[CounterIndex][MacType].GetOffset) { continue; } pAC->Pnmi.Port[PhysPortIndex]. CounterOffset[CounterIndex] = GetPhysStatVal( pAC, IoC, PhysPortIndex, CounterIndex); pAC->Pnmi.Port[PhysPortIndex]. CounterHigh[CounterIndex] = 0; } pAC->Pnmi.MacUpdatedFlag --; break; case SK_PNMI_EVT_RLMT_PORT_UP: PhysPortIndex = (unsigned int)Param.Para32[0];#ifdef DEBUG if (PhysPortIndex >= SK_MAX_MACS) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_PORT_UP parameter" " wrong, PhysPortIndex=%d\n", PhysPortIndex)); return (0); }#endif /* * Store a trap message in the trap buffer and generate an event for * user space applications with the SK_DRIVER_SENDEVENT macro. */ QueueRlmtPortTrap(pAC, OID_SKGE_TRAP_RLMT_PORT_UP, PhysPortIndex); (void)SK_DRIVER_SENDEVENT(pAC, IoC); /* Bugfix for XMAC errata (#10620)*/ if (pAC->GIni.GIMacType == SK_MAC_XMAC){ /* Add incremental difference to offset (#10620)*/ (void)pAC->GIni.GIFunc.pFnMacStatistic(pAC, IoC, PhysPortIndex, XM_RXE_SHT_ERR, &Val32); Value = (((SK_U64)pAC->Pnmi.Port[PhysPortIndex]. CounterHigh[SK_PNMI_HRX_SHORTS] << 32) | (SK_U64)Val32); pAC->Pnmi.Port[PhysPortIndex].CounterOffset[SK_PNMI_HRX_SHORTS] += Value - pAC->Pnmi.Port[PhysPortIndex].RxShortZeroMark; } /* Tell VctStatus() that a link was up meanwhile. */ pAC->Pnmi.VctStatus[PhysPortIndex] |= SK_PNMI_VCT_LINK; break; case SK_PNMI_EVT_RLMT_PORT_DOWN: PhysPortIndex = (unsigned int)Param.Para32[0];#ifdef DEBUG if (PhysPortIndex >= SK_MAX_MACS) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_PORT_DOWN parameter" " wrong, PhysPortIndex=%d\n", PhysPortIndex)); return (0); }#endif /* * Store a trap message in the trap buffer and generate an event for * user space applications with the SK_DRIVER_SENDEVENT macro. */ QueueRlmtPortTrap(pAC, OID_SKGE_TRAP_RLMT_PORT_DOWN, PhysPortIndex); (void)SK_DRIVER_SENDEVENT(pAC, IoC); /* Bugfix #10620 - get zero level for incremental difference */ if ((pAC->GIni.GIMacType == SK_MAC_XMAC)) { (void)pAC->GIni.GIFunc.pFnMacStatistic(pAC, IoC, PhysPortIndex, XM_RXE_SHT_ERR, &Val32); pAC->Pnmi.Port[PhysPortIndex].RxShortZeroMark = (((SK_U64)pAC->Pnmi.Port[PhysPortIndex]. CounterHigh[SK_PNMI_HRX_SHORTS] << 32) | (SK_U64)Val32); } break; case SK_PNMI_EVT_RLMT_ACTIVE_DOWN: PhysPortIndex = (unsigned int)Param.Para32[0]; NetIndex = (SK_U32)Param.Para32[1];#ifdef DEBUG if (PhysPortIndex >= SK_MAX_MACS) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_ACTIVE_DOWN parameter too high, PhysPort=%d\n", PhysPortIndex)); } if (NetIndex >= pAC->Rlmt.NumNets) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_ACTIVE_DOWN parameter too high, NetIndex=%d\n", NetIndex)); }#endif /* * For now, ignore event if NetIndex != 0. */ if (Param.Para32[1] != 0) { return (0); } /* * Nothing to do if port is already inactive */ if (!pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) { return (0); } /* * Update statistic counters to calculate new offset for the virtual * port and increment semaphore to indicate that an update was already * done. */ if (MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1) != SK_PNMI_ERR_OK) { SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return"); return (0); } pAC->Pnmi.MacUpdatedFlag ++; /* * Calculate new counter offset for virtual port to grant continous * counting on port switches. The virtual port consists of all currently * active ports. The port down event indicates that a port is removed * from the virtual port. Therefore add the counter value of the removed * port to the CounterOffset for the virtual port to grant the same * counter value. */ for (CounterIndex = 0; CounterIndex < SK_PNMI_MAX_IDX; CounterIndex ++) { if (!StatAddr[CounterIndex][MacType].GetOffset) { continue; } Value = GetPhysStatVal(pAC, IoC, PhysPortIndex, CounterIndex); pAC->Pnmi.VirtualCounterOffset[CounterIndex] += Value; } /* * Set port to inactive */ pAC->Pnmi.Port[PhysPortIndex].ActiveFlag = SK_FALSE; pAC->Pnmi.MacUpdatedFlag --; break; case SK_PNMI_EVT_RLMT_ACTIVE_UP: PhysPortIndex = (unsigned int)Param.Para32[0]; NetIndex = (SK_U32)Param.Para32[1];#ifdef DEBUG if (PhysPortIndex >= SK_MAX_MACS) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_ACTIVE_UP parameter too high, PhysPort=%d\n", PhysPortIndex)); } if (NetIndex >= pAC->Rlmt.NumNets) { SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL, ("PNM
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -