realtek-doc/sources/rtk-gp3000/include/dal/ca8277b/dal_ca8277b_rate.h
2025-12-04 22:26:46 +05:00

524 lines
No EOL
15 KiB
C
Executable file

/*
* Copyright (C) 2012 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision: 39101 $
* $Date: 2013-05-03 17:35:27 +0800 (週五, 03 五月 2013) $
*
* Purpose : Definition of Port Bandwidth Control and Storm Control API
*
* Feature : The file includes the following modules and sub-modules
* (1) Configuration of Ingress Port Bandwidth Control [Ingress Rate Limit]
* (2) Configuration of Egress Port Bandwidth Control [Egress Rate Limit]
* (3) Configuration of Storm Control
* (3) Configuration of meter
*
*/
#ifndef __DAL_CA8277B_RATE_H__
#define __DAL_CA8277B_RATE_H__
/*
* Include Files
*/
/*
* Symbol Definition
*/
/*
* Data Declaration
*/
/*
* Function Declaration
*/
/* Module Name : Rate */
/* Sub-module Name: Configuration of egress port bandwidth control */
/* Function Name:
* dal_ca8277b_rate_init
* Description:
* Initial the rate module.
* Input:
* None.
* Output:
* None.
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* None.
*/
extern int32
dal_ca8277b_rate_init(void);
/* Function Name:
* dal_ca8277b_rate_portIgrBandwidthCtrlRate_get
* Description:
* Get the ingress bandwidth control rate.
* Input:
* port - port id
* Output:
* pRate - ingress bandwidth control rate
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - Invalid port id
* RT_ERR_NULL_POINTER - NULL pointer
* Note:
* (1) The rate unit is 1 kbps and the range is from 8k to 1048568k.
* (2) The granularity of rate is 8 kbps
*/
extern int32
dal_ca8277b_rate_portIgrBandwidthCtrlRate_get(rtk_port_t port, uint32 *pRate);
/* Function Name:
* dal_ca8277b_rate_portIgrBandwidthCtrlRate_set
* Description:
* Set the ingress bandwidth control rate.
* Input:
* port - port id
* rate - ingress bandwidth control rate
* Output:
* None.
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - Invalid port id
* RT_ERR_RATE - Invalid input rate
* Note:
* (1) The rate unit is 1 kbps and the range is from 8k to 1048568k.
* (2) The granularity of rate is 8 kbps
*/
extern int32
dal_ca8277b_rate_portIgrBandwidthCtrlRate_set(rtk_port_t port, uint32 rate);
/* Function Name:
* dal_ca8277b_rate_portEgrBandwidthCtrlRate_get
* Description:
* Get the egress bandwidth control rate.
* Input:
* port - port id
* Output:
* pRate - egress bandwidth control rate
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - Invalid port id
* RT_ERR_NULL_POINTER - NULL pointer
* Note:
* (1) The rate unit is 1 kbps and the range is from 1k to 1048568k.
* (2) The granularity of rate is 1 kbps
*/
extern int32
dal_ca8277b_rate_portEgrBandwidthCtrlRate_get(rtk_port_t port, uint32 *pRate);
/* Function Name:
* dal_ca8277b_rate_portEgrBandwidthCtrlRate_set
* Description:
* Set the egress bandwidth control rate.
* Input:
* port - port id
* rate - egress bandwidth control rate
* Output:
* None.
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - Invalid port id
* RT_ERR_RATE - Invalid input rate
* Note:
* (1) The rate unit is 1 kbps and the range is from 1k to 1048568k.
* (2) The granularity of rate is 1 kbps
*/
extern int32
dal_ca8277b_rate_portEgrBandwidthCtrlRate_set(rtk_port_t port, uint32 rate);
/* Function Name:
* dal_ca8277b_rate_egrQueueBwCtrlEnable_get
* Description:
* Get enable status of egress bandwidth control on specified queue.
* Input:
* port - port id
* queue - queue id
* Output:
* pEnable - Pointer to enable status of egress queue bandwidth control
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_QUEUE_ID - invalid queue id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_ca8277b_rate_egrQueueBwCtrlEnable_get(
rtk_port_t port,
rtk_qid_t queue,
rtk_enable_t *pEnable);
/* Function Name:
* dal_ca8277b_rate_egrQueueBwCtrlEnable_set
* Description:
* Set enable status of egress bandwidth control on specified queue.
* Input:
* port - port id
* queue - queue id
* enable - enable status of egress queue bandwidth control
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_QUEUE_ID - invalid queue id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_ca8277b_rate_egrQueueBwCtrlEnable_set(
rtk_port_t port,
rtk_qid_t queue,
rtk_enable_t enable);
/* Function Name:
* dal_ca8277b_rate_egrQueueBwCtrlMeterIdx_get
* Description:
* Get rate of egress bandwidth control on specified queue.
* Input:
* port - port id
* queue - queue id
* Output:
* pMeterIndex - meter index
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_QUEUE_ID - invalid queue id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The actual rate is "rate * chip granularity".
* The unit of granularity in Apollo is 8Kbps.
*/
extern int32
dal_ca8277b_rate_egrQueueBwCtrlMeterIdx_get(
rtk_port_t port,
rtk_qid_t queue,
uint32 *pMeterIndex);
/* Function Name:
* dal_ca8277b_rate_egrQueueBwCtrlMeterIdx_set
* Description:
* Set rate of egress bandwidth control on specified queue.
* Input:
* port - port id
* queue - queue id
* meterIndex - meter index
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_QUEUE_ID - invalid queue id
* RT_ERR_FILTER_METER_ID - Invalid meter
* Note:
* The actual rate is "rate * chip granularity".
* The unit of granularity in Apollo is 8Kbps.
*/
extern int32
dal_ca8277b_rate_egrQueueBwCtrlMeterIdx_set(
rtk_port_t port,
rtk_qid_t queue,
uint32 meterIndex);
/* Function Name:
* dal_ca8277b_rate_stormControlRate_get
* Description:
* Get the storm control meter index.
* Input:
* port - port id
* stormType - storm group type
* Output:
* pIndex - storm control meter index.
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - Invalid port id
* RT_ERR_ENTRY_NOTFOUND - The global strom group is not enable for this group
* RT_ERR_NULL_POINTER - NULL pointer
* Note:
* The storm group types are as following:
* - STORM_GROUP_UNKNOWN_UNICAST
* - STORM_GROUP_UNKNOWN_MULTICAST
* - STORM_GROUP_MULTICAST
* - STORM_GROUP_BROADCAST
* - STORM_GROUP_DHCP
* - STORM_GROUP_ARP
* - STORM_GROUP_IGMP_MLD
* - Before call this API must make sure the global strom gruop for given group is enabled,
* otherwise this API will return RT_ERR_ENTRY_NOTFOUND
*/
extern int32
dal_ca8277b_rate_stormControlMeterIdx_get(
rtk_port_t port,
rtk_rate_storm_group_t stormType,
uint32 *pIndex);
/* Function Name:
* dal_ca8277b_rate_stormControlMeterIdx_set
* Description:
* Set the storm control meter index.
* Input:
* port - port id
* storm_type - storm group type
* index - storm control meter index.
* Output:
* None.
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - Invalid port id
* RT_ERR_ENTRY_NOTFOUND - The global strom group is not enable for this group
* RT_ERR_FILTER_METER_ID - Invalid meter
* RT_ERR_RATE - Invalid input bandwidth
* Note:
* The storm group types are as following:
* - STORM_GROUP_UNKNOWN_UNICAST
* - STORM_GROUP_UNKNOWN_MULTICAST
* - STORM_GROUP_MULTICAST
* - STORM_GROUP_BROADCAST
* - STORM_GROUP_DHCP
* - STORM_GROUP_ARP
* - STORM_GROUP_IGMP_MLD
* - Before call this API must make sure the global strom gruop for given group is enabled,
* otherwise this API will return RT_ERR_ENTRY_NOTFOUND
*/
extern int32
dal_ca8277b_rate_stormControlMeterIdx_set(
rtk_port_t port,
rtk_rate_storm_group_t stormType,
uint32 index);
/* Function Name:
* dal_ca8277b_rate_stormControlPortEnable_get
* Description:
* Get enable status of storm control on specified port.
* Input:
* port - port id
* stormType - storm group type
* Output:
* pEnable - pointer to enable status of storm control
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_SFC_UNKNOWN_GROUP - Unknown storm group
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The storm group types are as following:
* - STORM_GROUP_UNKNOWN_UNICAST
* - STORM_GROUP_UNKNOWN_MULTICAST
* - STORM_GROUP_MULTICAST
* - STORM_GROUP_BROADCAST
* - STORM_GROUP_DHCP
* - STORM_GROUP_ARP
* - STORM_GROUP_IGMP_MLD
*/
extern int32
dal_ca8277b_rate_stormControlPortEnable_get(
rtk_port_t port,
rtk_rate_storm_group_t stormType,
rtk_enable_t *pEnable);
/* Function Name:
* dal_ca8277b_rate_stormControlPortEnable_set
* Description:
* Set enable status of storm control on specified port.
* Input:
* port - port id
* stormType - storm group type
* enable - enable status of storm control
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_SFC_UNKNOWN_GROUP - Unknown storm group
* RT_ERR_ENTRY_NOTFOUND - The global strom group is not enable for this group
* RT_ERR_INPUT - invalid input parameter
* Note:
* The storm group types are as following:
* - STORM_GROUP_UNKNOWN_UNICAST
* - STORM_GROUP_UNKNOWN_MULTICAST
* - STORM_GROUP_MULTICAST
* - STORM_GROUP_BROADCAST
* - STORM_GROUP_DHCP
* - STORM_GROUP_ARP
* - STORM_GROUP_IGMP_MLD
*/
extern int32
dal_ca8277b_rate_stormControlPortEnable_set(
rtk_port_t port,
rtk_rate_storm_group_t stormType,
rtk_enable_t enable);
/* Function Name:
* dal_ca8277b_rate_shareMeter_set
* Description:
* Set meter configuration
* Input:
* index - shared meter index
* rate - rate of share meter
* ifgInclude - include IFG or not, ENABLE:include DISABLE:exclude
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_FILTER_METER_ID - Invalid meter
* RT_ERR_RATE - Invalid rate
* RT_ERR_INPUT - Invalid input parameters
* Note:
* The API can set shared meter rate and ifg include for each meter.
* The rate unit is 1 kbps and the range is from 8k to 1048568k.
* The granularity of rate is 8 kbps. The ifg_include parameter is used
* for rate calculation with/without inter-frame-gap and preamble.
*/
extern int32
dal_ca8277b_rate_shareMeter_set (
uint32 index,
uint32 rate,
rtk_enable_t ifgInclude );
/* Function Name:
* dal_ca8277b_rate_shareMeter_get
* Description:
* Get meter configuration
* Input:
* index - shared meter index
* Output:
* pRate - pointer of rate of share meter
* pIfgInclude - include IFG or not, ENABLE:include DISABLE:exclude
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_FILTER_METER_ID - Invalid meter
* Note:
* The API can get shared meter rate and ifg include for each meter.
* The rate unit is 1 kbps and the granularity of rate is 8 kbps.
* The ifg_include parameter is used for rate calculation with/without inter-frame-gap and preamble
*/
extern int32
dal_ca8277b_rate_shareMeter_get (
uint32 index,
uint32* pRate,
rtk_enable_t* pIfgInclude );
/* Function Name:
* dal_ca8277b_rate_shareMeterMode_set
* Description:
* Set meter mode
* Input:
* index - shared meter index
* meterMode - meter mode(bit rate mode or packet rate mode)
* Output:
* None.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_INPUT - Error Input
* RT_ERR_FILTER_METER_ID - Invalid meter
* Note:
* The API can set shared meter type.
*/
extern int32
dal_ca8277b_rate_shareMeterMode_set (
uint32 index,
rtk_rate_metet_mode_t meterMode );
/* Function Name:
* dal_ca8277b_rate_shareMeterMode_get
* Description:
* Set meter mode
* Input:
* index - shared meter index
* pMeterMode - meter mode(bit rate mode or packet rate mode)
* Output:
* None.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_INPUT - Error Input
* RT_ERR_FILTER_METER_ID - Invalid meter
* Note:
* The API can get shared meter mode.
*/
extern int32
dal_ca8277b_rate_shareMeterMode_get (
uint32 index,
rtk_rate_metet_mode_t* pMeterMode);
/* Function Name:
* dal_ca8277b_rate_shareMeterBucket_set
* Description:
* Set meter Bucket Size
* Input:
* index - shared meter index
* bucketSize - Bucket Size
* Output:
* None.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_INPUT - Error Input
* RT_ERR_FILTER_METER_ID - Invalid meter
* Note:
* The API can set shared meter bucket size.
*/
extern int32
dal_ca8277b_rate_shareMeterBucket_set (
uint32 index,
uint32 bucketSize );
/* Function Name:
* dal_ca8277b_rate_shareMeterBucket_get
* Description:
* Get meter Bucket Size
* Input:
* index - shared meter index
* Output:
* pBucketSize - Bucket Size
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_FILTER_METER_ID - Invalid meter
* Note:
* The API can get shared meter bucket size.
*/
extern int32
dal_ca8277b_rate_shareMeterBucket_get (
uint32 index,
uint32* pBucketSize );
#endif /* __DAL_CA8277B_RATE_H__ */