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
11 * $Date: 2017-03-08 15:13:58 +0800 (週三, 08 三月 2017) $
13 * Purpose : RTK switch high-level API for RTL8367/RTL8367C
14 * Feature : Here is a list of all functions and variables in Leaky module.
18 #include <rtk_switch.h>
19 #include <rtk_error.h>
23 #include <rtl8367c_asicdrv.h>
24 #include <rtl8367c_asicdrv_portIsolation.h>
25 #include <rtl8367c_asicdrv_rma.h>
26 #include <rtl8367c_asicdrv_igmp.h>
34 * type - Packet type for VLAN leaky.
35 * enable - Leaky status.
40 * RT_ERR_FAILED - Failed
41 * RT_ERR_SMI - SMI access error
42 * RT_ERR_INPUT - Invalid input parameters.
43 * RT_ERR_ENABLE - Invalid enable input
45 * This API can set VLAN leaky for RMA ,IGMP/MLD, CDP, CSSTP, and LLDP packets.
46 * The leaky frame types are as following:
51 * - LEAKY_UNDEF_BRG_04,
52 * - LEAKY_UNDEF_BRG_05,
53 * - LEAKY_UNDEF_BRG_06,
54 * - LEAKY_UNDEF_BRG_07,
55 * - LEAKY_PROVIDER_BRIDGE_GROUP_ADDRESS,
56 * - LEAKY_UNDEF_BRG_09,
57 * - LEAKY_UNDEF_BRG_0A,
58 * - LEAKY_UNDEF_BRG_0B,
59 * - LEAKY_UNDEF_BRG_0C,
60 * - LEAKY_PROVIDER_BRIDGE_GVRP_ADDRESS,
62 * - LEAKY_UNDEF_BRG_0F,
63 * - LEAKY_BRG_MNGEMENT,
64 * - LEAKY_UNDEFINED_11,
65 * - LEAKY_UNDEFINED_12,
66 * - LEAKY_UNDEFINED_13,
67 * - LEAKY_UNDEFINED_14,
68 * - LEAKY_UNDEFINED_15,
69 * - LEAKY_UNDEFINED_16,
70 * - LEAKY_UNDEFINED_17,
71 * - LEAKY_UNDEFINED_18,
72 * - LEAKY_UNDEFINED_19,
73 * - LEAKY_UNDEFINED_1A,
74 * - LEAKY_UNDEFINED_1B,
75 * - LEAKY_UNDEFINED_1C,
76 * - LEAKY_UNDEFINED_1D,
77 * - LEAKY_UNDEFINED_1E,
78 * - LEAKY_UNDEFINED_1F,
81 * - LEAKY_UNDEF_GARP_22,
82 * - LEAKY_UNDEF_GARP_23,
83 * - LEAKY_UNDEF_GARP_24,
84 * - LEAKY_UNDEF_GARP_25,
85 * - LEAKY_UNDEF_GARP_26,
86 * - LEAKY_UNDEF_GARP_27,
87 * - LEAKY_UNDEF_GARP_28,
88 * - LEAKY_UNDEF_GARP_29,
89 * - LEAKY_UNDEF_GARP_2A,
90 * - LEAKY_UNDEF_GARP_2B,
91 * - LEAKY_UNDEF_GARP_2C,
92 * - LEAKY_UNDEF_GARP_2D,
93 * - LEAKY_UNDEF_GARP_2E,
94 * - LEAKY_UNDEF_GARP_2F,
96 * - LEAKY_IPMULTICAST.
101 rtk_api_ret_t
rtk_leaky_vlan_set(rtk_leaky_type_t type
, rtk_enable_t enable
)
103 rtk_api_ret_t retVal
;
105 rtl8367c_rma_t rmacfg
;
108 /* Check initialization state */
109 RTK_CHK_INIT_STATE();
111 if (type
>= LEAKY_END
)
114 if (enable
>= RTK_ENABLE_END
)
117 if (type
>= 0 && type
<= LEAKY_UNDEF_GARP_2F
)
119 if ((retVal
= rtl8367c_getAsicRma(type
, &rmacfg
)) != RT_ERR_OK
)
122 rmacfg
.vlan_leaky
= enable
;
124 if ((retVal
= rtl8367c_setAsicRma(type
, &rmacfg
)) != RT_ERR_OK
)
127 else if (LEAKY_IPMULTICAST
== type
)
129 for (port
= 0; port
<= RTK_PORT_ID_MAX
; port
++)
131 if ((retVal
= rtl8367c_setAsicIpMulticastVlanLeaky(port
,enable
)) != RT_ERR_OK
)
135 else if (LEAKY_IGMP
== type
)
137 if ((retVal
= rtl8367c_setAsicIGMPVLANLeaky(enable
)) != RT_ERR_OK
)
140 else if (LEAKY_CDP
== type
)
142 if ((retVal
= rtl8367c_getAsicRmaCdp(&rmacfg
)) != RT_ERR_OK
)
145 rmacfg
.vlan_leaky
= enable
;
147 if ((retVal
= rtl8367c_setAsicRmaCdp(&rmacfg
)) != RT_ERR_OK
)
150 else if (LEAKY_CSSTP
== type
)
152 if ((retVal
= rtl8367c_getAsicRmaCsstp(&rmacfg
)) != RT_ERR_OK
)
155 rmacfg
.vlan_leaky
= enable
;
157 if ((retVal
= rtl8367c_setAsicRmaCsstp(&rmacfg
)) != RT_ERR_OK
)
160 else if (LEAKY_LLDP
== type
)
162 if ((retVal
= rtl8367c_getAsicRmaLldp(&tmp
,&rmacfg
)) != RT_ERR_OK
)
165 rmacfg
.vlan_leaky
= enable
;
167 if ((retVal
= rtl8367c_setAsicRmaLldp(tmp
, &rmacfg
)) != RT_ERR_OK
)
179 * type - Packet type for VLAN leaky.
181 * pEnable - Leaky status.
184 * RT_ERR_FAILED - Failed
185 * RT_ERR_SMI - SMI access error
186 * RT_ERR_INPUT - Invalid input parameters.
188 * This API can get VLAN leaky status for RMA ,IGMP/MLD, CDP, CSSTP, and LLDP packets.
189 * The leaky frame types are as following:
194 * - LEAKY_UNDEF_BRG_04,
195 * - LEAKY_UNDEF_BRG_05,
196 * - LEAKY_UNDEF_BRG_06,
197 * - LEAKY_UNDEF_BRG_07,
198 * - LEAKY_PROVIDER_BRIDGE_GROUP_ADDRESS,
199 * - LEAKY_UNDEF_BRG_09,
200 * - LEAKY_UNDEF_BRG_0A,
201 * - LEAKY_UNDEF_BRG_0B,
202 * - LEAKY_UNDEF_BRG_0C,
203 * - LEAKY_PROVIDER_BRIDGE_GVRP_ADDRESS,
205 * - LEAKY_UNDEF_BRG_0F,
206 * - LEAKY_BRG_MNGEMENT,
207 * - LEAKY_UNDEFINED_11,
208 * - LEAKY_UNDEFINED_12,
209 * - LEAKY_UNDEFINED_13,
210 * - LEAKY_UNDEFINED_14,
211 * - LEAKY_UNDEFINED_15,
212 * - LEAKY_UNDEFINED_16,
213 * - LEAKY_UNDEFINED_17,
214 * - LEAKY_UNDEFINED_18,
215 * - LEAKY_UNDEFINED_19,
216 * - LEAKY_UNDEFINED_1A,
217 * - LEAKY_UNDEFINED_1B,
218 * - LEAKY_UNDEFINED_1C,
219 * - LEAKY_UNDEFINED_1D,
220 * - LEAKY_UNDEFINED_1E,
221 * - LEAKY_UNDEFINED_1F,
224 * - LEAKY_UNDEF_GARP_22,
225 * - LEAKY_UNDEF_GARP_23,
226 * - LEAKY_UNDEF_GARP_24,
227 * - LEAKY_UNDEF_GARP_25,
228 * - LEAKY_UNDEF_GARP_26,
229 * - LEAKY_UNDEF_GARP_27,
230 * - LEAKY_UNDEF_GARP_28,
231 * - LEAKY_UNDEF_GARP_29,
232 * - LEAKY_UNDEF_GARP_2A,
233 * - LEAKY_UNDEF_GARP_2B,
234 * - LEAKY_UNDEF_GARP_2C,
235 * - LEAKY_UNDEF_GARP_2D,
236 * - LEAKY_UNDEF_GARP_2E,
237 * - LEAKY_UNDEF_GARP_2F,
239 * - LEAKY_IPMULTICAST.
244 rtk_api_ret_t
rtk_leaky_vlan_get(rtk_leaky_type_t type
, rtk_enable_t
*pEnable
)
246 rtk_api_ret_t retVal
;
248 rtl8367c_rma_t rmacfg
;
250 /* Check initialization state */
251 RTK_CHK_INIT_STATE();
253 if (type
>= LEAKY_END
)
257 return RT_ERR_NULL_POINTER
;
259 if (type
>= 0 && type
<= LEAKY_UNDEF_GARP_2F
)
261 if ((retVal
= rtl8367c_getAsicRma(type
, &rmacfg
)) != RT_ERR_OK
)
264 *pEnable
= rmacfg
.vlan_leaky
;
267 else if (LEAKY_IPMULTICAST
== type
)
269 for (port
= 0; port
<= RTK_PORT_ID_MAX
; port
++)
271 if ((retVal
= rtl8367c_getAsicIpMulticastVlanLeaky(port
, &tmp
)) != RT_ERR_OK
)
273 if (port
>0&&(tmp
!=*pEnable
))
274 return RT_ERR_FAILED
;
278 else if (LEAKY_IGMP
== type
)
280 if ((retVal
= rtl8367c_getAsicIGMPVLANLeaky(&tmp
)) != RT_ERR_OK
)
285 else if (LEAKY_CDP
== type
)
287 if ((retVal
= rtl8367c_getAsicRmaCdp(&rmacfg
)) != RT_ERR_OK
)
290 *pEnable
= rmacfg
.vlan_leaky
;
292 else if (LEAKY_CSSTP
== type
)
294 if ((retVal
= rtl8367c_getAsicRmaCsstp(&rmacfg
)) != RT_ERR_OK
)
297 *pEnable
= rmacfg
.vlan_leaky
;
299 else if (LEAKY_LLDP
== type
)
301 if ((retVal
= rtl8367c_getAsicRmaLldp(&tmp
, &rmacfg
)) != RT_ERR_OK
)
304 *pEnable
= rmacfg
.vlan_leaky
;
311 * rtk_leaky_portIsolation_set
313 * Set port isolation leaky.
315 * type - Packet type for port isolation leaky.
316 * enable - Leaky status.
321 * RT_ERR_FAILED - Failed
322 * RT_ERR_SMI - SMI access error
323 * RT_ERR_INPUT - Invalid input parameters.
324 * RT_ERR_ENABLE - Invalid enable input
326 * This API can set port isolation leaky for RMA ,IGMP/MLD, CDP, CSSTP, and LLDP packets.
327 * The leaky frame types are as following:
332 * - LEAKY_UNDEF_BRG_04,
333 * - LEAKY_UNDEF_BRG_05,
334 * - LEAKY_UNDEF_BRG_06,
335 * - LEAKY_UNDEF_BRG_07,
336 * - LEAKY_PROVIDER_BRIDGE_GROUP_ADDRESS,
337 * - LEAKY_UNDEF_BRG_09,
338 * - LEAKY_UNDEF_BRG_0A,
339 * - LEAKY_UNDEF_BRG_0B,
340 * - LEAKY_UNDEF_BRG_0C,
341 * - LEAKY_PROVIDER_BRIDGE_GVRP_ADDRESS,
343 * - LEAKY_UNDEF_BRG_0F,
344 * - LEAKY_BRG_MNGEMENT,
345 * - LEAKY_UNDEFINED_11,
346 * - LEAKY_UNDEFINED_12,
347 * - LEAKY_UNDEFINED_13,
348 * - LEAKY_UNDEFINED_14,
349 * - LEAKY_UNDEFINED_15,
350 * - LEAKY_UNDEFINED_16,
351 * - LEAKY_UNDEFINED_17,
352 * - LEAKY_UNDEFINED_18,
353 * - LEAKY_UNDEFINED_19,
354 * - LEAKY_UNDEFINED_1A,
355 * - LEAKY_UNDEFINED_1B,
356 * - LEAKY_UNDEFINED_1C,
357 * - LEAKY_UNDEFINED_1D,
358 * - LEAKY_UNDEFINED_1E,
359 * - LEAKY_UNDEFINED_1F,
362 * - LEAKY_UNDEF_GARP_22,
363 * - LEAKY_UNDEF_GARP_23,
364 * - LEAKY_UNDEF_GARP_24,
365 * - LEAKY_UNDEF_GARP_25,
366 * - LEAKY_UNDEF_GARP_26,
367 * - LEAKY_UNDEF_GARP_27,
368 * - LEAKY_UNDEF_GARP_28,
369 * - LEAKY_UNDEF_GARP_29,
370 * - LEAKY_UNDEF_GARP_2A,
371 * - LEAKY_UNDEF_GARP_2B,
372 * - LEAKY_UNDEF_GARP_2C,
373 * - LEAKY_UNDEF_GARP_2D,
374 * - LEAKY_UNDEF_GARP_2E,
375 * - LEAKY_UNDEF_GARP_2F,
377 * - LEAKY_IPMULTICAST.
382 rtk_api_ret_t
rtk_leaky_portIsolation_set(rtk_leaky_type_t type
, rtk_enable_t enable
)
384 rtk_api_ret_t retVal
;
386 rtl8367c_rma_t rmacfg
;
389 /* Check initialization state */
390 RTK_CHK_INIT_STATE();
392 if (type
>= LEAKY_END
)
395 if (enable
>= RTK_ENABLE_END
)
398 if (type
>= 0 && type
<= LEAKY_UNDEF_GARP_2F
)
400 if ((retVal
= rtl8367c_getAsicRma(type
, &rmacfg
)) != RT_ERR_OK
)
403 rmacfg
.portiso_leaky
= enable
;
405 if ((retVal
= rtl8367c_setAsicRma(type
, &rmacfg
)) != RT_ERR_OK
)
408 else if (LEAKY_IPMULTICAST
== type
)
410 for (port
= 0; port
< RTK_MAX_NUM_OF_PORT
; port
++)
412 if ((retVal
= rtl8367c_setAsicIpMulticastPortIsoLeaky(port
,enable
)) != RT_ERR_OK
)
416 else if (LEAKY_IGMP
== type
)
418 if ((retVal
= rtl8367c_setAsicIGMPIsoLeaky(enable
)) != RT_ERR_OK
)
421 else if (LEAKY_CDP
== type
)
423 if ((retVal
= rtl8367c_getAsicRmaCdp(&rmacfg
)) != RT_ERR_OK
)
426 rmacfg
.portiso_leaky
= enable
;
428 if ((retVal
= rtl8367c_setAsicRmaCdp(&rmacfg
)) != RT_ERR_OK
)
431 else if (LEAKY_CSSTP
== type
)
433 if ((retVal
= rtl8367c_getAsicRmaCsstp(&rmacfg
)) != RT_ERR_OK
)
436 rmacfg
.portiso_leaky
= enable
;
438 if ((retVal
= rtl8367c_setAsicRmaCsstp(&rmacfg
)) != RT_ERR_OK
)
441 else if (LEAKY_LLDP
== type
)
443 if ((retVal
= rtl8367c_getAsicRmaLldp(&tmp
, &rmacfg
)) != RT_ERR_OK
)
446 rmacfg
.portiso_leaky
= enable
;
448 if ((retVal
= rtl8367c_setAsicRmaLldp(tmp
, &rmacfg
)) != RT_ERR_OK
)
456 * rtk_leaky_portIsolation_get
458 * Get port isolation leaky.
460 * type - Packet type for port isolation leaky.
462 * pEnable - Leaky status.
465 * RT_ERR_FAILED - Failed
466 * RT_ERR_SMI - SMI access error
467 * RT_ERR_INPUT - Invalid input parameters.
469 * This API can get port isolation leaky status for RMA ,IGMP/MLD, CDP, CSSTP, and LLDP packets.
470 * The leaky frame types are as following:
475 * - LEAKY_UNDEF_BRG_04,
476 * - LEAKY_UNDEF_BRG_05,
477 * - LEAKY_UNDEF_BRG_06,
478 * - LEAKY_UNDEF_BRG_07,
479 * - LEAKY_PROVIDER_BRIDGE_GROUP_ADDRESS,
480 * - LEAKY_UNDEF_BRG_09,
481 * - LEAKY_UNDEF_BRG_0A,
482 * - LEAKY_UNDEF_BRG_0B,
483 * - LEAKY_UNDEF_BRG_0C,
484 * - LEAKY_PROVIDER_BRIDGE_GVRP_ADDRESS,
486 * - LEAKY_UNDEF_BRG_0F,
487 * - LEAKY_BRG_MNGEMENT,
488 * - LEAKY_UNDEFINED_11,
489 * - LEAKY_UNDEFINED_12,
490 * - LEAKY_UNDEFINED_13,
491 * - LEAKY_UNDEFINED_14,
492 * - LEAKY_UNDEFINED_15,
493 * - LEAKY_UNDEFINED_16,
494 * - LEAKY_UNDEFINED_17,
495 * - LEAKY_UNDEFINED_18,
496 * - LEAKY_UNDEFINED_19,
497 * - LEAKY_UNDEFINED_1A,
498 * - LEAKY_UNDEFINED_1B,
499 * - LEAKY_UNDEFINED_1C,
500 * - LEAKY_UNDEFINED_1D,
501 * - LEAKY_UNDEFINED_1E,
502 * - LEAKY_UNDEFINED_1F,
505 * - LEAKY_UNDEF_GARP_22,
506 * - LEAKY_UNDEF_GARP_23,
507 * - LEAKY_UNDEF_GARP_24,
508 * - LEAKY_UNDEF_GARP_25,
509 * - LEAKY_UNDEF_GARP_26,
510 * - LEAKY_UNDEF_GARP_27,
511 * - LEAKY_UNDEF_GARP_28,
512 * - LEAKY_UNDEF_GARP_29,
513 * - LEAKY_UNDEF_GARP_2A,
514 * - LEAKY_UNDEF_GARP_2B,
515 * - LEAKY_UNDEF_GARP_2C,
516 * - LEAKY_UNDEF_GARP_2D,
517 * - LEAKY_UNDEF_GARP_2E,
518 * - LEAKY_UNDEF_GARP_2F,
520 * - LEAKY_IPMULTICAST.
525 rtk_api_ret_t
rtk_leaky_portIsolation_get(rtk_leaky_type_t type
, rtk_enable_t
*pEnable
)
527 rtk_api_ret_t retVal
;
528 rtk_uint32 port
, tmp
;
529 rtl8367c_rma_t rmacfg
;
531 /* Check initialization state */
532 RTK_CHK_INIT_STATE();
534 if (type
>= LEAKY_END
)
538 return RT_ERR_NULL_POINTER
;
540 if (type
>= 0 && type
<= LEAKY_UNDEF_GARP_2F
)
542 if ((retVal
= rtl8367c_getAsicRma(type
, &rmacfg
)) != RT_ERR_OK
)
545 *pEnable
= rmacfg
.portiso_leaky
;
548 else if (LEAKY_IPMULTICAST
== type
)
550 for (port
= 0; port
< RTK_MAX_NUM_OF_PORT
; port
++)
552 if ((retVal
= rtl8367c_getAsicIpMulticastPortIsoLeaky(port
, &tmp
)) != RT_ERR_OK
)
554 if (port
> 0 &&(tmp
!= *pEnable
))
555 return RT_ERR_FAILED
;
559 else if (LEAKY_IGMP
== type
)
561 if ((retVal
= rtl8367c_getAsicIGMPIsoLeaky(&tmp
)) != RT_ERR_OK
)
566 else if (LEAKY_CDP
== type
)
568 if ((retVal
= rtl8367c_getAsicRmaCdp(&rmacfg
)) != RT_ERR_OK
)
571 *pEnable
= rmacfg
.portiso_leaky
;
573 else if (LEAKY_CSSTP
== type
)
575 if ((retVal
= rtl8367c_getAsicRmaCsstp(&rmacfg
)) != RT_ERR_OK
)
578 *pEnable
= rmacfg
.portiso_leaky
;
580 else if (LEAKY_LLDP
== type
)
582 if ((retVal
= rtl8367c_getAsicRmaLldp(&tmp
, &rmacfg
)) != RT_ERR_OK
)
585 *pEnable
= rmacfg
.portiso_leaky
;