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

📄 txc_envoy_mac_valid.c

📁 TranSwitch Envoy CE2 & Envoy CE4 设备驱动及编程指南
💻 C
📖 第 1 页 / 共 3 页
字号:
/*--------------------------------------------------------------------------

  *******                           ****
     *     *****     **    *    *  *       *    *   *  *****   ****   *    *
     *     *    *   *  *   **   *  *       *    *   *    *    *    *  *    *
     *     *    *  *    *  * *  *   ****   *    *   *    *    *       ******
     *     *****   ******  *  * *       *  * ** *   *    *    *       *    *
     *     *   *   *    *  *   **  *    *  **  **   *    *    *    *  *    *
     *     *    *  *    *  *    *   ****   *    *   *    *     ****   *    *

                        Proprietary and Confidential 

    This program is made available only to customers and prospective customers 
of TranSwitch Corporation under license and may be used only with TranSwitch 
semi-conductor products.

                      Copyright(c) 2004 TranSwitch Inc.

 --------------------------------------------------------------------------

             *******  **      **  **        **   ********   **      **
             *******  ***     **  **        **  **********  **      **
             **       ** *    **  **        **  **      **   **    **
             *****    **  *   **   **      **   **      **     *  *
             *****    **   *  **    **    **    **      **      **
             **       **    * **     **  **     **      **      **
             *******  **     ***      ****      **********      **
             *******  **      **       **        ********       **

 --------------------------------------------------------------------------
                           TranSwitch Envoy-CE2/CE4
                                Device Driver
 --------------------------------------------------------------------------
                                                                             
   Workfile:  txc_envoy_mac_valid.c                                             
                                                                             
   Description:  Validation functions for MAC API function calls.                                          
                                                                             
  -------------------------------------------------------------------------- 
                               Revision History                              
  -------------------------------------------------------------------------- 
   Rev #     Date           Author                Description               
   -----    -------      -----------              -----------               
   0.5.0    6/03/04      F. Giannella         Initial release (beta)

 *--------------------------------------------------------------------------*/



/****************************************************************************
 **                             Include Files                              **
 ****************************************************************************/

#include "txc_envoy_api.h"
#include "txc_envoy_mac_support.h"
#include "txc_envoy_database.h"



/****************************************************************************
 **                            Static Functions                            **
 ****************************************************************************/


static TXC_U16BIT ENVOY_VerifySetMacHandleAndPort (TXC_U16BIT, TXC_U16BIT);
static TXC_U16BIT ENVOY_VerifyGetMacHandleAndPort (TXC_U16BIT, TXC_U16BIT);



/****************************************************************************
 **                        Static/Global Variables                         **
 ****************************************************************************/



/****************************************************************************
 **                                  Code                                  **
 ****************************************************************************/


/*--------------------------------------------------------------------------*
                                                                             
   FUNCTION:  ENVOY_MacResetValid                                              
                                                                             
   DESCRIPTION: This function validates the ENVOYMacReset                                         
                                                                             
   INPUTS:  Same as ENVOY_MacReset                                   
  
   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in      
             appendix.                                                                 
                                                                             
   CAVEATS:  None.                                                           
                                                                             
   REVISION HISTORY:

    Rev       Date          Author               Description
   -----    -------      ------------         -----------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
 *--------------------------------------------------------------------------*/

TXC_U16BIT ENVOY_MacResetValid (TXC_U16BIT handle,                                TXC_U16BIT port,                                 TXC_IfMAC_RESET_STRUCT *macResetPtr                               ){
    TXC_U16BIT error;

    /* first, check the handle & port */
    error = ENVOY_VerifySetMacHandleAndPort (handle, port);

    /* now range check the data */
    if (error == TXC_NO_ERR)
    {
        /* check the reset type */
        if (macResetPtr->resetMode >= TXC_IfMAC_END_OF_RESET_ENUM)
        {
            error = TXC_INVALID_PARM_ERR;
            macResetPtr->resetMode = TXC_IfMAC_RESET_ENUM_ERR;
        }

    }
    /* return the error code */
    return error;
}




/*--------------------------------------------------------------------------*

   FUNCTION:  ENVOY_SetMacIfaceValid

   DESCRIPTION: This function validates the ENVOYSetMacIface

   INPUTS:  Same as ENVOY_SetMacIface

   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in
   appendix.

   CAVEATS:  The hardware default on the interface comes up in GPSI mode,
   which is not recommended for use.

   REVISION HISTORY:

    Rev       Date          Author               Description
   -----    -------      ------------         -----------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
*--------------------------------------------------------------------------*/

TXC_U16BIT ENVOY_SetMacIfaceValid(TXC_U16BIT handle, TXC_U16BIT port, 
           TXC_IfMAC_CONFIG_STRUCT *macIfaceDataPtr)
{
    TXC_U16BIT error;

    /* first, check the handle & port */
    error = ENVOY_VerifySetMacHandleAndPort (handle, port);

    /* now range check the data */

    if (error == TXC_NO_ERR)
    {
        if ((macIfaceDataPtr->fullDuplexEnable != TXC_FALSE) &&
            (macIfaceDataPtr->fullDuplexEnable != TXC_TRUE))
        {
            error = TXC_INVALID_PARM_ERR;
            macIfaceDataPtr->fullDuplexEnable = TXC_BOOL_INVALID;
        }

        if ((macIfaceDataPtr->maxFrameLen > ENVOY_MAX_FRAME_SIZE) ||
            (macIfaceDataPtr->maxFrameLen < ENVOY_MIN_FRAME_SIZE))
        {
            error = TXC_INVALID_PARM_ERR;
            macIfaceDataPtr->maxFrameLen = TXC_U16_INVALID;
        }

        if ((macIfaceDataPtr->ingressFrameLenCheckEnable != TXC_FALSE) &&
            (macIfaceDataPtr->ingressFrameLenCheckEnable != TXC_TRUE))
        {
            error = TXC_INVALID_PARM_ERR;
            macIfaceDataPtr->ingressFrameLenCheckEnable = TXC_BOOL_INVALID;
        }

        if ((macIfaceDataPtr->hugeFrameEnable != TXC_FALSE) &&
            (macIfaceDataPtr->hugeFrameEnable != TXC_TRUE))
        {
            error = TXC_INVALID_PARM_ERR;
            macIfaceDataPtr->hugeFrameEnable = TXC_BOOL_INVALID;
        }

        /* check the back-to-back packet Inter-Packet Gap value */
        if (macIfaceDataPtr->b2bIPG > ENVOY_MAC_MAX_IPG_SIZE)
        {
            error = TXC_INVALID_PARM_ERR;
            macIfaceDataPtr->b2bIPG = TXC_U16_INVALID;
        }

        /* check the minimum Inter-frame gap */
        if (macIfaceDataPtr->minIFG > ENVOY_MAC_MAX_IFG_SIZE)
        {
            error = TXC_INVALID_PARM_ERR;
            macIfaceDataPtr->minIFG = TXC_U16_INVALID;
        }

        /* check the preamble length */
        if (macIfaceDataPtr->preambleLen > ENVOY_MAX_PREAMBLE_LEN)
        {
            error = TXC_INVALID_PARM_ERR;
            macIfaceDataPtr->preambleLen = TXC_U16_INVALID;
        }

        if (macIfaceDataPtr->egressPadAndCrcAppendMode >= TXC_IfMAC_END_OF_PAD_CRC_ENUM)
        {
            error = TXC_INVALID_PARM_ERR;
            macIfaceDataPtr->egressPadAndCrcAppendMode = TXC_IfMAC_PAD_CRC_ENUM_ERR;
        }
    }
    /* return the error code */
    return error;
}




/*--------------------------------------------------------------------------*

   FUNCTION:  ENVOY_GetMacIfaceValid

   DESCRIPTION: This function validates the ENVOY_MacIfaceGet

   INPUTS:  Same as ENVOY_MacIfaceGet
  
   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in appendix.

   CAVEATS:  None.

   REVISION HISTORY:

    Rev       Date          Author               Description
   -----    -------      ------------         -----------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
 *--------------------------------------------------------------------------*/
TXC_U16BIT ENVOY_GetMacIfaceValid(TXC_U16BIT handle,                                   TXC_U16BIT port){
    TXC_U16BIT error;
    
    /* only check the handle & port */
    error = ENVOY_VerifyGetMacHandleAndPort (handle, port);

    /* return the error code */
    return error;
}




/*--------------------------------------------------------------------------*

   FUNCTION:  ENVOY_SetMacOperationalStateValid

   DESCRIPTION: This function validates the ENVOYSetMacIface

   INPUTS:  Same as TXC_IfMAC_OperationalStateSet

   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in
   appendix.

   CAVEATS:  The hardware default on the interface comes up in GPSI mode,
   which is not recommended for use.

   REVISION HISTORY:

    Rev       Date          Author               Description
   -----    -------      ------------         -----------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
 *--------------------------------------------------------------------------*/

TXC_U16BIT ENVOY_SetMacOperationalStateValid (TXC_U16BIT handle, TXC_U16BIT port, 
             TXC_IfMAC_OPERATIONAL_STATE_STRUCT *macOperationalStateDataPtr)
{
    TXC_U16BIT error;

    /* first, check the handle & port */
    error = ENVOY_VerifySetMacHandleAndPort (handle, port);

    /* now range check the data */
    if (error == TXC_NO_ERR)
    {
        if (macOperationalStateDataPtr->macTransferEnableMode >= TXC_IfMAC_END_OF_ENABLE_MODE_ENUM)
        {
            error = TXC_INVALID_PARM_ERR;
            macOperationalStateDataPtr->macTransferEnableMode = TXC_IfMAC_ENABLE_MODE_ENUM_ERR;
        }                                                   
    }

    /* return the error code */
    return error;
}




/*--------------------------------------------------------------------------*

   FUNCTION:  ENVOY_GetMacOperationalStateValid

   DESCRIPTION: This function validates the ENVOYGetMacTrafficCtrl

   INPUTS:  Same as ENVOY_GetMacTrafficCtrl
  
   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in appendix.

   CAVEATS:  None.

   REVISION HISTORY:

   REVISION HISTORY:

    Rev       Date          Author               Description
   -----    -------      ------------         -----------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)

⌨️ 快捷键说明

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