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

📄 ixatmcodelet.c

📁 intel IXP400系列cpu(2.3版)的库文件
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * @file    IxAtmCodelet.c * * @date    17-May-2002 * * @brief   API of the IXP400 Atm Codelet (IxAtmCodelet) * * A detailed description of the design of this codelet is contained in * IxAtmCodelet_p.h * * IxAtmCodelet API Functions: *       ixAtmCodeletInit *       ixAtmCodeletUbrChannelsProvision *       ixAtmCodeletUbrChannelsRemove *       ixAtmCodeletPortRateModify *       ixAtmCodeletPortQuery  *       ixAtmCodeletShow *  * @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 -- *//* * System defined include files */#if defined(__wince) && defined(IX_USE_SERCONSOLE)	#include "IxSerConsole.h"	#define printf ixSerPrintf	#define gets ixSerGets#endif#ifdef __vxworks#include <end.h>    /* END drivers */#include <endLib.h> /* END drivers */#endif /* def __vxworks */#include "IxOsal.h"#include "IxQMgr.h"#include "IxNpeMh.h"#include "IxNpeDl.h"#include "IxAtmdAcc.h"#include "IxAtmm.h"#include "IxAtmCodelet.h"#include "IxAtmCodelet_p.h"/* * Defines and macros */#define IX_ATMCODELET_UTOPIA_PHY_ADDR_BASE  (0)#define IX_ATMCODELET_UTOPIA_TX_PORT_RATE   (22257 * 53 * 8) /* TX_PORT_RATE gives 							      * approx 9Mbps.*/#define IX_ATMCODELET_UTOPIA_RX_PORT_RATE   (52 * 1024 * 1024)  /* The actual 52 Mbps								 * is 52 x 1024 x 1024 */#define IX_ATMCODELET_MAX_PACKET_LENGTH     (1500)#define IX_ATMCODELET_MAX_CELLS_TO_SEND     32/* Define if queue manager dispatcher should be interrupt or polled */#ifdef  __vxworks#define IX_ATMCODELET_USE_QMGR_INT FALSE#else#define IX_ATMCODELET_USE_QMGR_INT TRUE#endif/* * This function macro is used to reduce the ammount of code needed to check * the return value of component initialisation functions. The * parameter FUNCTION_CALL is for example: * IX_ATMCODELET_COMP_INIT(ixAtmmUtopiaInit(numPorts, phyMode, portCfgs, loopbackMode)); */#define IX_ATMCODELET_COMP_INIT(FUNCTION_CALL) do{\  if (IX_SUCCESS != FUNCTION_CALL) \  { \     IX_ATMCODELET_LOG ("IxAtmCodelet: %s Failed\n", #FUNCTION_CALL); \  } \  else \  { \     IX_ATMCODELET_LOG ("IxAtmCodelet: %s Succeeded\n", #FUNCTION_CALL); \  } \}while(0)/* * Variable declarations global to this file. Externs are followed by * statics. */static BOOL ixAtmCodeletInitialized                = FALSE;static BOOL ixAtmCodeletUtopiaLoopbackEnabled      = FALSE;static BOOL ixAtmCodeletSoftwareLoopbackEnabled    = FALSE;static UINT32 ixAtmCodeletNumPortsConfigured = 0;static IxAtmCodeletStats ixAtmCodeletStats;/* Number of VCs configured */static UINT32 ixAtmCodeletNumChannelsConfigured = 0;static IxAtmCodeletMode ixAtmCodeletMode;static IxQMgrDispatcherFuncPtr dispatcherFunc ;/* * Function prototypes *//* --------------------------------------------------------------   This is the entry point for the IxQMgrDispatcher task used for   IX_ATMCODELET_SOFTWARE_LOOPBACK mode of operation.   -------------------------------------------------------------- */PRIVATE intixAtmCodeletDispatchTask (void *arg, void **ptrRetObj);/* * Function definitions *//* --------------------------------------------------------------   Initialise system components used by the Atm Codelet.   -------------------------------------------------------------- */PUBLIC IX_STATUSixAtmCodeletSystemInit (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;}/* --------------------------------------------------------------   Initialise the Atm Codelet.   In software loopback only 1 PDU is sent for every rxToTxRatio    PDUs received. NOTE: that the rxToTxRatio only applies to    IX_ATMCODELET_SOFTWARE_LOOPBACK mode.   -------------------------------------------------------------- */PUBLIC IX_STATUSixAtmCodeletInit (UINT32 numPorts, 		  UINT32 rxToTxRatio){    IX_STATUS retval;    IxAtmmPortCfg portCfgs[IX_UTOPIA_MAX_PORTS];    IxAtmmUtopiaLoopbackMode loopbackMode;#if IX_UTOPIAMODE == 1    IxAtmmPhyMode phyMode = IX_ATMM_SPHY_MODE;#else    IxAtmmPhyMode phyMode = IX_ATMM_MPHY_MODE;#endif    IxAtmLogicalPort port;    /* Check parameters */    if (numPorts < 1 || numPorts > IX_UTOPIA_MAX_PORTS)    {	IX_ATMCODELET_LOG("ixAtmCodeletInit(): numPorts (%u) invalid\n", numPorts);	return IX_FAIL;    }    if (IX_ATMCODELET_UTOPIA_LOOPBACK == ixAtmCodeletMode)    {	ixAtmCodeletUtopiaLoopbackEnabled = TRUE;    }    else if (IX_ATMCODELET_SOFTWARE_LOOPBACK == ixAtmCodeletMode)    {	ixAtmCodeletSoftwareLoopbackEnabled = TRUE;    }    else if (IX_ATMCODELET_REMOTE_LOOPBACK != ixAtmCodeletMode)    {	IX_ATMCODELET_LOG ("Invalid IxAtmCodelet mode\n");	return IX_FAIL;    }    if (ixAtmCodeletSoftwareLoopbackEnabled)    {	if (rxToTxRatio == 0)	{	    IX_ATMCODELET_LOG("rxToTxRatio of 0 not allowed\n");	    return IX_FAIL;	}    }    else    {	if (rxToTxRatio > 0)	{	    /* Display a message to inform the user that rxToTxRatio only applies to	     * IX_ATMCODELET_SOFTWARE_LOOPBACK mode.	     */	    IX_ATMCODELET_LOG ("rxToTxRatio ignored when codeletSoftwareLoopbackEnabled := FALSE\n");	}    }

⌨️ 快捷键说明

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