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

📄 ixatmdrxcfgif.c

📁 有关ARM开发板上的IXP400网络驱动程序的源码以。
💻 C
📖 第 1 页 / 共 2 页
字号:
/*** @file IxAtmdRxCfgIf.c* * @author Intel Corporation* @date 17 March 2002** @brief ATM RX configuration interface** This interface is used by IxAtmdAcc client to setup a RX channel** Design Notes:*    All function of this interface are protected by a lock* *  * @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 --*//** Sytem defined include files*//** Put the user defined include files required.*/#include "IxOsal.h"#include "IxAtmdAccCtrl.h"#include "IxAtmdDefines_p.h"#include "IxAtmdAssert_p.h"#include "IxAtmdUtil_p.h"#include "IxAtmdNpe_p.h"#include "IxAtmdPortMgmt_p.h"#include "IxAtmdRxCfgInfo_p.h"#include "IxAtmdRxCfgIf_p.h"/**** @struct IxAtmdAccRxStats** @brief Rx ststs** This structure is used to collect stats informations abour rx activity**/typedef struct{    /* rx control counters */    unsigned int connectCount;    unsigned int disconnectCount;    unsigned int connectDenied;    unsigned int disconnectDenied;    /* rx error counters */    unsigned int rxNotificationSetErrorCount;    unsigned int rxFreeThresholdSetErrorCount;} IxAtmdAccRxStats;static IxAtmdAccRxStats ixAtmdAccRxStats;/* ---------------------------------------------------------*  interface lock and initialisation protection*/static IxOsalMutex rxControlLock;static BOOL ixAtmdAccRxCfgInitDone = FALSE;#define IX_ATMDACC_RX_LOCK() (void)ixOsalMutexLock (&rxControlLock, IX_OSAL_WAIT_FOREVER)#define IX_ATMDACC_RX_UNLOCK() (void)ixOsalMutexUnlock (&rxControlLock)/* function prototype */PRIVATE IX_STATUSixAtmdAccRxVcConnectParamsValidate (IxAtmLogicalPort port,                                    unsigned int vpi,                                    unsigned int vci,                                    IxAtmdAccAalType aalServiceType,                                    IxAtmRxQueueId rxQueueId,                                    IxAtmdAccRxVcRxCallback rxCallback,                                    unsigned int minimumQueueSize,                                    IxAtmConnId * connIdPtr,                                    IxAtmNpeRxVcId * npeVcIdPtr );PRIVATE IX_STATUSixAtmdAccRxVcConnectPerform (IxAtmLogicalPort port,                             unsigned int vpi,                             unsigned int vci,                             IxAtmdAccAalType aalServiceType,                             IxAtmRxQueueId atmdRxQueueId,                             IxAtmdAccUserId userId,                             IxAtmdAccRxVcRxCallback rxCallback,                             unsigned int minimumQueueSize,                             IxAtmConnId * connIdPtr,                             IxAtmNpeRxVcId * npeVcIdPtr);/* ---------------------------------------------------------* Initialisations*/IX_STATUSixAtmdAccRxCfgIfInit (void){    IX_STATUS returnStatus;    if(ixAtmdAccRxCfgInitDone)    {        /* init already done, this is an error */        returnStatus = IX_FAIL;    }    else    {        ixAtmdAccRxCfgIfStatsReset ();        /* initialise dependant component */        returnStatus = ixAtmdAccRxCfgInfoInit ();        if (returnStatus == IX_SUCCESS)        {            /* initialise the internal lock */            returnStatus = ixOsalMutexInit (&rxControlLock);            /* map the return status */            if (returnStatus != IX_SUCCESS)            {                returnStatus = IX_FAIL;            }        } /* end of if(returnStatus) */    }    if (returnStatus == IX_SUCCESS)    {        /* mark initialisation as done */        ixAtmdAccRxCfgInitDone = TRUE;    }    return returnStatus;}/* Uninitialisation of Rx sub component */IX_STATUSixAtmdAccRxCfgIfUninit (void){    IX_STATUS returnStatus;    if (!ixAtmdAccRxCfgInitDone)    {        /* init not done, this is an error */        returnStatus = IX_FAIL;    }    else    {    /* destroy the internal lock */      returnStatus = ixOsalMutexDestroy (&rxControlLock);        if (IX_SUCCESS == returnStatus)        {          /* uninitialise dependant component */             returnStatus = ixAtmdAccRxCfgInfoUninit ();        } /* end of if(returnStatus) */    }    if (IX_SUCCESS == returnStatus)    {        /* mark uninitialisation as done */        ixAtmdAccRxCfgInitDone = FALSE;    }    return returnStatus;}/* ---------------------------------------------------------*  initialisation*/voidixAtmdAccRxCfgIfStatsReset (void){    /* initialise the stats counters */    ixOsalMemSet(&ixAtmdAccRxStats, 0, sizeof(ixAtmdAccRxStats));    /* initialise the stats of the dependant component */    ixAtmdAccRxCfgInfoStatsReset();}/* -------------------------------------------------*  validate input params for ixAtmdAccRxVcConnect*/PRIVATE IX_STATUSixAtmdAccRxVcConnectParamsValidate (IxAtmLogicalPort port,                                    unsigned int vpi,                                    unsigned int vci,                                    IxAtmdAccAalType aalServiceType,                                    IxAtmRxQueueId rxQueueId,                                    IxAtmdAccRxVcRxCallback rxCallback,                                    unsigned int minimumQueueSize,                                    IxAtmConnId * connIdPtr,                                    IxAtmNpeRxVcId * npeVcIdPtr ){    /* check the following :    * - value ranges    * - null callback pointers    * - vpi 0 / vci 0 cannot be used (idle cells)    * - if the minimum queue size requested is    *   not a default value, it should be    *   an acceptable value, i.e less than the biggest    *   size that the qmgr can handle    */    if ((vpi > IX_ATM_MAX_VPI)         || (vci > IX_ATM_MAX_VCI)         || (rxCallback == NULL)         || ((rxQueueId != IX_ATM_RX_A) &&             (rxQueueId != IX_ATM_RX_B))         || (connIdPtr == NULL)         || (npeVcIdPtr == NULL)         || ((minimumQueueSize != IX_ATMDACC_DEFAULT_REPLENISH_COUNT) &&         (minimumQueueSize > IX_ATMDACC_QMGR_MAX_QUEUE_SIZE)))    {        return IX_FAIL;    } /* end of if(port) */        /* perform sevice specific checks */    switch (aalServiceType)    {    case IX_ATMDACC_AAL5:    case IX_ATMDACC_AAL0_48:    case IX_ATMDACC_AAL0_52:        if ((port >= IX_UTOPIA_MAX_PORTS)            || (port < IX_UTOPIA_PORT_0)            ||((vpi == IX_ATMDACC_OAM_RX_VPI)            && (vci == IX_ATMDACC_OAM_RX_VCI)))        {            return IX_FAIL;        }        break;    case IX_ATMDACC_OAM:        if ((port != IX_ATMDACC_OAM_RX_PORT)            || (vpi != IX_ATMDACC_OAM_RX_VPI)            || (vci != IX_ATMDACC_OAM_RX_VCI))        {            return IX_FAIL;        }        break;    default:        return IX_FAIL;        break;    }    return IX_SUCCESS;}/* ---------------------------------------------------------*    do real function of rx connect*/PRIVATE IX_STATUSixAtmdAccRxVcConnectPerform (IxAtmLogicalPort port,                             unsigned int vpi,                             unsigned int vci,                             IxAtmdAccAalType aalServiceType,                             IxAtmRxQueueId atmdRxQueueId,                             IxAtmdAccUserId userId,                             IxAtmdAccRxVcRxCallback rxCallback,                             unsigned int minimumQueueSize,                             IxAtmConnId * connIdPtr,                             IxAtmNpeRxVcId * npeVcIdPtr){    IX_STATUS returnStatus = IX_SUCCESS;    /* check that the port has been configured and is UP */    if ((aalServiceType != IX_ATMDACC_OAM) && !(ixAtmdAccPortIsEnabled (port)))    {        returnStatus = IX_FAIL;    }    if (returnStatus == IX_SUCCESS)    {        if (ixAtmdAccRxCfgRxVcExists (port, vpi, vci))        {            returnStatus = IX_FAIL;        }    }    if (returnStatus == IX_SUCCESS)    {        /* get a free channel from the pool of available channels */        returnStatus = ixAtmdAccRxCfgChannelGet ( port, vpi, vci, aalServiceType, npeVcIdPtr, connIdPtr);    }    if (returnStatus == IX_SUCCESS)    {        /* get a rx free queue from the ppol of existing rx free queues */        returnStatus = ixAtmdAccRxCfgFreeQueueGet (aalServiceType, minimumQueueSize,            *npeVcIdPtr);    }    if (returnStatus == IX_SUCCESS)    {        /* all parameters are valid, resources are available        *  so we configure the channel        */        returnStatus = ixAtmdAccRxCfgChannelSet (*connIdPtr,            *npeVcIdPtr,            port,            vpi,            vci,            aalServiceType,            atmdRxQueueId,            userId,            rxCallback);    } /* end of if(returnStatus) */    return returnStatus;}/* ---------------------------------------------------------*    rx connect*/PUBLIC IX_STATUSixAtmdAccRxVcConnect (IxAtmLogicalPort port,                      unsigned int vpi,                      unsigned int vci,                      IxAtmdAccAalType aalServiceType,                      IxAtmRxQueueId rxQueueId,                      IxAtmdAccUserId userId,                      IxAtmdAccRxVcRxCallback rxCallback,                      unsigned int minimumQueueSize,                      IxAtmConnId * connIdPtr,                      IxAtmNpeRxVcId * npeVcIdPtr ){    IX_STATUS returnStatus;    /* we have not been initialised no point    *   in continuing    */    if(!ixAtmdAccRxCfgInitDone)    {        return IX_FAIL;    }    /* check the input params */    returnStatus = ixAtmdAccRxVcConnectParamsValidate (port,        vpi,        vci,        aalServiceType,        rxQueueId,        rxCallback,        minimumQueueSize,        connIdPtr,        npeVcIdPtr);    IX_ATMDACC_RX_LOCK ();    if(returnStatus == IX_SUCCESS)    {        returnStatus = ixAtmdAccRxVcConnectPerform (port,            vpi,            vci,

⌨️ 快捷键说明

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