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

📄 skgepnmi.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 5 页
字号:
 *	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 */{	int		Ret;	unsigned int	TableIndex;	unsigned int	DstOffset;	unsigned int	Len;	unsigned int	InstanceNo;	unsigned int	InstanceCnt;	SK_U32		Instance;	SK_U32		Id;	/* Check if the passed buffer has the right size */	if (*pLen < SK_PNMI_STRUCT_SIZE) {		/* Check if we can return the error within the buffer */		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);	}	    /* Check NetIndex */	if (NetIndex >= pAC->Rlmt.NumNets) {		return (SK_PNMI_ERR_UNKNOWN_NET);	}		SK_PNMI_CHECKFLAGS("PnmiStruct: On call");	/*	 * Update the values of RLMT and SIRQ and increment semaphores to	 * indicate that an update was already done.	 */	if ((Ret = RlmtUpdate(pAC, IoC, NetIndex)) != 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);	}	pAC->Pnmi.RlmtUpdatedFlag ++;	pAC->Pnmi.SirqUpdatedFlag ++;	/* Preset/Set values */	for (TableIndex = 0; TableIndex < ID_TABLE_SIZE; TableIndex ++) {		if ((IdTable[TableIndex].Access != SK_PNMI_RW) &&			(IdTable[TableIndex].Access != SK_PNMI_WO)) {			continue;		}		InstanceNo = IdTable[TableIndex].InstanceNo;		Id = IdTable[TableIndex].Id;		for (InstanceCnt = 1; InstanceCnt <= InstanceNo;			InstanceCnt ++) {			DstOffset = IdTable[TableIndex].Offset +				(InstanceCnt - 1) *				IdTable[TableIndex].StructSize;			/*			 * Because VPD multiple instance variables are			 * not setable we do not need to evaluate VPD			 * instances. Have a look to VPD instance			 * calculation in SkPnmiGetStruct().			 */			Instance = (SK_U32)InstanceCnt;			/*			 * Evaluate needed buffer length			 */			Len = 0;			Ret = IdTable[TableIndex].Func(pAC, IoC,				SK_PNMI_GET, IdTable[TableIndex].Id,				NULL, &Len, Instance, TableIndex, NetIndex);			if (Ret == SK_PNMI_ERR_UNKNOWN_INST) {				break;			}			if (Ret != SK_PNMI_ERR_TOO_SHORT) {				pAC->Pnmi.RlmtUpdatedFlag --;				pAC->Pnmi.SirqUpdatedFlag --;				SK_PNMI_CHECKFLAGS("PnmiStruct: On return");				SK_PNMI_SET_STAT(pBuf,					SK_PNMI_ERR_GENERAL, DstOffset);				*pLen = SK_PNMI_MIN_STRUCT_SIZE;				return (SK_PNMI_ERR_GENERAL);			}			if (Id == OID_SKGE_VPD_ACTION) {				switch (*(pBuf + DstOffset)) {				case SK_PNMI_VPD_CREATE:					Len = 3 + *(pBuf + DstOffset + 3);					break;				case SK_PNMI_VPD_DELETE:					Len = 3;					break;				default:					Len = 1;					break;				}			}			/* Call the OID handler function */			Ret = IdTable[TableIndex].Func(pAC, IoC, Action,				IdTable[TableIndex].Id, pBuf + DstOffset,				&Len, Instance, TableIndex, NetIndex);			if (Ret != SK_PNMI_ERR_OK) {				pAC->Pnmi.RlmtUpdatedFlag --;				pAC->Pnmi.SirqUpdatedFlag --;				SK_PNMI_CHECKFLAGS("PnmiStruct: On return");				SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_BAD_VALUE,					DstOffset);				*pLen = SK_PNMI_MIN_STRUCT_SIZE;				return (SK_PNMI_ERR_BAD_VALUE);			}		}	}	pAC->Pnmi.RlmtUpdatedFlag --;	pAC->Pnmi.SirqUpdatedFlag --;	SK_PNMI_CHECKFLAGS("PnmiStruct: On return");	SK_PNMI_SET_STAT(pBuf, SK_PNMI_ERR_OK, (SK_U32)(-1));	return (SK_PNMI_ERR_OK);}/***************************************************************************** * * LookupId - Lookup an OID in the IdTable * * Description: *	Scans the IdTable to find the table entry of an OID. * * Returns: *	The table index or -1 if not found. */PNMI_STATIC int LookupId(SK_U32 Id)		/* Object identifier to be searched */{	int i;	for (i = 0; i < ID_TABLE_SIZE; i++) {		if (IdTable[i].Id == Id) {			return i;		}	}	return (-1);}/***************************************************************************** * * OidStruct - Handler of OID_SKGE_ALL_DATA * * Description: *	This OID performs a Get/Preset/SetStruct call and returns all data *	in a SK_PNMI_STRUCT_DATA structure. * * 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_INST The requested instance of the OID doesn't *                           exist (e.g. port instance 3 on a two port *	                         adapter. */PNMI_STATIC int OidStruct(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,	/* On call: pBuf buffer length. On return: used buffer */SK_U32 Instance,	/* Instance (1..n) that is to be queried or -1 */unsigned int TableIndex, /* Index to the Id table */SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode always zero */{	if (Id != OID_SKGE_ALL_DATA) {		SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR003,			SK_PNMI_ERR003MSG);		*pLen = 0;		return (SK_PNMI_ERR_GENERAL);	}	/*	 * Check instance. We only handle single instance variables	 */	if (Instance != (SK_U32)(-1) && Instance != 1) {		*pLen = 0;		return (SK_PNMI_ERR_UNKNOWN_INST);	}	switch (Action) {	case SK_PNMI_GET:		return (SkPnmiGetStruct(pAC, IoC, pBuf, pLen, NetIndex));	case SK_PNMI_PRESET:		return (SkPnmiPreSetStruct(pAC, IoC, pBuf, pLen, NetIndex));	case SK_PNMI_SET:		return (SkPnmiSetStruct(pAC, IoC, pBuf, pLen, NetIndex));	}	SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR004, SK_PNMI_ERR004MSG);	*pLen = 0;	return (SK_PNMI_ERR_GENERAL);}/***************************************************************************** * * Perform - OID handler of OID_SKGE_ACTION * * Description: *	None. * * 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_INST The requested instance of the OID doesn't *                           exist (e.g. port instance 3 on a two port *	                         adapter. */PNMI_STATIC int Perform(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,	/* On call: pBuf buffer length. On return: used buffer */SK_U32 Instance,	/* Instance (1..n) that is to be queried or -1 */unsigned int TableIndex, /* Index to the Id table */SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode always zero */{	int	Ret;	SK_U32	ActionOp;	/*	 * Check instance. We only handle single instance variables	 */	if (Instance != (SK_U32)(-1) && Instance != 1) {		*pLen = 0;		return (SK_PNMI_ERR_UNKNOWN_INST);	}	if (*pLen < sizeof(SK_U32)) {		*pLen = sizeof(SK_U32);		return (SK_PNMI_ERR_TOO_SHORT);	}	/* Check if a get should be performed */	if (Action == SK_PNMI_GET) {		/* A get is easy. We always return the same value */		ActionOp = (SK_U32)SK_PNMI_ACT_IDLE;		SK_PNMI_STORE_U32(pBuf, ActionOp);		*pLen = sizeof(SK_U32);		return (SK_PNMI_ERR_OK);	}	/* Continue with PRESET/SET action */	if (*pLen > sizeof(SK_U32)) {		return (SK_PNMI_ERR_BAD_VALUE);	}	/* Check if the command is a known one */	SK_PNMI_READ_U32(pBuf, ActionOp);	if (*pLen > sizeof(SK_U32) ||		(ActionOp != SK_PNMI_ACT_IDLE &&		ActionOp != SK_PNMI_ACT_RESET &&		ActionOp != SK_PNMI_ACT_SELFTEST &&		ActionOp != SK_PNMI_ACT_RESETCNT)) {		*pLen = 0;		return (SK_PNMI_ERR_BAD_VALUE);	}	/* A preset ends here */	if (Action == SK_PNMI_PRESET) {		return (SK_PNMI_ERR_OK);	}	switch (ActionOp) {	case SK_PNMI_ACT_IDLE:		/* Nothing to do */		break;	case SK_PNMI_ACT_RESET:		/*		 * Perform a driver reset or something that comes near		 * to this.		 */		Ret = SK_DRIVER_RESET(pAC, IoC);		if (Ret != 0) {			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR005,				SK_PNMI_ERR005MSG);			return (SK_PNMI_ERR_GENERAL);		}		break;	case SK_PNMI_ACT_SELFTEST:		/*		 * Perform a driver selftest or something similar to this.		 * Currently this feature is not used and will probably		 * implemented in 

⌨️ 快捷键说明

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