Пример #1
0
IX_STATUS 
ixEthAccCodeletSwBridge(IxEthAccPortId inPort,
			IxEthAccPortId outPort)
{
    IX_ETHACC_IS_CODELET_INITIALISED();

    if (!ixEthAccCodeletHardwareExists[inPort]
	|| !ixEthAccCodeletHardwareExists[outPort])
    {
	/* Bridge operation only works 
	 * when two Eth NPEs are available
	 *
	 * B0 silicon may have only one eth coprocessor
	 * A0 silicon has two Eth coprocessors
	 */
	printf("\n*********************************************************************\n");
	printf ("Bridge operation needs two Eth coprocessors.\n");
	printf ("Underlying silicon has only one Eth coprocessor!\n");
	printf("\n*********************************************************************\n");
	return IX_FAIL ; 
    }

    if ( ixEthAccCodeletSwBridgeStart(inPort, 
				      outPort)
	 != IX_SUCCESS)
    {
	printf("CodeletMain: Failed to start the Bridge Operation\n");
	return (IX_FAIL);
    }

    printf("\n");
    printf("Bridge Operation started. Begin sending packets from\n");
    printf("external source between port %u and port %u\n", 
	   (UINT32)inPort, 
	   (UINT32)outPort);
    printf("\n");

    if(ixEthAccCodeletLoop()
       != IX_SUCCESS)
    {
	return (IX_FAIL);
    }

    if ( ixEthAccCodeletSwBridgeStop(inPort, 
				     outPort) 
	 != IX_SUCCESS)
    {
	printf("CodeletMain: Failed to stop the Bridge Operation\n");
	return (IX_FAIL);
    }

    /* wait for pending traffic to be completely received */
    if (ixEthAccCodeletRecoverBuffers() 
	!= IX_SUCCESS)
    {
	printf("Warning : Not all buffers are accounted for!\n");
    }

    return (IX_SUCCESS);
}
Пример #2
0
IX_STATUS 
ixEthAccCodeletTxGenRxSinkLoopback(IxEthAccPortId inPort,
				   IxEthAccPortId outPort)
{
    IX_ETHACC_IS_CODELET_INITIALISED();
    
#if defined(__linux) && (IX_ETH_CODELET_QMGR_DISPATCH_MODE==TRUE)
    printf("\n*********************************************************************\n");
    printf("WARNING: This operation uses too much CPU time in interrupt mode to display\n");
    printf("         any counters. Please recompile the codelet for polled mode when\n");
    printf("         using this operation\n\n");
    printf("Polled mode: set IX_ETH_CODELET_QMGR_DISPATCH_MODE to FALSE in IxEthAccCodelet_p.h\n");
    printf("*********************************************************************\n\n");
#endif

    /* This configuration requires two NPE be available to use */
    if ( !((ixEthAccCodeletHardwareExists[inPort]) &&
	   (ixEthAccCodeletHardwareExists[outPort]) ))
    {
	printf("CodeletMain: Failed to start Tx Gen RX Sink Operation as two NPEs are needed\n");
	return (IX_FAIL);
    }

    if (ixEthAccCodeletTxGenRxSinkLoopbackStart(outPort, inPort)
        != IX_ETH_ACC_SUCCESS)
    {
	printf("CodeletMain: Failed to start the Tx Gen RX Sink Operation\n");
	return IX_FAIL;
    }

    printf("\n");
    printf("TxGen RxSink successfully started.\n");
    printf("Begin sending packets from external source\n");  
    printf("Or use a crossover cable between port %d and port %d\n",inPort,outPort);  
    printf("\n");

    /* wait for user input */
    if (ixEthAccCodeletLoop() != IX_SUCCESS)
    {
	return (IX_FAIL);
    }
    
    /* stop traffic, recover buffers */
    if (ixEthAccCodeletTxGenRxSinkLoopbackStop(outPort, inPort)
	    != IX_ETH_ACC_SUCCESS)
    {
	printf("CodeletMain: Failed to stop the Tx Gen RX Sink Operation\n");
	return (IX_FAIL);
    }

    /* wait for pending traffic to be completely received */
    if (ixEthAccCodeletRecoverBuffers() 
	!= IX_SUCCESS)
    {
	printf("Warning : Not all buffers are accounted for!\n");
    }

    return (IX_SUCCESS);
}
Пример #3
0
IX_STATUS 
ixEthAccCodeletRxSink(void)
{
    IxEthAccPortId portId;
 
    IX_ETHACC_IS_CODELET_INITIALISED();

    /* Configure all available ports and start traffic */
    for (portId = 0; portId < IX_ETHACC_CODELET_MAX_PORT; portId++)
    {
	if (ixEthAccCodeletHardwareExists[portId])
	{
	    if (ixEthAccCodeletRxSinkStart(portId) 
		!= IX_ETH_ACC_SUCCESS)
	    {
		printf("CodeletMain: Failed to configure the RX Sink Operation Port %u\n",
		       (UINT32)portId);
		return IX_FAIL;
	    }
	}
    }

    printf("\n");
    printf("Rx Sink Operation started.\n");
    printf("Begin sending packets in from external source\n");
    printf("\n");

    /* wait for user input */
    if(ixEthAccCodeletLoop() != IX_SUCCESS)
    {
	printf("CodeletMain: Failed to get User Input (should never happen)");
	return (IX_FAIL);
    }
    
    /* Stop traffic and unconfigure all available ports */
    for (portId = 0; portId < IX_ETHACC_CODELET_MAX_PORT; portId++)
    {
	if (ixEthAccCodeletHardwareExists[portId])
	{
	    if (ixEthAccCodeletRxSinkStop(portId) 
		!= IX_ETH_ACC_SUCCESS)
	    {
		printf("CodeletMain: Failed to unconfigure the RX Sink Operation Port %u\n",
		       (UINT32)portId);
		return IX_FAIL;
	    }
	}
    }

    /* wait for pending traffic to be completely received */
    if (ixEthAccCodeletRecoverBuffers() 
	!= IX_SUCCESS)
    {
	printf("CodeletMain: Warning! Not all buffers are accounted for\n");
    }

    return (IX_SUCCESS);
}
Пример #4
0
/*
 * Function definition: ixEthAccCodeletDBLearningRun()
 *
 * Run ethDB demo for all ports passed as parameters
 */
IX_STATUS 
ixEthAccCodeletDBLearningRun(BOOL validPorts[])
{
    IxEthAccPortId portId;
    IxEthDBPortId portPtr;

    IxEthDBMacAddr staticMacAddress[IX_ETHACC_CODELET_MAX_PORT] = 
	{{{0,1,2,3,4,5}}, {{6,7,8,9,0,1}}};

    IxEthDBMacAddr dynamMacAddress[IX_ETHACC_CODELET_MAX_PORT] = 
	{{{0xa,0xb,0xc,0xd,0xe,0xf}}, {{0x0,0xb,0x3,0xc,0x4,0xd}}};

    if (ixEthAccCodeletDBMaintenanceStart()
	!= IX_SUCCESS)
    {
	printf("DbLearning: Error spawning DB maintenance task\n");
	return (IX_FAIL);
    }

    /* configure all existing ports */
    for (portId = 0; portId < IX_ETHACC_CODELET_MAX_PORT; portId++)
    {
	if (validPorts[portId])
	{
	    /* Configure the port */
	    printf("Configuring the port...\n");

	    if (ixEthAccCodeletPortConfigure(portId,
					     ixEthAccCodeletMemPoolFreeRxCB,
					     (IxEthAccPortMultiBufferRxCallback) NULL,
					     ixEthAccCodeletMemPoolFreeTxCB,
					     portId) 
		!= IX_ETH_ACC_SUCCESS)
	    {
		printf("DbLearning: Failed to configure the port %u\n",
		       (UINT32)portId);
		return IX_FAIL;
	    }

	    /* Enable the port */
	    printf("Enabling the port...\n");

	    if(ixEthAccPortEnable(portId) != IX_ETH_ACC_SUCCESS)
	    {
		printf("DbLearning: Error enabling port %u\n", 
		       (UINT32)portId);
		return (IX_FAIL);
	    }
	    
	    /* Add some static entries */
	    printf("Adding static entries...\n");
	    
	    if (ixEthDBFilteringStaticEntryProvision(portId,
						     &staticMacAddress[portId])
		!= IX_ETH_DB_SUCCESS)
	    {
		printf("DbLearning: Failed to add static MAC to port %u\n", 
		       (UINT32)portId);
		return (IX_FAIL);
	    }

            ixOsalSleep(100);
	    
	    /* Verify that the address has successfully been added */
	    if (ixEthDBFilteringDatabaseSearch(&portPtr, 
					       &staticMacAddress[portId])
		== IX_ETH_DB_NO_SUCH_ADDR)
	    {
		printf("DbLearning: Static MAC address not found in Database\n");
		return (IX_FAIL);
	    }
	    
	    /* Add some dynamic entries */
	    printf("Adding dynamic entries...\n");
	    
	    if (ixEthDBFilteringDynamicEntryProvision(portId,
						      &dynamMacAddress[portId])
		!= IX_ETH_DB_SUCCESS)
	    {
		printf("DbLearning: Failed to add dynamic MAC to port %u\n", 
		       (UINT32)portId);
	    }
	    
	    printf("Enabling aging...\n");
	    
	    if (ixEthDBPortAgingEnable(portId) != IX_ETH_DB_SUCCESS)
	    {
		printf("DbLearning: Failed to enable aging for port %u\n", 
		       (UINT32)portId);
		return (IX_FAIL);
	    }
	}
    }
 
    ixEthDBFilteringDatabaseShowAll();

    /* Wait 4 minutes over aging time (for safety) and verify that the 
     * dynamic entries have been removed 
     */
    printf("Aging entries.\nWaiting for %d minutes...\n", 
	   IX_ETH_DB_LEARNING_ENTRY_AGE_TIME / 60 + 3);
    
    ixOsalSleep((IX_ETH_DB_LEARNING_ENTRY_AGE_TIME + 180) * 1000);
     
    ixEthDBFilteringDatabaseShowAll();
    
    for (portId = 0; portId < IX_ETHACC_CODELET_MAX_PORT; portId++)
    {
	if (validPorts[portId])
	{
	    if(ixEthDBFilteringEntryDelete(&staticMacAddress[portId])
	       != IX_ETH_DB_SUCCESS)
	    {
		printf("DbLearning: Failed to remove static MAC on port %u\n", 
		       (UINT32)portId);
	    }
	    
	    /* Disable ports */
	    if(ixEthAccPortDisable(portId) != IX_ETH_ACC_SUCCESS)
	    {
		printf("DbLearning: Error disabling port %u\n",
		       (UINT32)portId);
		return (IX_FAIL);
	    }
	}
    }

    /* wait for pending traffic to be completely received */
    if (ixEthAccCodeletRecoverBuffers() 
	!= IX_SUCCESS)
    {
	printf("Warning : Not all buffers are accounted for!\n");
    }    

    return (IX_SUCCESS);
}
Пример #5
0
/*
 * Function definition: ixEthAccCodeletPhyLoopback()
 *
 * See header file for documentation.
 */
IX_STATUS
ixEthAccCodeletPhyLoopback(void)
{
    IxEthAccPortId portId;
 
    IX_ETHACC_IS_CODELET_INITIALISED();

#if defined(__linux) && (IX_ETH_CODELET_QMGR_DISPATCH_MODE==TRUE)
    printf("\n*********************************************************************\n");
    printf("WARNING: This operation uses too much CPU time in interrupt mode to display\n");
    printf("         any counters. Please recompile the codelet for polled mode when\n");
    printf("         using this operation.\n\n");
    printf("Polled mode: set IX_ETH_CODELET_QMGR_DISPATCH_MODE to FALSE in IxEthAccCodelet_p.h\n");
    printf("*********************************************************************\n\n");
#endif    /* Configure all available ports */

    for (portId = 0; portId < IX_ETHACC_CODELET_MAX_PORT; portId++)
    {
	if (ixEthAccCodeletHardwareExists[portId])
	{
	    if (ixEthAccCodeletPhyLoopbackStart(portId) 
		!= IX_ETH_ACC_SUCCESS)
	    {
		printf("CodeletMain: Failed to configure the PHY Loopback Operation on Port %u\n",
		       (UINT32)portId);
		return IX_FAIL;
	    }
	}
    }

    printf("\n");
    printf("PHY Loopback operation successfully started\n");
    printf("\n");

    /* wait for user input */
    if(ixEthAccCodeletLoop() != IX_SUCCESS)
    {
	return (IX_FAIL);
    }

    /* Stop traffic and unconfigure all available ports */
    for (portId = 0; portId < IX_ETHACC_CODELET_MAX_PORT; portId++)
    {
	if (ixEthAccCodeletHardwareExists[portId])
	{
	    if (ixEthAccCodeletPhyLoopbackStop(portId) 
		!= IX_ETH_ACC_SUCCESS)
	    {
		printf("CodeletMain: Failed to unconfigure the PHY Loopback Operation on Port %u\n",
		       (UINT32)portId);
		return IX_FAIL;
	    }
	}
    }

    /* wait for pending traffic to be completely received */
    if (ixEthAccCodeletRecoverBuffers() 
	!= IX_SUCCESS)
    {
	printf("Warning: Not all buffers are accounted for!\n");
    }

    return (IX_SUCCESS);
}