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

📄 ixatmcodeletmain.c

📁 有关ARM开发板上的IXP400网络驱动程序的源码以。
💻 C
📖 第 1 页 / 共 2 页
字号:
/** * @file    IxAtmCodeletMain.c * * @date    27-May-2000 * * @brief   IxAtmCodelet scenarios. *  * @par * IXP400 SW Release version 2.1 *  * -- 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/* * 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;/* * 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);    }    /* 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);    }    /* 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);    }    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);    }    /* 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);    }    /* 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);    }    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");         return IX_FAIL;      }	     return IX_SUCCESS;}/*  * This is the ATM Codelet main function that will be used by the user as a single * point of execution */PUBLIC IX_STATUSixAtmCodeletMain(IxAtmCodeletMode modeType, IxAtmCodeletAalType aalType){    /* Validate the type of AAL selected */    if (aalType <= ixAtmCodeletAalTypeInvalid || aalType >= ixAtmCodeletAalTypeMax)    {	IX_ATMCODELET_LOG ("Invalid AAL Type\n");	ixAtmCodeletMainUsage();	return IX_FAIL;    }

⌨️ 快捷键说明

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