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

📄 skgepnmi.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
 *	all instance of the OID will be set. * * 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. *	SK_PNMI_ERR_READ_ONLY    The OID is read-only and cannot be set. *	SK_PNMI_ERR_UNKNOWN_OID  The requested OID is unknown. *	SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't *                               exist (e.g. port instance 3 on a two port *	                         adapter. */int SkPnmiPreSetVar(SK_AC *pAC,		/* Pointer to adapter context */SK_IOC IoC,		/* IO context handle */SK_U32 Id,		/* Object ID that is to be processed */void *pBuf,		/* Buffer which stores the mgmt data to be set */unsigned int *pLen,	/* Total length of mgmt data */SK_U32 Instance)	/* Instance (1..n) that is to be set or -1 */{	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiPreSetVar: Called, Id=0x%x, BufLen=%d\n",		Id, *pLen));	return (PnmiVar(pAC, IoC, SK_PNMI_PRESET, Id, (char *)pBuf, pLen,		Instance));}/***************************************************************************** * * SkPnmiSetVar - Sets the value of a single OID * * Description: *	Calls a general sub-function for all this 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. *	If as instance a -1 is passed, an array of values is supposed and *	all instance of the OID will be set. * * 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. *	SK_PNMI_ERR_READ_ONLY    The OID is read-only and cannot be set. *	SK_PNMI_ERR_UNKNOWN_OID  The requested OID is unknown. *	SK_PNMI_ERR_UNKNOWN_INST The requested instance of the OID doesn't *                               exist (e.g. port instance 3 on a two port *	                         adapter. */int SkPnmiSetVar(SK_AC *pAC,		/* Pointer to adapter context */SK_IOC IoC,		/* IO context handle */SK_U32 Id,		/* Object ID that is to be processed */void *pBuf,		/* Buffer which stores the mgmt data to be set */unsigned int *pLen,	/* Total length of mgmt data */SK_U32 Instance)	/* Instance (1..n) that is to be set or -1 */{	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiSetVar: Called, Id=0x%x, BufLen=%d\n", Id,		*pLen));	return (PnmiVar(pAC, IoC, SK_PNMI_SET, Id, (char *)pBuf, pLen,		Instance));}/***************************************************************************** * * SkPnmiGetStruct - Retrieves the management database in SK_PNMI_STRUCT_DATA * * Description: *	Runs through the IdTable, queries the single OIDs and stores the *	returned data into the management database structure *	SK_PNMI_STRUCT_DATA. The offset of the OID in the structure *	is stored in the IdTable. 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 take *	                         the data. */int SkPnmiGetStruct(SK_AC *pAC,		/* Pointer to adapter context */SK_IOC IoC,		/* IO context handle */void *pBuf,		/* Buffer which will store the retrieved data */unsigned int *pLen)	/* Length of buffer */{	int		Ret;	unsigned int	TableIndex;	unsigned int	DstOffset;	unsigned int	InstanceNo;	unsigned int	InstanceCnt;	SK_U32		Instance;	unsigned int	TmpLen;	char		KeyArr[SK_PNMI_VPD_ARR_SIZE][SK_PNMI_VPD_STR_SIZE];		SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiGetStruct: Called, BufLen=%d\n", *pLen));	if (*pLen < SK_PNMI_STRUCT_SIZE) {		if (*pLen >= SK_PNMI_MIN_STRUCT_SIZE) {			SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_TOO_SHORT,				(SK_U32)(-1));		}		*pLen = SK_PNMI_STRUCT_SIZE;		return (SK_PNMI_ERR_TOO_SHORT);	}	/* Update statistic */	SK_PNMI_CHECKFLAGS("SkPnmiGetStruct: On call");	if ((Ret = MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1)) !=		SK_PNMI_ERR_OK) {		SK_PNMI_SET_STAT(pBuf, Ret, (SK_U32)(-1));		*pLen = SK_PNMI_MIN_STRUCT_SIZE;		return (Ret);	}	if ((Ret = RlmtUpdate(pAC, IoC)) != SK_PNMI_ERR_OK) {		SK_PNMI_SET_STAT(pBuf, Ret, (SK_U32)(-1));		*pLen = SK_PNMI_MIN_STRUCT_SIZE;		return (Ret);	}	if ((Ret = SirqUpdate(pAC, IoC)) != SK_PNMI_ERR_OK) {		SK_PNMI_SET_STAT(pBuf, Ret, (SK_U32)(-1));		*pLen = SK_PNMI_MIN_STRUCT_SIZE;		return (Ret);	}	/*	 * Increment semaphores to indicate that an update was	 * already done	 */	pAC->Pnmi.MacUpdatedFlag ++;	pAC->Pnmi.RlmtUpdatedFlag ++;	pAC->Pnmi.SirqUpdatedFlag ++;	/* Get vpd keys for instance calculation */	Ret = GetVpdKeyArr(pAC, IoC, &KeyArr[0][0], sizeof(KeyArr), &TmpLen);	if (Ret != SK_PNMI_ERR_OK) {		pAC->Pnmi.MacUpdatedFlag --;		pAC->Pnmi.RlmtUpdatedFlag --;		pAC->Pnmi.SirqUpdatedFlag --;		SK_PNMI_CHECKFLAGS("SkPnmiGetStruct: On return");		SK_PNMI_SET_STAT(pBuf, Ret, (SK_U32)(-1));		*pLen = SK_PNMI_MIN_STRUCT_SIZE;		return (SK_PNMI_ERR_GENERAL);	}	/* Retrieve values */	SK_MEMSET((char *)pBuf, 0, SK_PNMI_STRUCT_SIZE);	for (TableIndex = 0; TableIndex < sizeof(IdTable)/sizeof(IdTable[0]);		TableIndex ++) {		InstanceNo = IdTable[TableIndex].InstanceNo;		for (InstanceCnt = 1; InstanceCnt <= InstanceNo;			InstanceCnt ++) {			DstOffset = IdTable[TableIndex].Offset +				(InstanceCnt - 1) *				IdTable[TableIndex].StructSize;			/*			 * For the VPD the instance is not an index number			 * but the key itself. Determin with the instance			 * counter the VPD key to be used.			 */			if (IdTable[TableIndex].Id == OID_SKGE_VPD_KEY ||				IdTable[TableIndex].Id == OID_SKGE_VPD_VALUE ||				IdTable[TableIndex].Id == OID_SKGE_VPD_ACCESS ||				IdTable[TableIndex].Id == OID_SKGE_VPD_ACTION) {				SK_PNMI_READ_U32(KeyArr[InstanceCnt - 1],					Instance);			}			else {				Instance = (SK_U32)InstanceCnt;			}			TmpLen = *pLen - DstOffset;			Ret = IdTable[TableIndex].Func(pAC, IoC, SK_PNMI_GET,				IdTable[TableIndex].Id, (char *)pBuf +				DstOffset, &TmpLen, Instance, TableIndex);			/*			 * An unknown instance error means that we reached			 * the last instance of that variable. Proceed with			 * the next OID in the table and ignore the return			 * code.			 */			if (Ret == SK_PNMI_ERR_UNKNOWN_INST) {				break;			}			if (Ret != SK_PNMI_ERR_OK) {				pAC->Pnmi.MacUpdatedFlag --;				pAC->Pnmi.RlmtUpdatedFlag --;				pAC->Pnmi.SirqUpdatedFlag --;				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_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiPreSetStruct: Called, BufLen=%d\n", *pLen));	return (PnmiStruct(pAC, IoC, SK_PNMI_PRESET, (char *)pBuf, pLen));}/***************************************************************************** * * 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_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiSetStruct: Called, BufLen=%d\n", *pLen));	return (PnmiStruct(pAC, IoC, SK_PNMI_SET, (char *)pBuf, pLen));}/***************************************************************************** * * 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_PORT_SWITCH  Generated by RLMT to notify that the *	                              active port switched. PNMI will split *	                              this into two message ACTIVE_DOWN and *	                              ACTIVE_UP to be future compatible with *	                              load balancing and card fail over. *	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. * * 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;	int		CounterIndex;	int		Ret;	SK_U16		MacStatus;	SK_U64		OverflowStatus;	SK_U64		Mask;	SK_U32		MacCntEvent;	SK_U64		Value;	SK_U16		Register;	SK_EVPARA	EventParam;	SK_U64		NewestValue;	SK_U64		OldestValue;	SK_U64		Delta;	SK_PNMI_ESTIMATE *pEst;#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 long)Event, (unsigned long)Param.Para64));	}#endif	SK_PNMI_CHECKFLAGS("SkPnmiEvent: On call");	switch (Event) {	case SK_PNMI_EVT_SIRQ_OVERFLOW:		PhysPortIndex = (int)Param.Para32[0];		MacStatus = (SK_U16)Param.Para32[1]

⌨️ 快捷键说明

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