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
10 * Purpose : RTL8367/RTL8367C switch high-level API
12 * Feature : The file includes Trunk module high-layer TRUNK defination
16 #ifndef __RTK_API_TRUNK_H__
17 #define __RTK_API_TRUNK_H__
20 * Data Type Declaration
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
31 #define RTK_MAX_NUM_OF_TRUNK_HASH_VAL 16
33 typedef struct rtk_trunk_hashVal2Port_s
35 rtk_uint8 value
[RTK_MAX_NUM_OF_TRUNK_HASH_VAL
];
36 } rtk_trunk_hashVal2Port_t
;
38 typedef enum rtk_trunk_group_e
47 typedef enum rtk_trunk_separateType_e
53 } rtk_trunk_separateType_t
;
55 typedef enum rtk_trunk_mode_e
57 TRUNK_MODE_NORMAL
= 0,
65 * Set trunking group available port mask
67 * trk_gid - trunk group id
68 * pTrunk_member_portmask - Logic trunking member port mask
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.
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.
81 extern rtk_api_ret_t
rtk_trunk_port_set(rtk_trunk_group_t trk_gid
, rtk_portmask_t
*pTrunk_member_portmask
);
86 * Get trunking group available port mask
88 * trk_gid - trunk group id
90 * pTrunk_member_portmask - Logic trunking member port mask
93 * RT_ERR_FAILED - Failed
94 * RT_ERR_SMI - SMI access error
95 * RT_ERR_LA_TRUNK_ID - Invalid trunking group
97 * The API can get 2 port trunking group.
99 extern rtk_api_ret_t
rtk_trunk_port_get(rtk_trunk_group_t trk_gid
, rtk_portmask_t
*pTrunk_member_portmask
);
102 * rtk_trunk_distributionAlgorithm_set
104 * Set port trunking hash select sources
106 * trk_gid - trunk group id
107 * algo_bitmask - Bitmask of the distribution algorithm
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.
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}
125 * - 0b0100000: TCP/UDP Source Port
126 * - 0b1000000: TCP/UDP Destination Port
128 * - 0b0000011: SMAC & SPA
129 * - Note that it could be an arbitrary combination or independent set
131 extern rtk_api_ret_t
rtk_trunk_distributionAlgorithm_set(rtk_trunk_group_t trk_gid
, rtk_uint32 algo_bitmask
);
134 * rtk_trunk_distributionAlgorithm_get
136 * Get port trunking hash select sources
138 * trk_gid - trunk group id
140 * pAlgo_bitmask - Bitmask of the distribution algorithm
143 * RT_ERR_FAILED - Failed
144 * RT_ERR_SMI - SMI access error
145 * RT_ERR_LA_TRUNK_ID - Invalid trunking group
147 * The API can get port trunking hash algorithm sources.
149 extern rtk_api_ret_t
rtk_trunk_distributionAlgorithm_get(rtk_trunk_group_t trk_gid
, rtk_uint32
*pAlgo_bitmask
);
152 * rtk_trunk_trafficSeparate_set
154 * Set the traffic separation setting of a trunk group from the specified device.
156 * trk_gid - trunk group id
157 * separateType - traffic separation setting
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
167 * SEPARATE_NONE: disable traffic separation
168 * SEPARATE_FLOOD: trunk MSB link up port is dedicated to TX flooding (L2 lookup miss) traffic
170 extern rtk_api_ret_t
rtk_trunk_trafficSeparate_set(rtk_trunk_group_t trk_gid
, rtk_trunk_separateType_t separateType
);
173 * rtk_trunk_trafficSeparate_get
175 * Get the traffic separation setting of a trunk group from the specified device.
177 * trk_gid - trunk group id
179 * pSeparateType - pointer separated traffic type
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
187 * SEPARATE_NONE: disable traffic separation
188 * SEPARATE_FLOOD: trunk MSB link up port is dedicated to TX flooding (L2 lookup miss) traffic
190 extern rtk_api_ret_t
rtk_trunk_trafficSeparate_get(rtk_trunk_group_t trk_gid
, rtk_trunk_separateType_t
*pSeparateType
);
196 * Set the trunk mode to the specified device.
204 * RT_ERR_INPUT - invalid input parameter
206 * The enum of the trunk mode as following
207 * - TRUNK_MODE_NORMAL
210 extern rtk_api_ret_t
rtk_trunk_mode_set(rtk_trunk_mode_t mode
);
215 * Get the trunk mode from the specified device.
219 * pMode - pointer buffer of trunk mode
223 * RT_ERR_NULL_POINTER - input parameter may be null pointer
225 * The enum of the trunk mode as following
226 * - TRUNK_MODE_NORMAL
229 extern rtk_api_ret_t
rtk_trunk_mode_get(rtk_trunk_mode_t
*pMode
);
232 * rtk_trunk_trafficPause_set
234 * Set the traffic pause setting of a trunk group.
236 * trk_gid - trunk group id
237 * enable - traffic pause state
243 * RT_ERR_LA_TRUNK_ID - invalid trunk ID
247 extern rtk_api_ret_t
rtk_trunk_trafficPause_set(rtk_trunk_group_t trk_gid
, rtk_enable_t enable
);
250 * rtk_trunk_trafficPause_get
252 * Get the traffic pause setting of a trunk group.
254 * trk_gid - trunk group id
256 * pEnable - pointer of traffic pause state.
260 * RT_ERR_LA_TRUNK_ID - invalid trunk ID
261 * RT_ERR_NULL_POINTER - input parameter may be null pointer
265 extern rtk_api_ret_t
rtk_trunk_trafficPause_get(rtk_trunk_group_t trk_gid
, rtk_enable_t
*pEnable
);
268 * rtk_trunk_hashMappingTable_set
270 * Set hash value to port array in the trunk group id from the specified device.
272 * trk_gid - trunk group id
273 * pHash2Port_array - ports associate with the hash value
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
286 * Trunk group 0 & 1 shares the same hash mapping table.
287 * Trunk group 2 uses a independent table.
289 extern rtk_api_ret_t
rtk_trunk_hashMappingTable_set(rtk_trunk_group_t trk_gid
, rtk_trunk_hashVal2Port_t
*pHash2Port_array
);
292 * rtk_trunk_hashMappingTable_get
294 * Get hash value to port array in the trunk group id from the specified device.
296 * trk_gid - trunk group id
298 * pHash2Port_array - pointer buffer of ports associate with the hash value
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
306 * Trunk group 0 & 1 shares the same hash mapping table.
307 * Trunk group 2 uses a independent table.
309 extern rtk_api_ret_t
rtk_trunk_hashMappingTable_get(rtk_trunk_group_t trk_gid
, rtk_trunk_hashVal2Port_t
*pHash2Port_array
);
312 * rtk_trunk_portQueueEmpty_get
314 * Get the port mask which all queues are empty.
318 * pEmpty_portmask - pointer empty port mask
322 * RT_ERR_NULL_POINTER - input parameter may be null pointer
326 extern rtk_api_ret_t
rtk_trunk_portQueueEmpty_get(rtk_portmask_t
*pEmpty_portmask
);
328 #endif /* __RTK_API_TRUNK_H__ */