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