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 : RTL8367C switch high-level API for RTL8367C
14 * Feature : 802.1X related functions
17 #include <rtl8367c_asicdrv_dot1x.h>
19 * rtl8367c_setAsic1xPBEnConfig
21 * Set 802.1x port-based port enable configuration
23 * port - Physical port number (0~7)
24 * enabled - 1: enabled, 0: disabled
29 * RT_ERR_SMI - SMI access error
30 * RT_ERR_PORT_ID - Invalid port number
34 ret_t
rtl8367c_setAsic1xPBEnConfig(rtk_uint32 port
, rtk_uint32 enabled
)
36 if(port
>= RTL8367C_PORTNO
)
37 return RT_ERR_PORT_ID
;
39 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_PORT_ENABLE_REG
, port
, enabled
);
42 * rtl8367c_getAsic1xPBEnConfig
44 * Get 802.1x port-based port enable configuration
46 * port - Physical port number (0~7)
47 * pEnabled - 1: enabled, 0: disabled
52 * RT_ERR_SMI - SMI access error
53 * RT_ERR_PORT_ID - Invalid port number
57 ret_t
rtl8367c_getAsic1xPBEnConfig(rtk_uint32 port
, rtk_uint32
*pEnabled
)
59 if(port
>= RTL8367C_PORTNO
)
60 return RT_ERR_PORT_ID
;
62 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_PORT_ENABLE_REG
, port
, pEnabled
);
65 * rtl8367c_setAsic1xPBAuthConfig
67 * Set 802.1x port-based authorised port configuration
69 * port - Physical port number (0~7)
70 * auth - 1: authorised, 0: non-authorised
75 * RT_ERR_SMI - SMI access error
76 * RT_ERR_PORT_ID - Invalid port number
80 ret_t
rtl8367c_setAsic1xPBAuthConfig(rtk_uint32 port
, rtk_uint32 auth
)
82 if(port
>= RTL8367C_PORTNO
)
83 return RT_ERR_PORT_ID
;
85 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_PORT_AUTH_REG
, port
, auth
);
88 * rtl8367c_getAsic1xPBAuthConfig
90 * Get 802.1x port-based authorised port configuration
92 * port - Physical port number (0~7)
93 * pAuth - 1: authorised, 0: non-authorised
98 * RT_ERR_SMI - SMI access error
99 * RT_ERR_PORT_ID - Invalid port number
103 ret_t
rtl8367c_getAsic1xPBAuthConfig(rtk_uint32 port
, rtk_uint32
*pAuth
)
105 if(port
>= RTL8367C_PORTNO
)
106 return RT_ERR_PORT_ID
;
108 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_PORT_AUTH_REG
, port
, pAuth
);
111 * rtl8367c_setAsic1xPBOpdirConfig
113 * Set 802.1x port-based operational direction
115 * port - Physical port number (0~7)
116 * opdir - Operation direction 1: IN, 0:BOTH
120 * RT_ERR_OK - Success
121 * RT_ERR_SMI - SMI access error
122 * RT_ERR_PORT_ID - Invalid port number
126 ret_t
rtl8367c_setAsic1xPBOpdirConfig(rtk_uint32 port
, rtk_uint32 opdir
)
128 if(port
>= RTL8367C_PORTNO
)
129 return RT_ERR_PORT_ID
;
131 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_PORT_OPDIR_REG
, port
, opdir
);
134 * rtl8367c_getAsic1xPBOpdirConfig
136 * Get 802.1x port-based operational direction
138 * port - Physical port number (0~7)
139 * pOpdir - Operation direction 1: IN, 0:BOTH
143 * RT_ERR_OK - Success
144 * RT_ERR_SMI - SMI access error
145 * RT_ERR_PORT_ID - Invalid port number
149 ret_t
rtl8367c_getAsic1xPBOpdirConfig(rtk_uint32 port
, rtk_uint32
* pOpdir
)
151 if(port
>= RTL8367C_PORTNO
)
152 return RT_ERR_PORT_ID
;
154 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_PORT_OPDIR_REG
, port
, pOpdir
);
157 * rtl8367c_setAsic1xMBEnConfig
159 * Set 802.1x mac-based port enable configuration
161 * port - Physical port number (0~7)
162 * enabled - 1: enabled, 0: disabled
166 * RT_ERR_OK - Success
167 * RT_ERR_SMI - SMI access error
168 * RT_ERR_PORT_ID - Invalid port number
172 ret_t
rtl8367c_setAsic1xMBEnConfig(rtk_uint32 port
, rtk_uint32 enabled
)
174 if(port
>= RTL8367C_PORTNO
)
175 return RT_ERR_PORT_ID
;
177 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_MAC_ENABLE_REG
, port
, enabled
);
180 * rtl8367c_getAsic1xMBEnConfig
182 * Get 802.1x mac-based port enable configuration
184 * port - Physical port number (0~7)
185 * pEnabled - 1: enabled, 0: disabled
189 * RT_ERR_OK - Success
190 * RT_ERR_SMI - SMI access error
191 * RT_ERR_PORT_ID - Invalid port number
195 ret_t
rtl8367c_getAsic1xMBEnConfig(rtk_uint32 port
, rtk_uint32
*pEnabled
)
197 if(port
>= RTL8367C_PORTNO
)
198 return RT_ERR_PORT_ID
;
200 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_MAC_ENABLE_REG
, port
, pEnabled
);
203 * rtl8367c_setAsic1xMBOpdirConfig
205 * Set 802.1x mac-based operational direction
207 * opdir - Operation direction 1: IN, 0:BOTH
211 * RT_ERR_OK - Success
212 * RT_ERR_SMI - SMI access error
216 ret_t
rtl8367c_setAsic1xMBOpdirConfig(rtk_uint32 opdir
)
218 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_CFG_REG
, RTL8367C_DOT1X_MAC_OPDIR_OFFSET
, opdir
);
221 * rtl8367c_getAsic1xMBOpdirConfig
223 * Get 802.1x mac-based operational direction
225 * pOpdir - Operation direction 1: IN, 0:BOTH
229 * RT_ERR_OK - Success
230 * RT_ERR_SMI - SMI access error
234 ret_t
rtl8367c_getAsic1xMBOpdirConfig(rtk_uint32
*pOpdir
)
236 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_CFG_REG
, RTL8367C_DOT1X_MAC_OPDIR_OFFSET
, pOpdir
);
239 * rtl8367c_setAsic1xProcConfig
241 * Set 802.1x unauth. behavior configuration
243 * port - Physical port number (0~7)
244 * proc - 802.1x unauth. behavior configuration 0:drop 1:trap to CPU 2:Guest VLAN
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
255 ret_t
rtl8367c_setAsic1xProcConfig(rtk_uint32 port
, rtk_uint32 proc
)
258 if(port
>= RTL8367C_PORTNO
)
259 return RT_ERR_PORT_ID
;
261 if(proc
>= DOT1X_UNAUTH_END
)
262 return RT_ERR_DOT1X_PROC
;
266 return rtl8367c_setAsicRegBits(RTL8367C_DOT1X_UNAUTH_ACT_BASE
, RTL8367C_DOT1X_UNAUTH_ACT_MASK(port
),proc
);
270 return rtl8367c_setAsicRegBits(RTL8367C_REG_DOT1X_UNAUTH_ACT_W1
, RTL8367C_DOT1X_UNAUTH_ACT_MASK(port
),proc
);
274 * rtl8367c_getAsic1xProcConfig
276 * Get 802.1x unauth. behavior configuration
278 * port - Physical port number (0~7)
279 * pProc - 802.1x unauth. behavior configuration 0:drop 1:trap to CPU 2:Guest VLAN
283 * RT_ERR_OK - Success
284 * RT_ERR_SMI - SMI access error
285 * RT_ERR_PORT_ID - Invalid port number
289 ret_t
rtl8367c_getAsic1xProcConfig(rtk_uint32 port
, rtk_uint32
* pProc
)
291 if(port
>= RTL8367C_PORTNO
)
292 return RT_ERR_PORT_ID
;
295 return rtl8367c_getAsicRegBits(RTL8367C_DOT1X_UNAUTH_ACT_BASE
, RTL8367C_DOT1X_UNAUTH_ACT_MASK(port
),pProc
);
297 return rtl8367c_getAsicRegBits(RTL8367C_REG_DOT1X_UNAUTH_ACT_W1
, RTL8367C_DOT1X_UNAUTH_ACT_MASK(port
),pProc
);
300 * rtl8367c_setAsic1xGuestVidx
302 * Set 802.1x guest vlan index
304 * index - 802.1x guest vlan index (0~31)
308 * RT_ERR_OK - Success
309 * RT_ERR_SMI - SMI access error
310 * RT_ERR_DOT1X_GVLANIDX - Invalid cvid index
314 ret_t
rtl8367c_setAsic1xGuestVidx(rtk_uint32 index
)
316 if(index
>= RTL8367C_CVIDXNO
)
317 return RT_ERR_DOT1X_GVLANIDX
;
319 return rtl8367c_setAsicRegBits(RTL8367C_DOT1X_CFG_REG
, RTL8367C_DOT1X_GVIDX_MASK
, index
);
322 * rtl8367c_getAsic1xGuestVidx
324 * Get 802.1x guest vlan index
326 * pIndex - 802.1x guest vlan index (0~31)
330 * RT_ERR_OK - Success
331 * RT_ERR_SMI - SMI access error
335 ret_t
rtl8367c_getAsic1xGuestVidx(rtk_uint32
*pIndex
)
337 return rtl8367c_getAsicRegBits(RTL8367C_DOT1X_CFG_REG
, RTL8367C_DOT1X_GVIDX_MASK
, pIndex
);
340 * rtl8367c_setAsic1xGVOpdir
342 * Set 802.1x guest vlan talk to auth. DA
344 * enabled - 0:disable 1:enable
348 * RT_ERR_OK - Success
349 * RT_ERR_SMI - SMI access error
353 ret_t
rtl8367c_setAsic1xGVOpdir(rtk_uint32 enabled
)
355 return rtl8367c_setAsicRegBit(RTL8367C_DOT1X_CFG_REG
, RTL8367C_DOT1X_GVOPDIR_OFFSET
, enabled
);
358 * rtl8367c_getAsic1xGVOpdir
360 * Get 802.1x guest vlan talk to auth. DA
362 * pEnabled - 0:disable 1:enable
366 * RT_ERR_OK - Success
367 * RT_ERR_SMI - SMI access error
371 ret_t
rtl8367c_getAsic1xGVOpdir(rtk_uint32
*pEnabled
)
373 return rtl8367c_getAsicRegBit(RTL8367C_DOT1X_CFG_REG
, RTL8367C_DOT1X_GVOPDIR_OFFSET
, pEnabled
);
376 * rtl8367c_setAsic1xTrapPriority
378 * Set 802.1x Trap priority
380 * priority - priority (0~7)
384 * RT_ERR_OK - Success
385 * RT_ERR_SMI - SMI access error
386 * RT_ERR_QOS_INT_PRIORITY - Invalid priority
390 ret_t
rtl8367c_setAsic1xTrapPriority(rtk_uint32 priority
)
392 if(priority
> RTL8367C_PRIMAX
)
393 return RT_ERR_QOS_INT_PRIORITY
;
395 return rtl8367c_setAsicRegBits(RTL8367C_REG_QOS_TRAP_PRIORITY0
, RTL8367C_DOT1X_PRIORTY_MASK
,priority
);
398 * rtl8367c_getAsic1xTrapPriority
400 * Get 802.1x Trap priority
402 * pPriority - priority (0~7)
406 * RT_ERR_OK - Success
407 * RT_ERR_SMI - SMI access error
411 ret_t
rtl8367c_getAsic1xTrapPriority(rtk_uint32
*pPriority
)
413 return rtl8367c_getAsicRegBits(RTL8367C_REG_QOS_TRAP_PRIORITY0
, RTL8367C_DOT1X_PRIORTY_MASK
, pPriority
);