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

📄 bcm570x.c

📁 F:worksip2440a board可启动u-boot-like.tar.gz F:worksip2440a board可启动u-boot-like.tar.gz
💻 C
📖 第 1 页 / 共 4 页
字号:
LM_STATUSMM_ReadConfig32(PLM_DEVICE_BLOCK pDevice,		LM_UINT32 Offset,		LM_UINT32 *pValue32){    UM_DEVICE_BLOCK *pUmDevice;    pUmDevice = (UM_DEVICE_BLOCK *) pDevice;    pci_read_config_dword(pUmDevice->pdev,			  Offset, (u32 *) pValue32);    return LM_STATUS_SUCCESS;}LM_STATUSMM_WriteConfig32(PLM_DEVICE_BLOCK pDevice,		 LM_UINT32 Offset,		 LM_UINT32 Value32){    UM_DEVICE_BLOCK *pUmDevice;    pUmDevice = (UM_DEVICE_BLOCK *) pDevice;    pci_write_config_dword(pUmDevice->pdev,			   Offset, Value32);    return LM_STATUS_SUCCESS;}LM_STATUSMM_ReadConfig16(PLM_DEVICE_BLOCK pDevice,		LM_UINT32 Offset,		LM_UINT16 *pValue16){    UM_DEVICE_BLOCK *pUmDevice;    pUmDevice = (UM_DEVICE_BLOCK *) pDevice;    pci_read_config_word(pUmDevice->pdev,			 Offset, (u16*) pValue16);    return LM_STATUS_SUCCESS;}LM_STATUSMM_WriteConfig16(PLM_DEVICE_BLOCK pDevice,		 LM_UINT32 Offset,		 LM_UINT16 Value16){    UM_DEVICE_BLOCK *pUmDevice;    pUmDevice = (UM_DEVICE_BLOCK *) pDevice;    pci_write_config_word(pUmDevice->pdev,			  Offset, Value16);    return LM_STATUS_SUCCESS;}LM_STATUSMM_AllocateSharedMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,			PLM_VOID *pMemoryBlockVirt,			PLM_PHYSICAL_ADDRESS pMemoryBlockPhy,			LM_BOOL Cached){    PLM_VOID pvirt;    PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;    dma_addr_t mapping;    pvirt = malloc(BlockSize);    mapping = (dma_addr_t)(pvirt);    if (!pvirt)	return LM_STATUS_FAILURE;    pUmDevice->mem_list[pUmDevice->mem_list_num] = pvirt;    pUmDevice->dma_list[pUmDevice->mem_list_num] = mapping;    pUmDevice->mem_size_list[pUmDevice->mem_list_num++] = BlockSize;    memset(pvirt, 0, BlockSize);    *pMemoryBlockVirt = (PLM_VOID) pvirt;    MM_SetAddr (pMemoryBlockPhy, (dma_addr_t) mapping);    return LM_STATUS_SUCCESS;}LM_STATUSMM_AllocateMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,	PLM_VOID *pMemoryBlockVirt){    PLM_VOID pvirt;    PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;    pvirt = malloc(BlockSize);    if (!pvirt)	return LM_STATUS_FAILURE;    pUmDevice->mem_list[pUmDevice->mem_list_num] = pvirt;    pUmDevice->dma_list[pUmDevice->mem_list_num] = 0;    pUmDevice->mem_size_list[pUmDevice->mem_list_num++] = BlockSize;    memset(pvirt, 0, BlockSize);    *pMemoryBlockVirt = pvirt;    return LM_STATUS_SUCCESS;}LM_STATUSMM_MapMemBase(PLM_DEVICE_BLOCK pDevice){    printf("BCM570x PCI Memory base address @0x%x\n",	   (unsigned int)pDevice->pMappedMemBase);    return LM_STATUS_SUCCESS;}LM_STATUSMM_InitializeUmPackets(PLM_DEVICE_BLOCK pDevice){    int i;    void* skb;    PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;    PUM_PACKET pUmPacket = NULL;    PLM_PACKET pPacket = NULL;    for (i = 0; i < pDevice->RxPacketDescCnt; i++) {	pPacket = QQ_PopHead(&pDevice->RxPacketFreeQ.Container);	pUmPacket = (PUM_PACKET) pPacket;	if (pPacket == 0) {	    printf("MM_InitializeUmPackets: Bad RxPacketFreeQ\n");	}	skb = bcm570xPktAlloc(pUmDevice->index,			      pPacket->u.Rx.RxBufferSize + 2);	if (skb == 0) {	    pUmPacket->skbuff = 0;	    QQ_PushTail(&pUmDevice->rx_out_of_buf_q.Container, pPacket);	    printf("MM_InitializeUmPackets: out of buffer.\n");	    continue;	}	pUmPacket->skbuff = skb;	QQ_PushTail(&pDevice->RxPacketFreeQ.Container, pPacket);    }    pUmDevice->rx_low_buf_thresh = pDevice->RxPacketDescCnt / 8;    return LM_STATUS_SUCCESS;}LM_STATUSMM_GetConfig(PLM_DEVICE_BLOCK pDevice){    PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;    int index = pDevice->index;    if (auto_speed[index] == 0)	pDevice->DisableAutoNeg = TRUE;    else	pDevice->DisableAutoNeg = FALSE;    if (line_speed[index] == 0) {	pDevice->RequestedMediaType =	    LM_REQUESTED_MEDIA_TYPE_AUTO;	pDevice->DisableAutoNeg = FALSE;    }    else {	if (line_speed[index] == 1000) {	    if (pDevice->EnableTbi) {		pDevice->RequestedMediaType =		    LM_REQUESTED_MEDIA_TYPE_FIBER_1000MBPS_FULL_DUPLEX;	    }	    else if (full_duplex[index]) {		pDevice->RequestedMediaType =		    LM_REQUESTED_MEDIA_TYPE_UTP_1000MBPS_FULL_DUPLEX;	    }	    else {		pDevice->RequestedMediaType =		    LM_REQUESTED_MEDIA_TYPE_UTP_1000MBPS;	    }	    if (!pDevice->EnableTbi)		pDevice->DisableAutoNeg = FALSE;	}	else if (line_speed[index] == 100) {	    if (full_duplex[index]) {		pDevice->RequestedMediaType =		    LM_REQUESTED_MEDIA_TYPE_UTP_100MBPS_FULL_DUPLEX;	    }	    else {		pDevice->RequestedMediaType =		    LM_REQUESTED_MEDIA_TYPE_UTP_100MBPS;	    }	}	else if (line_speed[index] == 10) {	    if (full_duplex[index]) {		pDevice->RequestedMediaType =		    LM_REQUESTED_MEDIA_TYPE_UTP_10MBPS_FULL_DUPLEX;	    }	    else {		pDevice->RequestedMediaType =		    LM_REQUESTED_MEDIA_TYPE_UTP_10MBPS;	    }	}	else {	    pDevice->RequestedMediaType =		LM_REQUESTED_MEDIA_TYPE_AUTO;	    pDevice->DisableAutoNeg = FALSE;	}    }    pDevice->FlowControlCap = 0;    if (rx_flow_control[index] != 0) {	pDevice->FlowControlCap |= LM_FLOW_CONTROL_RECEIVE_PAUSE;    }    if (tx_flow_control[index] != 0) {	pDevice->FlowControlCap |= LM_FLOW_CONTROL_TRANSMIT_PAUSE;    }    if ((auto_flow_control[index] != 0) &&	(pDevice->DisableAutoNeg == FALSE)) {	pDevice->FlowControlCap |= LM_FLOW_CONTROL_AUTO_PAUSE;	if ((tx_flow_control[index] == 0) &&	    (rx_flow_control[index] == 0)) {	    pDevice->FlowControlCap |=		LM_FLOW_CONTROL_TRANSMIT_PAUSE |		LM_FLOW_CONTROL_RECEIVE_PAUSE;	}    }    /* Default MTU for now */    pUmDevice->mtu = 1500;#if T3_JUMBO_RCV_RCB_ENTRY_COUNT    if (pUmDevice->mtu > 1500) {	pDevice->RxMtu = pUmDevice->mtu;	pDevice->RxJumboDescCnt = DEFAULT_JUMBO_RCV_DESC_COUNT;    }    else {	pDevice->RxJumboDescCnt = 0;    }    pDevice->RxJumboDescCnt = rx_jumbo_desc_cnt[index];#else    pDevice->RxMtu = pUmDevice->mtu;#endif    if (T3_ASIC_REV(pDevice->ChipRevId) == T3_ASIC_REV_5701) {	pDevice->UseTaggedStatus = TRUE;	pUmDevice->timer_interval = CFG_HZ;    }    else {	pUmDevice->timer_interval = CFG_HZ/50;    }    pDevice->TxPacketDescCnt = tx_pkt_desc_cnt[index];    pDevice->RxStdDescCnt = rx_std_desc_cnt[index];    /* Note:  adaptive coalescence really isn't adaptive in this driver */    pUmDevice->rx_adaptive_coalesce = rx_adaptive_coalesce[index];    if (!pUmDevice->rx_adaptive_coalesce) {	pDevice->RxCoalescingTicks = rx_coalesce_ticks[index];	if (pDevice->RxCoalescingTicks > MAX_RX_COALESCING_TICKS)	    pDevice->RxCoalescingTicks = MAX_RX_COALESCING_TICKS;	pUmDevice->rx_curr_coalesce_ticks =pDevice->RxCoalescingTicks;	pDevice->RxMaxCoalescedFrames = rx_max_coalesce_frames[index];	if (pDevice->RxMaxCoalescedFrames>MAX_RX_MAX_COALESCED_FRAMES)	    pDevice->RxMaxCoalescedFrames =				MAX_RX_MAX_COALESCED_FRAMES;	pUmDevice->rx_curr_coalesce_frames =	    pDevice->RxMaxCoalescedFrames;	pDevice->StatsCoalescingTicks = stats_coalesce_ticks[index];	if (pDevice->StatsCoalescingTicks>MAX_STATS_COALESCING_TICKS)	    pDevice->StatsCoalescingTicks=		MAX_STATS_COALESCING_TICKS;	}	else {	    pUmDevice->rx_curr_coalesce_frames =		DEFAULT_RX_MAX_COALESCED_FRAMES;	    pUmDevice->rx_curr_coalesce_ticks =		DEFAULT_RX_COALESCING_TICKS;	}    pDevice->TxCoalescingTicks = tx_coalesce_ticks[index];    if (pDevice->TxCoalescingTicks > MAX_TX_COALESCING_TICKS)	pDevice->TxCoalescingTicks = MAX_TX_COALESCING_TICKS;    pDevice->TxMaxCoalescedFrames = tx_max_coalesce_frames[index];    if (pDevice->TxMaxCoalescedFrames > MAX_TX_MAX_COALESCED_FRAMES)	pDevice->TxMaxCoalescedFrames = MAX_TX_MAX_COALESCED_FRAMES;    if (enable_wol[index]) {	pDevice->WakeUpModeCap = LM_WAKE_UP_MODE_MAGIC_PACKET;	pDevice->WakeUpMode = LM_WAKE_UP_MODE_MAGIC_PACKET;    }    pDevice->NicSendBd = TRUE;    /* Don't update status blocks during interrupt */    pDevice->RxCoalescingTicksDuringInt = 0;    pDevice->TxCoalescingTicksDuringInt = 0;    return LM_STATUS_SUCCESS;}LM_STATUSMM_StartTxDma(PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket){    PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;    printf("Start TX DMA: dev=%d packet @0x%x\n",	   (int)pUmDevice->index, (unsigned int)pPacket);    return LM_STATUS_SUCCESS;}LM_STATUSMM_CompleteTxDma(PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket){    PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;    printf("Complete TX DMA: dev=%d packet @0x%x\n",	   (int)pUmDevice->index, (unsigned int)pPacket);    return LM_STATUS_SUCCESS;}LM_STATUSMM_IndicateStatus(PLM_DEVICE_BLOCK pDevice, LM_STATUS Status){    char buf[128];    char lcd[4];    PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;    LM_FLOW_CONTROL flow_control;    pUmDevice->delayed_link_ind = 0;    memset(lcd, 0x0, 4);    if (Status == LM_STATUS_LINK_DOWN) {	sprintf(buf,"eth%d: %s: NIC Link is down\n",		pUmDevice->index,pUmDevice->name);	lcd[0] = 'L';lcd[1]='N';lcd[2]='K';lcd[3] = '?';    } else if (Status == LM_STATUS_LINK_ACTIVE) {	sprintf(buf,"eth%d:%s: ", pUmDevice->index, pUmDevice->name);	if (pDevice->LineSpeed == LM_LINE_SPEED_1000MBPS){	    strcat(buf,"1000 Mbps ");	    lcd[0] = '1';lcd[1]='G';lcd[2]='B';	} else if (pDevice->LineSpeed == LM_LINE_SPEED_100MBPS){	    strcat(buf,"100 Mbps ");	    lcd[0] = '1';lcd[1]='0';lcd[2]='0';	} else if (pDevice->LineSpeed == LM_LINE_SPEED_10MBPS){	    strcat(buf,"10 Mbps ");	    lcd[0] = '1';lcd[1]='0';lcd[2]=' ';	}	if (pDevice->DuplexMode == LM_DUPLEX_MODE_FULL){	    strcat(buf, "full duplex");	    lcd[3] = 'F';	} else {	    strcat(buf, "half duplex");	    lcd[3] = 'H';	}	strcat(buf, " link up");	flow_control = pDevice->FlowControl &	    (LM_FLOW_CONTROL_RECEIVE_PAUSE |	     LM_FLOW_CONTROL_TRANSMIT_PAUSE);	if (flow_control) {	    if (flow_control & LM_FLOW_CONTROL_RECEIVE_PAUSE) {		strcat(buf,", receive ");		if (flow_control & LM_FLOW_CONTROL_TRANSMIT_PAUSE)		    strcat(buf," & transmit ");	    }	    else {		strcat(buf,", transmit ");	    }	    strcat(buf,"flow control ON");	} else {	    strcat(buf, ", flow control OFF");	}	strcat(buf,"\n");	printf("%s",buf);    }#if 0    sysLedDsply(lcd[0],lcd[1],lcd[2],lcd[3]);#endif    return LM_STATUS_SUCCESS;}LM_STATUSMM_FreeRxBuffer(PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket){    PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;    PUM_PACKET pUmPacket;    void *skb;    pUmPacket = (PUM_PACKET) pPacket;    if ((skb = pUmPacket->skbuff))	bcm570xPktFree(pUmDevice->index, skb);    pUmPacket->skbuff = 0;    return LM_STATUS_SUCCESS;}unsigned longMM_AnGetCurrentTime_us(PAN_STATE_INFO pAnInfo){    return get_timer(0);}/* *   Transform an MBUF chain into a single MBUF. *   This routine will fail if the amount of data in the *   chain overflows a transmit buffer.  In that case, *   the incoming MBUF chain will be freed.  This routine can *   also fail by not being able to allocate a new MBUF (including *   cluster and mbuf headers).  In that case the failure is *   non-fatal.  The incoming cluster chain is not freed, giving *   the caller the choice of whether to try a retransmit later. */LM_STATUSMM_CoalesceTxBuffer(PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket){    PUM_PACKET pUmPacket = (PUM_PACKET) pPacket;    PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;    void *skbnew;    int len = 0;    if (len == 0)

⌨️ 快捷键说明

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