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

📄 fei82557end.c

📁 INTEL IXP425的VXWORKS BSP
💻 C
📖 第 1 页 / 共 5 页
字号:
* The number of clusters can be specified by either passing a value in the * nCluster parameter, in which case the nCluster value must be at least * nRFDs * 2, or by setting the cluster to RFD ratio (clToRfdRatio) to a number * equal or greater than 2.* * * The <nTfds> parameter specifies the number of transmit descriptor/buffers * to be allocated. If this parameter is less than two, a default of 64 is used.** The <nRfds> parameter specifies the number of receive descriptors to be* allocated. If this parameter is less than two or NONE (-1) a default of * 128 is used.* * The <flags> parameter specifies the user flags may control the run-time * characteristics of the Ethernet chip. Not implemented.* * The <offset> parameter is used to align IP header on word boundary for CPUs * that need long word aligned access to the IP packet (this will normally be * zero or two). This parameter is optional, the default value is zero.** The <deviceId> parameter is used to indicate the specific type of device * being used, the 82557 or subsequent.  This is used to determine if features * which were introduced after the 82557 can be used. The default is the 82557. * If this is set to any value other than ZERO (0), NONE (-1), or * FEI82557_DEVICE_ID (0x1229) it is assumed that the device will support * features not in the 82557.** The <maxRxFrames> parameter limits the number of frames the receive handler * will service in one pass. It is intended to prevent the tNetTask from * monoploizing the CPU and starving applications. This parameter is optional, * the default value is nRFDs * 2.* * The <clToRfdRatio> parameter sets the number of clusters as a ratio of nRFDs. * The minimum setting for this parameter is 2. This parameter is optional, the* default value is 5.* * The <nClusters> parameter sets the number of clusters to allocate. This value * must be  at least nRFD * 2.  If this value is set then the <clToRfdRatio> is * ignored. This parameter is optional, the default is nRFDs * clToRfdRatio.* * RETURNS: an END object pointer, or NULL on error.** SEE ALSO: ifLib,* .I "Intel 82557 User's Manual"*/END_OBJ* fei82557EndLoad    (    char *initString      /* parameter string */    )    {    DRV_CTRL *  pDrvCtrl;       /* pointer to DRV_CTRL structure */    UCHAR       enetAddr[6];    /* ethernet address */    UINT32      speed;    UINT32      scbStatus;    char        bucket[2];    DRV_LOG (DRV_DEBUG_LOAD, ("Loading end\n"), 1, 2, 3, 4, 5, 6);	/*printf(" fei82557EndLoad initString=%s \n",initString);*/    if (initString == NULL)        return (NULL);    if (initString[0] == 0)        {        bcopy ((char *)DEV_NAME, (void *)initString, DEV_NAME_LEN);        return (0);        }    /* allocate the device structure */    pDrvCtrl = (DRV_CTRL *) calloc (sizeof (DRV_CTRL), 1);    if (pDrvCtrl == NULL)        return (NULL);    /* Parse InitString */    if (fei82557InitParse (pDrvCtrl, initString) == ERROR)        goto errorExit;        /* sanity check the unit number */    if (pDrvCtrl->unit < 0 )        goto errorExit;        /* Initialize pDrvCtrl->rbdIndex */    pDrvCtrl->rbdIndex = 0;    pDrvCtrl->rfdIndex = 0;    /*      * initialize the default parameter for the Physical medium      * layer control user has his chance to override in the BSP,      * just be CAREFUL      */    pDrvCtrl->board.phyAddr  = 1;    pDrvCtrl->board.phySpeed = PHY_AUTO_SPEED;    pDrvCtrl->board.phyDpx   = PHY_AUTO_DPX;    pDrvCtrl->board.others   = 0;    pDrvCtrl->board.tcbTxThresh = FEI_TCB_TX_THRESH;    /* callout to perform adapter init */    if (sys557Init (pDrvCtrl->unit, &pDrvCtrl->board) == ERROR)        goto errorExit;  	    /* get CSR address from the FEI_BOARD_INFO structure */    if ((pDrvCtrl->pCSR = (CSR_ID) pDrvCtrl->board.baseAddr) == NULL)        goto errorExit;        /* probe for memory-mapped CSR */    CACHE_PIPE_FLUSH();    CSR_WORD_RD (CSR_STAT_OFFSET, scbStatus);    if (vxMemProbe ((char *) &scbStatus, VX_READ, 2,                    &bucket[0]) != OK)        {        DRV_LOG (DRV_DEBUG_LOAD,                   (": need MMU mapping for address 0x%x\n"),                   (UINT32) pDrvCtrl->pCSR, 2, 3, 4, 5, 6);        goto errorExit;        }        /* memory initialization */       if (fei82557InitMem (pDrvCtrl) == ERROR)        goto errorExit;       /* initialize the Physical medium layer */      if (fei82557PhyInit (pDrvCtrl) != OK)        {        DRV_LOG (DRV_DEBUG_LOAD,"Check line connection.\n",0,0,0,0,0,0); 	 printf("\r\n  Check line connection.\n");	        }     speed = ((((int) pDrvCtrl->board.phySpeed) == PHY_100MBS) ?                FEI_100MBS : FEI_10MBS);    if (fei82557ClkRate == 0)        fei82557ClkRate = sysClkRateGet ();    /* Create TX restart watchdog ID */    pDrvCtrl->txRetryWDId = wdCreate();    if(pDrvCtrl->txRetryWDId == NULL)        {        DRV_LOG (DRV_DEBUG_LOAD, "failed to create TX watchdog ID\n",                 0, 0, 0, 0, 0, 0);        goto errorExit;        }    /*      * reset the chip: this should be replaced by a true      * adapter reset routine, once the init code is here.     */     #if 1 /*2004/05/16*/	    if (fei82557Reset (pDrvCtrl) != OK)        goto errorExit;     #endif /*2004/05/16*/    /* CU and RU should be idle following fei82557Reset() */    if (fei82557SCBCommand (pDrvCtrl, SCB_C_CULDBASE, TRUE, 0x0) == ERROR)        goto errorExit;    if (fei82557SCBCommand (pDrvCtrl, SCB_C_RULDBASE, TRUE, 0x0) == ERROR)        goto errorExit;    pDrvCtrl->attached = TRUE;    /* get our ethernet hardware address */    bcopy ((char *)&pDrvCtrl->board.enetAddr,           (char *)&enetAddr[0],           FEI_ADDR_LEN);    DRV_LOG (DRV_DEBUG_LOAD, ("fei82557Load...\n                         ADRR: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x \n "),                         enetAddr[0],                        enetAddr[1],                        enetAddr[2],                        enetAddr[3],                        enetAddr[4],                        enetAddr[5]);    /* endObj initializations */    if (END_OBJ_INIT (&pDrvCtrl->endObj, (DEV_OBJ*) pDrvCtrl,                      DEV_NAME, pDrvCtrl->unit, &netFuncs,                      "Intel 82557 Ethernet Enhanced Network Driver") == ERROR)        goto errorExit;#ifdef INCLUDE_RFC_2233    /* Initialize MIB-II entries (for RFC 2233 ifXTable) */    pDrvCtrl->endObj.pMib2Tbl = m2IfAlloc(M2_ifType_ethernet_csmacd,                                          (UINT8*) enetAddr, 6,                                          ETHERMTU, speed,                                          DEV_NAME, pDrvCtrl->unit);    if (pDrvCtrl->endObj.pMib2Tbl == NULL)        {        logMsg ("%s%d - MIB-II initializations failed\n",                (int)DEV_NAME, pDrvCtrl->unit,0,0,0,0);        goto errorExit;        }            /*      * Set the RFC2233 flag bit in the END object flags field and     * install the counter update routines.     */    m2IfPktCountRtnInstall(pDrvCtrl->endObj.pMib2Tbl, m2If8023PacketCount);    /*     * Make a copy of the data in mib2Tbl struct as well. We do this     * mainly for backward compatibility issues. There might be some     * code that might be referencing the END pointer and might     * possibly do lookups on the mib2Tbl, which will cause all sorts     * of problems.     */    bcopy ((char *)&pDrvCtrl->endObj.pMib2Tbl->m2Data.mibIfTbl,                   (char *)&pDrvCtrl->endObj.mib2Tbl, sizeof (M2_INTERFACETBL));    /* Mark the device ready */    END_OBJ_READY (&pDrvCtrl->endObj,                   IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST |                   END_MIB_2233);#else    /* Old RFC 1213 mib2 interface */    if (END_MIB_INIT (&pDrvCtrl->endObj, M2_ifType_ethernet_csmacd,                      (u_char *) &enetAddr[0], FEI_ADDR_LEN,                      ETHERMTU, speed) == ERROR)        goto errorExit;    /* Mark the device ready */    END_OBJ_READY (&pDrvCtrl->endObj,                   IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST);#endif /* INCLUDE_RFC_2233 */    DRV_LOG (DRV_DEBUG_LOAD, ("fei82557Load... Done \n"), 1, 2, 3, 4, 5, 6);    return (&pDrvCtrl->endObj);errorExit:    DRV_LOG (DRV_DEBUG_LOAD, "fei82557Load failed\n", 0,0,0,0,0,0);    fei82557Unload (pDrvCtrl);    free ((char *) pDrvCtrl);    return NULL;    }/********************************************************************************* fei82557Unload - unload a driver from the system** RETURNS: N/A*/LOCAL STATUS fei82557Unload    (    DRV_CTRL *pDrvCtrl       /* pointer to DRV_CTRL structure */    )    {        DRV_LOG (DRV_DEBUG_LOAD, ("Unloading end..."), 1, 2, 3, 4, 5, 6);#ifdef INCLUDE_RFC_2233    /* Free MIB-II entries */    m2IfFree(pDrvCtrl->endObj.pMib2Tbl);    pDrvCtrl->endObj.pMib2Tbl = NULL;#endif /* INCLUDE_RFC_2233 */    pDrvCtrl->attached = FALSE;    /* free lists */    END_OBJECT_UNLOAD (&pDrvCtrl->endObj);    /* free allocated memory if necessary */    if ((FEI_FLAG_ISSET (FEI_OWN_MEM)) &&         (pDrvCtrl->pClusterBase != NULL))        cacheDmaFree (pDrvCtrl->pClusterBase);    /* free allocated memory if necessary */    cfree (pDrvCtrl->pMclBlkMemArea);    DRV_LOG (DRV_DEBUG_LOAD, ("fei82557Unload... Done\n"), 1, 2, 3, 4, 5, 6);    return (OK);    }/********************************************************************************* fei82557InitParse - parse parameter values from initString** RETURNS: OK or ERROR*/LOCAL STATUS fei82557InitParse    (    DRV_CTRL *  pDrvCtrl,               /* pointer to DRV_CTRL structure */

⌨️ 快捷键说明

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