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 OAM(802.3ah) module.
18 #include <rtk_switch.h>
19 #include <rtk_error.h>
23 #include <rtl8367c_asicdrv.h>
24 #include <rtl8367c_asicdrv_oam.h>
27 /* Module Name : OAM */
32 * Initialize oam module.
41 * Must initialize oam module before calling any oam APIs.
43 rtk_api_ret_t
rtk_oam_init(void)
46 } /* end of rtk_oam_init */
52 * This API set OAM state.
59 * RT_ERR_FAILED - Failed
60 * RT_ERR_SMI - SMI access error
61 * RT_ERR_INPUT - Error parameter
63 * This API set OAM state.
65 rtk_api_ret_t
rtk_oam_state_set(rtk_enable_t enabled
)
69 /* Check initialization state */
72 if (enabled
>= RTK_ENABLE_END
)
75 if ((retVal
= rtl8367c_setAsicOamEnable(enabled
))!=RT_ERR_OK
)
84 * This API get OAM state.
88 * pEnabled - H/W IGMP state
91 * RT_ERR_FAILED - Failed
92 * RT_ERR_SMI - SMI access error
93 * RT_ERR_INPUT - Error parameter
95 * This API set current OAM state.
97 rtk_api_ret_t
rtk_oam_state_get(rtk_enable_t
*pEnabled
)
101 /* Check initialization state */
102 RTK_CHK_INIT_STATE();
104 if ((retVal
= rtl8367c_getAsicOamEnable(pEnabled
))!=RT_ERR_OK
)
113 * rtk_oam_parserAction_set
115 * Set OAM parser action
118 * action - parser action
124 * RT_ERR_PORT_ID - invalid port id
128 rtk_api_ret_t
rtk_oam_parserAction_set(rtk_port_t port
, rtk_oam_parser_act_t action
)
130 rtk_api_ret_t retVal
;
132 /* Check initialization state */
133 RTK_CHK_INIT_STATE();
135 /* Check Port Valid */
136 RTK_CHK_PORT_VALID(port
);
138 if (action
>= OAM_PARSER_ACTION_END
)
141 if ((retVal
= rtl8367c_setAsicOamParser(rtk_switch_port_L2P_get(port
), action
))!=RT_ERR_OK
)
148 * rtk_oam_parserAction_set
150 * Get OAM parser action
154 * pAction - parser action
158 * RT_ERR_PORT_ID - invalid port id
162 rtk_api_ret_t
rtk_oam_parserAction_get(rtk_port_t port
, rtk_oam_parser_act_t
*pAction
)
164 rtk_api_ret_t retVal
;
166 /* Check initialization state */
167 RTK_CHK_INIT_STATE();
169 /* Check Port Valid */
170 RTK_CHK_PORT_VALID(port
);
172 if ((retVal
= rtl8367c_getAsicOamParser(rtk_switch_port_L2P_get(port
), pAction
))!=RT_ERR_OK
)
180 * rtk_oam_multiplexerAction_set
182 * Set OAM multiplexer action
185 * action - parser action
191 * RT_ERR_PORT_ID - invalid port id
195 rtk_api_ret_t
rtk_oam_multiplexerAction_set(rtk_port_t port
, rtk_oam_multiplexer_act_t action
)
197 rtk_api_ret_t retVal
;
199 /* Check initialization state */
200 RTK_CHK_INIT_STATE();
202 /* Check Port Valid */
203 RTK_CHK_PORT_VALID(port
);
205 if (action
>= OAM_MULTIPLEXER_ACTION_END
)
208 if ((retVal
= rtl8367c_setAsicOamMultiplexer(rtk_switch_port_L2P_get(port
), action
))!=RT_ERR_OK
)
215 * rtk_oam_parserAction_set
217 * Get OAM multiplexer action
221 * pAction - parser action
225 * RT_ERR_PORT_ID - invalid port id
229 rtk_api_ret_t
rtk_oam_multiplexerAction_get(rtk_port_t port
, rtk_oam_multiplexer_act_t
*pAction
)
231 rtk_api_ret_t retVal
;
233 /* Check initialization state */
234 RTK_CHK_INIT_STATE();
236 /* Check Port Valid */
237 RTK_CHK_PORT_VALID(port
);
239 if ((retVal
= rtl8367c_getAsicOamMultiplexer(rtk_switch_port_L2P_get(port
), pAction
))!=RT_ERR_OK
)