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

📄 skgepnmi.c

📁 这是Marvell Technology Group Ltd. 4355 (rev 12)网卡在linux下的驱动程序源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
#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 /* DEBUG */		PhysPortIndex = (unsigned int)Param.Para64;		/* Update XMAC statistic to get fresh values. */		if (MacUpdate(pAC, IoC, 0, pAC->GIni.GIMacsFound - 1) !=			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 inactive. */		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) { /* SingleNet mode. */			pAC->Pnmi.DualNetActiveFlag = SK_FALSE;		}		else { /* DualNet mode. */			pAC->Pnmi.DualNetActiveFlag = SK_TRUE;		}		break;	case SK_PNMI_EVT_VCT_RESET:		PhysPortIndex = Param.Para32[0];		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],					SK_PNMI_VCT_TIMER_CHECK, SKGE_PNMI, SK_PNMI_EVT_VCT_RESET, Param);				break;			}			VctGetResults(pAC, IoC, PhysPortIndex);			EventParam.Para32[0] = PhysPortIndex;			EventParam.Para32[1] = -1;			SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_RESET, EventParam);			/* 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, *	SkGePnmiPreSetVar, or SkGePnmiSetVar. * * Returns: *	SK_PNMI_ERR_XXX. For details have a look at the description of the *	calling functions. *	SK_PNMI_ERR_UNKNOWN_NET  The requested NetIndex doesn't exist */PNMI_STATIC int PnmiVar(SK_AC *pAC,		/* Pointer to adapter context */SK_IOC IoC,		/* IO context handle */int Action,		/* GET/PRESET/SET action */SK_U32 Id,		/* Object ID that is to be processed */char *pBuf,		/* Buffer used for the management data transfer */unsigned int *pLen,	/* Total length of pBuf management data  */SK_U32 Instance,	/* Instance (1..n) that is to be set or -1 */SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode always zero */{	unsigned int	TableIndex;	int		Ret;	if ((TableIndex = LookupId(Id)) == (unsigned int)(-1)) {		*pLen = 0;		return (SK_PNMI_ERR_UNKNOWN_OID);	}	/* Check NetIndex. */	if (NetIndex >= pAC->Rlmt.NumNets) {		return (SK_PNMI_ERR_UNKNOWN_NET);	}	SK_PNMI_CHECKFLAGS("PnmiVar: On call");	Ret = IdTable[TableIndex].Func(pAC, IoC, Action, Id, pBuf, pLen,		Instance, TableIndex, NetIndex);	SK_PNMI_CHECKFLAGS("PnmiVar: On return");	return (Ret);}/***************************************************************************** * * PnmiStruct - Presets and Sets data in structure SK_PNMI_STRUCT_DATA * * Description: *	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. The function is called *	by SkGePnmiPreSetStruct and SkGePnmiSetStruct. * * Returns: *	SK_PNMI_ERR_XXX. The codes are described in the calling functions. *	SK_PNMI_ERR_UNKNOWN_NET  The requested NetIndex doesn't exist */PNMI_STATIC int PnmiStruct(SK_AC *pAC,		/* Pointer to adapter context */SK_IOC IoC,		/* IO context handle */int  Action,	/* PRESET/SET action to be performed */char *pBuf,		/* Buffer used for the management data transfer */unsigned int *pLen,	/* Length of pBuf management data buffer */SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode always zero */

⌨️ 快捷键说明

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