kernel: add missing config symbols for 5.15
[openwrt/openwrt.git] / target / linux / mediatek / files-5.10 / drivers / net / phy / rtk / rtl8367c / rtl8367c_asicdrv_dot1x.c
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 * $Revision: 76306 $
11 * $Date: 2017-03-08 15:13:58 +0800 (週三, 08 三月 2017) $
12 *
13 * Purpose : RTL8367C switch high-level API for RTL8367C
14 * Feature : 802.1X related functions
15 *
16 */
17 #include <rtl8367c_asicdrv_dot1x.h>
18 /* Function Name:
19 * rtl8367c_setAsic1xPBEnConfig
20 * Description:
21 * Set 802.1x port-based port enable configuration
22 * Input:
23 * port - Physical port number (0~7)
24 * enabled - 1: enabled, 0: disabled
25 * Output:
26 * None
27 * Return:
28 * RT_ERR_OK - Success
29 * RT_ERR_SMI - SMI access error
30 * RT_ERR_PORT_ID - Invalid port number
31 * Note:
32 * None
33 */
34 ret_t rtl8367c_setAsic1xPBEnConfig(rtk_uint32 port, rtk_uint32 enabled)
35 {
36 if(port >= RTL8367C_PORTNO)
37 return RT_ERR_PORT_ID;
38
39 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_PORT_ENABLE_REG, port, enabled);
40 }
41 /* Function Name:
42 * rtl8367c_getAsic1xPBEnConfig
43 * Description:
44 * Get 802.1x port-based port enable configuration
45 * Input:
46 * port - Physical port number (0~7)
47 * pEnabled - 1: enabled, 0: disabled
48 * Output:
49 * None
50 * Return:
51 * RT_ERR_OK - Success
52 * RT_ERR_SMI - SMI access error
53 * RT_ERR_PORT_ID - Invalid port number
54 * Note:
55 * None
56 */
57 ret_t rtl8367c_getAsic1xPBEnConfig(rtk_uint32 port, rtk_uint32 *pEnabled)
58 {
59 if(port >= RTL8367C_PORTNO)
60 return RT_ERR_PORT_ID;
61
62 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_PORT_ENABLE_REG, port, pEnabled);
63 }
64 /* Function Name:
65 * rtl8367c_setAsic1xPBAuthConfig
66 * Description:
67 * Set 802.1x port-based authorised port configuration
68 * Input:
69 * port - Physical port number (0~7)
70 * auth - 1: authorised, 0: non-authorised
71 * Output:
72 * None
73 * Return:
74 * RT_ERR_OK - Success
75 * RT_ERR_SMI - SMI access error
76 * RT_ERR_PORT_ID - Invalid port number
77 * Note:
78 * None
79 */
80 ret_t rtl8367c_setAsic1xPBAuthConfig(rtk_uint32 port, rtk_uint32 auth)
81 {
82 if(port >= RTL8367C_PORTNO)
83 return RT_ERR_PORT_ID;
84
85 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_PORT_AUTH_REG, port, auth);
86 }
87 /* Function Name:
88 * rtl8367c_getAsic1xPBAuthConfig
89 * Description:
90 * Get 802.1x port-based authorised port configuration
91 * Input:
92 * port - Physical port number (0~7)
93 * pAuth - 1: authorised, 0: non-authorised
94 * Output:
95 * None
96 * Return:
97 * RT_ERR_OK - Success
98 * RT_ERR_SMI - SMI access error
99 * RT_ERR_PORT_ID - Invalid port number
100 * Note:
101 * None
102 */
103 ret_t rtl8367c_getAsic1xPBAuthConfig(rtk_uint32 port, rtk_uint32 *pAuth)
104 {
105 if(port >= RTL8367C_PORTNO)
106 return RT_ERR_PORT_ID;
107
108 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_PORT_AUTH_REG, port, pAuth);
109 }
110 /* Function Name:
111 * rtl8367c_setAsic1xPBOpdirConfig
112 * Description:
113 * Set 802.1x port-based operational direction
114 * Input:
115 * port - Physical port number (0~7)
116 * opdir - Operation direction 1: IN, 0:BOTH
117 * Output:
118 * None
119 * Return:
120 * RT_ERR_OK - Success
121 * RT_ERR_SMI - SMI access error
122 * RT_ERR_PORT_ID - Invalid port number
123 * Note:
124 * None
125 */
126 ret_t rtl8367c_setAsic1xPBOpdirConfig(rtk_uint32 port, rtk_uint32 opdir)
127 {
128 if(port >= RTL8367C_PORTNO)
129 return RT_ERR_PORT_ID;
130
131 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_PORT_OPDIR_REG, port, opdir);
132 }
133 /* Function Name:
134 * rtl8367c_getAsic1xPBOpdirConfig
135 * Description:
136 * Get 802.1x port-based operational direction
137 * Input:
138 * port - Physical port number (0~7)
139 * pOpdir - Operation direction 1: IN, 0:BOTH
140 * Output:
141 * None
142 * Return:
143 * RT_ERR_OK - Success
144 * RT_ERR_SMI - SMI access error
145 * RT_ERR_PORT_ID - Invalid port number
146 * Note:
147 * None
148 */
149 ret_t rtl8367c_getAsic1xPBOpdirConfig(rtk_uint32 port, rtk_uint32* pOpdir)
150 {
151 if(port >= RTL8367C_PORTNO)
152 return RT_ERR_PORT_ID;
153
154 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_PORT_OPDIR_REG, port, pOpdir);
155 }
156 /* Function Name:
157 * rtl8367c_setAsic1xMBEnConfig
158 * Description:
159 * Set 802.1x mac-based port enable configuration
160 * Input:
161 * port - Physical port number (0~7)
162 * enabled - 1: enabled, 0: disabled
163 * Output:
164 * None
165 * Return:
166 * RT_ERR_OK - Success
167 * RT_ERR_SMI - SMI access error
168 * RT_ERR_PORT_ID - Invalid port number
169 * Note:
170 * None
171 */
172 ret_t rtl8367c_setAsic1xMBEnConfig(rtk_uint32 port, rtk_uint32 enabled)
173 {
174 if(port >= RTL8367C_PORTNO)
175 return RT_ERR_PORT_ID;
176
177 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_MAC_ENABLE_REG, port, enabled);
178 }
179 /* Function Name:
180 * rtl8367c_getAsic1xMBEnConfig
181 * Description:
182 * Get 802.1x mac-based port enable configuration
183 * Input:
184 * port - Physical port number (0~7)
185 * pEnabled - 1: enabled, 0: disabled
186 * Output:
187 * None
188 * Return:
189 * RT_ERR_OK - Success
190 * RT_ERR_SMI - SMI access error
191 * RT_ERR_PORT_ID - Invalid port number
192 * Note:
193 * None
194 */
195 ret_t rtl8367c_getAsic1xMBEnConfig(rtk_uint32 port, rtk_uint32 *pEnabled)
196 {
197 if(port >= RTL8367C_PORTNO)
198 return RT_ERR_PORT_ID;
199
200 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_MAC_ENABLE_REG, port, pEnabled);
201 }
202 /* Function Name:
203 * rtl8367c_setAsic1xMBOpdirConfig
204 * Description:
205 * Set 802.1x mac-based operational direction
206 * Input:
207 * opdir - Operation direction 1: IN, 0:BOTH
208 * Output:
209 * None
210 * Return:
211 * RT_ERR_OK - Success
212 * RT_ERR_SMI - SMI access error
213 * Note:
214 * None
215 */
216 ret_t rtl8367c_setAsic1xMBOpdirConfig(rtk_uint32 opdir)
217 {
218 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_CFG_REG, RTL8367C_DOT1X_MAC_OPDIR_OFFSET, opdir);
219 }
220 /* Function Name:
221 * rtl8367c_getAsic1xMBOpdirConfig
222 * Description:
223 * Get 802.1x mac-based operational direction
224 * Input:
225 * pOpdir - Operation direction 1: IN, 0:BOTH
226 * Output:
227 * None
228 * Return:
229 * RT_ERR_OK - Success
230 * RT_ERR_SMI - SMI access error
231 * Note:
232 * None
233 */
234 ret_t rtl8367c_getAsic1xMBOpdirConfig(rtk_uint32 *pOpdir)
235 {
236 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_CFG_REG, RTL8367C_DOT1X_MAC_OPDIR_OFFSET, pOpdir);
237 }
238 /* Function Name:
239 * rtl8367c_setAsic1xProcConfig
240 * Description:
241 * Set 802.1x unauth. behavior configuration
242 * Input:
243 * port - Physical port number (0~7)
244 * proc - 802.1x unauth. behavior configuration 0:drop 1:trap to CPU 2:Guest VLAN
245 * Output:
246 * None
247 * Return:
248 * RT_ERR_OK - Success
249 * RT_ERR_SMI - SMI access error
250 * RT_ERR_PORT_ID - Invalid port number
251 * RT_ERR_DOT1X_PROC - Unauthorized behavior error
252 * Note:
253 * None
254 */
255 ret_t rtl8367c_setAsic1xProcConfig(rtk_uint32 port, rtk_uint32 proc)
256 {
257
258 if(port >= RTL8367C_PORTNO)
259 return RT_ERR_PORT_ID;
260
261 if(proc >= DOT1X_UNAUTH_END)
262 return RT_ERR_DOT1X_PROC;
263
264 if(port < 8)
265 {
266 return rtl8367c_setAsicRegBits(RTL8367C_DOT1X_UNAUTH_ACT_BASE, RTL8367C_DOT1X_UNAUTH_ACT_MASK(port),proc);
267 }
268 else
269 {
270 return rtl8367c_setAsicRegBits(RTL8367C_REG_DOT1X_UNAUTH_ACT_W1, RTL8367C_DOT1X_UNAUTH_ACT_MASK(port),proc);
271 }
272 }
273 /* Function Name:
274 * rtl8367c_getAsic1xProcConfig
275 * Description:
276 * Get 802.1x unauth. behavior configuration
277 * Input:
278 * port - Physical port number (0~7)
279 * pProc - 802.1x unauth. behavior configuration 0:drop 1:trap to CPU 2:Guest VLAN
280 * Output:
281 * None
282 * Return:
283 * RT_ERR_OK - Success
284 * RT_ERR_SMI - SMI access error
285 * RT_ERR_PORT_ID - Invalid port number
286 * Note:
287 * None
288 */
289 ret_t rtl8367c_getAsic1xProcConfig(rtk_uint32 port, rtk_uint32* pProc)
290 {
291 if(port >= RTL8367C_PORTNO)
292 return RT_ERR_PORT_ID;
293
294 if(port < 8)
295 return rtl8367c_getAsicRegBits(RTL8367C_DOT1X_UNAUTH_ACT_BASE, RTL8367C_DOT1X_UNAUTH_ACT_MASK(port),pProc);
296 else
297 return rtl8367c_getAsicRegBits(RTL8367C_REG_DOT1X_UNAUTH_ACT_W1, RTL8367C_DOT1X_UNAUTH_ACT_MASK(port),pProc);
298 }
299 /* Function Name:
300 * rtl8367c_setAsic1xGuestVidx
301 * Description:
302 * Set 802.1x guest vlan index
303 * Input:
304 * index - 802.1x guest vlan index (0~31)
305 * Output:
306 * None
307 * Return:
308 * RT_ERR_OK - Success
309 * RT_ERR_SMI - SMI access error
310 * RT_ERR_DOT1X_GVLANIDX - Invalid cvid index
311 * Note:
312 * None
313 */
314 ret_t rtl8367c_setAsic1xGuestVidx(rtk_uint32 index)
315 {
316 if(index >= RTL8367C_CVIDXNO)
317 return RT_ERR_DOT1X_GVLANIDX;
318
319 return rtl8367c_setAsicRegBits(RTL8367C_DOT1X_CFG_REG, RTL8367C_DOT1X_GVIDX_MASK, index);
320 }
321 /* Function Name:
322 * rtl8367c_getAsic1xGuestVidx
323 * Description:
324 * Get 802.1x guest vlan index
325 * Input:
326 * pIndex - 802.1x guest vlan index (0~31)
327 * Output:
328 * None
329 * Return:
330 * RT_ERR_OK - Success
331 * RT_ERR_SMI - SMI access error
332 * Note:
333 * None
334 */
335 ret_t rtl8367c_getAsic1xGuestVidx(rtk_uint32 *pIndex)
336 {
337 return rtl8367c_getAsicRegBits(RTL8367C_DOT1X_CFG_REG, RTL8367C_DOT1X_GVIDX_MASK, pIndex);
338 }
339 /* Function Name:
340 * rtl8367c_setAsic1xGVOpdir
341 * Description:
342 * Set 802.1x guest vlan talk to auth. DA
343 * Input:
344 * enabled - 0:disable 1:enable
345 * Output:
346 * None
347 * Return:
348 * RT_ERR_OK - Success
349 * RT_ERR_SMI - SMI access error
350 * Note:
351 * None
352 */
353 ret_t rtl8367c_setAsic1xGVOpdir(rtk_uint32 enabled)
354 {
355 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_CFG_REG, RTL8367C_DOT1X_GVOPDIR_OFFSET, enabled);
356 }
357 /* Function Name:
358 * rtl8367c_getAsic1xGVOpdir
359 * Description:
360 * Get 802.1x guest vlan talk to auth. DA
361 * Input:
362 * pEnabled - 0:disable 1:enable
363 * Output:
364 * None
365 * Return:
366 * RT_ERR_OK - Success
367 * RT_ERR_SMI - SMI access error
368 * Note:
369 * None
370 */
371 ret_t rtl8367c_getAsic1xGVOpdir(rtk_uint32 *pEnabled)
372 {
373 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_CFG_REG, RTL8367C_DOT1X_GVOPDIR_OFFSET, pEnabled);
374 }
375 /* Function Name:
376 * rtl8367c_setAsic1xTrapPriority
377 * Description:
378 * Set 802.1x Trap priority
379 * Input:
380 * priority - priority (0~7)
381 * Output:
382 * None
383 * Return:
384 * RT_ERR_OK - Success
385 * RT_ERR_SMI - SMI access error
386 * RT_ERR_QOS_INT_PRIORITY - Invalid priority
387 * Note:
388 * None
389 */
390 ret_t rtl8367c_setAsic1xTrapPriority(rtk_uint32 priority)
391 {
392 if(priority > RTL8367C_PRIMAX)
393 return RT_ERR_QOS_INT_PRIORITY;
394
395 return rtl8367c_setAsicRegBits(RTL8367C_REG_QOS_TRAP_PRIORITY0, RTL8367C_DOT1X_PRIORTY_MASK,priority);
396 }
397 /* Function Name:
398 * rtl8367c_getAsic1xTrapPriority
399 * Description:
400 * Get 802.1x Trap priority
401 * Input:
402 * pPriority - priority (0~7)
403 * Output:
404 * None
405 * Return:
406 * RT_ERR_OK - Success
407 * RT_ERR_SMI - SMI access error
408 * Note:
409 * None
410 */
411 ret_t rtl8367c_getAsic1xTrapPriority(rtk_uint32 *pPriority)
412 {
413 return rtl8367c_getAsicRegBits(RTL8367C_REG_QOS_TRAP_PRIORITY0, RTL8367C_DOT1X_PRIORTY_MASK, pPriority);
414 }
415