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

📄 atmoc3cpmain.c

📁 摩托罗拉Motolola公司网络处理器C3的示范代码.实现了ATM的AAL2层交换功能.想了解网络处理器的可以
💻 C
字号:
/* *  Copyright (c) 1998, 1999, 2000, 2001, 2002 C-Port Corporation, a Motorola Company *  All Rights Reserved * *  The information contained in this file is C-Port Corporation confidential and proprietary. *  Any reproduction, use or disclosure, in whole or in part, of this *  program, including any attempt to obtain a human-readable version of this *  program, without the express, prior written consent of C-Port *  Corporation or Motorola Incorporated is strictly prohibited. */#include <dcpKernelSvcs.h>#include <dcpBufferSvcs.h>#include <dcpPduSvcs.h>#include <dcpTableSvcs.h>#include <dcpQueueSvcs.h>#include <atm.h>#include <atmIf.h>#include <atmCellDesc.h>#include <atmStatus.h>#include <atmPrivate.h>#include <aal2.h>#include "sonetMon.h"#include "sonetMonCpIf.h"#include <qos.h>#include <qosIf.h>/* *  Globals for thread support */KsContext atmRxNextContext;KsContext atmTxNextContext;KsContext atmQosMainContext;KsContext atmQoSIngressContext;QsMessage ALIGNED64 cpInitDescStorage;#define ATMQOS_MAINTHREAD_STACKSIZE          512 #define ATM_RX_THREAD_STACK_SIZE             192 #define ATM_TX_THREAD_STACK_SIZE             192 #define ATMQOS_INGRESSTHREAD_STACKSIZE       512 TsTableId MY_TABLE_ID; TsTableId MY_QOS_TABLE_ID; TsTableId TABLE_ID_EGRESS;int32u atmPortNum;/* *  Vc Control Block lookup tag */int viTag = 0;BsPoolId poolId;TsEntry sdpEntry = {0, 32, NULL, REQ_IDX(0), 0};/* * Global variables for QoS CPs. */QsQueueId inputQosCpQ[NUM_ATM_TRAFFIC_CLASS]; /* Input Qs for the QoSCp */QsQueueId startCbrQueue;QsQueueId startRtVbrQueue;QsQueueId startNrtVbrQueue;int32u    timeElapsedCbrRtVbr  = 0;int32u    timeElapsedNrtVbr    = 0;int32u    numCellTimeElapsed   = 0;/* Index to the input Qs processed by PRR Scheduler */QsQueueId shaperQptr[NUM_ATM_TRAFFIC_CLASS];QsQueueId atmTxQueue;         /* QId of the AtmTx */QsQueueId atmBaseQueue;       /* Base Q for the ATMCP */QsQueueId atmQosQueue;        /* Base Q for the QoSCP */TsTableId tableId;            /* Switching Table Id *//* *  Main routine */int DCPmain (){    QsQueueId     baseQueueId;    int32u        cpId;    int32u        numQs;    volatile      int8u* rxBitCtl;    KsStatus       status;    /*  Initialize all of the system services */    ksInitialize(ATMQOS_MAINTHREAD_STACKSIZE);       /* DCP kernel services */    bsInitialize();                                 /* DCP buffer services */    pduInitialize ();                               /* DCP PDU services */    tsTableInitialize();                            /* DCP Lookup services */    qsInitialize(0);                                /* DCP Queue services  */    ksEventDeregisterInterrupt(ksEventIdQmuError);    /*     * Get the baseQ id for this CP.     */    cpId = ksCpGetId();    qsQueueGet(ksProcIdCreate(ProcCP,0,cpId), &baseQueueId, &numQs);    /*     * Get the messages sent by the XP from the ATM or QoS Cp's baseQ.     * The XP sends the Switching Table Id and the buffer pool Id for      * ATM CPs.     * The XP sends the Switching Table Id and the QId of the atmTx     * queue for QOS CPs.     */    while(!qsQueueGetLength(baseQueueId))    {#ifdef AAL_PROTO_TEST        ksPrintf("Queue length is 0");#endif    }    qsMessageReceiveStart(baseQueueId, &cpInitDescStorage);    while(!qsMessageReceiveComplete(baseQueueId, &cpInitDescStorage));    if (ATM_CP(cpId))    {        AtmAal2CpInitDesc *atmCpInitDesc;        /* Variables for XP and SONET queues*/        QsQueueId      xpBaseQ;        QsQueueId      sonetMonitorQ;        /* Variables for SONET initialization */        PsSonetType    sonetRate;        sonetRate = psSonetTypeOC3c;        atmBaseQueue = baseQueueId;        qsQueueGet(XPprocID, &xpBaseQ, &numQs);        sonetMonitorQ = xpBaseQ + 1;        atmCpInitDesc = (AtmAal2CpInitDesc*)                 qsMessageGetData((QsMessage*)&cpInitDescStorage);        /*         * Get PoolId information from the         * AtmCpInitDesc.         */        poolId = atmCpInitDesc->poolId;        bsPoolInitialize(poolId);        MY_TABLE_ID    = TS_TABLEID_INIT(atmCpInitDesc->tableId, 4,                                           TS_TYPE_COMPLEX);        atmInitialize();        tsTableInitRequest(MY_TABLE_ID, &sdpEntry);          #ifndef SIM        ksPrintf("ATM stats location 0x%x", &atmStatsBuffer);#endif        atmPortNum = atmCpInitDesc->atmPortNum;        status = ksContextCreate(ATM_RX_THREAD_STACK_SIZE, atmRx, &atmTxNextContext);        if (status != ksStatusSuccess) {            ksPrintf(" ATM Rx Context not Created : %d",status);        }        status = ksContextCreate(ATM_TX_THREAD_STACK_SIZE, atmTx, &atmRxNextContext);        if (status != ksStatusSuccess) {            ksPrintf(" ATM Tx Context not Created : %d",status);        }        sonetMonitorInitialize(sonetMonitorQ,             psSonetModeNorthAmerica,            psSonetPathLabelAtm, sonetRate);        /* Let XP know this is enabled */        rxBitCtl = (volatile int8u*)ksSdpProcControlGet(                               ksProcIdGet(), ksRxBit);        rxBitCtl[1] = 0x1;        /* Switch into receive context */        ksContextSwitch(atmTxNextContext);    }    else if (QOS_CP(cpId))    {        QosCpInitDesc *qosCpInitDesc;        atmQosQueue = baseQueueId;        qosCpInitDesc = (QosCpInitDesc *)qsMessageGetData((QsMessage *)                            &cpInitDescStorage);        tableId    = TS_TABLEID_INIT(qosCpInitDesc->tableId, 4,                                           TS_TYPE_COMPLEX);        atmTxQueue = qosCpInitDesc->atmTxQueue;        /*         * Initialise all the input queues for the QoSCp.         */           inputQosCpQ[CBR]    = NUM_SHAPER_QUEUES + CBR;        inputQosCpQ[RTVBR]  = NUM_SHAPER_QUEUES + RTVBR;        inputQosCpQ[NRTVBR] = NUM_SHAPER_QUEUES + NRTVBR;        inputQosCpQ[UBR]    = NUM_SHAPER_QUEUES + UBR;           startCbrQueue    = atmQosQueue + START_CBR_QUEUE;        startRtVbrQueue  = atmQosQueue + START_RTVBR_QUEUE;        startNrtVbrQueue = atmQosQueue + START_NRTVBR_QUEUE;           /*         * Initialize the Qarray for the current set of Qs services by the         * Egress (PRR Scheduler). Offset for CBR, rt/nrt VBR Qs are set as         * zero.         */           shaperQptr[CBR]    = 0;        shaperQptr[RTVBR]  = 0;        shaperQptr[NRTVBR] = 0;        shaperQptr[UBR]    = UBR;           /*         * Start the Ingress Context.         */        status = ksContextCreate(ATMQOS_INGRESSTHREAD_STACKSIZE, atmQosIngress,                        &atmQoSIngressContext);        if (status != ksStatusSuccess) {            ksPrintf(" ATM Qos Context not Created : %d",status);        }           /* Switch into receive context */        ksContextSwitch(atmQoSIngressContext);    }    ksContextExit();    while (1) ; }

⌨️ 快捷键说明

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