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

📄 ixethaccsysend.c

📁 ixp425 bsp for vxworks
💻 C
📖 第 1 页 / 共 3 页
字号:
 * It is assumed that the MAC addresses are stored in non-volatile storage. * * @return IX_SUCCESS - MAC address successfuly set * @return IX_FAIL - Error setting MAC address */PRIVATE IX_STATUS ixdp425EthAccMacSet(int port)    {    IxEthAccMacAddr npeMacAddr;#ifdef IXDP_ETHACC_USE_NVRAM_MAC    if (sysNvRamGet((UINT8 *)&npeMacAddr.macAddress,                     IX_IEEE803_MAC_ADDRESS_SIZE,                     nvRamNpeMacAddr[port]) == ERROR)        {        printf("ixe %d - Unable to read MAC address from non-volatile storage!\n"               , port              );        return(IX_FAIL);        }    /* Check for a valid MAC address - Only compare first three bytes */    if ( bcmp( (char *)&npeMacAddr.macAddress, ixdp425IntelMacPrefix, 3) )        {        /* Don't have a valid MAC in NVRAM so we fall back to Intel's base addresses */        bcopy ((char *)sysIxEthAccEndEnetAddr, (char *)npeMacAddr.macAddress, 6);        npeMacAddr.macAddress[5] += port;        printf("ixe ETH PHY %d Hard Coded MAC address is: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n"           , port           ,npeMacAddr.macAddress[0], npeMacAddr.macAddress[1]           ,npeMacAddr.macAddress[2], npeMacAddr.macAddress[3]           ,npeMacAddr.macAddress[4], npeMacAddr.macAddress[5]);        }    else        {#ifdef SYS_END_DEBUG        printf("ixe ETH PHY %d MAC address is: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n"           , port           ,npeMacAddr.macAddress[0], npeMacAddr.macAddress[1]           ,npeMacAddr.macAddress[2], npeMacAddr.macAddress[3]           ,npeMacAddr.macAddress[4], npeMacAddr.macAddress[5]);#endif /* SYS_END_DEBUG */        }#else	/* Hard encoded MAC */    bcopy ((char *)sysIxEthAccEndEnetAddr, (char *)npeMacAddr.macAddress, 6);    npeMacAddr.macAddress[5] += port;    printf("ixe ETH PHY %d Hard Coded MAC address is: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n"           , port           ,npeMacAddr.macAddress[0], npeMacAddr.macAddress[1]           ,npeMacAddr.macAddress[2], npeMacAddr.macAddress[3]           ,npeMacAddr.macAddress[4], npeMacAddr.macAddress[5]);#endif     if (ixEthAccPortUnicastMacAddressSet(port, &npeMacAddr) != IX_ETH_ACC_SUCCESS)        {        return(IX_FAIL);        }    return(IX_SUCCESS);    }#ifndef INCLUDE_IXETHACC_POLL_MODE/* task used for traffic debug (debug through interrupts*   is not possible)*/static void dispatchTask(void){    while (1)    {	taskDelay(0);	(*dispatcherFunc) (IX_QMGR_QUELOW_GROUP);    }}#endif/** * @fn IX_STATUS ixdp425EthAccStartDispatch() * * @param BOOL interruptMode - start in interrupt or polled mode * * This function starts the Queue manager dispatch timer. *  * @return IX_SUCCESS - Dispatch timer successfully started * @return IX_FAIL - Error starting dispatch timer */PRIVATE IX_STATUS ixdp425EthAccStartDispatch(BOOL interruptMode)    {    ixQMgrDispatcherLoopGet(&dispatcherFunc);    if (interruptMode)   /* Interrupt mode */        {#ifdef SYS_END_DEBUG        DRV_LOG("ixdp425EthAccStartDispatch: interrupt mode\n");#endif /* SYS_END_DEBUG */        /*          * Hook the QM QLOW dispatcher to the interrupt controller.          * The ethernet NPEs use queues 24 through 27.         */        if (ixOsServIntBind(IXP425_INT_LVL_QM1,                            (VOIDFUNCPTR)dispatcherFunc,                            (void *)IX_QMGR_QUELOW_GROUP) != IX_SUCCESS)            {            printf("ixe Ethernet Lib - Failed to bind to QM1 interrupt\n"                  );            return(IX_FAIL);            }        }    else    /* Polled mode */        {#ifdef INCLUDE_IXETHACC_POLL_MODE        /*          * Hook the QM QLOW dispatcher to clock interrupts	 * (best performances)         */        ixpAuxClkDisable();        ixpAuxClkRateSet (IXDP_ETHACC_POLL_TICKS_PER_SECOND);        ixpAuxClkConnect ((FUNCPTR)dispatcherFunc,                          IX_QMGR_QUELOW_GROUP);        ixpAuxClkEnable();#else /* INCLUDE_IXETHACC_POLL_MODE */        /*          * Run the QM QLOW dispatcher in a task	 * (for debug purposes)         */	taskSpawn("QMgr",     /* Name */		  100,        /* Priority */		  0,          /* Options */		  4096 * 2,   /* Stack Size */		  (FUNCPTR)(dispatchTask),		  0,0,0,0,0,0,0,0,0,0);#endif /* INCLUDE_IXETHACC_POLL_MODE */        }    return(IX_SUCCESS);    }/* this function is called once at initialisation */IX_STATUS ixdp425EthLibInit(){      UINT32 phyNo;    if (ixdp425EthLibInitialised)        {        printf("ixe Ethernet Lib - Ethernet codelet already initialised\n");        return(IX_SUCCESS);        }    /* Init ixEthAccPhyAddresses to 0xffffffff to indicate non-existent */    for (phyNo=0; phyNo<IX_ETH_ACC_NUMBER_OF_PORTS; phyNo++)        ixEthAccPhyAddresses[phyNo] = 0xffffffff;    /* Initialise Queue Manager */#ifdef SYS_END_DEBUG    DRV_LOG("ixdp425EthLibInit: Initialising Queue Manager...\n");#endif /* SYS_END_DEBUG */    if (ixQMgrInit() != IX_SUCCESS)        {	logMsg("ERROR ixe Eth Lib : unable to initialize QMGR\n", 1, 2, 3, 4, 5, 6);	return (IX_FAIL);        }    /* Start the Queue Manager dispatcher loop */#ifdef INCLUDE_IXETHACC_POLL_MODE    if (ixdp425EthAccStartDispatch(FALSE) != IX_SUCCESS)#else /*INCLUDE_IXETHACC_POLL_MODE*/    if (ixdp425EthAccStartDispatch(TRUE) != IX_SUCCESS)#endif /*INCLUDE_IXETHACC_POLL_MODE*/        {        printf("ixdp425EthLibInit: Error starting Intel queue manager dispatch loop!\n");        return(IX_FAIL);        }    /* Initialise and Start NPEs */    if(ixNpeDlNpeInitAndStart(NPE_B_IMAGE) != IX_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to init NPE B!\n", 1, 2, 3, 4, 5, 6);	return (IX_FAIL);    }     if(ixNpeDlNpeInitAndStart(NPE_C_IMAGE) != IX_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to init NPE C!\n", 1, 2, 3, 4, 5, 6);	return (IX_FAIL);    }    /* start the NPE message handler */    if(ixNpeMhInitialize(IX_NPEMH_NPEINTERRUPTS_YES) != IX_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to start NPE Message handler!\n", 1, 2, 3, 4, 5, 6);	return (IX_FAIL);    }    /* start access driver */    printf("Starting EthAcc component ...\n");    if (ixEthAccInit() != IX_ETH_ACC_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to start Ethernet Access driver!\n", 1, 2, 3, 4, 5, 6);	return (IX_FAIL);    }    /* initialise the ports */    if (ixEthAccPortInit(IX_ETH_PORT_1) != IX_ETH_ACC_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to init port %d!\n" ,IX_ETH_PORT_1, 2, 3, 4, 5, 6 );	return(IX_FAIL);    }    if (ixEthAccPortInit(IX_ETH_PORT_2) != IX_ETH_ACC_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to init port %d!\n" ,IX_ETH_PORT_2, 2, 3, 4, 5, 6 );	return(IX_FAIL);    }    /* initialise the phys */    if (ixdp425EthAccPhyDetect() != IX_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to detect phy\n" , 1, 2, 3, 4, 5, 6);	return(IX_FAIL);    }    /* initialise the phys */    if (ixdp425EthAccPhyInit(IX_ETH_PORT_1) != IX_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to init phy for port %d\n" , IX_ETH_PORT_1, 2, 3, 4, 5, 6);	return(IX_FAIL);    }    if (ixdp425EthAccPhyInit(IX_ETH_PORT_2) != IX_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to init phy for port %d\n" , IX_ETH_PORT_2, 2, 3, 4, 5, 6);	return(IX_FAIL);    }    ixdp425EthAccNPEStarted[IX_ETH_PORT_1] = TRUE;    ixdp425EthAccNPEStarted[IX_ETH_PORT_2] = TRUE;    ixdp425EthLibInitialised = TRUE;    return(IX_SUCCESS);    }/* this function is called during muxLoad */IX_STATUS ixdp425EthLibLoad(int port){      UINT32 npeImageId;    npeImageId = (port == IX_ETH_PORT_1? NPE_B_IMAGE : NPE_C_IMAGE );    if (ixdp425EthAccNPEStarted[port] == FALSE)    {	/* this setup is done after a suspend take place,	* this is already done at initialisation 	*/ 	if(ixNpeDlNpeInitAndStart(npeImageId) != IX_SUCCESS)	{	    logMsg("ERROR ixe Eth Lib : unable to init NPE port %d!\n", port, 2, 3, 4, 5, 6);	    return (IX_FAIL);	}		/* initialise the phys for this port */	if (ixdp425EthAccPhyConfig(port) != IX_SUCCESS)	{	    logMsg("ERROR ixe Eth Lib : unable to configure phy for port %d\n" , port, 2, 3, 4, 5, 6);	    return(IX_FAIL);	}	/* initialise the phys for this port */	if (ixdp425EthAccPhyInit(port) != IX_SUCCESS)	{	    logMsg("ERROR ixe Eth Lib : unable to init phy for port %d\n" , port, 2, 3, 4, 5, 6);	    return(IX_FAIL);	}	/* remember that the NPE is started */	ixdp425EthAccNPEStarted[port] = TRUE;    }    /* at thgis point, the NPE started from scratch     * it is necessary to initialise all the setup      */    /* set the mac address */    if (ixdp425EthAccMacSet(port) != IX_SUCCESS)    {        logMsg("ERROR ixe Eth Lib : Error MAC setup for port %d!\n" , port, 2, 3, 4, 5, 6);        return(IX_FAIL);    }    /* set the FCS setup */    if (ixEthAccPortTxFrameAppendFCSEnable(port) != IX_ETH_ACC_SUCCESS)    {        logMsg("ERROR ixe Eth Lib : Error FCS setup for port %d!\n" , port, 2, 3, 4, 5, 6);        return(IX_FAIL);    }        if (ixEthAccPortRxFrameAppendFCSDisable(port) != IX_ETH_ACC_SUCCESS)    {        logMsg("ERROR ixe Eth Lib : Error FCS setup for port %d!\n" , port, 2, 3, 4, 5, 6);	return(IX_FAIL);    }    if(ixEthAccPortPromiscuousModeClear(port) != IX_ETH_ACC_SUCCESS)    {        logMsg("ERROR ixe Eth Lib : Error Promiscuous Mode Clear for port %d!\n" , port, 2, 3, 4, 5, 6);	return (IX_FAIL);    }    if(ixEthAccTxSchedulingDisciplineSet(port, FIFO_NO_PRIORITY) != IX_ETH_ACC_SUCCESS)    {        logMsg("ERROR ixe Eth Lib : Error Discipline setup for port %d!\n" , port, 2, 3, 4, 5, 6);	return (IX_FAIL);    }    return(IX_SUCCESS);}/* this function is called during muxStart */IX_STATUS ixdp425EthLibStart(int port){     /* Enable ports */    if(ixEthAccPortEnable(port) != IX_ETH_ACC_SUCCESS)    {        logMsg("ERROR ixe Eth Lib : Unable to enable port %d!\n" , port, 2, 3, 4, 5, 6);	return (IX_FAIL);    }    return(IX_SUCCESS);}/* this function is called during muxStop */IX_STATUS ixdp425EthLibStop(int port){  #ifdef SYS_END_DEBUG        DRV_LOG("ixdp425EthLibStop(%d)\n", port);#endif /* SYS_END_DEBUG */    if (ixdp425EthAccNPEStarted[port] == TRUE)    {	/* Disable ports - unused MBufs will be returned */	if(ixEthAccPortDisable(port) != IX_ETH_ACC_SUCCESS)	{	    logMsg("ERROR ixe Eth Lib : unable to disable port %d\n", port, 2, 3, 4, 5, 6);	    return (IX_FAIL);	}	ixdp425EthAccNPEStarted[port] = FALSE;        /* wait unit last messages are processed */        taskDelay(60);    }        return IX_SUCCESS;}/* this function is called suring muxUnload */IX_STATUS ixdp425EthLibUnload(int port){  #ifdef SYS_END_DEBUG        DRV_LOG("ixdp425EthLibUnload(%d)\n", port);#endif /* SYS_END_DEBUG */    /* ensure the traffic is stopped */    return ixdp425EthLibStop(port);}STATUS ixdp425EthEndMuxInit()    {    END_TBL_ENTRY     *pDevTbl;    UINT32 phyNo;    for ( pDevTbl = endDevTbl; pDevTbl->endLoadFunc != END_TBL_END; pDevTbl++ )        ; /* Do nothing as we just want the increment */    /* TODO - How to we tie phys ports to ixe's ?????? */    for (phyNo=0; phyNo<IX_ETH_ACC_NUMBER_OF_PORTS; phyNo++)        {#ifndef INCLUDE_IXETHACC_PORT0_END        if ( phyNo == 0 )            continue;#endif#ifndef INCLUDE_IXETHACC_PORT1_END        if ( phyNo == 1 )            continue;#endif        /* Fill in the endDev entry for this device */        pDevTbl->unit = phyNo;        pDevTbl->endLoadFunc = ixEthAccEndLoad;        pDevTbl->endLoadString = ixpEndLoadStr[phyNo];        pDevTbl->endLoan = 1;        pDevTbl->pBSP = NULL;        pDevTbl->processed = FALSE;        pDevTbl++;        }    return OK;    }STATUS ixdp425EthEndStartUp()    {    END_TBL_ENTRY     *pDevTbl;    END_OBJ *         pCookie = NULL;    UINT32 ixdp425EthEndMask;    UINT8 nvImage[NV_RAM_IF_SIZE+1];

⌨️ 快捷键说明

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