2 * Copyright (C) 2013 Realtek Semiconductor Corp.
5 * Unless you and Realtek execute a separate written software license
6 * agreement governing use of this software, this software is licensed
7 * to you under the terms of the GNU General Public License version 2,
8 * available at https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
10 * Purpose : RTL8367/RTL8367C switch high-level API
12 * Feature : The file includes rate module high-layer API defination
16 #ifndef __RTK_API_RATE_H__
17 #define __RTK_API_RATE_H__
22 //#include <rtk_types.h>
25 * Data Type Declaration
27 #define RTK_MAX_METER_ID (rtk_switch_maxMeterId_get())
28 #define RTK_METER_NUM (RTK_MAX_METER_ID + 1)
30 typedef enum rtk_meter_type_e
{
31 METER_TYPE_KBPS
= 0, /* Kbps */
32 METER_TYPE_PPS
, /* Packet per second */
38 * Function Declaration
43 * rtk_rate_shareMeter_set
45 * Set meter configuration
47 * index - shared meter index
48 * type - shared meter type
49 * rate - rate of share meter
50 * ifg_include - include IFG or not, ENABLE:include DISABLE:exclude
55 * RT_ERR_FAILED - Failed
56 * RT_ERR_SMI - SMI access error
57 * RT_ERR_FILTER_METER_ID - Invalid meter
58 * RT_ERR_RATE - Invalid rate
59 * RT_ERR_INPUT - Invalid input parameters
61 * The API can set shared meter rate and ifg include for each meter.
62 * The rate unit is 1 kbps and the range is from 8k to 1048568k if type is METER_TYPE_KBPS and
63 * the granularity of rate is 8 kbps.
64 * The rate unit is packets per second and the range is 1 ~ 0x1FFF if type is METER_TYPE_PPS.
65 * The ifg_include parameter is used
66 * for rate calculation with/without inter-frame-gap and preamble.
68 rtk_api_ret_t
rtk_rate_shareMeter_set(rtk_meter_id_t index
, rtk_meter_type_t type
, rtk_rate_t rate
, rtk_enable_t ifg_include
);
71 * rtk_rate_shareMeter_get
73 * Get meter configuration
75 * index - shared meter index
78 * pRate - pointer of rate of share meter
79 * pIfg_include - include IFG or not, ENABLE:include DISABLE:exclude
82 * RT_ERR_FAILED - Failed
83 * RT_ERR_SMI - SMI access error
84 * RT_ERR_FILTER_METER_ID - Invalid meter
88 rtk_api_ret_t
rtk_rate_shareMeter_get(rtk_meter_id_t index
, rtk_meter_type_t
*pType
, rtk_rate_t
*pRate
, rtk_enable_t
*pIfg_include
);
91 * rtk_rate_shareMeterBucket_set
93 * Set meter Bucket Size
95 * index - shared meter index
96 * bucket_size - Bucket Size
101 * RT_ERR_FAILED - Failed
102 * RT_ERR_INPUT - Error Input
103 * RT_ERR_SMI - SMI access error
104 * RT_ERR_FILTER_METER_ID - Invalid meter
106 * The API can set shared meter bucket size.
108 extern rtk_api_ret_t
rtk_rate_shareMeterBucket_set(rtk_meter_id_t index
, rtk_uint32 bucket_size
);
111 * rtk_rate_shareMeterBucket_get
113 * Get meter Bucket Size
115 * index - shared meter index
117 * pBucket_size - Bucket Size
120 * RT_ERR_FAILED - Failed
121 * RT_ERR_SMI - SMI access error
122 * RT_ERR_FILTER_METER_ID - Invalid meter
124 * The API can get shared meter bucket size.
126 extern rtk_api_ret_t
rtk_rate_shareMeterBucket_get(rtk_meter_id_t index
, rtk_uint32
*pBucket_size
);
129 * rtk_rate_igrBandwidthCtrlRate_set
131 * Set port ingress bandwidth control
134 * rate - Rate of share meter
135 * ifg_include - include IFG or not, ENABLE:include DISABLE:exclude
136 * fc_enable - enable flow control or not, ENABLE:use flow control DISABLE:drop
141 * RT_ERR_FAILED - Failed
142 * RT_ERR_SMI - SMI access error
143 * RT_ERR_PORT_ID - Invalid port number.
144 * RT_ERR_ENABLE - Invalid IFG parameter.
145 * RT_ERR_INBW_RATE - Invalid ingress rate parameter.
147 * The rate unit is 1 kbps and the range is from 8k to 1048568k. The granularity of rate is 8 kbps.
148 * The ifg_include parameter is used for rate calculation with/without inter-frame-gap and preamble.
150 extern rtk_api_ret_t
rtk_rate_igrBandwidthCtrlRate_set( rtk_port_t port
, rtk_rate_t rate
, rtk_enable_t ifg_include
, rtk_enable_t fc_enable
);
153 * rtk_rate_igrBandwidthCtrlRate_get
155 * Get port ingress bandwidth control
159 * pRate - Rate of share meter
160 * pIfg_include - Rate's calculation including IFG, ENABLE:include DISABLE:exclude
161 * pFc_enable - enable flow control or not, ENABLE:use flow control DISABLE:drop
164 * RT_ERR_FAILED - Failed
165 * RT_ERR_SMI - SMI access error
166 * RT_ERR_PORT_ID - Invalid port number.
167 * RT_ERR_INPUT - Invalid input parameters.
169 * The rate unit is 1 kbps and the range is from 8k to 1048568k. The granularity of rate is 8 kbps.
170 * The ifg_include parameter is used for rate calculation with/without inter-frame-gap and preamble.
172 extern rtk_api_ret_t
rtk_rate_igrBandwidthCtrlRate_get(rtk_port_t port
, rtk_rate_t
*pRate
, rtk_enable_t
*pIfg_include
, rtk_enable_t
*pFc_enable
);
175 * rtk_rate_egrBandwidthCtrlRate_set
177 * Set port egress bandwidth control
180 * rate - Rate of egress bandwidth
181 * ifg_include - include IFG or not, ENABLE:include DISABLE:exclude
186 * RT_ERR_FAILED - Failed
187 * RT_ERR_SMI - SMI access error
188 * RT_ERR_PORT_ID - Invalid port number.
189 * RT_ERR_INPUT - Invalid input parameters.
190 * RT_ERR_QOS_EBW_RATE - Invalid egress bandwidth/rate
192 * The rate unit is 1 kbps and the range is from 8k to 1048568k. The granularity of rate is 8 kbps.
193 * The ifg_include parameter is used for rate calculation with/without inter-frame-gap and preamble.
195 extern rtk_api_ret_t
rtk_rate_egrBandwidthCtrlRate_set(rtk_port_t port
, rtk_rate_t rate
, rtk_enable_t ifg_includ
);
198 * rtk_rate_egrBandwidthCtrlRate_get
200 * Get port egress bandwidth control
204 * pRate - Rate of egress bandwidth
205 * pIfg_include - Rate's calculation including IFG, ENABLE:include DISABLE:exclude
208 * RT_ERR_FAILED - Failed
209 * RT_ERR_SMI - SMI access error
210 * RT_ERR_PORT_ID - Invalid port number.
211 * RT_ERR_INPUT - Invalid input parameters.
213 * The rate unit is 1 kbps and the range is from 8k to 1048568k. The granularity of rate is 8 kbps.
214 * The ifg_include parameter is used for rate calculation with/without inter-frame-gap and preamble.
216 extern rtk_api_ret_t
rtk_rate_egrBandwidthCtrlRate_get(rtk_port_t port
, rtk_rate_t
*pRate
, rtk_enable_t
*pIfg_include
);
219 * rtk_rate_egrQueueBwCtrlEnable_set
221 * Set enable status of egress bandwidth control on specified queue.
225 * enable - enable status of egress queue bandwidth control
231 * RT_ERR_PORT_ID - invalid port id
232 * RT_ERR_QUEUE_ID - invalid queue id
233 * RT_ERR_INPUT - invalid input parameter
237 extern rtk_api_ret_t
rtk_rate_egrQueueBwCtrlEnable_set(rtk_port_t port
, rtk_qid_t queue
, rtk_enable_t enable
);
240 * rtk_rate_egrQueueBwCtrlRate_get
242 * Get rate of egress bandwidth control on specified queue.
246 * pIndex - shared meter index
248 * pRate - pointer to rate of egress queue bandwidth control
252 * RT_ERR_PORT_ID - invalid port id
253 * RT_ERR_QUEUE_ID - invalid queue id
254 * RT_ERR_FILTER_METER_ID - Invalid meter id
258 extern rtk_api_ret_t
rtk_rate_egrQueueBwCtrlEnable_get(rtk_port_t port
, rtk_qid_t queue
, rtk_enable_t
*pEnable
);
261 * rtk_rate_egrQueueBwCtrlRate_set
263 * Set rate of egress bandwidth control on specified queue.
267 * index - shared meter index
273 * RT_ERR_PORT_ID - invalid port id
274 * RT_ERR_QUEUE_ID - invalid queue id
275 * RT_ERR_FILTER_METER_ID - Invalid meter id
277 * The actual rate control is set in shared meters.
278 * The unit of granularity is 8Kbps.
280 extern rtk_api_ret_t
rtk_rate_egrQueueBwCtrlRate_set(rtk_port_t port
, rtk_qid_t queue
, rtk_meter_id_t index
);
283 * rtk_rate_egrQueueBwCtrlRate_get
285 * Get rate of egress bandwidth control on specified queue.
289 * pIndex - shared meter index
291 * pRate - pointer to rate of egress queue bandwidth control
295 * RT_ERR_PORT_ID - invalid port id
296 * RT_ERR_QUEUE_ID - invalid queue id
297 * RT_ERR_FILTER_METER_ID - Invalid meter id
299 * The actual rate control is set in shared meters.
300 * The unit of granularity is 8Kbps.
302 extern rtk_api_ret_t
rtk_rate_egrQueueBwCtrlRate_get(rtk_port_t port
, rtk_qid_t queue
, rtk_meter_id_t
*pIndex
);
304 #endif /* __RTK_API_RATE_H__ */