⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 skgepnmi.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 5 页
字号:
				SK_PNMI_CHECKFLAGS("SkPnmiGetStruct: On return");				SK_PNMI_SET_STAT(pBuf, Ret, DstOffset);				*pLen = SK_PNMI_MIN_STRUCT_SIZE;				return (Ret);			}		}	}	pAC->Pnmi.MacUpdatedFlag --;	pAC->Pnmi.RlmtUpdatedFlag --;	pAC->Pnmi.SirqUpdatedFlag --;	*pLen = SK_PNMI_STRUCT_SIZE;	SK_PNMI_CHECKFLAGS("SkPnmiGetStruct: On return");	SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_OK, (SK_U32)(-1));	return (SK_PNMI_ERR_OK);}/***************************************************************************** * * SkPnmiPreSetStruct - Presets the management database in SK_PNMI_STRUCT_DATA * * Description: *	Calls a general sub-function for all this set stuff. The preset does *	the same as a set, but returns just before finally setting the *	new value. This is usefull to check if a set might be successfull. *	The sub-function runs through the IdTable, checks which OIDs are able *	to set, and calls the handler function of the OID to perform the *	preset. The return value of the function will also be stored in *	SK_PNMI_STRUCT_DATA if the passed buffer has the minimum size of *	SK_PNMI_MIN_STRUCT_SIZE. * * Returns: *	SK_PNMI_ERR_OK           The request was successfully performed. *	SK_PNMI_ERR_GENERAL      A general severe internal error occured. *	SK_PNMI_ERR_TOO_SHORT    The passed buffer is too short to contain *	                         the correct data (e.g. a 32bit value is *	                         needed, but a 16 bit value was passed). *	SK_PNMI_ERR_BAD_VALUE    The passed value is not in the valid *	                         value range. */int SkPnmiPreSetStruct(SK_AC *pAC,		/* Pointer to adapter context */SK_IOC IoC,		/* IO context handle */void *pBuf,		/* Buffer which contains the data to be set */unsigned int *pLen,	/* Length of buffer */SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode always zero */{	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiPreSetStruct: Called, BufLen=%d, NetIndex=%d\n",			*pLen, NetIndex));	return (PnmiStruct(pAC, IoC, SK_PNMI_PRESET, (char *)pBuf,    					pLen, NetIndex));}/***************************************************************************** * * SkPnmiSetStruct - Sets the management database in SK_PNMI_STRUCT_DATA * * Description: *	Calls a general sub-function for all this set stuff. The return value *	of the function will also be stored in SK_PNMI_STRUCT_DATA if the *	passed buffer has the minimum size of SK_PNMI_MIN_STRUCT_SIZE. *	The sub-function runs through the IdTable, checks which OIDs are able *	to set, and calls the handler function of the OID to perform the *	set. The return value of the function will also be stored in *	SK_PNMI_STRUCT_DATA if the passed buffer has the minimum size of *	SK_PNMI_MIN_STRUCT_SIZE. * * Returns: *	SK_PNMI_ERR_OK           The request was successfully performed. *	SK_PNMI_ERR_GENERAL      A general severe internal error occured. *	SK_PNMI_ERR_TOO_SHORT    The passed buffer is too short to contain *	                         the correct data (e.g. a 32bit value is *	                         needed, but a 16 bit value was passed). *	SK_PNMI_ERR_BAD_VALUE    The passed value is not in the valid *	                         value range. */int SkPnmiSetStruct(SK_AC *pAC,		/* Pointer to adapter context */SK_IOC IoC,		/* IO context handle */void *pBuf,		/* Buffer which contains the data to be set */unsigned int *pLen,	/* Length of buffer */SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode always zero */{	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiSetStruct: Called, BufLen=%d, NetIndex=%d\n",			*pLen, NetIndex));	return (PnmiStruct(pAC, IoC, SK_PNMI_SET, (char *)pBuf,    					pLen, NetIndex));}/***************************************************************************** * * SkPnmiEvent - Event handler * * Description: *	Handles the following events: *	SK_PNMI_EVT_SIRQ_OVERFLOW     When a hardware counter overflows an *	                              interrupt will be generated which is *	                              first handled by SIRQ which generates a *	                              this event. The event increments the *	                              upper 32 bit of the 64 bit counter. *	SK_PNMI_EVT_SEN_XXX           The event is generated by the I2C module *	                              when a sensor reports a warning or *	                              error. The event will store a trap *	                              message in the trap buffer. *	SK_PNMI_EVT_CHG_EST_TIMER     The timer event was initiated by this *	                              module and is used to calculate the *	                              port switches per hour. *	SK_PNMI_EVT_CLEAR_COUNTER     The event clears all counters and *	                              timestamps. *	SK_PNMI_EVT_XMAC_RESET        The event is generated by the driver *	                              before a hard reset of the XMAC is *	                              performed. All counters will be saved *	                              and added to the hardware counter *	                              values after reset to grant continuous *	                              counter values. *	SK_PNMI_EVT_RLMT_PORT_UP      Generated by RLMT to notify that a port *	                              went logically up. A trap message will *	                              be stored to the trap buffer. *	SK_PNMI_EVT_RLMT_PORT_DOWN    Generated by RLMT to notify that a port *	                              went logically down. A trap message will *	                              be stored to the trap buffer. *	SK_PNMI_EVT_RLMT_SEGMENTATION Generated by RLMT to notify that two *	                              spanning tree root bridges were *	                              detected. A trap message will be stored *	                              to the trap buffer. *	SK_PNMI_EVT_RLMT_ACTIVE_DOWN  Notifies PNMI that an active port went *	                              down. PNMI will not further add the *	                              statistic values to the virtual port. *	SK_PNMI_EVT_RLMT_ACTIVE_UP    Notifies PNMI that a port went up and *	                              is now an active port. PNMI will now *	                              add the statistic data of this port to *	                              the virtual port. *	SK_PNMI_EVT_RLMT_SET_NETS     Notifies PNMI about the net mode. The first parameter *	                              contains the number of nets. 1 means single net, 2 means *	                              dual net. The second parameter is -1 * * Returns: *	Always 0 */int SkPnmiEvent(SK_AC *pAC,		/* Pointer to adapter context */SK_IOC IoC,		/* IO context handle */SK_U32 Event,		/* Event-Id */SK_EVPARA Param)	/* Event dependent parameter */{	unsigned int	PhysPortIndex;    unsigned int	MaxNetNumber;	int			CounterIndex;	int			Ret;	SK_U16		MacStatus;	SK_U64		OverflowStatus;	SK_U64		Mask;	int			MacType;	SK_U64		Value;	SK_U32		Val32;	SK_U16		Register;	SK_EVPARA	EventParam;	SK_U64		NewestValue;	SK_U64		OldestValue;	SK_U64		Delta;	SK_PNMI_ESTIMATE *pEst;	SK_U32		NetIndex;	SK_GEPORT	*pPrt;	SK_PNMI_VCT	*pVctBackupData;	SK_U32		RetCode;	int		i;	SK_U32		CableLength;#ifdef DEBUG	if (Event != SK_PNMI_EVT_XMAC_RESET) {		SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,			("PNMI: SkPnmiEvent: Called, Event=0x%x, Param=0x%x\n",			(unsigned int)Event, (unsigned int)Param.Para64));	}#endif /* DEBUG */	SK_PNMI_CHECKFLAGS("SkPnmiEvent: On call");	MacType = pAC->GIni.GIMacType;		switch (Event) {	case SK_PNMI_EVT_SIRQ_OVERFLOW:		PhysPortIndex = (int)Param.Para32[0];		MacStatus = (SK_U16)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_SIRQ_OVERFLOW parameter"				 " wrong, PhysPortIndex=0x%x\n",				PhysPortIndex));			return (0);		}#endif /* DEBUG */		OverflowStatus = 0;		/*		 * Check which source caused an overflow interrupt.		 */		if ((pAC->GIni.GIFunc.pFnMacOverflow(pAC, IoC, PhysPortIndex,				MacStatus, &OverflowStatus) != 0) ||			(OverflowStatus == 0)) {			SK_PNMI_CHECKFLAGS("SkPnmiEvent: On return");			return (0);		}		/*		 * Check the overflow status register and increment		 * the upper dword of corresponding counter.		 */		for (CounterIndex = 0; CounterIndex < sizeof(Mask) * 8;			CounterIndex ++) {			Mask = (SK_U64)1 << CounterIndex;			if ((OverflowStatus & Mask) == 0) {				continue;			}			switch (StatOvrflwBit[CounterIndex][MacType]) {			case SK_PNMI_HTX_UTILUNDER:			case SK_PNMI_HTX_UTILOVER:				if (MacType == SK_MAC_XMAC) {					XM_IN16(IoC, PhysPortIndex, XM_TX_CMD, &Register);					Register |= XM_TX_SAM_LINE;					XM_OUT16(IoC, PhysPortIndex, XM_TX_CMD, Register);				}				break;			case SK_PNMI_HRX_UTILUNDER:			case SK_PNMI_HRX_UTILOVER:				if (MacType == SK_MAC_XMAC) {					XM_IN16(IoC, PhysPortIndex, XM_RX_CMD, &Register);					Register |= XM_RX_SAM_LINE;					XM_OUT16(IoC, PhysPortIndex, XM_RX_CMD, Register);				}				break;			case SK_PNMI_HTX_OCTETHIGH:			case SK_PNMI_HTX_OCTETLOW:			case SK_PNMI_HTX_RESERVED:			case SK_PNMI_HRX_OCTETHIGH:			case SK_PNMI_HRX_OCTETLOW:			case SK_PNMI_HRX_IRLENGTH:			case SK_PNMI_HRX_RESERVED:						/*			 * the following counters aren't be handled (id > 63)			 */			case SK_PNMI_HTX_SYNC:			case SK_PNMI_HTX_SYNC_OCTET:				break;			case SK_PNMI_HRX_LONGFRAMES:				if (MacType == SK_MAC_GMAC) {					pAC->Pnmi.Port[PhysPortIndex].						CounterHigh[CounterIndex] ++;				}				break;			default:				pAC->Pnmi.Port[PhysPortIndex].					CounterHigh[CounterIndex] ++;			}		}		break;	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 /* DEBUG */		/*		 * 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 /* DEBUG */		/*		 * 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 /* DEBUG */		/*		 * 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 /* DEBUG */		/*		 * 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 initialization 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,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -