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

📄 ixatmcodeletmain.c

📁 intel IXP400系列cpu(2.3版)的库文件
💻 C
📖 第 1 页 / 共 2 页
字号:
/** * @file    IxAtmCodeletMain.c * * @date    27-May-2000 * * @brief   IxAtmCodelet scenarios. *  * @par * IXP400 SW Release version 2.3 *  * -- Copyright Notice -- *  * @par * Copyright (c) 2001-2005, Intel Corporation. * All rights reserved. *  * @par * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. Neither the name of the Intel Corporation nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. *  *  * @par * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. *  *  * @par * -- End of Copyright Notice -- *//* * User defined include files. */#if defined(__wince) && defined(IX_USE_SERCONSOLE)	#include "IxSerConsole.h"	#define printf ixSerPrintf	#define gets ixSerGets#endif#include "IxOsal.h"#include "IxAtmCodelet_p.h"#include "IxAtmCodelet.h"/* * Defines and macros */#define MAX_TIME_LIMIT_IN_SEC    (15)    /* 15 sec (unit seconds)*//* * Variable declarations global to this file. Externs are followed by * statics. */#define AAL5_CPCS_SDU_SEND_LENGTH  1500#define AAL0_CELLS_SEND_LENGTH     32#define AAL5_PACKET_SEND_COUNT     32#define AAL0_PACKET_SEND_COUNT     32/*  * Time in MS the packet sending thread should sleep when MBUF is running low. * This is only applicable to UTOPIA loopback and remote loopback mode. This * value is obtained from tuning experience on IXDP465 with 533Mhz silicon  */#define PACKET_SEND_MS_SLEEP  80/* * This is the divider for PACKET_SEND_MS_SLEEP when codelet mode is only * sending packet but not receiving (remote loopback). These mode consumes less * CPU resources and hence, require lesser sleeping time. */#define PACKET_SEND_MS_SLEEP_DEVIDER 2/* * Typedef  *//* Function pointer to send either AAL5 or AAL0 packets */typedef void (*IxAtmCodeletSduSendTaskFnPtr)(void);/*  * Global variables *//* Function pointer variable */IxAtmCodeletSduSendTaskFnPtr ixAtmCodeletSduSendTask;/* Initial value of AAL Type is invalid */IxAtmCodeletAalType ixAtmCodeletAalType = ixAtmCodeletAalTypeInvalid;/* Flag to enable OAM Ping */BOOL ixAtmCodeletOamPingF4F5Enabled = FALSE;/* * Static variable *//* Default to AAL5 Sleep time */static UINT32 loopSleepTime = PACKET_SEND_MS_SLEEP;/* * Function definitions *//* Function for OAM Ping F4 & F5 cells */PRIVATE void ixAtmCodeletOamPingF4F5CellsRun(void); /* Function to send AAL5 SDU */PRIVATE void ixAtmCodeletAal5SduSendTask (void);  /* Function to send AAL0 SDU */PRIVATE void ixAtmCodeletAal0SduSendTask (void);/* Function that displays the usage */PRIVATE void ixAtmCodeletMainUsage (void); /* Function that performs utopia loopback */PRIVATE IX_STATUS ixAtmCodeletMainUtopiaLoopbackRun (void);/* Function that performs software loopback */PRIVATE IX_STATUS ixAtmCodeletMainSoftwareLoopbackRun (void);/* Function that performs remote loopback */PRIVATE IX_STATUS ixAtmCodeletMainRemoteLoopbackRun (void);/* Function to create thread for SwLoopbackStatsShowTask */PRIVATE IX_STATUS ixAtmCodeletSoftwareLoopbackThreadCreate(void);/* Function that display the ATM Codelet Stats and/or Perform OAM    ping for Sw loopback*/PRIVATE void ixAtmCodeletSoftwareLoopbackStatsShowTask(void);PRIVATE IX_STATUSixAtmCodeletMainUtopiaLoopbackRun (void){    IX_STATUS retval;    UINT32 numPorts = 1;    UINT32 rxToTxRatio = 1;    IxOsalThread tid;    IxOsalThreadAttr threadAttr;    char *pThreadName = "PDU Send";    IxAtmCodeletMode mode = IX_ATMCODELET_UTOPIA_LOOPBACK;        IX_ATMCODELET_LOG ("*************************************\n");    IX_ATMCODELET_LOG ("********** UTOPIA LOOPBACK **********\n");    IX_ATMCODELET_LOG ("*************************************\n");    /* Initialise system for the codelet */    retval = ixAtmCodeletSystemInit (numPorts, mode);    if (IX_SUCCESS != retval)    {	IX_ATMCODELET_LOG ("Failed to initialise IxAtmCodelet\n");	return IX_FAIL;    }    retval = ixAtmCodeletInit (numPorts, rxToTxRatio);        if (IX_SUCCESS != retval)    {	IX_ATMCODELET_LOG ("Failed to initialise IxAtmCodelet\n");	return IX_FAIL;    }    /* AAL Type 5*/    if( ixAtmCodeletAalType == ixAtmCodeletAalType5)    { 	ixAtmCodeletSduSendTask = ixAtmCodeletAal5SduSendTask;	/* Provision some Aal5 channels */	retval = ixAtmCodeletUbrChannelsProvision (numPorts,						   IX_ATMCODELET_NUM_AAL5_CHANNELS,						   IX_ATMDACC_AAL5);	loopSleepTime = PACKET_SEND_MS_SLEEP;    }    /* AAL Type 0 with 48 bytes*/    if( ixAtmCodeletAalType == ixAtmCodeletAalType0_48)    { 	ixAtmCodeletSduSendTask = ixAtmCodeletAal0SduSendTask;	/* Provision some Aal0_48 channels */	retval = ixAtmCodeletUbrChannelsProvision (numPorts,						   IX_ATMCODELET_NUM_AAL0_48_CHANNELS,						   IX_ATMDACC_AAL0_48);	loopSleepTime = PACKET_SEND_MS_SLEEP;    }    /* AAL Type 0 with 52 bytes */    if( ixAtmCodeletAalType == ixAtmCodeletAalType0_52)    {	ixAtmCodeletSduSendTask = ixAtmCodeletAal0SduSendTask;	/* Provision some Aal0_52 channels */	retval = ixAtmCodeletUbrChannelsProvision (numPorts,						   IX_ATMCODELET_NUM_AAL0_52_CHANNELS,						   IX_ATMDACC_AAL0_52);	loopSleepTime = PACKET_SEND_MS_SLEEP;    }    if (IX_SUCCESS != retval)    {	IX_ATMCODELET_LOG ("Failed to provision channels\n");	return IX_FAIL;    }        /*Set attributes of thread*/    threadAttr.name = pThreadName;    threadAttr.stackSize = IX_ATMCODELET_QMGR_DISPATCHER_THREAD_STACK_SIZE;    threadAttr.priority = IX_ATMCODELET_QMGR_DISPATCHER_PRIORITY;    if (ixOsalThreadCreate(&tid,			   &threadAttr, 			   (IxOsalVoidFnVoidPtr)ixAtmCodeletSduSendTask,  			   NULL) != IX_SUCCESS)       { 	IX_ATMCODELET_LOG ("Error spawning SduSend task\n");  	return IX_FAIL;       }      if(IX_SUCCESS != ixOsalThreadStart(&tid))      {        IX_ATMCODELET_LOG ("Error starting thread\n");         return IX_FAIL;      }	     return IX_SUCCESS;}/* --------------------------------------------------------------   This scenario demonstrates that 32Mbps Rx/6 Mbps Tx can be   achieved.   -------------------------------------------------------------- */PRIVATE IX_STATUSixAtmCodeletMainSoftwareLoopbackRun (void){    IX_STATUS retval;    UINT32 numPorts = 1;    UINT32 rxToTxRatio = 5;/* Transmit 1 PDU for every 5 PDUs recieved. 			    * This will show 32Mbps Rx/6 Mbps Tx */    IxAtmCodeletMode mode = IX_ATMCODELET_SOFTWARE_LOOPBACK;    IX_ATMCODELET_LOG ("*************************************\n");    IX_ATMCODELET_LOG ("********* SOFTWARE LOOPBACK *********\n");    IX_ATMCODELET_LOG ("*************************************\n");    /* Initialise system for the codelet */    retval = ixAtmCodeletSystemInit (numPorts, mode);    if (IX_SUCCESS != retval)    {	IX_ATMCODELET_LOG ("Failed to initialise IxAtmCodelet\n");	return IX_FAIL;    }    /* Initialise the codelet */    retval = ixAtmCodeletInit (numPorts, rxToTxRatio);        if (IX_SUCCESS != retval)    {	IX_ATMCODELET_LOG ("Failed to initialise IxAtmCodelet\n");	return IX_FAIL;    }    /* AAL Type 5*/    if (ixAtmCodeletAalType == ixAtmCodeletAalType5)    {		/* Provision some Aal5 channels */	retval = ixAtmCodeletUbrChannelsProvision (numPorts,						   IX_ATMCODELET_NUM_AAL5_CHANNELS,						   IX_ATMDACC_AAL5);    }    /* AAL Type 0 with 48 bytes */    if (ixAtmCodeletAalType == ixAtmCodeletAalType0_48)    {	/* Provision some Aal0_48 channels */	retval = ixAtmCodeletUbrChannelsProvision (numPorts,						   IX_ATMCODELET_NUM_AAL0_48_CHANNELS,						   IX_ATMDACC_AAL0_48);    }    /* AAL Type 0 with 52 bytes */    if (ixAtmCodeletAalType == ixAtmCodeletAalType0_52)    {	/* Provision some Aal0_52 channels */	retval = ixAtmCodeletUbrChannelsProvision (numPorts,						   IX_ATMCODELET_NUM_AAL0_52_CHANNELS,						   IX_ATMDACC_AAL0_52);    }    if (IX_SUCCESS != retval)    {	IX_ATMCODELET_LOG ("Failed to provision channels\n");	return IX_FAIL;    }    return IX_SUCCESS;}PRIVATE IX_STATUSixAtmCodeletMainRemoteLoopbackRun (void){    IX_STATUS retval;    UINT32 numPorts = 1;    UINT32 rxToTxRatio = 1;    IxOsalThread tid;    IxOsalThreadAttr threadAttr;    char *pThreadName = "PDU Send";    IxAtmCodeletMode mode = IX_ATMCODELET_REMOTE_LOOPBACK;    IX_ATMCODELET_LOG ("*************************************\n");    IX_ATMCODELET_LOG ("*********** REMOTE LOOPBACK *********\n");    IX_ATMCODELET_LOG ("*************************************\n");    /* Initialise system for the codelet */    retval = ixAtmCodeletSystemInit (numPorts, mode);    if (IX_SUCCESS != retval)    {	IX_ATMCODELET_LOG ("Failed to initialise IxAtmCodelet\n");	return IX_FAIL;    }        /* Initialise the codelet */    retval = ixAtmCodeletInit (numPorts, rxToTxRatio);        if (IX_SUCCESS != retval)    {	IX_ATMCODELET_LOG ("Failed to initialise IxAtmCodelet\n");	return IX_FAIL;    }    /* AAL Type 5*/    if (ixAtmCodeletAalType == ixAtmCodeletAalType5)    {	ixAtmCodeletSduSendTask = ixAtmCodeletAal5SduSendTask;	/* Provision some Aal5 channels */	retval = ixAtmCodeletUbrChannelsProvision (numPorts,						   IX_ATMCODELET_NUM_AAL5_CHANNELS,						   IX_ATMDACC_AAL5);	/* Unlike UTOPIA loopback, remote loopback mode only send packets but	 * never process it. Hence, the sending thread sleeping time when	 * MBUF is full is theoritically half of the UTOPIA loopback mode. */	loopSleepTime = PACKET_SEND_MS_SLEEP / PACKET_SEND_MS_SLEEP_DEVIDER;    }    /* AAL Type 0 with 48 bytes */    if(ixAtmCodeletAalType == ixAtmCodeletAalType0_48)    {	ixAtmCodeletSduSendTask = ixAtmCodeletAal0SduSendTask;	/* Provision some Aal0_48 channels */	retval = ixAtmCodeletUbrChannelsProvision (numPorts,						   IX_ATMCODELET_NUM_AAL0_48_CHANNELS,						   IX_ATMDACC_AAL0_48);	/* Unlike UTOPIA loopback, remote loopback mode only send packets but	 * never process it. Hence, the sending thread sleeping time when	 * MBUF is full is theoritically half of the UTOPIA loopback mode. */	loopSleepTime = PACKET_SEND_MS_SLEEP / PACKET_SEND_MS_SLEEP_DEVIDER;    }    /* AAL Type 0 with 52 bytes */    if (ixAtmCodeletAalType == ixAtmCodeletAalType0_52)    {	ixAtmCodeletSduSendTask = ixAtmCodeletAal0SduSendTask;	/* Provision some Aal0_52 channels */	retval = ixAtmCodeletUbrChannelsProvision (numPorts,						   IX_ATMCODELET_NUM_AAL0_52_CHANNELS,						   IX_ATMDACC_AAL0_52);	/* Unlike UTOPIA loopback, remote loopback mode only send packets but	 * never process it. Hence, the sending thread sleeping time when	 * MBUF is full is theoritically half of the UTOPIA loopback mode. */	loopSleepTime = PACKET_SEND_MS_SLEEP / PACKET_SEND_MS_SLEEP_DEVIDER;    }    if (IX_SUCCESS != retval)    {	IX_ATMCODELET_LOG ("Failed to provision channels\n");	return IX_FAIL;    }    /*Set thread attribute*/    threadAttr.name = pThreadName;    threadAttr.stackSize = IX_ATMCODELET_QMGR_DISPATCHER_THREAD_STACK_SIZE;    threadAttr.priority = IX_ATMCODELET_QMGR_DISPATCHER_PRIORITY;    if (ixOsalThreadCreate(&tid,			   &threadAttr, 			   (IxOsalVoidFnVoidPtr)ixAtmCodeletSduSendTask,  			   NULL) != IX_SUCCESS)       {  	IX_ATMCODELET_LOG ("Error spawning SduSend task\n");  	return IX_FAIL;       }      if(IX_SUCCESS != ixOsalThreadStart(&tid))      {        IX_ATMCODELET_LOG ("Error starting thread task\n"); 

⌨️ 快捷键说明

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