📄 rclanmtl.c
字号:
for (i = 0; i < (int) sizeof(RCLINKSTATS) / 4; i++) pReturnAddr[i] = p32[i]; return RC_RTN_NO_ERROR; }/*** =========================================================================** Get82558LinkStatus()** =========================================================================*/RC_RETURNRCGetLinkStatus(U16 AdapterID, PU32 ReturnAddr, PFNWAITCALLBACK WaitCallback){ U32 msgOffset; volatile U32 timeout; volatile PU32 pMsg; volatile PU32 p32; PPAB pPab;/*kprintf("Get82558LinkStatus() ReturnPhysAddr:0x%08.8ulx\n", ReturnAddr);*/ pPab = PCIAdapterBlock[AdapterID]; if (pPab == NULL) return RC_RTN_ADPTR_NOT_REGISTERED; msgOffset = pPab->p_atu->InQueue; if (msgOffset == 0xFFFFFFFF) {#ifdef DEBUG dprintf("Get82558LinkStatus(): Inbound Free Q empty!\n");#endif return RC_RTN_FREE_Q_EMPTY; } /* calc virual address of msg - virual already mapped to physical */ pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);/*dprintf("Get82558LinkStatus - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*//*dprintf("Get82558LinkStatus - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/ pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0; pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID; pMsg[2] = DEFAULT_RECV_INIT_CONTEXT; pMsg[3] = 0x112; /* transaction context */ pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LINK_STATUS; pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); p32 = (PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB)); *p32 = 0xFFFFFFFF; /* post to Inbound Post Q */ pPab->p_atu->InQueue = msgOffset; timeout = 100000; while (1) { U32 i; if (WaitCallback) (*WaitCallback)(); for (i = 0; i < 1000; i++) ; if (*p32 != 0xFFFFFFFF) break; if (!timeout--) {#ifdef DEBUG kprintf("Timeout waiting for link status\n");#endif return RC_RTN_MSG_REPLY_TIMEOUT; } } *ReturnAddr = *p32; /* 1 = up 0 = down */ return RC_RTN_NO_ERROR; }/*** =========================================================================** RCGetMAC()**** get the MAC address the adapter is listening for in non-promiscous mode.** MAC address is in media format.** =========================================================================*/RC_RETURNRCGetMAC(U16 AdapterID, PU8 mac, PFNWAITCALLBACK WaitCallback){ unsigned i, timeout; U32 off; PU32 p; U32 temp[2]; PPAB pPab; PATU p_atu; pPab = PCIAdapterBlock[AdapterID]; if (pPab == NULL) return RC_RTN_ADPTR_NOT_REGISTERED; p_atu = pPab->p_atu; p_atu->EtherMacLow = 0; /* first zero return data */ p_atu->EtherMacHi = 0; off = p_atu->InQueue; /* get addresss of message */ if (0xFFFFFFFF == off) return RC_RTN_FREE_Q_EMPTY; p = (PU32)(pPab->pPci45LinBaseAddr + off);#ifdef RCDEBUG printk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n", (uint)p_atu, (uint)off, (uint)p);#endif /* RCDEBUG */ /* setup private message */ p[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0; p[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID; p[2] = 0; /* initiator context */ p[3] = 0x218; /* transaction context */ p[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_MAC_ADDR; p_atu->InQueue = off; /* send it to the I2O device */#ifdef RCDEBUG printk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n", (uint)p_atu, (uint)off, (uint)p);#endif /* RCDEBUG */ /* wait for the rcpci45 board to update the info */ timeout = 1000000; while (0 == p_atu->EtherMacLow) { if (WaitCallback) (*WaitCallback)(); for (i = 0; i < 1000; i++) ; if (!timeout--) { printk("rc_getmac: Timeout\n"); return RC_RTN_MSG_REPLY_TIMEOUT; } } /* read the mac address */ temp[0] = p_atu->EtherMacLow; temp[1] = p_atu->EtherMacHi; memcpy((char *)mac, (char *)temp, 6);#ifdef RCDEBUG// printk("rc_getmac: 0x%X\n", ptr);#endif /* RCDEBUG */ return RC_RTN_NO_ERROR;} /*** =========================================================================** RCSetMAC()**** set MAC address the adapter is listening for in non-promiscous mode.** MAC address is in media format.** =========================================================================*/RC_RETURNRCSetMAC(U16 AdapterID, PU8 mac){ 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] = SEVEN_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_SET_MAC_ADDR; pMsg[5] = *(unsigned *)mac; /* first four bytes */ pMsg[6] = *(unsigned *)(mac + 4); /* last two bytes */ pPab->p_atu->InQueue = off; /* send it to the I2O device */ return RC_RTN_NO_ERROR ;}/*** =========================================================================** RCSetLinkSpeed()**** set ethernet link speed. ** input: speedControl - determines action to take as follows** 0 = reset and auto-negotiate (NWay)** 1 = Full Duplex 100BaseT** 2 = Half duplex 100BaseT** 3 = Full Duplex 10BaseT** 4 = Half duplex 10BaseT** all other values are ignore (do nothing)** =========================================================================*/RC_RETURNRCSetLinkSpeed(U16 AdapterID, U16 LinkSpeedCode){ 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_SET_LINK_SPEED; pMsg[5] = LinkSpeedCode; /* link speed code */ pPab->p_atu->InQueue = off; /* send it to the I2O device */ return RC_RTN_NO_ERROR ;}/*** =========================================================================** RCSetPromiscuousMode()**** Defined values for Mode:** 0 - turn off promiscuous mode** 1 - turn on promiscuous mode**** =========================================================================*/RC_RETURNRCSetPromiscuousMode(U16 AdapterID, U16 Mode){ 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_SET_PROMISCUOUS_MODE; pMsg[5] = Mode; /* promiscuous mode setting */ pPab->p_atu->InQueue = off; /* send it to the device */ return RC_RTN_NO_ERROR ;}/*** =========================================================================** RCGetPromiscuousMode()**** get promiscuous mode setting**** Possible return values placed in pMode:** 0 = promisuous mode not set** 1 = promisuous mode is set**** =========================================================================*/RC_RETURNRCGetPromiscuousMode(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_PROMISCUOUS_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;}/*** =========================================================================** RCSetBroadcastMode()**** Defined values for Mode:** 0 - turn off promiscuous mode** 1 - turn on promiscuous mode**** =========================================================================*/RC_RETURNRCSetBroadcastMode(U16 AdapterID, U16 Mode){ 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_SET_BROADCAST_MODE; pMsg[5] = Mode; /* promiscuous mode setting */ pPab->p_atu->InQueue = off; /* send it to the device */ return RC_RTN_NO_ERROR ;}/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -