📄 txc_envoy_pkt_ctrl_real.c
字号:
/*--------------------------------------------------------------------------
******* ****
* ***** ** * * * * * * ***** **** * *
* * * * * ** * * * * * * * * * *
* * * * * * * * **** * * * * * ******
* ***** ****** * * * * * ** * * * * * *
* * * * * * ** * * ** ** * * * * * *
* * * * * * * **** * * * * **** * *
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_pkt_ctrl_real.c
Description: Physical layer implementation for the Packet control functions.
--------------------------------------------------------------------------
Revision History
--------------------------------------------------------------------------
Rev # Date Author Description
----- ------- ------------ ----------------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
/****************************************************************************
** Include Files **
****************************************************************************/
#include "txc_envoy_api.h"
/* do nothing if this driver is in virtual mode */
#ifndef TXC_ENVOY_VIRTUAL_DEVICE_MODE
#include "txc_envoy_pkt_ctrl_support.h"
#include "txc_envoy_database.h"
#include "txc_hw_platform.h"
#include "txc_envoy_mem_map.h"
#include <string.h>
/****************************************************************************
** Static Functions **
****************************************************************************/
/****************************************************************************
** Static/Global Variables **
****************************************************************************/
static void GetPktCtrlPortRange(TXC_U16BIT handle, TXC_U16BIT port,
TXC_U16BIT * start, TXC_U16BIT * end, TXC_U16BIT * inc);
/*--------------------------------------------------------------------------*
FUNCTION: GetPktCtrlPortRange
DESCRIPTION: This local function determines the range of ports to process
based on device type. For Envoy-CE2, only ports 0 and 8 can
be programmed for GMII. For Envoy-CE4 only ports 0, 8, 16 and
24 can be programmed for GMII. FG - to do : tighten the range.
INPUTS: handle, port
RETURNS: start port, end port and increment.
CAVEATS: None.
REVISION HISTORY:
Rev # Date Author Description
----- ------- ------------ ----------------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
static void GetPktCtrlPortRange(TXC_U16BIT handle, TXC_U16BIT port,
TXC_U16BIT * start, TXC_U16BIT * end, TXC_U16BIT * inc)
{
TXC_U16BIT deviceType;
/* First, get the device type. */
deviceType = ENVOY_DbGetDeviceType (handle);
if ((deviceType != ENVOY_CE2) && (deviceType != ENVOY_CE4) )
return;
/* determine if one MAC port is being accessed */
if (port == ENVOY_MAC_ALL_PORTS)
{
if (deviceType == ENVOY_CE2)
{
*start = 0;
*end = ENVOY_CE2_MAX_MAC_PORTS;
*inc = 1;
}
else /* that is, deviceType == ENVOY_CE4 */
{
*start = 0;
*end = ENVOY_CE4_MAX_MAC_PORTS;
*inc = 1;
}
}
else
{
*start = port;
*end = port + 1;
*inc = 1;
}
}
/****************************************************************************
** Code **
****************************************************************************/
/* ======================================================================== */
/* PACKET CONTROL FUNCTIONS */
/************************************************************************************/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/************************************************************************************
FUNCTION: ENVOY_SetIngressPacketCtrlReal
DESCRIPTION: This function actually processess the TXC_ENVOY_IngressPacketCtrlSet
API function.
INPUTS: Same as TXC_ENVOY_IngressPacketCtrlSet
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_SetIngressPacketCtrlReal (TXC_U16BIT handle, TXC_U16BIT port,
ENVOY_INGRESS_PKT_CTRL_STRUCT *ingressPktCtrlDataPtr)
{
TXC_U16BIT error = TXC_NO_ERR;
TXC_BATCH_REG_ACCESS_32BIT_STRUCT batchData;
TXC_REG_ACCESS_32BIT_STRUCT regData[1];
TXC_REG_32 *baseAddr;
TXC_REG_32 *portAddr;
TXC_U16BIT portIdx;
TXC_U16BIT endPort;
TXC_U16BIT startPort;
TXC_U16BIT portInc;
ENVOY_MAC_PKT_CTRL_STRUCT *macPktCtrlRegPtr;
/* First, fill the batch platform header. This function requires 4
registers to be written */
/* This function requires 5 registers to be written */
batchData.regDataPtr = ®Data[0];
batchData.writeVerifyFlag = TXC_WRITE_VERIFY_FLAG;
batchData.semId = ENVOY_DbGetSemId();
batchData.regCount = 1;
memset ( (char *)regData, 0, sizeof(regData) );
/* determine if one MAC port is being configured or all ports */
GetPktCtrlPortRange(handle, port, &startPort, &endPort, &portInc);
/* determine the base address of the device */
baseAddr = (TXC_REG_32 *) ENVOY_DbGetDeviceAddr (handle);
/* Setup the data and masks for Mac Address */
regData[0].data = ingressPktCtrlDataPtr->ingressDiscardErroredFramesEnable << 27;
regData[0].data |= ingressPktCtrlDataPtr->ingressDiscardTruncatedFramesEnable << 24;
regData[0].data |= ingressPktCtrlDataPtr->ingressDiscardLengthMismatchEnable << 25;
regData[0].data |= ingressPktCtrlDataPtr->ingressDiscardCrcMismatchEnable << 26;
regData[0].data |= ingressPktCtrlDataPtr->ingressDiscardAddressMismatchEnable << 29;
regData[0].data |= ingressPktCtrlDataPtr->ingressCrcRemoveEnable << 22;
regData[0].data |= ingressPktCtrlDataPtr->ingressPauseFrameDiscardEnable << 28;
regData[0].data |= ingressPktCtrlDataPtr->ingressPrependEnable;
regData[0].mask = 0x3F400001;
/* loop thru all ports setting up the MAC interface parameters */
for (portIdx = startPort; portIdx < endPort; )
{
portAddr = baseAddr + macPktCtrlOffset[portIdx];
macPktCtrlRegPtr = (ENVOY_MAC_PKT_CTRL_STRUCT *) portAddr;
/* Setup the addresses to write the MAC interface config */
regData[0].addr = (TXC_REG_32 *) &(macPktCtrlRegPtr->frameCtrlReg);
error = TXC_BatchReg32BitWrite (&batchData);
if (error != TXC_NO_ERR)
return(error);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -