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

📄 ixethaal5app.c

📁 intel IXP400系列cpu(2.3版)的库文件
💻 C
📖 第 1 页 / 共 5 页
字号:
/** * @file IxEthAal5App * * @date  June-2002  * * @brief This file contains the implementation of the IxEthAal5App * component. * *  * @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 -- */#ifdef __vxworks#include <end.h>    /* END drivers */#include <endLib.h> /* END drivers */#include <sysLib.h> /* system clock */#endif#include "IxOsal.h"#include "IxQMgr.h"#include "IxNpeDl.h"#include "IxNpeMh.h"#include "IxAtmdAcc.h"#include "IxAtmdAccCtrl.h"#include "IxAtmm.h"#include "IxEthDB.h"#include "IxEthDBPortDefs.h"#include "IxAdsl.h"#include "IxFeatureCtrl.h"#ifdef __wince#include "pkfuncs.h"#include "oalintr.h"#endif#include "IxEthAal5App.h"#include "IxEthAal5App_p.h"#if defined(__wince) && defined(IX_USE_SERCONSOLE)#include "IxSerConsole.h"#define printf ixSerPrintf#define gets ixSerGets#endif/* Define IXEAA_DEBUG to enable verbose debugging mode */#undef IXEAA_DEBUG/*************************** USEFULL DEFINES *********************************/#define ATM_CELL_SIZE 53#define AAL5_PAYLOAD_LENGTH           48/* Typically mbuffer data is allocated to size 2048 - this is enough to hold    largest possible Ethernet frame. Here it is 2064=43*48, the requirement of   AtmdAcc component is that mLen field of mbuffer is set to n*48. */#define IX_EAA_DEFAULT_MBUF_DATA_SIZE 2064/* User space is 8 words at the beginning of mbuffer data. First 4 bytes are    used to store information about the port (Eth 0,1 or Atm 0,1,2...) to which    buffer belongs. This information speeds up buffer replenishing (recycling).    Last 2 bytes hold RFC1483 header used for Ethernet frame encapsulation into    ATM packet. Thanks to that inserting of this header into mbuffer data is    avoided when eth. frame needs to be encapsulated.   User data is not visible to ixEthAcc or AtmdAcc components - mbuffer data    pointer (mData) points to first byte after user data. */#define IX_EAA_MBUF_USER_SPACE      (8*sizeof(UINT32))/* * Atm and eth mark are placed on the beginning of buffer data (user space) to  * mark that particular buffer belongs to Eth or ATM */#define IX_EAA_ATM_MARK             0x00000100#define IX_EAA_ETH_MARK             0x00000200/* * Atm or Eth mask are stored in first word of user data location [8:15] (bits),  * while VC id occupies location [0:7] */#define IX_EAA_MARK_MASK            0xFF00#define IX_EAA_ATM_VC_MASK          0x00FF#define IX_EAA_ETH_PORT_MASK        0x00FF#define IX_EAA_AAL5_TRAILER_SIZE                    8#define IX_EAA_AAL5_LENGTH_POS_FROM_END_OF_TRAILER  6#define IX_EAA_AAL5_TRAILER_FCS_SIZE                4#define IX_EAA_MIN_ETH_FRAME_SIZE   60#define IX_EAA_MAX_ETH_FRAME_SIZE   1514#define IX_EAA_NUM_ETH_PORTS        IXP400_ETH_ACC_MII_MAX_ADDR#define IX_EAA_ETH_FCS_SIZE         4/* * This is RFC1483 header used for encapsulation Ethernet frames by bridge * applications in VcMux mode. Header consist of two bytes set to 0. Refer * to RFC 1483 document for more details. */#define IX_EAA_RFC1483_VCMUX_ROUTED_IP_HEADER          0x4500#define IX_EAA_RFC1483_VCMUX_ROUTED_HEADER_SIZE        14#define IX_EAA_RFC1483_VCMUX_BRIDGED_HEADER            0x0000#define IX_EAA_RFC1483_VCMUX_BRIDGED_HEADER_SIZE       2#define IX_UTOPIA_PHY_ADDR          0/* Define maximum upload and download rates   available on utopia port. Because this application doesn't    use real time protocols (VBR), those rates doesn't have any    effect on real throughput. Moreover real data rates can be    limited by type of media connected to Utopia (like Adsl) */#define IX_EAA_UPLOAD_RATE          800000#define IX_EAA_DOWNLOAD_RATE        53000000/* Read comments in atmdAcc.h for IxAtmdAccAPI and minimumReplenishCount to   fully understand meaning of this value. */#define IX_EAA_MIN_REPLENISH_COUNT  1#define IX_EAA_INITIALIZED          1/** * @def NPE_A_IMAGE_ID_SINGLE_PORT_SPHY * @brief NPE A image to load for the required features * * This is an NPE-A image supporting ATM SPHY (single port) */#define NPE_A_IMAGE_ID_SINGLE_PORT_SPHY (IX_NPEDL_NPEIMAGE_NPEA_HSS0_ATM_SPHY_1_PORT)/** * @def NPE_A_IMAGE_ID_SINGLE_PORT_MPHY * @brief NPE A image to load for the required features * * This is an NPE-A image supporting ATM MPHY (single port) */#define NPE_A_IMAGE_ID_SINGLE_PORT_MPHY (IX_NPEDL_NPEIMAGE_NPEA_HSS0_ATM_MPHY_1_PORT)/** * @def NPE_A_IMAGE_ID_MULTI_PORT_MPHY * @brief NPE A image to load for the required features * * This is an NPE-A image supporting ATM MPHY (multi port) */#define NPE_A_IMAGE_ID_MULTI_PORT_MPHY  (IX_NPEDL_NPEIMAGE_NPEA_ATM_MPHY_12_PORT)/** * @def NPE_B_IMAGE_ID * @brief NPE B image to load for the required features * * This is an NPE-B image with Ethernet support */#define NPE_B_IMAGE_ID IX_NPEDL_NPEIMAGE_NPEB_ETH/** * @def NPE_C_IMAGE_ID * @brief NPE C image to load for the required features * * This is an NPE-C image with Ethernet support */#define NPE_C_IMAGE_ID IX_NPEDL_NPEIMAGE_NPEC_ETH/** * @def S * @brief Multiplier for @c ixOsalSleep to work in seconds */#define S 1000/* ADSL line number is 0 */#define IX_EAA_ADSL_LINE_NUM 0/* ADSL line type is normal */#define IX_EAA_ADSL_LINE_TYPE 0/* ADSL phy type is CPE */#define IX_EAA_ADSL_PHY_TYPE_CPE 0/* Thread Priority is set to low for EthAal5AppShowTask */#define IX_EAA_THREAD_PRI_LOW 140/* Thread Priority is set to low for ixEAAEthLinkStateMonitorLoop */#define IX_EAA_LINE_MONITOR_PRI 140#define PERIPHERAL_BUS_CLOCK     66 /* Preipheral Bus frequency 66MHz */#define TIMESTAMP_TICKS_PER_MSEC ((PERIPHERAL_BUS_CLOCK) * 1000) /*Time stamp*/#define MAX_TIME_LIMIT_IN_MSEC   120000 /* 120 sec */#define IX_EAA_MAX_TIME_SLEEP    15000 /* 15 sec*/#define IX_EAA_MAX_MAC           8 /* 8 MAC address */#define IX_EAA_INVALID_PHY_ADDR  0xffffffff /*Invalid PHY Address*/#define IX_ETHAAL5APP_THREAD_STACK_SIZE 10240 /* Thread stack size *//* By default, the number of pre-configured ATM VCs. */#define IX_EAA_NUM_PRE_CONFIGURED_ATM_VCS 8 /* * Typedef declarations global to this file only. *//* Eth Mii Duplex Mode Enumeration */typedef enum {     IX_EAA_UNKNOWN_MODE,     IX_EAA_FULL_DUPLEX_MODE,     IX_EAA_HALF_DUPLEX_MODE } IxEAAEthDuplexMode;/************************* CONFIGURATION DATA ********************************//* All variables below are used during configuration   phase and are initialized to default values. User can use functions   described below to change configuration, however it must be done   before starting application - !!! NO DYNAMIC CONFIGURATION CHANGES ARE   ALLOWED IN CURRENT VERSION !!! */static IxEthAccMacAddr macAddr1 = { { 0x00, 0x11, 0x02, 0x03, 0x04, 0x05 } };static IxEthAccMacAddr macAddr2 = { { 0x00, 0x21, 0x02, 0x03, 0x04, 0x05 } };static int             atmNumPortsEnabled = IX_EAA_NUM_ATM_PORTS;/* Initialize phyAddresses to invalid addresses */static UINT32 phyAddresses[IX_EAA_NUM_ETH_PORTS];static BOOL routedProtocol = FALSE;IxAtmmVc             ixEAAAtmTxVc[IX_EAA_NUM_ATM_VCS];IxAtmmVc             ixEAAAtmRxVc[IX_EAA_NUM_ATM_VCS];/**********************************************************************//* This variable is set to 1, after application is fully initialized */static int      appState = 0;/* Phy mode for Utopia interface - this variable can be modified during   initialization process */#if IX_UTOPIAMODE == 1static  IxAtmmPhyMode phyMode = IX_ATMM_SPHY_MODE;#elsestatic  IxAtmmPhyMode phyMode = IX_ATMM_MPHY_MODE;#endif/* Keeps UTOPIA settings for each port */IxAtmmPortCfg   portCfgs[IX_EAA_NUM_ATM_PORTS];/* Keeps connection Id's for each Atm port (each Atm port has one VC opened) */IxAtmConnId     atmVcRxId[ IX_EAA_NUM_ATM_VCS ];IxAtmConnId     atmVcTxId[ IX_EAA_NUM_ATM_VCS ];/* Each Atm VC and each Ethernet port has separate pool of buffers    declared here. */static IX_OSAL_MBUF_POOL *mBufAtmPool[ IX_EAA_NUM_ATM_VCS ];static IX_OSAL_MBUF_POOL *mBufEthPool[ IX_EAA_NUM_ETH_PORTS ];/* Each VC (so each Utopia Phy) will be able to learn one Mac address */IxEthAccMacAddr atmSrcMacAddrDBase[ IX_EAA_NUM_ATM_VCS ];UINT8 atmMacAddrLookup[ IX_EAA_NUM_ATM_VCS ][2 * IX_IEEE803_MAC_ADDRESS_SIZE];UINT32 atmPortIdLookup[ IX_EAA_NUM_ATM_VCS ];/* Each port will be able to remember the last Mac address */IxEthAccMacAddr ethSrcMacAddrDBase[ IX_EAA_NUM_ETH_PORTS ];/* array used to decide if an extra cell is needed to build a    an AAL5 PDU trailer */int extraAtmCellNeeded[48] = {  1, 0, 0, 0 ,0, 0, 0, 0, 0, 0, 0, 0 ,0, 0, 0, 0, 0, 0, 0, 0 ,0, 0, 0, 0, 0, 0, 0, 0 ,0, 0, 0, 0, 0, 0, 0, 0 ,0, 0, 0, 0, 0, 1, 1, 1 ,1, 1, 1, 1};/* Flag to set the ShowTask's loop */BOOL ixEthAal5AppShowTaskLoopEnable = FALSE;/*************************** STATISTICS DATA *********************************//* The following variables are not used in normal usage. To use these variables* need to specify IX_DEBUG=1 */#ifndef NDEBUGunsigned int    ixEAANumAtmRxChainedBuffers;unsigned int    ixEAANumAtmRxMACDroppedBuffers;unsigned int    ixEAANumAtmRxDropBuffers;unsigned int    ixEAANumEthRxChainedBuffers;unsigned int    ixEAANumEthRxMACDroppedBuffers;unsigned int    ixEAANumEthRxDropBuffers;#endifunsigned int    ixEAANumAtmRxEthFramesForwarded;unsigned int    ixEAANumAtmRxPackets;unsigned int    ixEAANumEthRxEthFramesForwarded;unsigned int    ixEAANumEthRxFrames;  #ifndef __linux /* for vxWorks and WinCE */static IxOsalThread pollTask;#endif/* Eth Mii-MAC Monitoring Task */static IxOsalThread lineMonitorTask;static IxQMgrDispatcherFuncPtr dispatcherFunc ;#ifndef __linux /* for vxWorks and WinCE *//* IxQMgrDispatcher's sleep duration */static UINT32 dispatcherSleepDuration = 0;#endif  /*****************************************************************************//************************ FUNCTION DECLARATIONS ******************************/void ixEAAAtmBufferRecycle( IxAtmConnId vcId, IX_OSAL_MBUF * mbufPtr );void ixEAAAtmRxCallback(IxAtmLogicalPort port,			IxAtmdAccUserId userId,                        IxAtmdAccPduStatus status,                        IxAtmdAccClpStatus clp,                        IX_OSAL_MBUF * mbufPtr);void ixEAAAtmTxDoneCallback(IxAtmdAccUserId userId, IX_OSAL_MBUF * mbufPtr);void ixEAAEthBufferRecycle( IxEthAccPortId portId, IX_OSAL_MBUF * mbufPtr );void ixEAAEthRxCallback(UINT32 callbackTag, IX_OSAL_MBUF *buffer, IxEthAccPortId portId);void ixEAAEthTxDoneCallback(UINT32 callbackTag, IX_OSAL_MBUF *buffer);void ixEthAal5AppShowTask(void);void ixEAAAddMAC( int vc,                   UINT8 mac1, UINT8 mac2, UINT8 mac3,                    UINT8 mac4, UINT8 mac5, UINT8 mac6 );void ixEAAShowMAC(void);void ixEAABufferInit(IX_OSAL_MBUF *mbufPtr, UINT32 poolId);void ixEAAAtmRxVcFreeLowCallback(IxAtmdAccUserId userId);IX_STATUS ixEAAUtopiaInit( void );IX_STATUS ixEAAATMInit( void );IX_STATUS ixEAAVCInit( void );IX_STATUS ixEAAEthNpeInit(void);IX_STATUS ixEthInit(BOOL speed, BOOL duplex, BOOL autoneg);IX_STATUS ixEAAEthChannelInit( void );int ixEAAShow(void);int ixEAAMain( void );void ixEAAEthLinkStateMonitorLoop(void);IX_STATUS ixEAASetupVc(UINT32 numberOfVc, UINT32 numberOfPorts);#ifdef __vxworksvoid ixEAAQDispatcherSleepDurationSet(UINT32 timeInMS);#endif/*****************************************************************************//*>>>>>>>>>>>>>>>>>>>>>>>> CONFIGURATION FUNCTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<*//* * This function can be used to add MAC address to Atm data base and assign it   to particular port. Valid ports are 0-7 */void ixEAAAddMAC( int vc,                   UINT8 mac1, UINT8 mac2, UINT8 mac3,                    UINT8 mac4, UINT8 mac5, UINT8 mac6 ){    if( vc < 0 || vc >= IX_EAA_NUM_ATM_VCS )    {

⌨️ 快捷键说明

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