mediatek: mt7622: add Linux 5.10 support
[openwrt/staging/rmilecki.git] / target / linux / mediatek / files-5.10 / drivers / net / phy / rtk / rtl8367c / include / rate.h
1 /*
2 * Copyright (C) 2013 Realtek Semiconductor Corp.
3 * All Rights Reserved.
4 *
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
9 *
10 * Purpose : RTL8367/RTL8367C switch high-level API
11 *
12 * Feature : The file includes rate module high-layer API defination
13 *
14 */
15
16 #ifndef __RTK_API_RATE_H__
17 #define __RTK_API_RATE_H__
18
19 /*
20 * Include Files
21 */
22 //#include <rtk_types.h>
23
24 /*
25 * Data Type Declaration
26 */
27 #define RTK_MAX_METER_ID (rtk_switch_maxMeterId_get())
28 #define RTK_METER_NUM (RTK_MAX_METER_ID + 1)
29
30 typedef enum rtk_meter_type_e{
31 METER_TYPE_KBPS = 0, /* Kbps */
32 METER_TYPE_PPS, /* Packet per second */
33 METER_TYPE_END
34 }rtk_meter_type_t;
35
36
37 /*
38 * Function Declaration
39 */
40
41 /* Rate */
42 /* Function Name:
43 * rtk_rate_shareMeter_set
44 * Description:
45 * Set meter configuration
46 * Input:
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
51 * Output:
52 * None
53 * Return:
54 * RT_ERR_OK - OK
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
60 * Note:
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.
67 */
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);
69
70 /* Function Name:
71 * rtk_rate_shareMeter_get
72 * Description:
73 * Get meter configuration
74 * Input:
75 * index - shared meter index
76 * Output:
77 * pType - Meter Type
78 * pRate - pointer of rate of share meter
79 * pIfg_include - include IFG or not, ENABLE:include DISABLE:exclude
80 * Return:
81 * RT_ERR_OK - OK
82 * RT_ERR_FAILED - Failed
83 * RT_ERR_SMI - SMI access error
84 * RT_ERR_FILTER_METER_ID - Invalid meter
85 * Note:
86 *
87 */
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);
89
90 /* Function Name:
91 * rtk_rate_shareMeterBucket_set
92 * Description:
93 * Set meter Bucket Size
94 * Input:
95 * index - shared meter index
96 * bucket_size - Bucket Size
97 * Output:
98 * None.
99 * Return:
100 * RT_ERR_OK - OK
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
105 * Note:
106 * The API can set shared meter bucket size.
107 */
108 extern rtk_api_ret_t rtk_rate_shareMeterBucket_set(rtk_meter_id_t index, rtk_uint32 bucket_size);
109
110 /* Function Name:
111 * rtk_rate_shareMeterBucket_get
112 * Description:
113 * Get meter Bucket Size
114 * Input:
115 * index - shared meter index
116 * Output:
117 * pBucket_size - Bucket Size
118 * Return:
119 * RT_ERR_OK - OK
120 * RT_ERR_FAILED - Failed
121 * RT_ERR_SMI - SMI access error
122 * RT_ERR_FILTER_METER_ID - Invalid meter
123 * Note:
124 * The API can get shared meter bucket size.
125 */
126 extern rtk_api_ret_t rtk_rate_shareMeterBucket_get(rtk_meter_id_t index, rtk_uint32 *pBucket_size);
127
128 /* Function Name:
129 * rtk_rate_igrBandwidthCtrlRate_set
130 * Description:
131 * Set port ingress bandwidth control
132 * Input:
133 * port - Port id
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
137 * Output:
138 * None
139 * Return:
140 * RT_ERR_OK - OK
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.
146 * Note:
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.
149 */
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);
151
152 /* Function Name:
153 * rtk_rate_igrBandwidthCtrlRate_get
154 * Description:
155 * Get port ingress bandwidth control
156 * Input:
157 * port - Port id
158 * Output:
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
162 * Return:
163 * RT_ERR_OK - OK
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.
168 * Note:
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.
171 */
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);
173
174 /* Function Name:
175 * rtk_rate_egrBandwidthCtrlRate_set
176 * Description:
177 * Set port egress bandwidth control
178 * Input:
179 * port - Port id
180 * rate - Rate of egress bandwidth
181 * ifg_include - include IFG or not, ENABLE:include DISABLE:exclude
182 * Output:
183 * None
184 * Return:
185 * RT_ERR_OK - OK
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
191 * Note:
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.
194 */
195 extern rtk_api_ret_t rtk_rate_egrBandwidthCtrlRate_set(rtk_port_t port, rtk_rate_t rate, rtk_enable_t ifg_includ);
196
197 /* Function Name:
198 * rtk_rate_egrBandwidthCtrlRate_get
199 * Description:
200 * Get port egress bandwidth control
201 * Input:
202 * port - Port id
203 * Output:
204 * pRate - Rate of egress bandwidth
205 * pIfg_include - Rate's calculation including IFG, ENABLE:include DISABLE:exclude
206 * Return:
207 * RT_ERR_OK - OK
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.
212 * Note:
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.
215 */
216 extern rtk_api_ret_t rtk_rate_egrBandwidthCtrlRate_get(rtk_port_t port, rtk_rate_t *pRate, rtk_enable_t *pIfg_include);
217
218 /* Function Name:
219 * rtk_rate_egrQueueBwCtrlEnable_set
220 * Description:
221 * Set enable status of egress bandwidth control on specified queue.
222 * Input:
223 * port - port id
224 * queue - queue id
225 * enable - enable status of egress queue bandwidth control
226 * Output:
227 * None
228 * Return:
229 * RT_ERR_OK
230 * RT_ERR_FAILED
231 * RT_ERR_PORT_ID - invalid port id
232 * RT_ERR_QUEUE_ID - invalid queue id
233 * RT_ERR_INPUT - invalid input parameter
234 * Note:
235 * None
236 */
237 extern rtk_api_ret_t rtk_rate_egrQueueBwCtrlEnable_set(rtk_port_t port, rtk_qid_t queue, rtk_enable_t enable);
238
239 /* Function Name:
240 * rtk_rate_egrQueueBwCtrlRate_get
241 * Description:
242 * Get rate of egress bandwidth control on specified queue.
243 * Input:
244 * port - port id
245 * queue - queue id
246 * pIndex - shared meter index
247 * Output:
248 * pRate - pointer to rate of egress queue bandwidth control
249 * Return:
250 * RT_ERR_OK
251 * RT_ERR_FAILED
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
255 * Note:
256 * None.
257 */
258 extern rtk_api_ret_t rtk_rate_egrQueueBwCtrlEnable_get(rtk_port_t port, rtk_qid_t queue, rtk_enable_t *pEnable);
259
260 /* Function Name:
261 * rtk_rate_egrQueueBwCtrlRate_set
262 * Description:
263 * Set rate of egress bandwidth control on specified queue.
264 * Input:
265 * port - port id
266 * queue - queue id
267 * index - shared meter index
268 * Output:
269 * None
270 * Return:
271 * RT_ERR_OK
272 * RT_ERR_FAILED
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
276 * Note:
277 * The actual rate control is set in shared meters.
278 * The unit of granularity is 8Kbps.
279 */
280 extern rtk_api_ret_t rtk_rate_egrQueueBwCtrlRate_set(rtk_port_t port, rtk_qid_t queue, rtk_meter_id_t index);
281
282 /* Function Name:
283 * rtk_rate_egrQueueBwCtrlRate_get
284 * Description:
285 * Get rate of egress bandwidth control on specified queue.
286 * Input:
287 * port - port id
288 * queue - queue id
289 * pIndex - shared meter index
290 * Output:
291 * pRate - pointer to rate of egress queue bandwidth control
292 * Return:
293 * RT_ERR_OK
294 * RT_ERR_FAILED
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
298 * Note:
299 * The actual rate control is set in shared meters.
300 * The unit of granularity is 8Kbps.
301 */
302 extern rtk_api_ret_t rtk_rate_egrQueueBwCtrlRate_get(rtk_port_t port, rtk_qid_t queue, rtk_meter_id_t *pIndex);
303
304 #endif /* __RTK_API_RATE_H__ */
305