armvirt: switch to Kernel 5.10
[openwrt/staging/chunkeey.git] / target / linux / mediatek / files-5.4 / drivers / net / phy / rtk / rtl8367c / 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: 75783 $
11 * $Date: 2017-02-13 14:54:53 +0800 (週一, 13 二月 2017) $
12 *
13 * Purpose : RTK switch high-level API for RTL8367/RTL8367C
14 * Feature : Here is a list of all functions and variables in 1X module.
15 *
16 */
17
18 #include <rtk_switch.h>
19 #include <rtk_error.h>
20 #include <dot1x.h>
21 #include <string.h>
22 #include <vlan.h>
23 #include <rtl8367c_asicdrv.h>
24 #include <rtl8367c_asicdrv_dot1x.h>
25 #include <rtl8367c_asicdrv_rma.h>
26 #include <rtl8367c_asicdrv_lut.h>
27 #include <rtl8367c_asicdrv_vlan.h>
28
29 /* Function Name:
30 * rtk_dot1x_unauthPacketOper_set
31 * Description:
32 * Set 802.1x unauth action configuration.
33 * Input:
34 * port - Port id.
35 * unauth_action - 802.1X unauth action.
36 * Output:
37 * None
38 * Return:
39 * RT_ERR_OK - OK
40 * RT_ERR_FAILED - Failed
41 * RT_ERR_SMI - SMI access error
42 * RT_ERR_PORT_ID - Invalid port number.
43 * RT_ERR_INPUT - Invalid input parameter.
44 * Note:
45 * This API can set 802.1x unauth action configuration.
46 * The unauth action is as following:
47 * - DOT1X_ACTION_DROP
48 * - DOT1X_ACTION_TRAP2CPU
49 * - DOT1X_ACTION_GUESTVLAN
50 */
51 rtk_api_ret_t rtk_dot1x_unauthPacketOper_set(rtk_port_t port, rtk_dot1x_unauth_action_t unauth_action)
52 {
53 rtk_api_ret_t retVal;
54
55 /* Check initialization state */
56 RTK_CHK_INIT_STATE();
57
58 /* Check port Valid */
59 RTK_CHK_PORT_VALID(port);
60
61 if (unauth_action >= DOT1X_ACTION_END)
62 return RT_ERR_DOT1X_PROC;
63
64 if ((retVal = rtl8367c_setAsic1xProcConfig(rtk_switch_port_L2P_get(port), unauth_action)) != RT_ERR_OK)
65 return retVal;
66
67 return RT_ERR_OK;
68 }
69
70 /* Function Name:
71 * rtk_dot1x_unauthPacketOper_get
72 * Description:
73 * Get 802.1x unauth action configuration.
74 * Input:
75 * port - Port id.
76 * Output:
77 * pUnauth_action - 802.1X unauth action.
78 * Return:
79 * RT_ERR_OK - OK
80 * RT_ERR_FAILED - Failed
81 * RT_ERR_SMI - SMI access error
82 * RT_ERR_INPUT - Invalid input parameters.
83 * RT_ERR_PORT_ID - Invalid port number.
84 * Note:
85 * This API can get 802.1x unauth action configuration.
86 * The unauth action is as following:
87 * - DOT1X_ACTION_DROP
88 * - DOT1X_ACTION_TRAP2CPU
89 * - DOT1X_ACTION_GUESTVLAN
90 */
91 rtk_api_ret_t rtk_dot1x_unauthPacketOper_get(rtk_port_t port, rtk_dot1x_unauth_action_t *pUnauth_action)
92 {
93 rtk_api_ret_t retVal;
94
95 /* Check initialization state */
96 RTK_CHK_INIT_STATE();
97
98 /* Check port Valid */
99 RTK_CHK_PORT_VALID(port);
100
101 if(NULL == pUnauth_action)
102 return RT_ERR_NULL_POINTER;
103
104 if ((retVal = rtl8367c_getAsic1xProcConfig(rtk_switch_port_L2P_get(port), pUnauth_action)) != RT_ERR_OK)
105 return retVal;
106
107 return RT_ERR_OK;
108 }
109
110 /* Function Name:
111 * rtk_dot1x_eapolFrame2CpuEnable_set
112 * Description:
113 * Set 802.1x EAPOL packet trap to CPU configuration
114 * Input:
115 * enable - The status of 802.1x EAPOL packet.
116 * Output:
117 * None
118 * Return:
119 * RT_ERR_OK - OK
120 * RT_ERR_FAILED - Failed
121 * RT_ERR_SMI - SMI access error
122 * RT_ERR_ENABLE - Invalid enable input.
123 * Note:
124 * To support 802.1x authentication functionality, EAPOL frame (ether type = 0x888E) has to
125 * be trapped to CPU.
126 * The status of EAPOL frame trap to CPU is as following:
127 * - DISABLED
128 * - ENABLED
129 */
130 rtk_api_ret_t rtk_dot1x_eapolFrame2CpuEnable_set(rtk_enable_t enable)
131 {
132 rtk_api_ret_t retVal;
133 rtl8367c_rma_t rmacfg;
134
135 /* Check initialization state */
136 RTK_CHK_INIT_STATE();
137
138 if (enable >= RTK_ENABLE_END)
139 return RT_ERR_ENABLE;
140
141 if ((retVal = rtl8367c_getAsicRma(3, &rmacfg)) != RT_ERR_OK)
142 return retVal;
143
144 if (ENABLED == enable)
145 rmacfg.operation = RMAOP_TRAP_TO_CPU;
146 else if (DISABLED == enable)
147 rmacfg.operation = RMAOP_FORWARD;
148
149 if ((retVal = rtl8367c_setAsicRma(3, &rmacfg)) != RT_ERR_OK)
150 return retVal;
151
152 return RT_ERR_OK;
153 }
154
155 /* Function Name:
156 * rtk_dot1x_eapolFrame2CpuEnable_get
157 * Description:
158 * Get 802.1x EAPOL packet trap to CPU configuration
159 * Input:
160 * None
161 * Output:
162 * pEnable - The status of 802.1x EAPOL packet.
163 * Return:
164 * RT_ERR_OK - OK
165 * RT_ERR_FAILED - Failed
166 * RT_ERR_SMI - SMI access error
167 * RT_ERR_INPUT - Invalid input parameters.
168 * Note:
169 * To support 802.1x authentication functionality, EAPOL frame (ether type = 0x888E) has to
170 * be trapped to CPU.
171 * The status of EAPOL frame trap to CPU is as following:
172 * - DISABLED
173 * - ENABLED
174 */
175 rtk_api_ret_t rtk_dot1x_eapolFrame2CpuEnable_get(rtk_enable_t *pEnable)
176 {
177 rtk_api_ret_t retVal;
178 rtl8367c_rma_t rmacfg;
179
180 /* Check initialization state */
181 RTK_CHK_INIT_STATE();
182
183 if(NULL == pEnable)
184 return RT_ERR_NULL_POINTER;
185
186 if ((retVal = rtl8367c_getAsicRma(3, &rmacfg)) != RT_ERR_OK)
187 return retVal;
188
189 if (RMAOP_TRAP_TO_CPU == rmacfg.operation)
190 *pEnable = ENABLED;
191 else
192 *pEnable = DISABLED;
193
194 return RT_ERR_OK;
195 }
196
197 /* Function Name:
198 * rtk_dot1x_portBasedEnable_set
199 * Description:
200 * Set 802.1x port-based enable configuration
201 * Input:
202 * port - Port id.
203 * enable - The status of 802.1x port.
204 * Output:
205 * None
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_ENABLE - Invalid enable input.
212 * RT_ERR_DOT1X_PORTBASEDPNEN - 802.1X port-based enable error
213 * Note:
214 * The API can update the port-based port enable register content. If a port is 802.1x
215 * port based network access control "enabled", it should be authenticated so packets
216 * from that port won't be dropped or trapped to CPU.
217 * The status of 802.1x port-based network access control is as following:
218 * - DISABLED
219 * - ENABLED
220 */
221 rtk_api_ret_t rtk_dot1x_portBasedEnable_set(rtk_port_t port, rtk_enable_t enable)
222 {
223 rtk_api_ret_t retVal;
224
225 /* Check initialization state */
226 RTK_CHK_INIT_STATE();
227
228 /* Check port Valid */
229 RTK_CHK_PORT_VALID(port);
230
231 if (enable >= RTK_ENABLE_END)
232 return RT_ERR_ENABLE;
233
234 if ((retVal = rtl8367c_setAsic1xPBEnConfig(rtk_switch_port_L2P_get(port),enable)) != RT_ERR_OK)
235 return retVal;
236
237 return RT_ERR_OK;
238 }
239
240 /* Function Name:
241 * rtk_dot1x_portBasedEnable_get
242 * Description:
243 * Get 802.1x port-based enable configuration
244 * Input:
245 * port - Port id.
246 * Output:
247 * pEnable - The status of 802.1x port.
248 * Return:
249 * RT_ERR_OK - OK
250 * RT_ERR_FAILED - Failed
251 * RT_ERR_SMI - SMI access error
252 * RT_ERR_INPUT - Invalid input parameters.
253 * RT_ERR_PORT_ID - Invalid port number.
254 * Note:
255 * The API can get the 802.1x port-based port status.
256 */
257 rtk_api_ret_t rtk_dot1x_portBasedEnable_get(rtk_port_t port, rtk_enable_t *pEnable)
258 {
259 rtk_api_ret_t retVal;
260
261 /* Check initialization state */
262 RTK_CHK_INIT_STATE();
263
264 /* Check port Valid */
265 RTK_CHK_PORT_VALID(port);
266
267 if(NULL == pEnable)
268 return RT_ERR_NULL_POINTER;
269
270 if ((retVal = rtl8367c_getAsic1xPBEnConfig(rtk_switch_port_L2P_get(port), pEnable)) != RT_ERR_OK)
271 return retVal;
272
273 return RT_ERR_OK;
274 }
275
276 /* Function Name:
277 * rtk_dot1x_portBasedAuthStatus_set
278 * Description:
279 * Set 802.1x port-based auth. port configuration
280 * Input:
281 * port - Port id.
282 * port_auth - The status of 802.1x port.
283 * Output:
284 * None
285 * Return:
286 * RT_ERR_OK - OK
287 * RT_ERR_FAILED - Failed
288 * RT_ERR_SMI - SMI access error
289 * RT_ERR_PORT_ID - Invalid port number.
290 * RT_ERR_DOT1X_PORTBASEDAUTH - 802.1X port-based auth error
291 * Note:
292 * The authenticated status of 802.1x port-based network access control is as following:
293 * - UNAUTH
294 * - AUTH
295 */
296 rtk_api_ret_t rtk_dot1x_portBasedAuthStatus_set(rtk_port_t port, rtk_dot1x_auth_status_t port_auth)
297 {
298 rtk_api_ret_t retVal;
299
300 /* Check initialization state */
301 RTK_CHK_INIT_STATE();
302
303 /* Check port Valid */
304 RTK_CHK_PORT_VALID(port);
305
306 if (port_auth >= AUTH_STATUS_END)
307 return RT_ERR_DOT1X_PORTBASEDAUTH;
308
309 if ((retVal = rtl8367c_setAsic1xPBAuthConfig(rtk_switch_port_L2P_get(port), port_auth)) != RT_ERR_OK)
310 return retVal;
311
312
313 return RT_ERR_OK;
314 }
315
316 /* Function Name:
317 * rtk_dot1x_portBasedAuthStatus_get
318 * Description:
319 * Get 802.1x port-based auth. port configuration
320 * Input:
321 * port - Port id.
322 * Output:
323 * pPort_auth - The status of 802.1x port.
324 * Return:
325 * RT_ERR_OK - OK
326 * RT_ERR_FAILED - Failed
327 * RT_ERR_SMI - SMI access error
328 * RT_ERR_INPUT - Invalid input parameters.
329 * RT_ERR_PORT_ID - Invalid port number.
330 * Note:
331 * The API can get 802.1x port-based port auth.information.
332 */
333 rtk_api_ret_t rtk_dot1x_portBasedAuthStatus_get(rtk_port_t port, rtk_dot1x_auth_status_t *pPort_auth)
334 {
335 rtk_api_ret_t retVal;
336
337 /* Check initialization state */
338 RTK_CHK_INIT_STATE();
339
340 if(NULL == pPort_auth)
341 return RT_ERR_NULL_POINTER;
342
343 /* Check port Valid */
344 RTK_CHK_PORT_VALID(port);
345
346 if ((retVal = rtl8367c_getAsic1xPBAuthConfig(rtk_switch_port_L2P_get(port), pPort_auth)) != RT_ERR_OK)
347 return retVal;
348 return RT_ERR_OK;
349 }
350
351 /* Function Name:
352 * rtk_dot1x_portBasedDirection_set
353 * Description:
354 * Set 802.1x port-based operational direction configuration
355 * Input:
356 * port - Port id.
357 * port_direction - Operation direction
358 * Output:
359 * None
360 * Return:
361 * RT_ERR_OK - OK
362 * RT_ERR_FAILED - Failed
363 * RT_ERR_SMI - SMI access error
364 * RT_ERR_PORT_ID - Invalid port number.
365 * RT_ERR_DOT1X_PORTBASEDOPDIR - 802.1X port-based operation direction error
366 * Note:
367 * The operate controlled direction of 802.1x port-based network access control is as following:
368 * - BOTH
369 * - IN
370 */
371 rtk_api_ret_t rtk_dot1x_portBasedDirection_set(rtk_port_t port, rtk_dot1x_direction_t port_direction)
372 {
373 rtk_api_ret_t retVal;
374
375 /* Check initialization state */
376 RTK_CHK_INIT_STATE();
377
378 /* Check port Valid */
379 RTK_CHK_PORT_VALID(port);
380
381 if (port_direction >= DIRECTION_END)
382 return RT_ERR_DOT1X_PORTBASEDOPDIR;
383
384 if ((retVal = rtl8367c_setAsic1xPBOpdirConfig(rtk_switch_port_L2P_get(port), port_direction)) != RT_ERR_OK)
385 return retVal;
386
387 return RT_ERR_OK;
388 }
389
390 /* Function Name:
391 * rtk_dot1x_portBasedDirection_get
392 * Description:
393 * Get 802.1X port-based operational direction configuration
394 * Input:
395 * port - Port id.
396 * Output:
397 * pPort_direction - Operation direction
398 * Return:
399 * RT_ERR_OK - OK
400 * RT_ERR_FAILED - Failed
401 * RT_ERR_SMI - SMI access error
402 * RT_ERR_INPUT - Invalid input parameters.
403 * RT_ERR_PORT_ID - Invalid port number.
404 * Note:
405 * The API can get 802.1x port-based operational direction information.
406 */
407 rtk_api_ret_t rtk_dot1x_portBasedDirection_get(rtk_port_t port, rtk_dot1x_direction_t *pPort_direction)
408 {
409 rtk_api_ret_t retVal;
410
411 /* Check initialization state */
412 RTK_CHK_INIT_STATE();
413
414 if(NULL == pPort_direction)
415 return RT_ERR_NULL_POINTER;
416
417 /* Check port Valid */
418 RTK_CHK_PORT_VALID(port);
419
420 if ((retVal = rtl8367c_getAsic1xPBOpdirConfig(rtk_switch_port_L2P_get(port), pPort_direction)) != RT_ERR_OK)
421 return retVal;
422
423 return RT_ERR_OK;
424 }
425
426 /* Function Name:
427 * rtk_dot1x_macBasedEnable_set
428 * Description:
429 * Set 802.1x mac-based port enable configuration
430 * Input:
431 * port - Port id.
432 * enable - The status of 802.1x port.
433 * Output:
434 * None
435 * Return:
436 * RT_ERR_OK - OK
437 * RT_ERR_FAILED - Failed
438 * RT_ERR_SMI - SMI access error
439 * RT_ERR_PORT_ID - Invalid port number.
440 * RT_ERR_ENABLE - Invalid enable input.
441 * RT_ERR_DOT1X_MACBASEDPNEN - 802.1X mac-based enable error
442 * Note:
443 * If a port is 802.1x MAC based network access control "enabled", the incoming packets should
444 * be authenticated so packets from that port won't be dropped or trapped to CPU.
445 * The status of 802.1x MAC-based network access control is as following:
446 * - DISABLED
447 * - ENABLED
448 */
449 rtk_api_ret_t rtk_dot1x_macBasedEnable_set(rtk_port_t port, rtk_enable_t enable)
450 {
451 rtk_api_ret_t retVal;
452
453 /* Check initialization state */
454 RTK_CHK_INIT_STATE();
455
456 /* Check port Valid */
457 RTK_CHK_PORT_VALID(port);
458
459 if (enable >= RTK_ENABLE_END)
460 return RT_ERR_ENABLE;
461
462 if ((retVal = rtl8367c_setAsic1xMBEnConfig(rtk_switch_port_L2P_get(port),enable)) != RT_ERR_OK)
463 return retVal;
464
465 return RT_ERR_OK;
466 }
467
468 /* Function Name:
469 * rtk_dot1x_macBasedEnable_get
470 * Description:
471 * Get 802.1x mac-based port enable configuration
472 * Input:
473 * port - Port id.
474 * Output:
475 * pEnable - The status of 802.1x port.
476 * Return:
477 * RT_ERR_OK - OK
478 * RT_ERR_FAILED - Failed
479 * RT_ERR_SMI - SMI access error
480 * RT_ERR_INPUT - Invalid input parameters.
481 * RT_ERR_PORT_ID - Invalid port number.
482 * Note:
483 * If a port is 802.1x MAC based network access control "enabled", the incoming packets should
484 * be authenticated so packets from that port wont be dropped or trapped to CPU.
485 * The status of 802.1x MAC-based network access control is as following:
486 * - DISABLED
487 * - ENABLED
488 */
489 rtk_api_ret_t rtk_dot1x_macBasedEnable_get(rtk_port_t port, rtk_enable_t *pEnable)
490 {
491 rtk_api_ret_t retVal;
492
493 /* Check initialization state */
494 RTK_CHK_INIT_STATE();
495
496 if(NULL == pEnable)
497 return RT_ERR_NULL_POINTER;
498
499 /* Check port Valid */
500 RTK_CHK_PORT_VALID(port);
501
502 if ((retVal = rtl8367c_getAsic1xMBEnConfig(rtk_switch_port_L2P_get(port), pEnable)) != RT_ERR_OK)
503 return retVal;
504
505 return RT_ERR_OK;
506 }
507
508 /* Function Name:
509 * rtk_dot1x_macBasedAuthMac_add
510 * Description:
511 * Add an authenticated MAC to ASIC
512 * Input:
513 * port - Port id.
514 * pAuth_mac - The authenticated MAC.
515 * fid - filtering database.
516 * Output:
517 * None
518 * Return:
519 * RT_ERR_OK - OK
520 * RT_ERR_FAILED - Failed
521 * RT_ERR_SMI - SMI access error
522 * RT_ERR_PORT_ID - Invalid port number.
523 * RT_ERR_ENABLE - Invalid enable input.
524 * RT_ERR_DOT1X_MACBASEDPNEN - 802.1X mac-based enable error
525 * Note:
526 * The API can add a 802.1x authenticated MAC address to port. If the MAC does not exist in LUT,
527 * user can't add this MAC to auth status.
528 */
529 rtk_api_ret_t rtk_dot1x_macBasedAuthMac_add(rtk_port_t port, rtk_mac_t *pAuth_mac, rtk_fid_t fid)
530 {
531 rtk_api_ret_t retVal;
532 rtk_uint32 method;
533 rtl8367c_luttb l2Table;
534
535 /* Check initialization state */
536 RTK_CHK_INIT_STATE();
537
538 /* must be unicast address */
539 if ((pAuth_mac == NULL) || (pAuth_mac->octet[0] & 0x1))
540 return RT_ERR_MAC;
541
542 /* Check port Valid */
543 RTK_CHK_PORT_VALID(port);
544
545 if (fid > RTL8367C_FIDMAX)
546 return RT_ERR_L2_FID;
547
548 memset(&l2Table, 0, sizeof(rtl8367c_luttb));
549
550 /* fill key (MAC,FID) to get L2 entry */
551 memcpy(l2Table.mac.octet, pAuth_mac->octet, ETHER_ADDR_LEN);
552 l2Table.fid = fid;
553 method = LUTREADMETHOD_MAC;
554 retVal = rtl8367c_getAsicL2LookupTb(method, &l2Table);
555 if ( RT_ERR_OK == retVal)
556 {
557 if (l2Table.spa != rtk_switch_port_L2P_get(port))
558 return RT_ERR_DOT1X_MAC_PORT_MISMATCH;
559
560 memcpy(l2Table.mac.octet, pAuth_mac->octet, ETHER_ADDR_LEN);
561 l2Table.fid = fid;
562 l2Table.efid = 0;
563 l2Table.auth = 1;
564 retVal = rtl8367c_setAsicL2LookupTb(&l2Table);
565 return retVal;
566 }
567 else
568 return retVal;
569
570 }
571
572 /* Function Name:
573 * rtk_dot1x_macBasedAuthMac_del
574 * Description:
575 * Delete an authenticated MAC to ASIC
576 * Input:
577 * port - Port id.
578 * pAuth_mac - The authenticated MAC.
579 * fid - filtering database.
580 * Output:
581 * None
582 * Return:
583 * RT_ERR_OK - OK
584 * RT_ERR_FAILED - Failed
585 * RT_ERR_SMI - SMI access error
586 * RT_ERR_MAC - Invalid MAC address.
587 * RT_ERR_PORT_ID - Invalid port number.
588 * Note:
589 * The API can delete a 802.1x authenticated MAC address to port. It only change the auth status of
590 * the MAC and won't delete it from LUT.
591 */
592 rtk_api_ret_t rtk_dot1x_macBasedAuthMac_del(rtk_port_t port, rtk_mac_t *pAuth_mac, rtk_fid_t fid)
593 {
594 rtk_api_ret_t retVal;
595 rtk_uint32 method;
596 rtl8367c_luttb l2Table;
597
598 /* Check initialization state */
599 RTK_CHK_INIT_STATE();
600
601 /* must be unicast address */
602 if ((pAuth_mac == NULL) || (pAuth_mac->octet[0] & 0x1))
603 return RT_ERR_MAC;
604
605 /* Check port Valid */
606 RTK_CHK_PORT_VALID(port);
607
608 if (fid > RTL8367C_FIDMAX)
609 return RT_ERR_L2_FID;
610
611 memset(&l2Table, 0, sizeof(rtl8367c_luttb));
612
613 /* fill key (MAC,FID) to get L2 entry */
614 memcpy(l2Table.mac.octet, pAuth_mac->octet, ETHER_ADDR_LEN);
615 l2Table.fid = fid;
616 method = LUTREADMETHOD_MAC;
617 retVal = rtl8367c_getAsicL2LookupTb(method, &l2Table);
618 if (RT_ERR_OK == retVal)
619 {
620 if (l2Table.spa != rtk_switch_port_L2P_get(port))
621 return RT_ERR_DOT1X_MAC_PORT_MISMATCH;
622
623 memcpy(l2Table.mac.octet, pAuth_mac->octet, ETHER_ADDR_LEN);
624 l2Table.fid = fid;
625 l2Table.auth = 0;
626 retVal = rtl8367c_setAsicL2LookupTb(&l2Table);
627 return retVal;
628 }
629 else
630 return retVal;
631
632 }
633
634 /* Function Name:
635 * rtk_dot1x_macBasedDirection_set
636 * Description:
637 * Set 802.1x mac-based operational direction configuration
638 * Input:
639 * mac_direction - Operation direction
640 * Output:
641 * None
642 * Return:
643 * RT_ERR_OK - OK
644 * RT_ERR_FAILED - Failed
645 * RT_ERR_SMI - SMI access error
646 * RT_ERR_INPUT - Invalid input parameter.
647 * RT_ERR_DOT1X_MACBASEDOPDIR - 802.1X mac-based operation direction error
648 * Note:
649 * The operate controlled direction of 802.1x mac-based network access control is as following:
650 * - BOTH
651 * - IN
652 */
653 rtk_api_ret_t rtk_dot1x_macBasedDirection_set(rtk_dot1x_direction_t mac_direction)
654 {
655 rtk_api_ret_t retVal;
656
657 /* Check initialization state */
658 RTK_CHK_INIT_STATE();
659
660 if (mac_direction >= DIRECTION_END)
661 return RT_ERR_DOT1X_MACBASEDOPDIR;
662
663 if ((retVal = rtl8367c_setAsic1xMBOpdirConfig(mac_direction)) != RT_ERR_OK)
664 return retVal;
665
666 return RT_ERR_OK;
667 }
668
669 /* Function Name:
670 * rtk_dot1x_macBasedDirection_get
671 * Description:
672 * Get 802.1x mac-based operational direction configuration
673 * Input:
674 * port - Port id.
675 * Output:
676 * pMac_direction - Operation direction
677 * Return:
678 * RT_ERR_OK - OK
679 * RT_ERR_FAILED - Failed
680 * RT_ERR_SMI - SMI access error
681 * RT_ERR_INPUT - Invalid input parameters.
682 * Note:
683 * The API can get 802.1x mac-based operational direction information.
684 */
685 rtk_api_ret_t rtk_dot1x_macBasedDirection_get(rtk_dot1x_direction_t *pMac_direction)
686 {
687 rtk_api_ret_t retVal;
688
689 /* Check initialization state */
690 RTK_CHK_INIT_STATE();
691
692 if(NULL == pMac_direction)
693 return RT_ERR_NULL_POINTER;
694
695 if ((retVal = rtl8367c_getAsic1xMBOpdirConfig(pMac_direction)) != RT_ERR_OK)
696 return retVal;
697
698 return RT_ERR_OK;
699 }
700
701 /* Function Name:
702 * Set 802.1x guest VLAN configuration
703 * Description:
704 * Set 802.1x mac-based operational direction configuration
705 * Input:
706 * vid - 802.1x guest VLAN ID
707 * Output:
708 * None
709 * Return:
710 * RT_ERR_OK - OK
711 * RT_ERR_FAILED - Failed
712 * RT_ERR_SMI - SMI access error
713 * RT_ERR_INPUT - Invalid input parameter.
714 * Note:
715 * The operate controlled 802.1x guest VLAN
716 */
717 rtk_api_ret_t rtk_dot1x_guestVlan_set(rtk_vlan_t vid)
718 {
719 rtk_api_ret_t retVal;
720 rtk_uint32 index;
721
722 /* Check initialization state */
723 RTK_CHK_INIT_STATE();
724
725 /* vid must be 0~4095 */
726 if (vid > RTL8367C_VIDMAX)
727 return RT_ERR_VLAN_VID;
728
729 if((retVal = rtk_vlan_checkAndCreateMbr(vid, &index)) != RT_ERR_OK)
730 return retVal;
731
732 if ((retVal = rtl8367c_setAsic1xGuestVidx(index)) != RT_ERR_OK)
733 return retVal;
734
735 return RT_ERR_OK;
736 }
737
738 /* Function Name:
739 * rtk_dot1x_guestVlan_get
740 * Description:
741 * Get 802.1x guest VLAN configuration
742 * Input:
743 * None
744 * Output:
745 * pVid - 802.1x guest VLAN ID
746 * Return:
747 * RT_ERR_OK - OK
748 * RT_ERR_FAILED - Failed
749 * RT_ERR_SMI - SMI access error
750 * RT_ERR_INPUT - Invalid input parameters.
751 * Note:
752 * The API can get 802.1x guest VLAN information.
753 */
754 rtk_api_ret_t rtk_dot1x_guestVlan_get(rtk_vlan_t *pVid)
755 {
756 rtk_api_ret_t retVal;
757 rtk_uint32 gvidx;
758 rtl8367c_vlanconfiguser vlanMC;
759
760 /* Check initialization state */
761 RTK_CHK_INIT_STATE();
762
763 if(NULL == pVid)
764 return RT_ERR_NULL_POINTER;
765
766 if ((retVal = rtl8367c_getAsic1xGuestVidx(&gvidx)) != RT_ERR_OK)
767 return retVal;
768
769 if ((retVal = rtl8367c_getAsicVlanMemberConfig(gvidx, &vlanMC)) != RT_ERR_OK)
770 return retVal;
771
772 *pVid = vlanMC.evid;
773
774 return RT_ERR_OK;
775 }
776
777 /* Function Name:
778 * rtk_dot1x_guestVlan2Auth_set
779 * Description:
780 * Set 802.1x guest VLAN to auth host configuration
781 * Input:
782 * enable - The status of guest VLAN to auth host.
783 * Output:
784 * None
785 * Return:
786 * RT_ERR_OK - OK
787 * RT_ERR_FAILED - Failed
788 * RT_ERR_SMI - SMI access error
789 * RT_ERR_INPUT - Invalid input parameter.
790 * Note:
791 * The operational direction of 802.1x guest VLAN to auth host control is as following:
792 * - ENABLED
793 * - DISABLED
794 */
795 rtk_api_ret_t rtk_dot1x_guestVlan2Auth_set(rtk_enable_t enable)
796 {
797 rtk_api_ret_t retVal;
798
799 /* Check initialization state */
800 RTK_CHK_INIT_STATE();
801
802 if (enable >= RTK_ENABLE_END)
803 return RT_ERR_ENABLE;
804
805 if ((retVal = rtl8367c_setAsic1xGVOpdir(enable)) != RT_ERR_OK)
806 return retVal;
807
808 return RT_ERR_OK;
809 }
810
811 /* Function Name:
812 * rtk_dot1x_guestVlan2Auth_get
813 * Description:
814 * Get 802.1x guest VLAN to auth host configuration
815 * Input:
816 * None
817 * Output:
818 * pEnable - The status of guest VLAN to auth host.
819 * Return:
820 * RT_ERR_OK - OK
821 * RT_ERR_FAILED - Failed
822 * RT_ERR_SMI - SMI access error
823 * RT_ERR_INPUT - Invalid input parameters.
824 * Note:
825 * The API can get 802.1x guest VLAN to auth host information.
826 */
827 rtk_api_ret_t rtk_dot1x_guestVlan2Auth_get(rtk_enable_t *pEnable)
828 {
829 rtk_api_ret_t retVal;
830
831 /* Check initialization state */
832 RTK_CHK_INIT_STATE();
833
834 if(NULL == pEnable)
835 return RT_ERR_NULL_POINTER;
836
837 if ((retVal = rtl8367c_getAsic1xGVOpdir(pEnable)) != RT_ERR_OK)
838 return retVal;
839
840 return RT_ERR_OK;
841 }
842
843