📄 txc_envoy_mac_api.c
字号:
/*--------------------------------------------------------------------------*
FUNCTION: TXC_IfMAC_StatusRtrv
DESCRIPTION: This function retrieves and clears the ethernet port received RMON
statistic counters.
INPUTS: handle: Instance of the Envoy device from which to read the statistics.
port: The ethernet MAC port to retrieve the configuration of. For Envoy-CE2,
the range is from 0 to 15, corresponding to ethernet physical port
1 to 16. For Envoy-CE4, the range is 0 to 31, corresponding to
ethernet physical ports 1 to 32. The value 0xFFFF cannot be used
to simultaneously get the configuration of multiple ethernet ports.
macStatusDataPtr: a pointer to ENVOY_MAC_RX_STATISTICS_STRUCT.
RETURNS: TXC_NO_ERR or an appropriate specific error code.
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT
TXC_IfMAC_StatusRtrv (
TXC_U16BIT handle,
TXC_U16BIT port,
TXC_U32BIT *macStatusDataPtr)
{
TXC_U16BIT error;
/* check for input parameters */
error = ENVOY_RtrvMacStatusValid (handle, port);
/* process the data if no error */
if (error == TXC_NO_ERR)
{
#ifdef TXC_ENVOY_VIRTUAL_DEVICE_MODE
/* error = ENVOY_RtrvMacStatusVirtual (handle, port, macStatusDataPtr); */
#else
error = ENVOY_RtrvMacStatusReal (handle, port, macStatusDataPtr);
#endif
}
/* return the error code */
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: TXC_ENVOY_MacRmonCtrlSet
DESCRIPTION: This function sets control modes associated with RMON counters
INPUTS: handle: Instance of the Envoy device to configure.
port: The ethernet MAC port to configure. For Envoy-CE2, the range is from
0 to 15, corresponding to ethernet physical port 1 to 8. For Envoy-CE4,
the range is 0 to 31, corresponding to ethernet physical ports 1 to 32.
The value 0xFFFF is used to configure all ethernet ports of specified
terminal the same way.
macRmonCtrlDataPtr: a pointer to type ENVOY_MAC_RMON_CTRL_STRUCT
RETURNS: TXC_NO_ERR or an appropriate specific error code.
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT
TXC_ENVOY_MacRmonCtrlSet(
TXC_U16BIT handle,
ENVOY_MAC_RMON_CTRL_STRUCT *macRmonCtrlDataPtr)
{
TXC_U16BIT error;
/* check for input parameters */
if ((error = ENVOY_SetMacRmonCtrlValid (handle, macRmonCtrlDataPtr)) != TXC_NO_ERR)
return error; /* return the error code */
/* process the data if no error */
#ifdef TXC_ENVOY_VIRTUAL_DEVICE_MODE
return error;
#else
error = ENVOY_SetMacRmonCtrlReal(handle, macRmonCtrlDataPtr);
#endif
/* return the error code */
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: TXC_ENVOY_MacRmonCtrlGet
DESCRIPTION: This function gets control modes associated with RMON counters
INPUTS: handle: Instance of the Envoy device to configure.
port: The ethernet MAC port to configure. For Envoy-CE2, the range is from
0 to 15, corresponding to ethernet physical port 1 to 8. For Envoy-CE4,
the range is 0 to 31, corresponding to ethernet physical ports 1 to 32.
The value 0xFFFF is used to configure all ethernet ports of specified
terminal the same way.
macRmonCtrlDataPtr: a pointer to type ENVOY_MAC_RMON_CTRL_STRUCT
RETURNS: TXC_NO_ERR or an appropriate specific error code.
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT TXC_ENVOY_MacRmonCtrlGet(TXC_U16BIT handle,
ENVOY_MAC_RMON_CTRL_STRUCT *macRmonCtrlDataPtr)
{
TXC_U16BIT error;
/* check for input parameters */
if ((error = ENVOY_GetMacRmonCtrlValid (handle, macRmonCtrlDataPtr)) != TXC_NO_ERR)
return error; /* return the error code */
/* process the data if no error */
#ifdef TXC_ENVOY_VIRTUAL_DEVICE_MODE
return error;
#else
error = ENVOY_GetMacRmonCtrlReal(handle, macRmonCtrlDataPtr);
#endif
/* return the error code */
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: TXC_ENVOY_MacRxStatisticsRtrv
DESCRIPTION: This function retrieves and clears the ethernet port received RMON
statistic counters.
INPUTS: handle: Instance of the Envoy device from which to read the statistics.
port: The ethernet MAC port to retrieve the configuration of. For Envoy-CE2,
the range is from 0 to 15, corresponding to ethernet physical port
1 to 16. For Envoy-CE4, the range is 0 to 31, corresponding to
ethernet physical ports 1 to 32. The value 0xFFFF cannot be used
to simultaneously get the configuration of multiple ethernet ports.
macRxStatisticsDataPtr: a pointer to ENVOY_MAC_RX_STATISTICS_STRUCT.
RETURNS: TXC_NO_ERR or an appropriate specific error code.
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT TXC_ENVOY_MacRxStatisticsRtrv (TXC_U16BIT handle, TXC_U16BIT port,
ENVOY_MAC_RX_STATISTICS_STRUCT *macRxStatisticsDataPtr)
{
TXC_U16BIT error;
/* check for input parameters */
error = ENVOY_RtrvMacRxStatisticsValid (handle, port);
/* process the data if no error */
if (error == TXC_NO_ERR)
{
#ifdef TXC_ENVOY_VIRTUAL_DEVICE_MODE
error = ENVOY_RtrvMacRxStatisticsVirtual (handle, port, macRxStatisticsDataPtr);
#else
error = ENVOY_RtrvMacRxStatisticsReal (handle, port, macRxStatisticsDataPtr);
#endif
}
/* return the error code */
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: TXC_ENVOY_MacTxStatisticsRtrv
DESCRIPTION: This function retrieves and clears the ethernet port transmit RMON
statistic counters.
INPUTS: handle: Instance of the Envoy device from which to read the statistics.
port: The ethernet MAC port to retrieve the configuration of. For Envoy-CE2,
the range is from 0 to 15, corresponding to ethernet physical port
1 to 16. For Envoy-CE4, the range is 0 to 31, corresponding to
ethernet physical ports 1 to 32. The value 0xFFFF cannot be used
to simultaneously get the configuration of multiple ethernet ports.
macTxStatisticsDataPtr: a pointer to type ENVOY_MAC_TX_STATISTICS_STRUCT.
RETURNS: TXC_NO_ERR or an appropriate specific error code.
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT TXC_ENVOY_MacTxStatisticsRtrv (TXC_U16BIT handle, TXC_U16BIT port,
ENVOY_MAC_TX_STATISTICS_STRUCT *macTxStatisticsDataPtr)
{
TXC_U16BIT error;
/* check for input parameters */
error = ENVOY_RtrvMacTxStatisticsValid (handle, port);
/* process the data if no error */
if (error == TXC_NO_ERR)
{
#ifdef TXC_ENVOY_VIRTUAL_DEVICE_MODE
error = ENVOY_RtrvMacTxStatisticsVirtual (handle, port, macTxStatisticsDataPtr);
#else
error = ENVOY_RtrvMacTxStatisticsReal (handle, port, macTxStatisticsDataPtr);
#endif
}
/* return the error code */
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: TXC_ENVOY_RegPoke
DESCRIPTION: This function sets pokes a 32-bit register
INPUTS: handle: Instance of the EtherMap-X device to configure.
offset: register offset, in 32-bit word unit
regData: 32-bit reg data
RETURNS: TXC_NO_ERR or an appropriate specific error code.
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT TXC_ENVOY_RegPoke
(TXC_U16BIT handle, TXC_U32BIT offset, TXC_U32BIT regData)
{
TXC_U16BIT error;
TXC_REG_32 *baseAddr, *regAddr;
/* test if the device is created */
error = ENVOY_DbVerifyHandle (handle);
if (error != TXC_NO_ERR)
return error;
/* determine the device base address and add offset */
baseAddr = (TXC_REG_32 *) ENVOY_DbGetDeviceAddr (handle);
regAddr = baseAddr + (offset >> 2); /* calculate 32-Bit register address */
#ifdef TXC_ENVOY_VIRTUAL_DEVICE_MODE
virRegData = regData;
return TXC_NO_ERR;
#else /* NOT TXC_ENVOY_VIRTUAL_DEVICE_MODE */
write32BitReg ((TXC_REG_32 *)regAddr, regData); /* pass 32-bit byte address */
return TXC_NO_ERR;
#endif
}
/*--------------------------------------------------------------------------*
FUNCTION: TXC_ENVOY_RegPeek
DESCRIPTION: This function peeks a 32-bit register
INPUTS: handle: Instance of the EtherMap-X device to configure.
offset: register offset in 32-bit word unit
regDataPtr: where to put the 32-bit reg data read
RETURNS: TXC_NO_ERR or an appropriate specific error code.
REVISION HISTORY:
Rev Date Author Description
----- ------- ------------ -----------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT TXC_ENVOY_RegPeek
(TXC_U16BIT handle, TXC_U32BIT offset, TXC_U32BIT *regDataPtr)
{
TXC_U16BIT error;
TXC_REG_32 *baseAddr, *regAddr, regData;
/* test if the device is created */
error = ENVOY_DbVerifyHandle (handle);
if (error != TXC_NO_ERR)
return error;
/* determine the device base address and add offset */
baseAddr = (TXC_REG_32 *) ENVOY_DbGetDeviceAddr (handle);
/* regAddr = baseAddr + offset; */ /* calculate 32-Bit register address */
regAddr = baseAddr + (offset >> 2); /* calculate 32-Bit register address */
#ifdef TXC_ENVOY_VIRTUAL_DEVICE_MODE
regData = virRegData;
#else /* NOT TXC_ENVOY_VIRTUAL_DEVICE_MODE */
/* read from register */
regData = read32BitReg ((TXC_REG_32 *)regAddr); /* pass 32-bit byte address */
#endif
/* return to user buffer */
*regDataPtr = regData;
return TXC_NO_ERR;
}
/****************************************************************************
** End of Module **
****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -