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

📄 ixethaccsysend.c

📁 INTEL IXP425的VXWORKS BSP
💻 C
📖 第 1 页 / 共 3 页
字号:
		    downloadVersionId.major = versionIdList[i].major;		    downloadVersionId.minor = versionIdList[i].minor;                }		else if (versionIdList[i].major == downloadVersionId.major                         && versionIdList[i].minor >= downloadVersionId.minor)                {		    downloadVersionId.minor = versionIdList[i].minor;                }            }	}    }#ifdef SYS_END_DEBUG    printf("ixe %d Version information\n", downloadVersionId.npeId - 1);    printf("Major ID:\t 0x%x\n", downloadVersionId.major);    printf("Minor ID:\t 0x%x\n", downloadVersionId.minor);    printf("Build ID:\t 0x%x\n", downloadVersionId.buildId);#endif /* SYS_END_DEBUG */    /* stop and reset the NPE */    status = ixNpeDlNpeStopAndReset (npeId);    if (status != IX_SUCCESS)    {        ixOsServLog (LOG_ERROR, "Failed to stop and reset NPE\n", 0, 0, 0, 0, 0, 0);        return IX_FAIL;    }    /* download the version */    status = ixNpeDlVersionDownload (        &downloadVersionId, /* versionIdPtr */        TRUE);              /* verify */    if (status != IX_SUCCESS)    {        ixOsServLog (LOG_ERROR, "Failed to download the version\n", 0, 0, 0, 0, 0, 0);        return IX_FAIL;    }    /* get the downloaded version */    status = ixNpeDlLoadedVersionGet (npeId, &uploadVersionId);    if (status != IX_SUCCESS)    {        ixOsServLog (LOG_ERROR, "Failed to get the downloaded version\n", 0, 0, 0, 0, 0, 0);        return IX_FAIL;    }    /* verify the downloaded version is the one we downloaded */    if (memcmp(&uploadVersionId, &downloadVersionId, sizeof (downloadVersionId)) != 0)    {        ixOsServLog (LOG_ERROR, "Version ID downloaded not as expected\n", 0, 0, 0, 0, 0, 0);        return IX_FAIL;    }    return IX_SUCCESS;    }/** * @fn IX_STATUS ixdp425EthAccMacSet() * * Set the MAC address for available Ports on the board. * 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 PORT %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 PORT %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;    *//***************************************************      *  Call functionRead Mac address from flash config space.      *      *  If successful, return true with mac address in MacAddress,      *        pBoard->enetAddr is assigned with MacAddress.      *  If failure, return false,        *        pBoard->enetAddr is assigned with sysMacBase.      ***************************************************      */    {    unsigned char MacAddress[6];    unsigned char key[100]; 	    sprintf(key, "mac_npe%d", port);        if(GetMac(key, &MacAddress[0]) == 0)    {            	 npeMacAddr.macAddress[0] = MacAddress[0];	 npeMacAddr.macAddress[1] = MacAddress[1];	 npeMacAddr.macAddress[2] = MacAddress[2];	 npeMacAddr.macAddress[3] = MacAddress[3];	 npeMacAddr.macAddress[4] = MacAddress[4];	 npeMacAddr.macAddress[5] = MacAddress[5];          }    else    {        bcopy ((char *)sysIxEthAccEndEnetAddr, (char *)npeMacAddr.macAddress, 3);        npeMacAddr.macAddress[3]= sysMacBase[2];        npeMacAddr.macAddress[4]= sysMacBase[1];        npeMacAddr.macAddress[5]= sysMacBase[0] + port;             }    }        printf("ixe ETH PORT %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)         */        sysAuxClkDisable();        sysAuxClkRateSet (IXDP_ETHACC_POLL_TICKS_PER_SECOND);        sysAuxClkConnect ((FUNCPTR)dispatcherFunc,                          IX_QMGR_QUELOW_GROUP);        sysAuxClkEnable();#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 NPEs */    if(ixdp425EthAccNpeInit(IX_NPEDL_NPEID_NPEB) != IX_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to init NPE B!\n", 1, 2, 3, 4, 5, 6);	return (IX_FAIL);    }     if(ixdp425EthAccNpeInit(IX_NPEDL_NPEID_NPEC) != 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 NPEs */    if(ixNpeDlNpeExecutionStart(IX_NPEDL_NPEID_NPEB) != IX_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to start NPE B!\n", 1, 2, 3, 4, 5, 6);	return (IX_FAIL);    }    if(ixNpeDlNpeExecutionStart(IX_NPEDL_NPEID_NPEC) != IX_SUCCESS)    {	logMsg("ERROR ixe Eth Lib : unable to start NPE C!\n", 1, 2, 3, 4, 5, 6);	return (IX_FAIL);    }    /* start access driver */    printf("\n\rStarting EthAcc component ...\n\r");    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){      IxNpeDlNpeId npeId;    npeId = (port == IX_ETH_PORT_1? IX_NPEDL_NPEID_NPEB : IX_NPEDL_NPEID_NPEC );    if (ixdp425EthAccNPEStarted[port] == FALSE)    {	/* this setup is done after a suspend take place,	* this is already done at initialisation 	*/ 	if(ixdp425EthAccNpeInit(npeId) != IX_SUCCESS)	{	    logMsg("ERROR ixe Eth Lib : unable to init NPE port %d!\n", port, 2, 3, 4, 5, 6);	    return (IX_FAIL);	}		if(ixNpeDlNpeExecutionStart(npeId) != IX_SUCCESS)	{	    logMsg("ERROR ixe Eth Lib : unable to start 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);

⌨️ 快捷键说明

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