mediatek: mt7622: add Linux 5.10 support
[openwrt/staging/rmilecki.git] / target / linux / mediatek / files-5.10 / drivers / net / phy / rtk / rtl8367c / rtl8367c_asicdrv_portIsolation.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: 76306 $
11 * $Date: 2017-03-08 15:13:58 +0800 (週三, 08 三月 2017) $
12 *
13 * Purpose : RTL8367C switch high-level API for RTL8367C
14 * Feature : Port isolation related functions
15 *
16 */
17
18 #include <rtl8367c_asicdrv_portIsolation.h>
19 /* Function Name:
20 * rtl8367c_setAsicPortIsolationPermittedPortmask
21 * Description:
22 * Set permitted port isolation portmask
23 * Input:
24 * port - Physical port number (0~10)
25 * permitPortmask - port mask
26 * Output:
27 * None
28 * Return:
29 * RT_ERR_OK - Success
30 * RT_ERR_SMI - SMI access error
31 * RT_ERR_PORT_ID - Invalid port number
32 * RT_ERR_PORT_MASK - Invalid portmask
33 * Note:
34 * None
35 */
36 ret_t rtl8367c_setAsicPortIsolationPermittedPortmask(rtk_uint32 port, rtk_uint32 permitPortmask)
37 {
38 if(port >= RTL8367C_PORTNO)
39 return RT_ERR_PORT_ID;
40
41 if( permitPortmask > RTL8367C_PORTMASK)
42 return RT_ERR_PORT_MASK;
43
44 return rtl8367c_setAsicReg(RTL8367C_PORT_ISOLATION_PORT_MASK_REG(port), permitPortmask);
45 }
46 /* Function Name:
47 * rtl8367c_getAsicPortIsolationPermittedPortmask
48 * Description:
49 * Get permitted port isolation portmask
50 * Input:
51 * port - Physical port number (0~10)
52 * pPermitPortmask - port mask
53 * Output:
54 * None
55 * Return:
56 * RT_ERR_OK - Success
57 * RT_ERR_SMI - SMI access error
58 * RT_ERR_PORT_ID - Invalid port number
59 * Note:
60 * None
61 */
62 ret_t rtl8367c_getAsicPortIsolationPermittedPortmask(rtk_uint32 port, rtk_uint32 *pPermitPortmask)
63 {
64 if(port >= RTL8367C_PORTNO)
65 return RT_ERR_PORT_ID;
66
67 return rtl8367c_getAsicReg(RTL8367C_PORT_ISOLATION_PORT_MASK_REG(port), pPermitPortmask);
68 }
69 /* Function Name:
70 * rtl8367c_setAsicPortIsolationEfid
71 * Description:
72 * Set port isolation EFID
73 * Input:
74 * port - Physical port number (0~10)
75 * efid - EFID (0~7)
76 * Output:
77 * None
78 * Return:
79 * RT_ERR_OK - Success
80 * RT_ERR_SMI - SMI access error
81 * RT_ERR_PORT_ID - Invalid port number
82 * RT_ERR_OUT_OF_RANGE - Input parameter out of range
83 * Note:
84 * EFID is used in individual learning in filtering database
85 */
86 ret_t rtl8367c_setAsicPortIsolationEfid(rtk_uint32 port, rtk_uint32 efid)
87 {
88 if(port >= RTL8367C_PORTNO)
89 return RT_ERR_PORT_ID;
90
91 if( efid > RTL8367C_EFIDMAX)
92 return RT_ERR_OUT_OF_RANGE;
93
94 return rtl8367c_setAsicRegBits(RTL8367C_PORT_EFID_REG(port), RTL8367C_PORT_EFID_MASK(port), efid);
95 }
96 /* Function Name:
97 * rtl8367c_getAsicPortIsolationEfid
98 * Description:
99 * Get port isolation EFID
100 * Input:
101 * port - Physical port number (0~10)
102 * pEfid - EFID (0~7)
103 * Output:
104 * None
105 * Return:
106 * RT_ERR_OK - Success
107 * RT_ERR_SMI - SMI access error
108 * RT_ERR_PORT_ID - Invalid port number
109 * Note:
110 * None
111 */
112 ret_t rtl8367c_getAsicPortIsolationEfid(rtk_uint32 port, rtk_uint32 *pEfid)
113 {
114 if(port >= RTL8367C_PORTNO)
115 return RT_ERR_PORT_ID;
116
117 return rtl8367c_getAsicRegBits(RTL8367C_PORT_EFID_REG(port), RTL8367C_PORT_EFID_MASK(port), pEfid);
118 }
119