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

📄 gei82543end.c

📁 IXP425的BSP代码
💻 C
📖 第 1 页 / 共 5 页
字号:
                  GEI_MAX_JUMBO_MTU_SIZE : pDrvCtrl->mtu);        }    else  /* normal frame */        pDrvCtrl->mtu = ETHERMTU;    /* increase transmit storage in FIFO for jumbo frames */      if (pDrvCtrl->mtu > ETHERMTU)        {        GEI_WRITE_REG(INTEL_82543GC_PBA, 0x20); /* 24KB for TX buffer */        }    /* perform memory allocation for descriptors */    if (gei82543EndMemInit (pDrvCtrl) == ERROR)        goto errorExit;    /* set up device structure based on user's flags */       if (pDrvCtrl->usrFlags & GEI_END_SET_TIMER)        {        pDrvCtrl->timerId = wdCreate ();        if (pDrvCtrl->timerId == NULL)            DRV_LOG (DRV_DEBUG_LOAD, ("create timer fails\n"),                                       1, 2, 3, 4, 5, 6);        }    if (pDrvCtrl->usrFlags & GEI_END_SET_RX_PRIORITY)        pDrvCtrl->dmaPriority = DMA_RX_PRIORITY;    else        pDrvCtrl->dmaPriority = DMA_FAIR_RX_TX;    if (pDrvCtrl->usrFlags & GEI_END_FREE_RESOURCE_DELAY)        {        pDrvCtrl->txIntDelay  = TXINT_DELAY_MORE;        pDrvCtrl->txResoFreeQuick = FALSE;        }    else        {        pDrvCtrl->txIntDelay  = TXINT_DELAY_LESS;        pDrvCtrl->txResoFreeQuick = TRUE;         }#ifdef INCLUDE_TBI_COMPATIBLE    pDrvCtrl->tbiCompatibility = FALSE;#endif /* INCLUDE_TBI_COMPATIBLE */       /* stop/reset the chip before configuration */    gei82543Reset (pDrvCtrl);        /* disable all chip interrupt */    gei82543DisableChipInt (pDrvCtrl);    /* turn off system interrupts */    SYS_INT_DISABLE(pDrvCtrl);    /* set the default value for device */    pDrvCtrl->rxIntDelay     = DEFAULT_RXINT_DELAY;    pDrvCtrl->maxRxNumPerInt = DEFAULT_RXRES_PROCESS_FACTOR *                                pDrvCtrl->rxDescNum;    pDrvCtrl->timerInterval  = DEFAULT_TIMER_INTERVAL;    pDrvCtrl->flowCtrl       = DEFAULT_FLOW_CONTRL;       pDrvCtrl->duplex         = DEFAULT_DUPLEX_MODE;         /* Misc. setting */    pDrvCtrl->flags          = 0;    pDrvCtrl->linkStatus     = LINK_STATUS_UNKNOWN;    pDrvCtrl->linkMethod     = GEI82543_HW_AUTO;    pDrvCtrl->txConfigureWord     = (TXCW_ANE_BIT | TXCW_FD_BIT);    pDrvCtrl->multiCastFilterType = DEFAULT_MULTI_FILTER_TYPE;     pDrvCtrl->attach         = FALSE;    pDrvCtrl->devStartFlag   = FALSE;    /* initialize the END and MIB2 parts of the structure */    /*     * The M2 element must come from m2Lib.h      * This setting is for a DIX type ethernet device.     */        if (END_OBJ_INIT (&pDrvCtrl->end, (DEV_OBJ *)pDrvCtrl, DEVICE_NAME,                      pDrvCtrl->unit, &gei82543EndFuncTable,                      "gei82543End Driver.") == ERROR ||         END_MIB_INIT (&pDrvCtrl->end, M2_ifType_ethernet_csmacd,                      &pDrvCtrl->adaptor.enetAddr[0], 6, pDrvCtrl->mtu,                      END_SPEED) == ERROR )        goto errorExit;   /* disable RX/TX operations now, will be re-enable in Start function */    gei82543TxRxDisable (pDrvCtrl);    pDrvCtrl->attach = TRUE;    DRV_LOG (DRV_DEBUG_LOAD, ("loading gei82543End...OK\n"),1,2,3,4,5,6);    return (&pDrvCtrl->end);errorExit:    /* free all allocated memory */    gei82543MemAllFree (pDrvCtrl);    if (pDrvCtrl != NULL)         free ((char *)pDrvCtrl);    DRV_LOG (DRV_DEBUG_LOAD, ("Loading gei82543End...Error\n"),                                1, 2, 3, 4, 5, 6);    return NULL;    }/*************************************************************************** gei82534EndParse - parse the init string** Parse the input string.  Fill in values in the driver control structure.** RETURNS: OK or ERROR for invalid arguments.*/LOCAL STATUS gei82543EndParse    (    END_DEVICE *    pDrvCtrl,       /* device pointer */    char *          initString      /* information string */    )    {    char *    tok;    char *    pHolder = NULL;    DRV_LOG (DRV_DEBUG_LOAD, ("gei82543EndParse...\n"), 1, 2, 3, 4, 5, 6);    /* parse the initString */    tok = strtok_r (initString, ":", &pHolder);    if (tok == NULL)    return ERROR;    pDrvCtrl->unit = atoi (tok);     /* address of shared memory */    tok = strtok_r (NULL, ":", &pHolder);    if (tok == NULL)    return ERROR;    pDrvCtrl->pMemBase = (char *) strtoul (tok, NULL, 16);     /* size of shared memory */    tok = strtok_r (NULL, ":", &pHolder);    if (tok == NULL)    return ERROR;    pDrvCtrl->memSize = strtoul (tok, NULL, 16);    /* number of rx descriptors */    tok = strtok_r (NULL, ":", &pHolder);    if (tok == NULL)     return ERROR;    pDrvCtrl->rxDescNum = strtoul (tok, NULL, 16);    /* number of tx descriptors */    tok = strtok_r (NULL, ":", &pHolder);    if (tok == NULL)    return ERROR;    pDrvCtrl->txDescNum = strtoul (tok, NULL, 16);       /* get the usrFlags */    tok = strtok_r (NULL, ":", &pHolder);    if (tok == NULL)    return ERROR;    pDrvCtrl->usrFlags = strtoul (tok, NULL, 16);    /* get the offset value */    tok = strtok_r (NULL, ":", &pHolder);    if (tok != NULL)        pDrvCtrl->offset = atoi (tok);    DRV_LOG (DRV_DEBUG_LOAD,            ("gei82543EndParse: unit=%d pMemBase=0x%x memSize=0x%x              rxDescNums=%d txDescNum=%d, usrFlags=0x%x\n"),              pDrvCtrl->unit,               (int)pDrvCtrl->pMemBase,              (int) pDrvCtrl->memSize,              pDrvCtrl->rxDescNum,              pDrvCtrl->txDescNum,              pDrvCtrl->usrFlags              );    /* check Jumbo Frame support */    if (pDrvCtrl->usrFlags & GEI_END_JUMBO_FRAME_SUPPORT)        {                /* get mtu */        tok = strtok_r (NULL, ":", &pHolder);        if (tok != NULL)            pDrvCtrl->mtu = atoi (tok);        DRV_LOG (DRV_DEBUG_LOAD, ("mtu = %d\n"),pDrvCtrl->mtu,                  2, 3, 4, 5, 6);        }    return OK;    }/*************************************************************************** gei82543MemAllFree - free all memory allocated by driver** This routine returns all allocated memory by this driver to OS** RETURN: N/A*/LOCAL void gei82543MemAllFree     (    END_DEVICE * pDrvCtrl    /* device to be initialized */    )    {    if (pDrvCtrl == NULL)        return;    /* release TxDesCtl */    if (pDrvCtrl->pTxDesCtlBase != NULL)        {        free (pDrvCtrl->pTxDesCtlBase);        }    if (pDrvCtrl->pTxPollBufAdr != NULL)        {        cacheDmaFree (pDrvCtrl->pTxPollBufAdr);        }    /* release TX/RX descriptors and RX buffer */    if (pDrvCtrl->pMemBase != NULL && (pDrvCtrl->memAllocFlag == TRUE))        {        cacheDmaFree (pDrvCtrl->pMemBase);        }    /* release RX mBlk pool */    if (pDrvCtrl->pMclkArea != NULL)        {        cfree (pDrvCtrl->pMclkArea);        }           /* release netPool structure */    if (pDrvCtrl->end.pNetPool != NULL)        {	    if (netPoolDelete(pDrvCtrl->end.pNetPool) != OK)            {            LOGMSG("netPoolDelete fails\n", 0,0,0,0,0,0);            }	    free ((char *)pDrvCtrl->end.pNetPool);        }    return;    }/*************************************************************************** gei82543EndMemInit - allocate and initialize memory for driver** This routine allocates and initializes memory for descriptors and * corresponding buffers, and sets up the receive data pool for receiving * packets. ** RETURNS: OK or ERROR.*/LOCAL STATUS gei82543EndMemInit    (    END_DEVICE * pDrvCtrl    /* device to be initialized */    )    {    M_CL_CONFIG geiMclBlkConfig; /* Mblk */    CL_DESC     geiClDesc;      /* Cluster descriptor */    UINT32      size;           /* required memory size */    UINT32      tmpBase;        /* temporary memory base */    UINT32      bufSz;          /* real cluster size */    int         bufNum;         /* temp variable */    DRV_LOG (DRV_DEBUG_LOAD, ("gei82543EndMemInit...\n"), 1, 2, 3, 4, 5, 6);    /* set the default TX/RX descriptor Number */    if (pDrvCtrl->txDescNum == 0)        pDrvCtrl->txDescNum = DEFAULT_NUM_TXDES;    if (pDrvCtrl->rxDescNum == 0)        pDrvCtrl->rxDescNum = DEFAULT_NUM_RXDES;    /* round up to multiple of 8, hardware requirement */    pDrvCtrl->txDescNum = ROUND_UP_MULTIPLE(pDrvCtrl->txDescNum,                                            INTEL_82543GC_MULTIPLE_DES);    pDrvCtrl->rxDescNum = ROUND_UP_MULTIPLE((UINT32)pDrvCtrl->rxDescNum,                                          (UINT32)INTEL_82543GC_MULTIPLE_DES);    /* calculate reasonable receive buffer size */    size = pDrvCtrl->mtu + GEI_DEFAULT_ETHERHEADER + ETHER_CRC_LENGTH;    if (size > GEI_MAX_FRAME_SIZE)        return ERROR;    if (pDrvCtrl->usrFlags & GEI_END_JUMBO_FRAME_SUPPORT)        {        for (bufSz = 2048; bufSz <= 16384; bufSz = bufSz << 1)             {                        if (size <= bufSz)                 {                 pDrvCtrl->rxBufSize = bufSz;                 break;                 }             }        }    else /* normal frame */        pDrvCtrl->rxBufSize = 2048;    /* add cluster ID and offset */    bufSz = size + pDrvCtrl->offset + CL_OVERHEAD;    bufNum = bufSz / GEI_DESC_ALIGN_BYTE;    if (bufSz != (bufNum * GEI_DESC_ALIGN_BYTE))              bufSz = (bufNum + 1) * GEI_DESC_ALIGN_BYTE;    /* get the needed memory size */    size = pDrvCtrl->txDescNum * TXDESC_SIZE +       /* for TX descriptor */           pDrvCtrl->rxDescNum * RXDESC_SIZE +       /* for RX descriptor */           pDrvCtrl->rxDescNum * bufSz *             /* for RX buffer */           (DEFAULT_LOAN_RXBUF_FACTOR + 1) +         /* for RX loan buffer */           1024;                                     /* for alignment */    if ((int)(pDrvCtrl->pMemBase) == NONE)        {        if (!CACHE_DMA_IS_WRITE_COHERENT ())            {            DRV_LOG (DRV_DEBUG_LOAD, ("gei82543EndMemInit: shared memory not                                        cache coherent\n"), 1, 2, 3, 4, 5, 6);            return ERROR;            }                /* alloc memory in driver */        pDrvCtrl->pMemBase = cacheDmaMalloc (size);        if (pDrvCtrl->pMemBase == NULL)      /* no memory available */            {            DRV_LOG (DRV_DEBUG_LOAD, ("gei82543EndMemInit: could not obtain                      memory\n"), 1, 2, 3, 4, 5, 6);            return (ERROR);            }        pDrvCtrl->memSize = size;        pDrvCtrl->cacheFuncs = cacheDmaFuncs;        pDrvCtrl->memAllocFlag = TRUE;        }    else

⌨️ 快捷键说明

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