5544aca7b28642aaf00708d0ae174bfdaddf7890
[openwrt/openwrt.git] / target / linux / mediatek / files-5.10 / drivers / net / phy / rtk / rtl8367c / include / cpu.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 CPU module high-layer API defination
13 *
14 */
15
16 #ifndef __RTK_API_CPU_H__
17 #define __RTK_API_CPU_H__
18
19
20 /*
21 * Data Type Declaration
22 */
23 typedef enum rtk_cpu_insert_e
24 {
25 CPU_INSERT_TO_ALL = 0,
26 CPU_INSERT_TO_TRAPPING,
27 CPU_INSERT_TO_NONE,
28 CPU_INSERT_END
29 }rtk_cpu_insert_t;
30
31 typedef enum rtk_cpu_position_e
32 {
33 CPU_POS_AFTER_SA = 0,
34 CPU_POS_BEFORE_CRC,
35 CPU_POS_END
36 }rtk_cpu_position_t;
37
38 typedef enum rtk_cpu_tag_length_e
39 {
40 CPU_LEN_8BYTES = 0,
41 CPU_LEN_4BYTES,
42 CPU_LEN_END
43 }rtk_cpu_tag_length_t;
44
45
46 typedef enum rtk_cpu_rx_length_e
47 {
48 CPU_RX_72BYTES = 0,
49 CPU_RX_64BYTES,
50 CPU_RX_END
51 }rtk_cpu_rx_length_t;
52
53
54 /* Function Name:
55 * rtk_cpu_enable_set
56 * Description:
57 * Set CPU port function enable/disable.
58 * Input:
59 * enable - CPU port function enable
60 * Output:
61 * None
62 * Return:
63 * RT_ERR_OK - OK
64 * RT_ERR_FAILED - Failed
65 * RT_ERR_SMI - SMI access error
66 * RT_ERR_INPUT - Invalid input parameter.
67 * RT_ERR_PORT_ID - Invalid port number.
68 * Note:
69 * The API can set CPU port function enable/disable.
70 */
71 extern rtk_api_ret_t rtk_cpu_enable_set(rtk_enable_t enable);
72
73 /* Function Name:
74 * rtk_cpu_enable_get
75 * Description:
76 * Get CPU port and its setting.
77 * Input:
78 * None
79 * Output:
80 * pEnable - CPU port function enable
81 * Return:
82 * RT_ERR_OK - OK
83 * RT_ERR_FAILED - Failed
84 * RT_ERR_SMI - SMI access error
85 * RT_ERR_INPUT - Invalid input parameters.
86 * RT_ERR_L2_NO_CPU_PORT - CPU port is not exist
87 * Note:
88 * The API can get CPU port function enable/disable.
89 */
90 extern rtk_api_ret_t rtk_cpu_enable_get(rtk_enable_t *pEnable);
91
92 /* Function Name:
93 * rtk_cpu_tagPort_set
94 * Description:
95 * Set CPU port and CPU tag insert mode.
96 * Input:
97 * port - Port id.
98 * mode - CPU tag insert for packets egress from CPU port.
99 * Output:
100 * None
101 * Return:
102 * RT_ERR_OK - OK
103 * RT_ERR_FAILED - Failed
104 * RT_ERR_SMI - SMI access error
105 * RT_ERR_INPUT - Invalid input parameter.
106 * RT_ERR_PORT_ID - Invalid port number.
107 * Note:
108 * The API can set CPU port and inserting proprietary CPU tag mode (Length/Type 0x8899)
109 * to the frame that transmitting to CPU port.
110 * The inset cpu tag mode is as following:
111 * - CPU_INSERT_TO_ALL
112 * - CPU_INSERT_TO_TRAPPING
113 * - CPU_INSERT_TO_NONE
114 */
115 extern rtk_api_ret_t rtk_cpu_tagPort_set(rtk_port_t port, rtk_cpu_insert_t mode);
116
117 /* Function Name:
118 * rtk_cpu_tagPort_get
119 * Description:
120 * Get CPU port and CPU tag insert mode.
121 * Input:
122 * None
123 * Output:
124 * pPort - Port id.
125 * pMode - CPU tag insert for packets egress from CPU port, 0:all insert 1:Only for trapped packets 2:no insert.
126 * Return:
127 * RT_ERR_OK - OK
128 * RT_ERR_FAILED - Failed
129 * RT_ERR_SMI - SMI access error
130 * RT_ERR_INPUT - Invalid input parameters.
131 * RT_ERR_L2_NO_CPU_PORT - CPU port is not exist
132 * Note:
133 * The API can get configured CPU port and its setting.
134 * The inset cpu tag mode is as following:
135 * - CPU_INSERT_TO_ALL
136 * - CPU_INSERT_TO_TRAPPING
137 * - CPU_INSERT_TO_NONE
138 */
139 extern rtk_api_ret_t rtk_cpu_tagPort_get(rtk_port_t *pPort, rtk_cpu_insert_t *pMode);
140
141 /* Function Name:
142 * rtk_cpu_awarePort_set
143 * Description:
144 * Set CPU aware port mask.
145 * Input:
146 * portmask - Port mask.
147 * Output:
148 * None
149 * Return:
150 * RT_ERR_OK - OK
151 * RT_ERR_FAILED - Failed
152 * RT_ERR_SMI - SMI access error
153 * RT_ERR_PORT_MASK - Invalid port mask.
154 * Note:
155 * The API can set configured CPU aware port mask.
156 */
157 extern rtk_api_ret_t rtk_cpu_awarePort_set(rtk_portmask_t *pPortmask);
158
159
160 /* Function Name:
161 * rtk_cpu_awarePort_get
162 * Description:
163 * Get CPU aware port mask.
164 * Input:
165 * None
166 * Output:
167 * pPortmask - Port mask.
168 * Return:
169 * RT_ERR_OK - OK
170 * RT_ERR_FAILED - Failed
171 * RT_ERR_SMI - SMI access error
172 * Note:
173 * The API can get configured CPU aware port mask.
174 */
175 extern rtk_api_ret_t rtk_cpu_awarePort_get(rtk_portmask_t *pPortmask);
176
177 /* Function Name:
178 * rtk_cpu_tagPosition_set
179 * Description:
180 * Set CPU tag position.
181 * Input:
182 * position - CPU tag position.
183 * Output:
184 * None
185 * Return:
186 * RT_ERR_OK - OK
187 * RT_ERR_FAILED - Failed
188 * RT_ERR_SMI - SMI access error
189 * RT_ERR_INPUT - Invalid input.
190 * Note:
191 * The API can set CPU tag position.
192 */
193 extern rtk_api_ret_t rtk_cpu_tagPosition_set(rtk_cpu_position_t position);
194
195 /* Function Name:
196 * rtk_cpu_tagPosition_get
197 * Description:
198 * Get CPU tag position.
199 * Input:
200 * None
201 * Output:
202 * pPosition - CPU tag position.
203 * Return:
204 * RT_ERR_OK - OK
205 * RT_ERR_FAILED - Failed
206 * RT_ERR_SMI - SMI access error
207 * RT_ERR_INPUT - Invalid input.
208 * Note:
209 * The API can get CPU tag position.
210 */
211 extern rtk_api_ret_t rtk_cpu_tagPosition_get(rtk_cpu_position_t *pPosition);
212
213 /* Function Name:
214 * rtk_cpu_tagLength_set
215 * Description:
216 * Set CPU tag length.
217 * Input:
218 * length - CPU tag length.
219 * Output:
220 * None
221 * Return:
222 * RT_ERR_OK - OK
223 * RT_ERR_FAILED - Failed
224 * RT_ERR_SMI - SMI access error
225 * RT_ERR_INPUT - Invalid input.
226 * Note:
227 * The API can set CPU tag length.
228 */
229 extern rtk_api_ret_t rtk_cpu_tagLength_set(rtk_cpu_tag_length_t length);
230
231 /* Function Name:
232 * rtk_cpu_tagLength_get
233 * Description:
234 * Get CPU tag length.
235 * Input:
236 * None
237 * Output:
238 * pLength - CPU tag length.
239 * Return:
240 * RT_ERR_OK - OK
241 * RT_ERR_FAILED - Failed
242 * RT_ERR_SMI - SMI access error
243 * RT_ERR_INPUT - Invalid input.
244 * Note:
245 * The API can get CPU tag length.
246 */
247 extern rtk_api_ret_t rtk_cpu_tagLength_get(rtk_cpu_tag_length_t *pLength);
248
249 /* Function Name:
250 * rtk_cpu_acceptLength_set
251 * Description:
252 * Set CPU accept length.
253 * Input:
254 * length - CPU tag length.
255 * Output:
256 * None
257 * Return:
258 * RT_ERR_OK - OK
259 * RT_ERR_FAILED - Failed
260 * RT_ERR_SMI - SMI access error
261 * RT_ERR_INPUT - Invalid input.
262 * Note:
263 * The API can set CPU accept length.
264 */
265 extern rtk_api_ret_t rtk_cpu_acceptLength_set(rtk_cpu_rx_length_t length);
266
267 /* Function Name:
268 * rtk_cpu_acceptLength_get
269 * Description:
270 * Get CPU accept length.
271 * Input:
272 * None
273 * Output:
274 * pLength - CPU tag length.
275 * Return:
276 * RT_ERR_OK - OK
277 * RT_ERR_FAILED - Failed
278 * RT_ERR_SMI - SMI access error
279 * RT_ERR_INPUT - Invalid input.
280 * Note:
281 * The API can get CPU accept length.
282 */
283 extern rtk_api_ret_t rtk_cpu_acceptLength_get(rtk_cpu_rx_length_t *pLength);
284
285 /* Function Name:
286 * rtk_cpu_priRemap_set
287 * Description:
288 * Configure CPU priorities mapping to internal absolute priority.
289 * Input:
290 * int_pri - internal priority value.
291 * new_pri - new internal priority value.
292 * Output:
293 * None
294 * Return:
295 * RT_ERR_OK - OK
296 * RT_ERR_FAILED - Failed
297 * RT_ERR_SMI - SMI access error
298 * RT_ERR_INPUT - Invalid input parameters.
299 * RT_ERR_VLAN_PRIORITY - Invalid 1p priority.
300 * RT_ERR_QOS_INT_PRIORITY - Invalid priority.
301 * Note:
302 * Priority of CPU tag assignment for internal asic priority, and it is used for queue usage and packet scheduling.
303 */
304 extern rtk_api_ret_t rtk_cpu_priRemap_set(rtk_pri_t int_pri, rtk_pri_t new_pri);
305
306 /* Function Name:
307 * rtk_cpu_priRemap_get
308 * Description:
309 * Configure CPU priorities mapping to internal absolute priority.
310 * Input:
311 * int_pri - internal priority value.
312 * Output:
313 * pNew_pri - new internal priority value.
314 * Return:
315 * RT_ERR_OK - OK
316 * RT_ERR_FAILED - Failed
317 * RT_ERR_SMI - SMI access error
318 * RT_ERR_INPUT - Invalid input parameters.
319 * RT_ERR_VLAN_PRIORITY - Invalid 1p priority.
320 * RT_ERR_QOS_INT_PRIORITY - Invalid priority.
321 * Note:
322 * Priority of CPU tag assignment for internal asic priority, and it is used for queue usage and packet scheduling.
323 */
324 extern rtk_api_ret_t rtk_cpu_priRemap_get(rtk_pri_t int_pri, rtk_pri_t *pNew_pri);
325
326
327 #endif /* __RTK_API_CPU_H__ */