📄 skgepnmi.c
字号:
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 /* DEBUG */ /* * Set all counters and timestamps to zero. * The according NetIndex is required as a * parameter of the event. */ ResetCounter(pAC, IoC, NetIndex); 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 /* DEBUG */ /* * 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 (MacType == 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 /* DEBUG */ /* * 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 (MacType == 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 /* DEBUG */ /* * 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, ("PNMI: ERR: SkPnmiEvent: SK_PNMI_EVT_RLMT_ACTIVE_UP parameter too high, NetIndex=%d\n", NetIndex)); }#endif /* DEBUG */ /* * For now, ignore event if NetIndex != 0. */ if (Param.Para32[1] != 0) { return (0); } /* * Nothing to do if port is already active */ if (pAC->Pnmi.Port[PhysPortIndex].ActiveFlag) { return (0); } /* * Statistic maintenance */ pAC->Pnmi.RlmtChangeCts ++; pAC->Pnmi.RlmtChangeTime = SK_PNMI_HUNDREDS_SEC(SkOsGetTime(pAC)); /* * Store a trap message in the trap buffer and generate an event for * user space applications with the SK_DRIVER_SENDEVENT macro. */ QueueRlmtNewMacTrap(pAC, PhysPortIndex); (void)SK_DRIVER_SENDEVENT(pAC, IoC); /* * 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. A new port is added to the virtual port. * Therefore substract the counter value of the new port from the * CounterOffset for the virtual port to grant the same 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 active */ pAC->Pnmi.Port[PhysPortIndex].ActiveFlag = SK_TRUE; pAC->Pnmi.MacUpdatedFlag --; break; case SK_PNMI_EVT_RLMT_SEGMENTATION: /* * Para.Para32[0] contains the NetIndex. */ /* * Store a trap message in the trap buffer and generate an event for * user space applications with the SK_DRIVER_SENDEVENT macro. */ QueueSimpleTrap(pAC, OID_SKGE_TRAP_RLMT_SEGMENTATION); (void)SK_DRIVER_SENDEVENT(pAC, IoC); break; case SK_PNMI_EVT_RLMT_SET_NETS: /* * Param.Para32[0] contains the number of Nets. * Param.Para32[1] is reserved, contains -1. */ /* * Check number of nets */ MaxNetNumber = pAC->GIni.GIMacsFound; if (((unsigned int)Param.Para32[0] < 1) || ((unsigned int)Param.Para32[0] > MaxNetNumber)) { return (SK_PNMI_ERR_UNKNOWN_NET); } if ((unsigned int)Param.Para32[0] == 1) { /* single net mode */ pAC->Pnmi.DualNetActiveFlag = SK_FALSE; } else { /* dual net mode */ pAC->Pnmi.DualNetActiveFlag = SK_TRUE; } break; case SK_PNMI_EVT_VCT_RESET: PhysPortIndex = Param.Para32[0]; pPrt = &pAC->GIni.GP[PhysPortIndex]; pVctBackupData = &pAC->Pnmi.VctBackup[PhysPortIndex]; if (pAC->Pnmi.VctStatus[PhysPortIndex] & SK_PNMI_VCT_PENDING) { RetCode = SkGmCableDiagStatus(pAC, IoC, PhysPortIndex, SK_FALSE); if (RetCode == 2) { /* * VCT test is still running. * Start VCT timer counter again. */ SK_MEMSET((char *) &Param, 0, sizeof(Param)); Param.Para32[0] = PhysPortIndex; Param.Para32[1] = -1; SkTimerStart(pAC, IoC, &pAC->Pnmi.VctTimeout[PhysPortIndex].VctTimer, 4000000, SKGE_PNMI, SK_PNMI_EVT_VCT_RESET, Param); break; } pAC->Pnmi.VctStatus[PhysPortIndex] &= ~SK_PNMI_VCT_PENDING; pAC->Pnmi.VctStatus[PhysPortIndex] |= (SK_PNMI_VCT_NEW_VCT_DATA | SK_PNMI_VCT_TEST_DONE); /* Copy results for later use to PNMI struct. */ for (i = 0; i < 4; i++) { if (pPrt->PMdiPairSts[i] == SK_PNMI_VCT_NORMAL_CABLE) { if ((pPrt->PMdiPairLen[i] > 35) && (pPrt->PMdiPairLen[i] < 0xff)) { pPrt->PMdiPairSts[i] = SK_PNMI_VCT_IMPEDANCE_MISMATCH; } } if ((pPrt->PMdiPairLen[i] > 35) && (pPrt->PMdiPairLen[i] != 0xff)) { CableLength = 1000 * (((175 * pPrt->PMdiPairLen[i]) / 210) - 28); } else { CableLength = 0; } pVctBackupData->PMdiPairLen[i] = CableLength; pVctBackupData->PMdiPairSts[i] = pPrt->PMdiPairSts[i]; } Param.Para32[0] = PhysPortIndex; Param.Para32[1] = -1; SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_RESET, Param); SkEventDispatcher(pAC, IoC); } break; default: break; } SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return"); return (0);}/****************************************************************************** * * Private functions * *//***************************************************************************** * * PnmiVar - Gets, presets, and sets single OIDs * * Description: * Looks up the requested OID, calls the corresponding handler * function, and passes the parameters with the get, preset, or * set command. The function is called by SkGePnmiGetVar,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -