📄 rclanmtl.c
字号:
** =========================================================================** RCGetBroadcastMode()**** get promiscuous mode setting**** Possible return values placed in pMode:** 0 = promisuous mode not set** 1 = promisuous mode is set**** =========================================================================*/RC_RETURNRCGetBroadcastMode(U16 AdapterID, PU32 pMode, PFNWAITCALLBACK WaitCallback){ U32 msgOffset, timeout; PU32 pMsg; volatile PU32 p32; PPAB pPab; pPab =PCIAdapterBlock[AdapterID]; msgOffset = pPab->p_atu->InQueue; if (msgOffset == 0xFFFFFFFF) { kprintf("RCGetLinkSpeed(): Inbound Free Q empty!\n"); return RC_RTN_FREE_Q_EMPTY; } /* calc virtual address of msg - virtual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset); /* virtual pointer to return buffer - clear first two dwords */ p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); p32[0] = 0xff; /* setup private message */ pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0; pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID; pMsg[2] = 0; /* initiator context */ pMsg[3] = 0x219; /* transaction context */ pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_BROADCAST_MODE; /* phys address to return status - area right after PAB */ pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; /* wait for response */ timeout = 1000000; while(1) { int i; if (WaitCallback) (*WaitCallback)(); for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ ; if (p32[0] != 0xff) break; if (!timeout--) { kprintf("Timeout waiting for promiscuous mode from adapter\n"); kprintf("0x%8.8lx\n", p32[0]); return RC_RTN_NO_LINK_SPEED; } } /* get mode */ *pMode = (U8)((volatile PU8)p32)[0] & 0x0f; return RC_RTN_NO_ERROR;}/*** =========================================================================** RCGetLinkSpeed()**** get ethernet link speed. **** 0 = Unknown** 1 = Full Duplex 100BaseT** 2 = Half duplex 100BaseT** 3 = Full Duplex 10BaseT** 4 = Half duplex 10BaseT**** =========================================================================*/RC_RETURNRCGetLinkSpeed(U16 AdapterID, PU32 pLinkSpeedCode, PFNWAITCALLBACK WaitCallback){ U32 msgOffset, timeout; PU32 pMsg; volatile PU32 p32; U8 IOPLinkSpeed; PPAB pPab; pPab =PCIAdapterBlock[AdapterID]; msgOffset = pPab->p_atu->InQueue; if (msgOffset == 0xFFFFFFFF) { kprintf("RCGetLinkSpeed(): Inbound Free Q empty!\n"); return RC_RTN_FREE_Q_EMPTY; } /* calc virtual address of msg - virtual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset); /* virtual pointer to return buffer - clear first two dwords */ p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); p32[0] = 0xff; /* setup private message */ pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0; pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID; pMsg[2] = 0; /* initiator context */ pMsg[3] = 0x219; /* transaction context */ pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LINK_SPEED; /* phys address to return status - area right after PAB */ pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; /* wait for response */ timeout = 1000000; while(1) { int i; if (WaitCallback) (*WaitCallback)(); for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ ; if (p32[0] != 0xff) break; if (!timeout--) { kprintf("Timeout waiting for link speed from IOP\n"); kprintf("0x%8.8lx\n", p32[0]); return RC_RTN_NO_LINK_SPEED; } } /* get Link speed */ IOPLinkSpeed = (U8)((volatile PU8)p32)[0] & 0x0f; *pLinkSpeedCode= IOPLinkSpeed; return RC_RTN_NO_ERROR;}/*** =========================================================================** RCReportDriverCapability(U16 AdapterID, U32 capability)**** Currently defined bits:** WARM_REBOOT_CAPABLE 0x01**** =========================================================================*/RC_RETURNRCReportDriverCapability(U16 AdapterID, U32 capability){ U32 off; PU32 pMsg; PPAB pPab; pPab =PCIAdapterBlock[AdapterID]; if (pPab == NULL) return RC_RTN_ADPTR_NOT_REGISTERED; off = pPab->p_atu->InQueue; /* get addresss of message */ if (0xFFFFFFFF == off) return RC_RTN_FREE_Q_EMPTY; pMsg = (PU32)(pPab->pPci45LinBaseAddr + off); /* setup private message */ pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0; pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID; pMsg[2] = 0; /* initiator context */ pMsg[3] = 0x219; /* transaction context */ pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_REPORT_DRIVER_CAPABILITY; pMsg[5] = capability; pPab->p_atu->InQueue = off; /* send it to the I2O device */ return RC_RTN_NO_ERROR ;}/*** =========================================================================** RCGetFirmwareVer()**** Return firmware version in the form "SoftwareVersion : Bt BootVersion"**** =========================================================================*/RC_RETURNRCGetFirmwareVer(U16 AdapterID, PU8 pFirmString, PFNWAITCALLBACK WaitCallback){ U32 msgOffset, timeout; PU32 pMsg; volatile PU32 p32; PPAB pPab; pPab =PCIAdapterBlock[AdapterID]; msgOffset = pPab->p_atu->InQueue; if (msgOffset == 0xFFFFFFFF) { kprintf("RCGetFirmwareVer(): Inbound Free Q empty!\n"); return RC_RTN_FREE_Q_EMPTY; } /* calc virtual address of msg - virtual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset); /* virtual pointer to return buffer - clear first two dwords */ p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); p32[0] = 0xff; /* setup private message */ pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0; pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID; pMsg[2] = 0; /* initiator context */ pMsg[3] = 0x219; /* transaction context */ pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_FIRMWARE_REV; /* phys address to return status - area right after PAB */ pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; /* wait for response */ timeout = 1000000; while(1) { int i; if (WaitCallback) (*WaitCallback)(); for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ ; if (p32[0] != 0xff) break; if (!timeout--) { kprintf("Timeout waiting for link speed from IOP\n"); return RC_RTN_NO_FIRM_VER; } } strcpy(pFirmString, (PU8)p32); return RC_RTN_NO_ERROR;}/*** =========================================================================** RCResetLANCard()**** ResourceFlags indicates whether to return buffer resource explicitly** to host or keep and reuse.** CallbackFunction (if not NULL) is the function to be called when ** reset is complete.** If CallbackFunction is NULL, ReturnAddr will have a 1 placed in it when** reset is done (if not NULL).**** =========================================================================*/RC_RETURN RCResetLANCard(U16 AdapterID, U16 ResourceFlags, PU32 ReturnAddr, PFNCALLBACK CallbackFunction){ unsigned long off; PU32 pMsg; PPAB pPab; int i; long timeout = 0; pPab =PCIAdapterBlock[AdapterID]; if (pPab == NULL) return RC_RTN_ADPTR_NOT_REGISTERED; off = pPab->p_atu->InQueue; /* get addresss of message */ if (0xFFFFFFFF == off) return RC_RTN_FREE_Q_EMPTY; pPab->pCallbackFunc = CallbackFunction; pMsg = (PU32)(pPab->pPci45LinBaseAddr + off); /* setup message */ pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0; pMsg[1] = I2O_LAN_RESET << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID; pMsg[2] = DEFAULT_RECV_INIT_CONTEXT; pMsg[3] = ResourceFlags << 16; /* resource flags */ pPab->p_atu->InQueue = off; /* send it to the I2O device */ if (CallbackFunction == (PFNCALLBACK)NULL) { /* call RCProcI2OMsgQ() until something in pPab->pCallbackFunc or until timer goes off */ while (pPab->pCallbackFunc == (PFNCALLBACK)NULL) { RCProcI2OMsgQ(AdapterID); for (i = 0; i < 100000; i++) /* please don't hog the bus!!! */ ; timeout++; if (timeout > 10000) { break; } } if (ReturnAddr != (PU32)NULL) *ReturnAddr = (U32)pPab->pCallbackFunc; } return RC_RTN_NO_ERROR ;}/*** =========================================================================** RCResetIOP()**** Send StatusGet Msg, wait for results return directly to buffer.**** =========================================================================*/RC_RETURN RCResetIOP(U16 AdapterID){ U32 msgOffset, timeout; PU32 pMsg; PPAB pPab; volatile PU32 p32; pPab = PCIAdapterBlock[AdapterID]; msgOffset = pPab->p_atu->InQueue; if (msgOffset == 0xFFFFFFFF) { return RC_RTN_FREE_Q_EMPTY; } /* calc virtual address of msg - virtual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset); pMsg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_0; pMsg[1] = I2O_EXEC_IOP_RESET << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID; pMsg[2] = 0; /* universal context */ pMsg[3] = 0; /* universal context */ pMsg[4] = 0; /* universal context */ pMsg[5] = 0; /* universal context */ /* phys address to return status - area right after PAB */ pMsg[6] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); pMsg[7] = 0; pMsg[8] = 1; /* return 1 byte */ /* virual pointer to return buffer - clear first two dwords */ p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); p32[0] = 0; p32[1] = 0; /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; /* wait for response */ timeout = 1000000; while(1) { int i; for (i = 0; i < 1000; i++) /* please don't hog the bus!!! */ ; if (p32[0] || p32[1]) break; if (!timeout--) { printk("RCResetIOP timeout\n"); return RC_RTN_MSG_REPLY_TIMEOUT; } } return RC_RTN_NO_ERROR;}/*** =========================================================================** RCShutdownLANCard()**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -