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

📄 skgepnmi.c

📁 F:worksip2440a board可启动u-boot-like.tar.gz F:worksip2440a board可启动u-boot-like.tar.gz
💻 C
📖 第 1 页 / 共 5 页
字号:
SK_AC *pAC,		/* Pointer to adapter context */SK_IOC IoC,		/* IO context handle */int Level)		/* Initialization level */{	unsigned int	PortMax;	/* Number of ports */	unsigned int	PortIndex;	/* Current port index in loop */	SK_U16		Val16;		/* Multiple purpose 16 bit variable */	SK_U8		Val8;		/* Mulitple purpose 8 bit variable */	SK_EVPARA	EventParam;	/* Event struct for timer event */	SK_GEPORT	*pPrt;	SK_PNMI_VCT	*pVctBackupData;	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiInit: Called, level=%d\n", Level));	switch (Level) {	case SK_INIT_DATA:		SK_MEMSET((char *)&pAC->Pnmi, 0, sizeof(pAC->Pnmi));		pAC->Pnmi.TrapBufFree = SK_PNMI_TRAP_QUEUE_LEN;		pAC->Pnmi.StartUpTime = SK_PNMI_HUNDREDS_SEC(SkOsGetTime(pAC));		pAC->Pnmi.RlmtChangeThreshold = SK_PNMI_DEF_RLMT_CHG_THRES;		for (PortIndex = 0; PortIndex < SK_MAX_MACS; PortIndex ++) {			pAC->Pnmi.Port[PortIndex].ActiveFlag = SK_FALSE;			pAC->Pnmi.DualNetActiveFlag = SK_FALSE;		}#ifdef SK_PNMI_CHECK		if (SK_PNMI_MAX_IDX != SK_PNMI_CNT_NO) {			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR049, SK_PNMI_ERR049MSG);			SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_INIT | SK_DBGCAT_FATAL,					   ("CounterOffset struct size (%d) differs from"						"SK_PNMI_MAX_IDX (%d)\n",						SK_PNMI_CNT_NO, SK_PNMI_MAX_IDX));			BRK;		}		if (SK_PNMI_MAX_IDX !=			(sizeof(StatAddr) / (sizeof(SK_PNMI_STATADDR) * SK_PNMI_MAC_TYPES))) {			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR050, SK_PNMI_ERR050MSG);			SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_INIT | SK_DBGCAT_FATAL,					   ("StatAddr table size (%d) differs from "						"SK_PNMI_MAX_IDX (%d)\n",						(sizeof(StatAddr) /						 (sizeof(SK_PNMI_STATADDR) * SK_PNMI_MAC_TYPES)),						 SK_PNMI_MAX_IDX));			BRK;		}#endif /* SK_PNMI_CHECK */		break;	case SK_INIT_IO:		/*		 * Reset MAC counters		 */		PortMax = pAC->GIni.GIMacsFound;		for (PortIndex = 0; PortIndex < PortMax; PortIndex ++) {			pAC->GIni.GIFunc.pFnMacResetCounter(pAC, IoC, PortIndex);		}		/* Initialize DSP variables for Vct() to 0xff => Never written! */		for (PortIndex = 0; PortIndex < PortMax; PortIndex ++) {			pPrt = &pAC->GIni.GP[PortIndex];			pPrt->PCableLen =0xff;			pVctBackupData = &pAC->Pnmi.VctBackup[PortIndex];			pVctBackupData->PCableLen = 0xff;		}		/*		 * Get pci bus speed		 */		SK_IN16(IoC, B0_CTST, &Val16);		if ((Val16 & CS_BUS_CLOCK) == 0) {			pAC->Pnmi.PciBusSpeed = 33;		}		else {			pAC->Pnmi.PciBusSpeed = 66;		}		/*		 * Get pci bus width		 */		SK_IN16(IoC, B0_CTST, &Val16);		if ((Val16 & CS_BUS_SLOT_SZ) == 0) {			pAC->Pnmi.PciBusWidth = 32;		}		else {			pAC->Pnmi.PciBusWidth = 64;		}		/*		 * Get chipset		 */		switch (pAC->GIni.GIChipId) {		case CHIP_ID_GENESIS:			pAC->Pnmi.Chipset = SK_PNMI_CHIPSET_XMAC;			break;		case CHIP_ID_YUKON:			pAC->Pnmi.Chipset = SK_PNMI_CHIPSET_YUKON;			break;		default:			break;		}		/*		 * Get PMD and DeviceType		 */		SK_IN8(IoC, B2_PMD_TYP, &Val8);		switch (Val8) {		case 'S':			pAC->Pnmi.PMD = 3;			if (pAC->GIni.GIMacsFound > 1) {				pAC->Pnmi.DeviceType = 0x00020002;			}			else {				pAC->Pnmi.DeviceType = 0x00020001;			}			break;		case 'L':			pAC->Pnmi.PMD = 2;			if (pAC->GIni.GIMacsFound > 1) {				pAC->Pnmi.DeviceType = 0x00020004;			}			else {				pAC->Pnmi.DeviceType = 0x00020003;			}			break;		case 'C':			pAC->Pnmi.PMD = 4;			if (pAC->GIni.GIMacsFound > 1) {				pAC->Pnmi.DeviceType = 0x00020006;			}			else {				pAC->Pnmi.DeviceType = 0x00020005;			}			break;		case 'T':			pAC->Pnmi.PMD = 5;			if (pAC->GIni.GIMacsFound > 1) {				pAC->Pnmi.DeviceType = 0x00020008;			}			else {				pAC->Pnmi.DeviceType = 0x00020007;			}			break;		default :			pAC->Pnmi.PMD = 1;			pAC->Pnmi.DeviceType = 0;			break;		}		/*		 * Get connector		 */		SK_IN8(IoC, B2_CONN_TYP, &Val8);		switch (Val8) {		case 'C':			pAC->Pnmi.Connector = 2;			break;		case 'D':			pAC->Pnmi.Connector = 3;			break;		case 'F':			pAC->Pnmi.Connector = 4;			break;		case 'J':			pAC->Pnmi.Connector = 5;			break;		case 'V':			pAC->Pnmi.Connector = 6;			break;		default:			pAC->Pnmi.Connector = 1;			break;		}		break;	case SK_INIT_RUN:		/*		 * Start timer for RLMT change counter		 */		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;	default:		break; /* Nothing todo */	}	return (0);}/***************************************************************************** * * SkPnmiGetVar - Retrieves the value of a single OID * * Description: *	Calls a general sub-function for all this stuff. If the instance *	-1 is passed, the values of all instances are returned in an *	array of values. * * 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. *	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 SkPnmiGetVar(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 to which to mgmt data will be retrieved */unsigned int *pLen,	/* On call: buffer length. On return: used buffer */SK_U32 Instance,	/* Instance (1..n) that is to be queried or -1 */SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode allways zero */{	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiGetVar: Called, Id=0x%x, BufLen=%d, Instance=%d, NetIndex=%d\n",			Id, *pLen, Instance, NetIndex));	return (PnmiVar(pAC, IoC, SK_PNMI_GET, Id, (char *)pBuf, pLen,		Instance, NetIndex));}/***************************************************************************** * * SkPnmiPreSetVar - Presets 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 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_U32 NetIndex)	/* NetIndex (0..n), in single net mode allways zero */{	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiPreSetVar: Called, Id=0x%x, BufLen=%d, Instance=%d, NetIndex=%d\n",			Id, *pLen, Instance, NetIndex));	return (PnmiVar(pAC, IoC, SK_PNMI_PRESET, Id, (char *)pBuf, pLen,		Instance, NetIndex));}/***************************************************************************** * * 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_U32 NetIndex)	/* NetIndex (0..n), in single net mode allways zero */{	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiSetVar: Called, Id=0x%x, BufLen=%d, Instance=%d, NetIndex=%d\n",			Id, *pLen, Instance, NetIndex));	return (PnmiVar(pAC, IoC, SK_PNMI_SET, Id, (char *)pBuf, pLen,		Instance, NetIndex));}/***************************************************************************** * * 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. *	SK_PNMI_ERR_UNKNOWN_NET  The requested NetIndex doesn't exist */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 */SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode allways zero */{	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_ENTRIES][SK_PNMI_VPD_KEY_SIZE];	SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_CTRL,		("PNMI: SkPnmiGetStruct: Called, BufLen=%d, NetIndex=%d\n",			*pLen, NetIndex));	if (*pLen < SK_PNMI_STRUCT_SIZE) {		if (*pLen >= SK_PNMI_MIN_STRUCT_SIZE) {

⌨️ 快捷键说明

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