コード例 #1
0
ファイル: bcm1250Rmon.c プロジェクト: ariavie/bcm
void sbrmonclr(int inst)
{
    DRV_CTRL * pDrvCtrl = (DRV_CTRL *) endFindByName ("sbe", inst);
 
    pDrvCtrl = (DRV_CTRL *) endFindByName ("sbe", inst);
    if ( pDrvCtrl == NULL )
        printf("can't find sbe%d\n", inst);
 
 
    SB_MAC_REG_WRITE(R_MAC_RMON_TX_BYTES, 0);
    SB_MAC_REG_WRITE(R_MAC_RMON_TX_BAD, 0);
    SB_MAC_REG_WRITE(R_MAC_RMON_TX_GOOD, 0);
 
}
コード例 #2
0
ファイル: if.c プロジェクト: ariavie/bcm
static int
sal_if_deconfig(char *pfx,  END_OBJ     *eo, char *if_name, int if_unit)
/*
 * Function: 
 * Purpose:	
 * Parameters:	pfx - prefix to print on errors/warnings
 *		if_name - name of interface ("sn" for "sn0")
 *		if_unit - unit # (0 for "sn0")
 * Returns:	0 - success
 *		-1 - failed
 */
{
#if defined(INCLUDE_DRIVERS)
    int		rv;

    SAL_MAP_NETUNIT(if_unit);

    if (NULL == endFindByName(if_name, if_unit)) {
	cli_out("%s: Error: can not locate device: %s%d\n", 
                pfx, if_name, if_unit);
	return(-1);
    }

    rv = sal_if_do_deconfig(pfx, eo, if_name, if_unit);
    LOG_INFO(BSL_LS_APPL_END,
             (BSL_META("%s: sal_if_deconfig complete: %s%d (%d)\n"), 
              pfx, if_name, if_unit, rv));
    return(rv);
#else  /* !defined(INCLUDE_DRIVERS) */
    return(-1);
#endif /* !defined(INCLUDE_DRIVERS) */
}
コード例 #3
0
ファイル: bcm1250Rmon.c プロジェクト: ariavie/bcm
void sbrmonshow(int inst)
{
    DRV_CTRL * pDrvCtrl = (DRV_CTRL *) endFindByName ("sbe", inst);
    UINT64   reg;
    UINT32   reg_hi, reg_lo;
 
    pDrvCtrl = (DRV_CTRL *) endFindByName ("sbe", inst);
    if ( pDrvCtrl == NULL )
        printf("can't find sbe%d\n", inst);
 
 
    reg = SB_MAC_REG_READ(R_MAC_RMON_TX_BYTES);
    reg_hi = (UINT32)(reg >> 32); reg_lo = (UINT32)(reg & 0xffffffff);
    printf("tx_byte = 0x%08x%08x \n", reg_hi, reg_lo);
 
    reg = SB_MAC_REG_READ(R_MAC_RMON_TX_BAD);
    reg_hi = (UINT32)(reg >> 32); reg_lo = (UINT32)(reg & 0xffffffff);
    printf("tx_bad = 0x%08x%08x \n", reg_hi, reg_lo);
 
    reg = SB_MAC_REG_READ(R_MAC_RMON_TX_GOOD);
    reg_hi = (UINT32)(reg >> 32); reg_lo = (UINT32)(reg & 0xffffffff);
    printf("tx_good = 0x%08x%08x \n", reg_hi, reg_lo);
 
}                                                                               
コード例 #4
0
void usrNetIpAttachCommon
    (
    char *    pDeviceName,	/* Device name */
    int       unitNum,		/* unit number */
    char *    pStr,		/* e.g. "IPv4", "IPv6" */
    FUNCPTR   pAttachRtn	/* attach routine */
    )
    {

    int unitNumber = unitNum;

    /* skip if no device is available */
    if (pDeviceName == NULL)
    	return;

#if 0    
    /* ipAttach for ppp is done during its bringup */
    if (strncmp (pDeviceName, "ppp", 3) == 0)
        return;
#endif

    if (endFindByName (pDeviceName, unitNum) == NULL)
        {
        if (sysBootParams.other [0] != EOS)
            {
            char *pStr;

            /*
             * the other parameter may or may not contain a
             * unit number.  If there is one, use it
             * and update sysBootParams.unitNum.
             */

            pStr = (char *)&sysBootParams.other;
            while (!isdigit ((int)*pStr) && *pStr != EOS)
                pStr++;

            if (pStr != EOS && sscanf (pStr, "%d", &unitNumber) == 1)
                {
                sysBootParams.unitNum = unitNumber;
                uNum = unitNumber;
                *pStr = EOS;
                }

            pDevName = sysBootParams.other;
            }
        else
            pDevName = NULL;

        pDeviceName = pDevName;
        }

    if (pAttachRtn == NULL) 
    	return;

    if ((*pAttachRtn) (unitNumber, pDeviceName) != OK)
        {
        if ( _func_printErr)
            (* _func_printErr) ("Failed to attach to device %s%d",
                            pDeviceName, unitNumber);
        return;
        }

    netAttachFlag = TRUE;       /* usrNetBoot.c */

    if (_func_printErr)
        (*_func_printErr)
        ("Attached %s interface to %s unit %d\n",pStr,pDeviceName,unitNumber);

    return;
    }
STATUS mirrorEndRunningState(void)
    {
    BRIDGE_PORT_INFO*   pPortInfo;
    END_OBJ *pEnd0, *pEnd1;
    END_MEDIA media;
    int error;
    long flags;


    pEnd1 = endFindByName (MIRROR_DEV_NAME,MIRROR_STACK_UNIT_NUM);
    pEnd0 = endFindByName (MIRROR_DEV_NAME,MIRROR_BRIDGE_UNIT_NUM);

    if (pEnd1) 
	flags = END_FLAGS_GET(pEnd1);
    else
	return OK;

    for (pPortInfo = (BRIDGE_PORT_INFO*)lstFirst(&bridgePortList);
         (pPortInfo != NULL) && (strcmp(pPortInfo->name, MIRROR_DEV_NAME)!=0);
         pPortInfo = (BRIDGE_PORT_INFO*)lstNext((NODE*)pPortInfo))
        {
        muxIoctl(pPortInfo->pMuxBindCookie,EIOCGIFMEDIA,(char *)&media);	    
        LOG_MSG("mirrorEndRunningState: port %s, unit %d, status 0x%x\n",
                  pPortInfo->name, pPortInfo->unitNum, 
		  media.endMediaStatus, 4, 5, 6);

        if ((media.endMediaStatus & (IFM_AVALID|IFM_ACTIVE)) == 
				(IFM_AVALID|IFM_ACTIVE))
	    {
            if ((flags & IP_IFF_RUNNING) == 0)
	        {
	        LOG_MSG("mirrorEndRunningState: state changed to RUNNING\n",
			1, 2, 3, 4, 5, 6);

    	        /* raise both interface flags - mark the devices as RUNNING */
    	        if (pEnd0) END_FLAGS_SET (pEnd0, IP_IFF_RUNNING);
    	        END_FLAGS_SET (pEnd1, IP_IFF_RUNNING);

	        /* inform the stack about the interface UP state change */
	        jobQueueStdPost (netJobQueueId, NET_TASK_QJOB_PRI,
                         muxLinkUpNotify, pEnd1,
                         NULL, NULL, NULL, NULL);
	        }

		return OK;
	    }
        } 

    if (flags & IP_IFF_RUNNING)
        {
	LOG_MSG("mirrorEndRunningState: state changed to NOT RUNNING\n",
		1, 2, 3, 4, 5, 6);

        /* mark both drivers as NOT RUNNING */
        if (pEnd0)  END_FLAGS_CLR (pEnd0, IP_IFF_RUNNING);
        END_FLAGS_CLR (pEnd1, IP_IFF_RUNNING);

	/* inform the stack about the interface UP state change */
	jobQueueStdPost (netJobQueueId, NET_TASK_QJOB_PRI,
                    muxLinkDownNotify, pEnd1,
                    NULL, NULL, NULL, NULL);
        }

    return OK;
    }
END_OBJ* mirrorEndLoad
    (
    char*   initString
    )
    {
    END_CTRL*   pDrvCtrl;

    if (initString == NULL)
        return NULL;
    
    if (initString[0] == 0)
        {
        bcopy((char *)MIRROR_DEV_NAME, initString, MIRROR_DEV_NAME_LEN);
        return NULL;
        }

    /* Parse InitString */
    switch (initString[0])
        {
        case '0':
            pDrvCtrl = &drvCtrl[0];
	    bzero((char *)pDrvCtrl,sizeof(END_CTRL)); 
            pDrvCtrl->unit = 0;
            SYS_ENET_ADDR_GET((char *) pDrvCtrl->enetAddr);

            break;
        
        case '1':
            pDrvCtrl = &drvCtrl[1];
	    bzero((char *)pDrvCtrl,sizeof(END_CTRL)); 
            pDrvCtrl->unit = 1;
            
            /* if unit ever REALLY needs a MAC address, change this appropriately */
            SYS_ENET_ADDR_GET((char *) pDrvCtrl->enetAddr);  
            
            break;
        
        default:
            return NULL;
        }

    /* Check if we are already attached */
    if (pDrvCtrl->endObject.attached == TRUE)
        return &pDrvCtrl->endObject;

    /* endObject initializations */
    if (END_OBJ_INIT(&pDrvCtrl->endObject, 
                     (void*)pDrvCtrl, 
                     MIRROR_DEV_NAME,
                     pDrvCtrl->unit, 
                     &netFuncs,
                     MIRROR_END_OBJ_STRING) == ERROR)
        {
        return NULL;
        }

    /* Initialize MIB2 entries */
    if (END_MIB_INIT(&pDrvCtrl->endObject, 
                     M2_ifType_ethernet_csmacd,
                     (UCHAR *) pDrvCtrl->enetAddr, 
                     6, 
                     ETHERMTU,
                     SPEED) == ERROR)
        {
        return NULL;
        }

    /* we need to import the memory pool from a real physical driver. At least
     * the WDB end driver is using it
     */

    if (pDrvCtrl->unit == 0)
        {
        char devName[END_NAME_MAX];
        int unit = 0;
        bzero(devName,END_NAME_MAX);

	if (bridgeNextPhyDevEndGet(devName,&unit) == ERROR)
            {
            printf("mirrorEndLoad: No physical device found\n");
            }
        else
	    {
	    END_OBJ * pEnd;

	    pEnd = endFindByName(devName,unit);

            if (pEnd != NULL)
	        pDrvCtrl->endObject.pNetPool = pEnd->pNetPool;

            pDrvCtrl->pPhyEnd = pEnd;
	    }
        }

    /* Mark the device ready */
    /* IFF_SCAT is not defined by default */
/*
    END_OBJ_READY(&pDrvCtrl->endObject,
                  IFF_NOTRAILERS | IP_IFF_BROADCAST | IFF_MULTICAST);
*/
    END_OBJ_READY(&pDrvCtrl->endObject,
                  IP_IFF_BROADCAST | IP_IFF_MULTICAST);

    /* Successful return */
    return &pDrvCtrl->endObject;
    }
コード例 #7
0
ファイル: IxAtmCodelet.c プロジェクト: dafyddcrosby/L4OS
/* --------------------------------------------------------------
   Initialise system components used by the Atm Codelet.
   -------------------------------------------------------------- */
PUBLIC IX_STATUS
ixAtmCodeletSystemInit (UINT32 numPorts,
			IxAtmCodeletMode mode)
{
    IX_STATUS retval = IX_SUCCESS;
#if IX_UTOPIAMODE == 1
    IxAtmmPhyMode phyMode = IX_ATMM_SPHY_MODE;
#else
    IxAtmmPhyMode phyMode = IX_ATMM_MPHY_MODE;
#endif
    IxOsalThread dispatchtid;
    IxOsalThreadAttr threadAttr;
    char *pThreadName = "QMgr Dispatcher";

#ifdef __vxworks
    if (endFindByName ("ixe", 0) != NULL)
    {
	IX_ATMCODELET_LOG ("FAIL : Driver ixe0 detected\n");
	printf("FAIL : Driver ixe0 detected\n");
	return IX_FAIL;
    }
    if (endFindByName ("ixe", 1) != NULL)
    {
	IX_ATMCODELET_LOG ("FAIL : Driver ixe1 detected\\n");
	printf("FAIL : Driver ixe1 detected\n");
	return IX_FAIL;
    }
#endif


    /**************** System initialisation ****************/
    /*
     * The IxQMgr component provides interfaces for configuring and accessing the IXP4XX
     * AQM hardware queues used to facilitate communication of data between the NPEs and
     * the xscale. IxAtmdAcc configures these queues. The IxQMgr component provides a
     * dispatcher that will call registered callback functions will specified queue events
     * occur.
     */
    IX_ATMCODELET_COMP_INIT(ixQMgrInit());

    ixQMgrDispatcherLoopGet(&dispatcherFunc);

    /* This next section sets up how the IxQMgrDispatcher is called. 
     * For the purposes of demonstration under vxWorks the IxQMgrDispatcher 
     * is polled, and under Linux intterrupts are used.
     * This offers the best performance respectively.
     */
    if (IX_ATMCODELET_USE_QMGR_INT)
    {
	/* Running IxQMgrDispatcher from interrupt level */

	/* 
	 * Bind the IxQMgr dispatcher to interrupt. The IX_QMGR_QUELOW_GROUP group
	 * of queues concern ATM Transmit , Receive, Transmit Done queues
	 */

	retval = ixOsalIrqBind(IX_OSAL_IXP400_QM1_IRQ_LVL,
			       (IxOsalVoidFnVoidPtr)(dispatcherFunc),
			       (void *)IX_QMGR_QUELOW_GROUP);

	if (IX_SUCCESS != retval)
	{
	    IX_ATMCODELET_LOG ("Failed to bind to QM1 interrupt\n");
	    return IX_FAIL;
	}
	
	/*
	 * Bind the IxQMgr dispatcher to interrupt. The IX_QMGR_QUELOW_GROUP group
	 * of queues concern ATM Receive Free queues.
	 */
	retval = ixOsalIrqBind(IX_OSAL_IXP400_QM2_IRQ_LVL,
			       (IxOsalVoidFnVoidPtr)(dispatcherFunc),
			       (void *)IX_QMGR_QUEUPP_GROUP);
	if (IX_SUCCESS != retval)
	{
	    IX_ATMCODELET_LOG ("Failed to bind to QM2 interrupt\n");
	    return IX_FAIL;
	}
    }
    else /* Running IxQMgrDispatcher from task level */
    {
      threadAttr.name = pThreadName;
      threadAttr.stackSize = IX_ATMCODELET_QMGR_DISPATCHER_THREAD_STACK_SIZE;
      threadAttr.priority = IX_ATMCODELET_QMGR_DISPATCHER_PRIORITY;

      if (ixOsalThreadCreate(&dispatchtid,
			     &threadAttr,
			     (IxOsalVoidFnVoidPtr)ixAtmCodeletDispatchTask,
			      NULL) != IX_SUCCESS)
	{
	    IX_ATMCODELET_LOG ("Error spawning dispatch task\n");
	    return IX_FAIL;
	}  

      if(IX_SUCCESS != ixOsalThreadStart(&dispatchtid))
	{
	  IX_ATMCODELET_LOG ("Error starting dispatch task\n");
	  return IX_FAIL;
	}
    }

    /* Initialise IxNpeMh */
    IX_ATMCODELET_COMP_INIT(ixNpeMhInitialize (IX_NPEMH_NPEINTERRUPTS_YES));

    /* Download NPE image */
    retval = ixAtmUtilsAtmImageDownload (numPorts, &phyMode);

    if (retval != IX_SUCCESS)
    {
	IX_ATMCODELET_LOG ("NPE download failed\n");
	return IX_FAIL;
    }
    
    ixAtmCodeletMode = mode;

    return IX_SUCCESS;
}
コード例 #8
0
ファイル: IxEthAccCodeletMain.c プロジェクト: cilynx/dd-wrt
/*
 * Function definition: ixEthAccCodeletInit()
 *
 * See header file for documentation.
 */
IX_STATUS ixEthAccCodeletInit(IxEthAccCodeletOperation operationType,
                    IxEthAccPortId inPort,
                    IxEthAccPortId outPort)
{  
    IxEthAccPortId portId;

    IxOsalThread statsPollThread;
    IxOsalThreadAttr threadAttr;

    threadAttr.name      = "Codelet Stats";
    threadAttr.stackSize = 32 * 1024; /* 32kbytes */
    threadAttr.priority  = 128;


#ifdef __ixp46X
    /* Set the expansion bus fuse register to enable MUX for NPEA MII */
    {
        UINT32 expbusCtrlReg;
        expbusCtrlReg = ixFeatureCtrlRead ();
        expbusCtrlReg |= ((unsigned long)1<<8);
        ixFeatureCtrlWrite (expbusCtrlReg);
    }
#endif

    /* check the component is already initialized */
    if(ixEthAccCodeletInitialised) 
    {
	printf("CodeletMain: Ethernet codelet already initialised\n");
	return(IX_SUCCESS);
    }

#ifdef __vxworks
    /* When the ixe drivers are running, the codelets
    * cannot run.
    */
    for (portId = 0; portId < IX_ETHACC_CODELET_MAX_PORT; portId++)
    {
        if (endFindByName ("ixe", portId) != NULL)
        {
            printf("CodeletMain: FAIL: Driver ixe%d detected\n",portId);
            return IX_FAIL;
        }
    }
#endif

    /* Initialize NPE IMAGE ID here again to prevent confusion in multiple 
     * ixEthAccCodeletMain() calls with different operationType.
     */   
    ETH_NPEA_IMAGEID = IX_NPEDL_NPEIMAGE_NPEA_ETH_MACFILTERLEARN_HSSCHAN_COEXIST;
    ETH_NPEB_IMAGEID = IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB;
    ETH_NPEC_IMAGEID = IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB;

    /* Create mutexes for thread control */
    ixEthAccCodeletStatsPollTaskStop = TRUE;
    ixOsalMutexInit (&ixEthAccCodeletStatsPollTaskRunning);

    /* Initialise MBUF pool */
    if(ixEthAccCodeletMemPoolInit() != IX_SUCCESS)
    {
	printf("CodeletMain: Error initialising mBuf pool\n");
	return (IX_FAIL);
    }

    /* Check Silicon stepping */
    printf("Checking Silicon stepping...\n");

    if (ixFeatureCtrlDeviceRead() == IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X)
    {

        if ((ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK) == 
           IX_FEATURE_CTRL_SILICON_TYPE_B0)
        {
            /*
             * If it is B0 Silicon, we only enable port when its corresponding  
             * Eth Coprocessor is available.
             */
            if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_ETH0) == 
                IX_FEATURE_CTRL_COMPONENT_ENABLED)
            {
                ixEthAccCodeletHardwareExists[IX_ETH_PORT_1] = TRUE;
            }

            if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_ETH1) == 
               IX_FEATURE_CTRL_COMPONENT_ENABLED)
            {
                ixEthAccCodeletHardwareExists[IX_ETH_PORT_2] = TRUE;
            }
        }
        else if ((ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK) == 
                  IX_FEATURE_CTRL_SILICON_TYPE_A0) 
        {
            /*
             * If it is A0 Silicon, we enable both as both Eth Coprocessors 
             * are available. 
             */ 
            ixEthAccCodeletHardwareExists[IX_ETH_PORT_1] = TRUE;
            ixEthAccCodeletHardwareExists[IX_ETH_PORT_2] = TRUE;
        }
        else
        {
            printf("CodeletMain: Error. Operation for other silicon stepping is undefined!.\n");
            return (IX_FAIL);
        }
    }
    else if (ixFeatureCtrlDeviceRead() == IX_FEATURE_CTRL_DEVICE_TYPE_IXP46X)
    {
        ixEthAccCodeletHardwareExists[IX_ETH_PORT_1] = TRUE;
        ixEthAccCodeletHardwareExists[IX_ETH_PORT_2] = TRUE;
#ifdef __ixp46X
        ixEthAccCodeletHardwareExists[IX_ETH_PORT_3] = TRUE;
#endif
    }

    /***********************************************************************
     *
     * System initialisation done. Now initialise Access components. 
     *
     ***********************************************************************/

    /* Initialise Queue Manager */
    printf("Initialising Queue Manager...\n");
    if (ixQMgrInit() != IX_SUCCESS)
    {
	printf("CodeletMain: Error initialising queue manager!\n");
	return (IX_FAIL);
    }

    /* Start the Queue Manager dispatcher */   
    if(ixEthAccCodeletDispatcherStart(IX_ETH_CODELET_QMGR_DISPATCH_MODE) 
       != IX_SUCCESS)
    {
	printf("CodeletMain: Error starting queue manager dispatch loop!\n");
	return (IX_FAIL);
    }

    /* Initialise NPE Message handler */
    printf("\nStarting NPE message handler...\n");
    if(ixNpeMhInitialize(IX_NPEMH_NPEINTERRUPTS_YES) != IX_SUCCESS)
    {
	printf("CodeletMain: Error initialising NPE Message handler!\n");
	return (IX_FAIL);
    }

    /* Initialise NPEs firmware */
    printf ("Initialising NPEs...\n");
    if (ixEthAccCodeletHardwareExists[IX_ETH_PORT_1])
    {
        if ((operationType == IX_ETHACC_CODELET_BRIDGE_WIFI) && (inPort == IX_ETH_PORT_1))
        {
            printf("CodeletMain: the 802.3 <=> 802.11 header conversion image is loaded on NPE B\n");
            ETH_NPEB_IMAGEID = IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB;
        }

	if (IX_SUCCESS != ixNpeDlNpeInitAndStart(ETH_NPEB_IMAGEID))
        {
	    printf ("CodeletMain: Error initialising and starting NPE B!\n");
	    return (IX_FAIL);
	}
    }

    if (ixEthAccCodeletHardwareExists[IX_ETH_PORT_2])
    {
        if ((operationType == IX_ETHACC_CODELET_BRIDGE_WIFI) && (inPort == IX_ETH_PORT_2))
        {
            printf("CodeletMain: the 802.3 <=> 802.11 header conversion image is loaded on NPE C\n");
            ETH_NPEC_IMAGEID = IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB;
        }

	if (IX_SUCCESS != ixNpeDlNpeInitAndStart(ETH_NPEC_IMAGEID))
        {
	    printf ("CodeletMain: Error initialising and starting NPE C!\n");
	    return (IX_FAIL);
	}
    }
#ifdef __ixp46X
    if (ixEthAccCodeletHardwareExists[IX_ETH_PORT_3])
    {
        if ((operationType == IX_ETHACC_CODELET_BRIDGE_WIFI) && (inPort == IX_ETH_PORT_3))
        {
            printf("CodeletMain: the 802.3 <=> 802.11 header conversion image is loaded on NPE A\n");
            ETH_NPEA_IMAGEID = IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB;
        }

	if (IX_SUCCESS != ixNpeDlNpeInitAndStart(ETH_NPEA_IMAGEID))
        {
	    printf ("CodeletMain: Error initialising and starting NPE A!\n");
	    return (IX_FAIL);
	}
    }
#endif

    printf ("Initialising Access Layers\n");

    /* Enable QoS on ethDB. This has to be done before ethAcc initialisation */
    if (operationType == IX_ETHACC_CODELET_BRIDGE_QOS)
    {
	printf("Enabling QoS\n");
        if (IX_ETH_DB_SUCCESS != ixEthDBInit())
	{
	    printf ("CodeletMain: Error initialising EthDB\n");
	    return (IX_FAIL);
	}

	(void)ixEthDBPortInit(inPort);

        if (IX_ETH_DB_SUCCESS != ixEthDBFeatureEnable(inPort, 
						      IX_ETH_DB_VLAN_QOS, 
						      TRUE))
	{
            printf("CodeletMain: Error enabling QoS on port %d\n",inPort);
	    return (IX_FAIL);
        }
    }

    /* initialise ethAcc : QoS, if needed is already configured */
    if (ixEthAccInit() != IX_ETH_ACC_SUCCESS)
    {
	printf("CodeletMain: Error initialising Ethernet access driver!\n");
	return (IX_FAIL);
    }

    /***********************************************************************
     *
     * Access components initialisation done. Now initialize the ports
     *
     ***********************************************************************/

    /* Configure all available ports */
    for (portId = 0; portId < IX_ETHACC_CODELET_MAX_PORT; portId++)
    {
	if (ixEthAccCodeletHardwareExists[portId])
	{
	    if(ixEthAccCodeletPortInit(portId) != IX_ETH_ACC_SUCCESS)
            {
   	        printf("CodeletMain: Error setup port %u\n",
		       portId);
	        return (IX_FAIL);
            }
        }
    }

    /* Find and initialise all available PHYs */
    printf ("Discover and reset the PHYs...\n");
    if(ixEthAccCodeletPhyInit() != IX_SUCCESS)
    {
	printf("CodeletMain: Error initialising Ethernet phy(s)!\n");
	return (IX_FAIL);
    }

    /***********************************************************************
     *
     * PortInitialization done. Now start the codelet features
     *
     ***********************************************************************/

    /* starts ethDB maintenance running from a different task */
    if (ixEthAccCodeletDBMaintenanceStart()
	!= IX_SUCCESS)
    {
	printf("CodeletMain: Error spawning DB maintenance task\n");
	return (IX_FAIL);
    }

    /* Starts the traffic display (in a different task) this is initially
     * set to FALSE in order to allow the traffic stats to start only
     * once traffic is started to be received 
     */
    ixEthAccCodeletTrafficPollEnabled = FALSE;

    if (ixOsalThreadCreate(&statsPollThread,
			   &threadAttr,
			   (IxOsalVoidFnVoidPtr) ixEthAccCodeletStatsPollTask,
			   NULL)	
	!= IX_SUCCESS)
    {
	printf("CodeletMain: Error spawning stats task\n");
	return (IX_FAIL);
    }

     /* Start the thread */
    if (ixOsalThreadStart(&statsPollThread) != IX_SUCCESS)
    {
	printf("CodeletMain: Error failed to start the stats thread\n");
        return IX_FAIL;
    }
    ixEthAccCodeletInitialised = TRUE;
    return (IX_SUCCESS);
}
コード例 #9
0
ファイル: if.c プロジェクト: ariavie/bcm
static void *
sal_if_config(char *pfx, int u, char *if_name, int if_unit, 
	      char *if_host, sal_mac_addr_t if_mac, int if_vlan, 
	      sal_ip_addr_t if_ip, sal_ip_addr_t if_netmask)
/*
 * Function: 	sal_if_config
 * Purpose:	Configure a network device (load driver and start)
 * Parameters:	pfx - string printed for error messages.
 *		name - device name ("sn" for "sn0")
 *		unit - unint number (0 for "sn0")
 * Returns:	NULL - failed
 *		!NULL - opaque pointer.
 */
{
#ifdef INCLUDE_DRIVERS
    extern END_OBJ *socend_load(char *is, void *);
    char	if_name_str[END_NAME_MAX];
    char	if_init_str[64];
    char 	if_ip_str[SAL_IPADDR_STR_LEN];
    char	if_mac_str[SAL_MACADDR_STR_LEN];
    END_OBJ	*eo;			/* END object  */
#if VX_VERSION == 64 || VX_VERSION == 65 || VX_VERSION == 66 || VX_VERSION == 68
#else
    M2_INTERFACETBL	m2;
#endif
#if VX_VERSION == 66 || VX_VERSION == 68
    char if_cfg_str[256];
    char if_mask_str[SAL_IPADDR_STR_LEN];
#endif

    SAL_MAP_NETUNIT(if_unit);
    LOG_INFO(BSL_LS_APPL_END,
             (BSL_META_U(u,
                         "%s: sal_if_config *** if_name=%s if_unit=%d\n"), 
              pfx, if_name, if_unit));
    /* Build vxWorks device name */
    sprintf(if_name_str, "%s%d", if_name, if_unit);

    /* Check to see if end device already loaded */

    if (NULL == (eo = endFindByName(if_name, if_unit))) {
	LOG_INFO(BSL_LS_APPL_END,
                 (BSL_META_U(u,
                             "%s: End device not loaded: if %s if_unit %d\n"), 
                  pfx, if_name, if_unit));
	format_macaddr(if_mac_str, if_mac);
	sprintf(if_init_str, "%d:%s:%d", u, if_mac_str, if_vlan);
	if (NULL == (eo = muxDevLoad(if_unit, socend_load, 
				     if_init_str, 0, NULL))) {
	    cli_out("%s: muxDevLoad failed: Unit %d\n", pfx, u);
	    return(NULL);
	}

	LOG_INFO(BSL_LS_APPL_END,
                 (BSL_META_U(u,
                             "%s: muxDevLoad successful: 0x%x\n"), pfx, (int)eo));
	if (ERROR == muxDevStart(eo)) {
	    cli_out("%s: muxDevStart failed: Unit %d\n", pfx, u);
	    (void)muxDevUnload(if_name, if_unit);
	    return(NULL);
	}
	LOG_INFO(BSL_LS_APPL_END,
                 (BSL_META_U(u,
                             "%s: muxDevStart successful: 0x%x\n"), pfx, (int)eo));
    }
#if VX_VERSION == 64 || VX_VERSION == 65 || VX_VERSION == 66 || VX_VERSION == 68
#else
    /*
     * Configure device....
     */
    if (OK != muxIoctl(eo, EIOCGMIB2, (caddr_t)&m2)) {
        cli_out("%s: muxIoctl failed: Unit %d\n", pfx, u);
	(void)sal_if_do_deconfig(pfx, eo, if_name, if_unit);
	return(NULL);
    }
    LOG_INFO(BSL_LS_APPL_END,
             (BSL_META_U(u,
                         "%s: muxIOCTL successful: Unit %d\n"), pfx, u));
#endif /* VX_VERSION */

    /*
     * Setup interface in following order:
     *		[1] Attach TCP/IP to END device
     *		[2] Set Netmask (if non-0)
     *		[3] Set IP address
     *		[4] Set host name associated with interface (if given).
     */
    if (OK != ipAttach(if_unit, if_name)) { /* [1] */
        cli_out("%s: ipAttach failed: Unit %d (interface %s)\n", 
                pfx, u, if_name_str);
	(void)sal_if_do_deconfig(pfx, eo, if_name, if_unit);
	return(NULL);
    }
    LOG_INFO(BSL_LS_APPL_END,
             (BSL_META_U(u,
                         "%s: ipAttach successful: if_name %s if_unit %d\n"), 
              pfx, if_name, if_unit));

#if VX_VERSION == 66 || VX_VERSION == 68

    format_ipaddr(if_ip_str, if_ip);	/* [3] */

    if (0 != if_netmask) {		/* [2] */
        format_ipaddr(if_mask_str, if_netmask);	/* [3] */
    }

    sprintf(if_cfg_str, "%s up inet add %s netmask %s", if_name_str, if_ip_str, if_mask_str);
   
    if (ERROR == ifconfig(if_cfg_str)) {
        cli_out("%s: ifconfig failed: %s%d: %s\n",
                pfx, if_name, if_unit, if_cfg_str);
        (void)sal_if_do_deconfig(pfx, eo, if_name, if_unit);
        return(NULL);
    }
    LOG_INFO(BSL_LS_APPL_END,
             (BSL_META_U(u,
                         "%s: ifconfig: if %s, cfg str %s\n"),
              pfx, if_name_str, if_cfg_str));
#else
    if (0 != if_netmask) {		/* [2] */
#ifdef VXWORKS_NETWORK_STACK_6_5
#ifdef VXWORKS_NETWORK_STACK_FIXME_SHOW
#error VXWORKS_NETWORK_STACK_FIXME     
#endif   
#else 
	if (ERROR == ifMaskSet(if_name_str, if_netmask)) {
	    cli_out("%s: ifMaskSet failed: %s 0x%x\n", 
                    pfx, if_name_str, if_netmask);
	    (void)sal_if_do_deconfig(pfx, eo, if_name, if_unit);
	    return(NULL);
	}
#endif 
    }

    format_ipaddr(if_ip_str, if_ip);	/* [3] */
#ifdef VXWORKS_NETWORK_STACK_6_5
#ifdef VXWORKS_NETWORK_STACK_FIXME_SHOW
#error VXWORKS_NETWORK_STACK_FIXME
#endif
#else
    if (OK != ifAddrSet(if_name_str, (char *)if_ip_str)) {
	cli_out("%s: ifAddrSet failed: %s <-- %s\n", pfx, if_name, if_ip_str);
	(void)sal_if_do_deconfig(pfx, eo, if_name, if_unit);
	return(NULL);
    }
#endif 

    LOG_INFO(BSL_LS_APPL_END,
             (BSL_META_U(u,
                         "%s: ifAddrSet successful: if %s\n"), pfx, if_name_str));
#endif

    if (if_host && *if_host) {		/* [4] */
	LOG_INFO(BSL_LS_APPL_END,
                 (BSL_META_U(u,
                             "%s: Setting hostname: %s\n"), pfx, if_host));
	if (OK != hostAdd (if_host, if_ip_str)) {
	    cli_out("%s: Warning: Failed to set hostname %s for device %s\n", 
                    pfx, if_host, if_name_str);
	}
    }

    return((void *)eo);			/* This is our opaque value */
#else /* !defined(INCLUDE_DRIVERS) */
    cli_out("sal_if_config: Interface configuration not compiled in\n");
    return(NULL);
#endif /* !defined(INCLUDE_DRIVERS) */
}
コード例 #10
0
ファイル: wdbEndPktDrv.c プロジェクト: andy345/vxworks5
STATUS wdbEndPktDevInit
    (
    WDB_END_PKT_DEV *	pPktDev,	/* device structure to init */
    void		(*stackRcv) (),	/* receive packet callback (udpRcv) */
    char *		pDevice,	/* Device (ln, ie, etc.) that we */
    					/* wish to bind to. */
    int         	unit            /* unit number (0, 1, etc.) */
    )
    {
    END_OBJ *	pEnd;
    char	ifname [20];
    char	inetAdrs [24];

    /* initialize the wdbDrvIf field with driver info */

    pPktDev->wdbDrvIf.mode	= WDB_COMM_MODE_POLL| WDB_COMM_MODE_INT;
    pPktDev->wdbDrvIf.mtu	= WDB_END_PKT_MTU;
    pPktDev->wdbDrvIf.stackRcv	= stackRcv;		/* udpRcv */
    pPktDev->wdbDrvIf.devId	= (WDB_END_PKT_DEV *)pPktDev;
    pPktDev->wdbDrvIf.pollRtn	= wdbEndPoll;
    pPktDev->wdbDrvIf.pktTxRtn	= wdbEndTx;
    pPktDev->wdbDrvIf.modeSetRtn = wdbEndModeSet;

    /* initialize the device specific fields in the driver structure */

    pPktDev->inputBusy		= FALSE;
    pPktDev->outputBusy		= FALSE;

#ifndef	STANDALONE_AGENT
    /*
     * Here is where we bind to the lower layer.
     * We do not, as yet, provide for a shutdown routine, but perhaps
     * later.
     * We are a promiscous protocol.
     * The Int routine a fakeout.  Interrupts are handled by the lower
     * layer but we use a similar mechanism to check packets for 
     * the proper type and hand them off to the WDB agent from
     * the "interrupt" routine if it's appropriate to do so.
     */

#ifdef WDB_NPT_CAPABLE
    if (muxTkDrvCheck (pDevice) == TRUE)
	{
	if ((pPktDev->pCookie = muxTkBind (pDevice, unit, wdbNptInt,
					   (FUNCPTR)wdbNptShutdown,
                                           NULL, NULL, MUX_PROTO_SNARF,
					   "Wind Debug Agent",
					   NULL, NULL, NULL)) == NULL)
	    {
	    if (wdbEndDebug)
		logMsg ("Could not bind to NPT Device %s, loading...\n",
			(int)pDevice, 2, 3, 4, 5, 6);
	    return (ERROR);
	    }
	}
    else  /* END */
	{
	if (wdbEndDebug)
	    logMsg ("Not a NPT device! %s\n", (int)pDevice,2,3,4,5,6);
#endif /* WDB_NPT_CAPABLE */
	if ((pPktDev->pCookie = muxBind (pDevice, unit, wdbEndInt, NULL,
					 NULL, NULL, MUX_PROTO_SNARF,
			 		 "Wind Debug Agent", NULL)) == NULL)
	    {
	    if (wdbEndDebug)
		logMsg ("Could not bind to %s, loading...\n",
			(int)pDevice, 2, 3, 4, 5, 6);
	    return (ERROR);
	    }
#ifdef WDB_NPT_CAPABLE
	}
#endif /* WDB_NPT_CAPABLE */

    pEnd = PCOOKIE_TO_ENDOBJ(pPktDev->pCookie);


#else	/* STANDALONE_AGENT */
    /*
     * for standalone agent, we simply need to get the address of the 
     * of the device.
     */

     if ((pPktDev->pCookie = endFindByName (pDevice, unit)) == NULL)
	return (ERROR); 
#endif	/* STANDALONE_AGENT */

    /* build interface name */

    sprintf (ifname, "%s%d", pDevice, unit);

    /* get interface inet address */

    if (ifAddrGet (ifname, inetAdrs) != OK)
    	{
	if (wdbEndDebug)
	    logMsg ("Could not get inet address of %s interface...\n",
	    	(int) ifname, 2, 3, 4, 5, 6);
	return (ERROR);
	}

    pPktDev->ipAddr.s_addr = inet_addr (inetAdrs);

    pEnd = PCOOKIE_TO_ENDOBJ(pPktDev->pCookie);

    if ((pInPkt = memalign (4,pEnd->mib2Tbl.ifMtu)) == NULL)
        return (ERROR);
   
    if ((pPktDev->pInBlk = wdbEndMblkClGet (pEnd, pEnd->mib2Tbl.ifMtu))
        == NULL)
	return (ERROR);
    pPktDev->pInBlk->mBlkHdr.mFlags |= M_PKTHDR;

    if ((pPktDev->pOutBlk = wdbEndMblkClGet (pEnd, pEnd->mib2Tbl.ifMtu))
        == NULL)
	return (ERROR);
    pPktDev->pOutBlk->mBlkHdr.mFlags |= M_PKTHDR;

    if ((pPktDev->lastHAddr = wdbEndMblkClGet (pEnd, pEnd->mib2Tbl.ifMtu))
        == NULL)
	return (ERROR);

    if ((pPktDev->srcAddr = wdbEndMblkClGet (pEnd, pEnd->mib2Tbl.ifMtu))
        == NULL)
	return (ERROR);

    /* Set the length to the size of the buffer just allocated. */
    pPktDev->pInBlk->mBlkHdr.mLen = pPktDev->pInBlk->pClBlk->clSize;

    pPktDev->lastHAddr->mBlkHdr.mLen = pEnd->mib2Tbl.ifPhysAddress.addrLength;

    memset (pPktDev->lastHAddr->mBlkHdr.mData, 0xff,
            pPktDev->lastHAddr->mBlkHdr.mLen);

    /*
     * Create a source address structure so we can send fully
     * qualified packets.
     */
     
    muxIoctl (pPktDev->pCookie, EIOCGADDR, pPktDev->srcAddr->mBlkHdr.mData);

    
    pEndPktDev = pPktDev;

    return (OK);
    }