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: 2013-08-26 13:51:29 +0800 (週一, 26 八月 2013) $
13 * Purpose : RTL8367C switch high-level API for RTL8367C
14 * Feature : OAM related functions
18 #include <rtl8367c_asicdrv_oam.h>
20 * rtl8367c_setAsicOamParser
22 * Set OAM parser state
24 * port - Physical port number (0~7)
25 * parser - Per-Port OAM parser state
30 * RT_ERR_SMI - SMI access error
31 * RT_ERR_PORT_ID - Invalid port number
32 * RT_ERR_NOT_ALLOWED - Invalid paser state
36 ret_t
rtl8367c_setAsicOamParser(rtk_uint32 port
, rtk_uint32 parser
)
38 if(port
>= RTL8367C_PORTNO
)
39 return RT_ERR_PORT_ID
;
41 if(parser
> OAM_PARFWDCPU
)
42 return RT_ERR_NOT_ALLOWED
;
44 return rtl8367c_setAsicRegBits(RTL8367C_REG_OAM_PARSER_CTRL0
+ port
/8, RTL8367C_OAM_PARSER_MASK(port
% 8), parser
);
47 * rtl8367c_getAsicOamParser
49 * Get OAM parser state
51 * port - Physical port number (0~7)
52 * pParser - Per-Port OAM parser state
57 * RT_ERR_SMI - SMI access error
58 * RT_ERR_PORT_ID - Invalid port number
62 ret_t
rtl8367c_getAsicOamParser(rtk_uint32 port
, rtk_uint32
* pParser
)
64 if(port
>= RTL8367C_PORTNO
)
65 return RT_ERR_PORT_ID
;
67 return rtl8367c_getAsicRegBits(RTL8367C_REG_OAM_PARSER_CTRL0
+ port
/8, RTL8367C_OAM_PARSER_MASK(port
%8), pParser
);
70 * rtl8367c_setAsicOamMultiplexer
72 * Set OAM multiplexer state
74 * port - Physical port number (0~7)
75 * multiplexer - Per-Port OAM multiplexer state
80 * RT_ERR_SMI - SMI access error
81 * RT_ERR_PORT_ID - Invalid port number
82 * RT_ERR_NOT_ALLOWED - Invalid multiplexer state
86 ret_t
rtl8367c_setAsicOamMultiplexer(rtk_uint32 port
, rtk_uint32 multiplexer
)
88 if(port
>= RTL8367C_PORTNO
)
89 return RT_ERR_PORT_ID
;
91 if(multiplexer
> OAM_MULCPU
)
92 return RT_ERR_NOT_ALLOWED
;
94 return rtl8367c_setAsicRegBits(RTL8367C_REG_OAM_MULTIPLEXER_CTRL0
+ port
/8, RTL8367C_OAM_MULTIPLEXER_MASK(port
%8), multiplexer
);
97 * rtl8367c_getAsicOamMultiplexer
99 * Get OAM multiplexer state
101 * port - Physical port number (0~7)
102 * pMultiplexer - Per-Port OAM multiplexer state
106 * RT_ERR_OK - Success
107 * RT_ERR_SMI - SMI access error
108 * RT_ERR_PORT_ID - Invalid port number
112 ret_t
rtl8367c_getAsicOamMultiplexer(rtk_uint32 port
, rtk_uint32
* pMultiplexer
)
114 if(port
>= RTL8367C_PORTNO
)
115 return RT_ERR_PORT_ID
;
117 return rtl8367c_getAsicRegBits(RTL8367C_REG_OAM_MULTIPLEXER_CTRL0
+ port
/8, RTL8367C_OAM_MULTIPLEXER_MASK(port
%8), pMultiplexer
);
120 * rtl8367c_setAsicOamCpuPri
122 * Set trap priority for OAM packet
124 * priority - priority (0~7)
128 * RT_ERR_OK - Success
129 * RT_ERR_SMI - SMI access error
130 * RT_ERR_QOS_INT_PRIORITY - Invalid priority
134 ret_t
rtl8367c_setAsicOamCpuPri(rtk_uint32 priority
)
136 if(priority
> RTL8367C_PRIMAX
)
137 return RT_ERR_QOS_INT_PRIORITY
;
139 return rtl8367c_setAsicRegBits(RTL8367C_REG_QOS_TRAP_PRIORITY0
, RTL8367C_OAM_PRIOIRTY_MASK
, priority
);
142 * rtl8367c_getAsicOamCpuPri
144 * Get trap priority for OAM packet
146 * pPriority - priority (0~7)
150 * RT_ERR_OK - Success
151 * RT_ERR_SMI - SMI access error
155 ret_t
rtl8367c_getAsicOamCpuPri(rtk_uint32
*pPriority
)
157 return rtl8367c_getAsicRegBits(RTL8367C_REG_QOS_TRAP_PRIORITY0
, RTL8367C_OAM_PRIOIRTY_MASK
, pPriority
);
160 * rtl8367c_setAsicOamEnable
162 * Set OAM function state
164 * enabled - OAM function usage 1:enable, 0:disabled
168 * RT_ERR_OK - Success
169 * RT_ERR_SMI - SMI access error
173 ret_t
rtl8367c_setAsicOamEnable(rtk_uint32 enabled
)
175 return rtl8367c_setAsicRegBit(RTL8367C_REG_OAM_CTRL
, RTL8367C_OAM_CTRL_OFFSET
, enabled
);
178 * rtl8367c_getAsicOamEnable
180 * Get OAM function state
182 * pEnabled - OAM function usage 1:enable, 0:disabled
186 * RT_ERR_OK - Success
187 * RT_ERR_SMI - SMI access error
191 ret_t
rtl8367c_getAsicOamEnable(rtk_uint32
*pEnabled
)
193 return rtl8367c_getAsicRegBit(RTL8367C_REG_OAM_CTRL
, RTL8367C_OAM_CTRL_OFFSET
, pEnabled
);