📄 skgepnmi.c
字号:
{ 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 another way. */ Ret = SK_DRIVER_SELFTEST(pAC, IoC); pAC->Pnmi.TestResult = Ret; break; case SK_PNMI_ACT_RESETCNT: /* Set all counters and timestamps to zero. */ ResetCounter(pAC, IoC, NetIndex); break; default: SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR006, SK_PNMI_ERR006MSG); return (SK_PNMI_ERR_GENERAL); } return (SK_PNMI_ERR_OK);}/***************************************************************************** * * Mac8023Stat - OID handler of OID_GEN_XXX and OID_802_3_XXX * * Description: * Retrieves the statistic values of the virtual port (logical * index 0). Only special OIDs of NDIS are handled which consist * of a 32 bit instead of a 64 bit value. The OIDs are public * because perhaps some other platform can use them too. * * 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_UNKNOWN_INST The requested instance of the OID doesn't * exist (e.g. port instance 3 on a two port * adapter. */PNMI_STATIC int Mac8023Stat(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_U64 StatVal; SK_U32 StatVal32; SK_BOOL Is64BitReq = SK_FALSE; /* Only the active MAC is returned. */ if (Instance != (SK_U32)(-1) && Instance != 1) { *pLen = 0; return (SK_PNMI_ERR_UNKNOWN_INST); } /* Check action type. */ if (Action != SK_PNMI_GET) { *pLen = 0; return (SK_PNMI_ERR_READ_ONLY); } /* Check length. */ switch (Id) { case OID_802_3_PERMANENT_ADDRESS: case OID_802_3_CURRENT_ADDRESS: if (*pLen < sizeof(SK_MAC_ADDR)) { *pLen = size
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -