mediatek: mt7622: add Linux 5.10 support
[openwrt/staging/rmilecki.git] / target / linux / mediatek / files-5.10 / drivers / net / phy / rtk / rtl8367c / include / trunk.h
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 * Purpose : RTL8367/RTL8367C switch high-level API
11 *
12 * Feature : The file includes Trunk module high-layer TRUNK defination
13 *
14 */
15
16 #ifndef __RTK_API_TRUNK_H__
17 #define __RTK_API_TRUNK_H__
18
19 /*
20 * Data Type Declaration
21 */
22 #define RTK_TRUNK_DPORT_HASH_MASK 0x40
23 #define RTK_TRUNK_SPORT_HASH_MASK 0x20
24 #define RTK_TRUNK_DIP_HASH_MASK 0x10
25 #define RTK_TRUNK_SIP_HASH_MASK 0x8
26 #define RTK_TRUNK_DMAC_HASH_MASK 0x4
27 #define RTK_TRUNK_SMAC_HASH_MASK 0x2
28 #define RTK_TRUNK_SPA_HASH_MASK 0x1
29
30
31 #define RTK_MAX_NUM_OF_TRUNK_HASH_VAL 16
32
33 typedef struct rtk_trunk_hashVal2Port_s
34 {
35 rtk_uint8 value[RTK_MAX_NUM_OF_TRUNK_HASH_VAL];
36 } rtk_trunk_hashVal2Port_t;
37
38 typedef enum rtk_trunk_group_e
39 {
40 TRUNK_GROUP0 = 0,
41 TRUNK_GROUP1,
42 TRUNK_GROUP2,
43 TRUNK_GROUP3,
44 TRUNK_GROUP_END
45 } rtk_trunk_group_t;
46
47 typedef enum rtk_trunk_separateType_e
48 {
49 SEPARATE_NONE = 0,
50 SEPARATE_FLOOD,
51 SEPARATE_END
52
53 } rtk_trunk_separateType_t;
54
55 typedef enum rtk_trunk_mode_e
56 {
57 TRUNK_MODE_NORMAL = 0,
58 TRUNK_MODE_DUMB,
59 TRUNK_MODE_END
60 } rtk_trunk_mode_t;
61
62 /* Function Name:
63 * rtk_trunk_port_set
64 * Description:
65 * Set trunking group available port mask
66 * Input:
67 * trk_gid - trunk group id
68 * pTrunk_member_portmask - Logic trunking member port mask
69 * Output:
70 * None
71 * Return:
72 * RT_ERR_OK - OK
73 * RT_ERR_FAILED - Failed
74 * RT_ERR_SMI - SMI access error
75 * RT_ERR_LA_TRUNK_ID - Invalid trunking group
76 * RT_ERR_PORT_MASK - Invalid portmask.
77 * Note:
78 * The API can set port trunking group port mask. Each port trunking group has max 4 ports.
79 * If enabled port mask has less than 2 ports available setting, then this trunking group function is disabled.
80 */
81 extern rtk_api_ret_t rtk_trunk_port_set(rtk_trunk_group_t trk_gid, rtk_portmask_t *pTrunk_member_portmask);
82
83 /* Function Name:
84 * rtk_trunk_port_get
85 * Description:
86 * Get trunking group available port mask
87 * Input:
88 * trk_gid - trunk group id
89 * Output:
90 * pTrunk_member_portmask - Logic trunking member port mask
91 * Return:
92 * RT_ERR_OK - OK
93 * RT_ERR_FAILED - Failed
94 * RT_ERR_SMI - SMI access error
95 * RT_ERR_LA_TRUNK_ID - Invalid trunking group
96 * Note:
97 * The API can get 2 port trunking group.
98 */
99 extern rtk_api_ret_t rtk_trunk_port_get(rtk_trunk_group_t trk_gid, rtk_portmask_t *pTrunk_member_portmask);
100
101 /* Function Name:
102 * rtk_trunk_distributionAlgorithm_set
103 * Description:
104 * Set port trunking hash select sources
105 * Input:
106 * trk_gid - trunk group id
107 * algo_bitmask - Bitmask of the distribution algorithm
108 * Output:
109 * None
110 * Return:
111 * RT_ERR_OK - OK
112 * RT_ERR_FAILED - Failed
113 * RT_ERR_SMI - SMI access error
114 * RT_ERR_LA_TRUNK_ID - Invalid trunking group
115 * RT_ERR_LA_HASHMASK - Hash algorithm selection error.
116 * RT_ERR_PORT_MASK - Invalid portmask.
117 * Note:
118 * The API can set port trunking hash algorithm sources.
119 * 7 bits mask for link aggregation group0 hash parameter selection {DIP, SIP, DMAC, SMAC, SPA}
120 * - 0b0000001: SPA
121 * - 0b0000010: SMAC
122 * - 0b0000100: DMAC
123 * - 0b0001000: SIP
124 * - 0b0010000: DIP
125 * - 0b0100000: TCP/UDP Source Port
126 * - 0b1000000: TCP/UDP Destination Port
127 * Example:
128 * - 0b0000011: SMAC & SPA
129 * - Note that it could be an arbitrary combination or independent set
130 */
131 extern rtk_api_ret_t rtk_trunk_distributionAlgorithm_set(rtk_trunk_group_t trk_gid, rtk_uint32 algo_bitmask);
132
133 /* Function Name:
134 * rtk_trunk_distributionAlgorithm_get
135 * Description:
136 * Get port trunking hash select sources
137 * Input:
138 * trk_gid - trunk group id
139 * Output:
140 * pAlgo_bitmask - Bitmask of the distribution algorithm
141 * Return:
142 * RT_ERR_OK - OK
143 * RT_ERR_FAILED - Failed
144 * RT_ERR_SMI - SMI access error
145 * RT_ERR_LA_TRUNK_ID - Invalid trunking group
146 * Note:
147 * The API can get port trunking hash algorithm sources.
148 */
149 extern rtk_api_ret_t rtk_trunk_distributionAlgorithm_get(rtk_trunk_group_t trk_gid, rtk_uint32 *pAlgo_bitmask);
150
151 /* Function Name:
152 * rtk_trunk_trafficSeparate_set
153 * Description:
154 * Set the traffic separation setting of a trunk group from the specified device.
155 * Input:
156 * trk_gid - trunk group id
157 * separateType - traffic separation setting
158 * Output:
159 * None
160 * Return:
161 * RT_ERR_OK
162 * RT_ERR_FAILED
163 * RT_ERR_UNIT_ID - invalid unit id
164 * RT_ERR_LA_TRUNK_ID - invalid trunk ID
165 * RT_ERR_LA_HASHMASK - invalid hash mask
166 * Note:
167 * SEPARATE_NONE: disable traffic separation
168 * SEPARATE_FLOOD: trunk MSB link up port is dedicated to TX flooding (L2 lookup miss) traffic
169 */
170 extern rtk_api_ret_t rtk_trunk_trafficSeparate_set(rtk_trunk_group_t trk_gid, rtk_trunk_separateType_t separateType);
171
172 /* Function Name:
173 * rtk_trunk_trafficSeparate_get
174 * Description:
175 * Get the traffic separation setting of a trunk group from the specified device.
176 * Input:
177 * trk_gid - trunk group id
178 * Output:
179 * pSeparateType - pointer separated traffic type
180 * Return:
181 * RT_ERR_OK
182 * RT_ERR_FAILED
183 * RT_ERR_UNIT_ID - invalid unit id
184 * RT_ERR_LA_TRUNK_ID - invalid trunk ID
185 * RT_ERR_NULL_POINTER - input parameter may be null pointer
186 * Note:
187 * SEPARATE_NONE: disable traffic separation
188 * SEPARATE_FLOOD: trunk MSB link up port is dedicated to TX flooding (L2 lookup miss) traffic
189 */
190 extern rtk_api_ret_t rtk_trunk_trafficSeparate_get(rtk_trunk_group_t trk_gid, rtk_trunk_separateType_t *pSeparateType);
191
192
193 /* Function Name:
194 * rtk_trunk_mode_set
195 * Description:
196 * Set the trunk mode to the specified device.
197 * Input:
198 * mode - trunk mode
199 * Output:
200 * None
201 * Return:
202 * RT_ERR_OK
203 * RT_ERR_FAILED
204 * RT_ERR_INPUT - invalid input parameter
205 * Note:
206 * The enum of the trunk mode as following
207 * - TRUNK_MODE_NORMAL
208 * - TRUNK_MODE_DUMB
209 */
210 extern rtk_api_ret_t rtk_trunk_mode_set(rtk_trunk_mode_t mode);
211
212 /* Function Name:
213 * rtk_trunk_mode_get
214 * Description:
215 * Get the trunk mode from the specified device.
216 * Input:
217 * None
218 * Output:
219 * pMode - pointer buffer of trunk mode
220 * Return:
221 * RT_ERR_OK
222 * RT_ERR_FAILED
223 * RT_ERR_NULL_POINTER - input parameter may be null pointer
224 * Note:
225 * The enum of the trunk mode as following
226 * - TRUNK_MODE_NORMAL
227 * - TRUNK_MODE_DUMB
228 */
229 extern rtk_api_ret_t rtk_trunk_mode_get(rtk_trunk_mode_t *pMode);
230
231 /* Function Name:
232 * rtk_trunk_trafficPause_set
233 * Description:
234 * Set the traffic pause setting of a trunk group.
235 * Input:
236 * trk_gid - trunk group id
237 * enable - traffic pause state
238 * Output:
239 * None
240 * Return:
241 * RT_ERR_OK
242 * RT_ERR_FAILED
243 * RT_ERR_LA_TRUNK_ID - invalid trunk ID
244 * Note:
245 * None.
246 */
247 extern rtk_api_ret_t rtk_trunk_trafficPause_set(rtk_trunk_group_t trk_gid, rtk_enable_t enable);
248
249 /* Function Name:
250 * rtk_trunk_trafficPause_get
251 * Description:
252 * Get the traffic pause setting of a trunk group.
253 * Input:
254 * trk_gid - trunk group id
255 * Output:
256 * pEnable - pointer of traffic pause state.
257 * Return:
258 * RT_ERR_OK
259 * RT_ERR_FAILED
260 * RT_ERR_LA_TRUNK_ID - invalid trunk ID
261 * RT_ERR_NULL_POINTER - input parameter may be null pointer
262 * Note:
263 * None.
264 */
265 extern rtk_api_ret_t rtk_trunk_trafficPause_get(rtk_trunk_group_t trk_gid, rtk_enable_t *pEnable);
266
267 /* Function Name:
268 * rtk_trunk_hashMappingTable_set
269 * Description:
270 * Set hash value to port array in the trunk group id from the specified device.
271 * Input:
272 * trk_gid - trunk group id
273 * pHash2Port_array - ports associate with the hash value
274 * Output:
275 * None
276 * Return:
277 * RT_ERR_OK
278 * RT_ERR_FAILED
279 * RT_ERR_UNIT_ID - invalid unit id
280 * RT_ERR_LA_TRUNK_ID - invalid trunk ID
281 * RT_ERR_NULL_POINTER - input parameter may be null pointer
282 * RT_ERR_LA_TRUNK_NOT_EXIST - the trunk doesn't exist
283 * RT_ERR_LA_NOT_MEMBER_PORT - the port is not a member port of the trunk
284 * RT_ERR_LA_CPUPORT - CPU port can not be aggregated port
285 * Note:
286 * Trunk group 0 & 1 shares the same hash mapping table.
287 * Trunk group 2 uses a independent table.
288 */
289 extern rtk_api_ret_t rtk_trunk_hashMappingTable_set(rtk_trunk_group_t trk_gid, rtk_trunk_hashVal2Port_t *pHash2Port_array);
290
291 /* Function Name:
292 * rtk_trunk_hashMappingTable_get
293 * Description:
294 * Get hash value to port array in the trunk group id from the specified device.
295 * Input:
296 * trk_gid - trunk group id
297 * Output:
298 * pHash2Port_array - pointer buffer of ports associate with the hash value
299 * Return:
300 * RT_ERR_OK
301 * RT_ERR_FAILED
302 * RT_ERR_UNIT_ID - invalid unit id
303 * RT_ERR_LA_TRUNK_ID - invalid trunk ID
304 * RT_ERR_NULL_POINTER - input parameter may be null pointer
305 * Note:
306 * Trunk group 0 & 1 shares the same hash mapping table.
307 * Trunk group 2 uses a independent table.
308 */
309 extern rtk_api_ret_t rtk_trunk_hashMappingTable_get(rtk_trunk_group_t trk_gid, rtk_trunk_hashVal2Port_t *pHash2Port_array);
310
311 /* Function Name:
312 * rtk_trunk_portQueueEmpty_get
313 * Description:
314 * Get the port mask which all queues are empty.
315 * Input:
316 * None.
317 * Output:
318 * pEmpty_portmask - pointer empty port mask
319 * Return:
320 * RT_ERR_OK
321 * RT_ERR_FAILED
322 * RT_ERR_NULL_POINTER - input parameter may be null pointer
323 * Note:
324 * None.
325 */
326 extern rtk_api_ret_t rtk_trunk_portQueueEmpty_get(rtk_portmask_t *pEmpty_portmask);
327
328 #endif /* __RTK_API_TRUNK_H__ */