1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2015 Intel Corporation
5 #ifndef _RTE_ETH_BOND_H_
6 #define _RTE_ETH_BOND_H_
11 * RTE Link Bonding Ethernet Device
12 * Link Bonding for 1GbE and 10GbE ports to allow the aggregation of multiple
13 * (slave) NICs into a single logical interface. The bonded device processes
14 * these interfaces based on the mode of operation specified and supported.
15 * This implementation supports 4 modes of operation round robin, active backup
16 * balance and broadcast. Providing redundant links, fault tolerance and/or
17 * load balancing of network ports
24 #include <rte_ether.h>
26 /* Supported modes of operation of link bonding library */
28 #define BONDING_MODE_ROUND_ROBIN (0)
29 /**< Round Robin (Mode 0).
30 * In this mode all transmitted packets will be balanced equally across all
31 * active slaves of the bonded in a round robin fashion. */
32 #define BONDING_MODE_ACTIVE_BACKUP (1)
33 /**< Active Backup (Mode 1).
34 * In this mode all packets transmitted will be transmitted on the primary
35 * slave until such point as the primary slave is no longer available and then
36 * transmitted packets will be sent on the next available slaves. The primary
37 * slave can be defined by the user but defaults to the first active slave
38 * available if not specified. */
39 #define BONDING_MODE_BALANCE (2)
40 /**< Balance (Mode 2).
41 * In this mode all packets transmitted will be balanced across the available
42 * slaves using one of three available transmit policies - l2, l2+3 or l3+4.
43 * See BALANCE_XMIT_POLICY macros definitions for further details on transmit
45 #define BONDING_MODE_BROADCAST (3)
46 /**< Broadcast (Mode 3).
47 * In this mode all transmitted packets will be transmitted on all available
48 * active slaves of the bonded. */
49 #define BONDING_MODE_8023AD (4)
50 /**< 802.3AD (Mode 4).
52 * This mode provides auto negotiation/configuration
53 * of peers and well as link status changes monitoring using out of band
54 * LACP (link aggregation control protocol) messages. For further details of
55 * LACP specification see the IEEE 802.3ad/802.1AX standards. It is also
57 * https://www.kernel.org/doc/Documentation/networking/bonding.txt.
59 * Important Usage Notes:
60 * - for LACP mode to work the rx/tx burst functions must be invoked
61 * at least once every 100ms, otherwise the out-of-band LACP messages will not
62 * be handled with the expected latency and this may cause the link status to be
63 * incorrectly marked as down or failure to correctly negotiate with peers.
64 * - For optimal performance during initial handshaking the array of mbufs provided
65 * to rx_burst should be at least 2 times the slave count size.
68 #define BONDING_MODE_TLB (5)
69 /**< Adaptive TLB (Mode 5)
70 * This mode provides an adaptive transmit load balancing. It dynamically
71 * changes the transmitting slave, according to the computed load. Statistics
72 * are collected in 100ms intervals and scheduled every 10ms */
73 #define BONDING_MODE_ALB (6)
74 /**< Adaptive Load Balancing (Mode 6)
75 * This mode includes adaptive TLB and receive load balancing (RLB). In RLB the
76 * bonding driver intercepts ARP replies send by local system and overwrites its
77 * source MAC address, so that different peers send data to the server on
78 * different slave interfaces. When local system sends ARP request, it saves IP
79 * information from it. When ARP reply from that peer is received, its MAC is
80 * stored, one of slave MACs assigned and ARP reply send to that peer.
83 /* Balance Mode Transmit Policies */
84 #define BALANCE_XMIT_POLICY_LAYER2 (0)
85 /**< Layer 2 (Ethernet MAC) */
86 #define BALANCE_XMIT_POLICY_LAYER23 (1)
87 /**< Layer 2+3 (Ethernet MAC + IP Addresses) transmit load balancing */
88 #define BALANCE_XMIT_POLICY_LAYER34 (2)
89 /**< Layer 3+4 (IP Addresses + UDP Ports) transmit load balancing */
92 * Create a bonded rte_eth_dev device
94 * @param name Name of new link bonding device.
95 * @param mode Mode to initialize bonding device in.
96 * @param socket_id Socket Id on which to allocate eth_dev resources.
99 * Port Id of created rte_eth_dev on success, negative value otherwise
102 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id);
105 * Free a bonded rte_eth_dev device
107 * @param name Name of the link bonding device.
110 * 0 on success, negative value otherwise
113 rte_eth_bond_free(const char *name);
116 * Add a rte_eth_dev device as a slave to the bonded device
118 * @param bonded_port_id Port ID of bonded device.
119 * @param slave_port_id Port ID of slave device.
122 * 0 on success, negative value otherwise
125 rte_eth_bond_slave_add(uint16_t bonded_port_id, uint16_t slave_port_id);
128 * Remove a slave rte_eth_dev device from the bonded device
130 * @param bonded_port_id Port ID of bonded device.
131 * @param slave_port_id Port ID of slave device.
134 * 0 on success, negative value otherwise
137 rte_eth_bond_slave_remove(uint16_t bonded_port_id, uint16_t slave_port_id);
140 * Set link bonding mode of bonded device
142 * @param bonded_port_id Port ID of bonded device.
143 * @param mode Bonding mode to set
146 * 0 on success, negative value otherwise
149 rte_eth_bond_mode_set(uint16_t bonded_port_id, uint8_t mode);
152 * Get link bonding mode of bonded device
154 * @param bonded_port_id Port ID of bonded device.
157 * link bonding mode on success, negative value otherwise
160 rte_eth_bond_mode_get(uint16_t bonded_port_id);
163 * Set slave rte_eth_dev as primary slave of bonded device
165 * @param bonded_port_id Port ID of bonded device.
166 * @param slave_port_id Port ID of slave device.
169 * 0 on success, negative value otherwise
172 rte_eth_bond_primary_set(uint16_t bonded_port_id, uint16_t slave_port_id);
175 * Get primary slave of bonded device
177 * @param bonded_port_id Port ID of bonded device.
180 * Port Id of primary slave on success, -1 on failure
183 rte_eth_bond_primary_get(uint16_t bonded_port_id);
186 * Populate an array with list of the slaves port id's of the bonded device
188 * @param bonded_port_id Port ID of bonded eth_dev to interrogate
189 * @param slaves Array to be populated with the current active slaves
190 * @param len Length of slaves array
193 * Number of slaves associated with bonded device on success,
194 * negative value otherwise
197 rte_eth_bond_slaves_get(uint16_t bonded_port_id, uint16_t slaves[],
201 * Populate an array with list of the active slaves port id's of the bonded
204 * @param bonded_port_id Port ID of bonded eth_dev to interrogate
205 * @param slaves Array to be populated with the current active slaves
206 * @param len Length of slaves array
209 * Number of active slaves associated with bonded device on success,
210 * negative value otherwise
213 rte_eth_bond_active_slaves_get(uint16_t bonded_port_id, uint16_t slaves[],
217 * Set explicit MAC address to use on bonded device and it's slaves.
219 * @param bonded_port_id Port ID of bonded device.
220 * @param mac_addr MAC Address to use on bonded device overriding
221 * slaves MAC addresses
224 * 0 on success, negative value otherwise
227 rte_eth_bond_mac_address_set(uint16_t bonded_port_id,
228 struct ether_addr *mac_addr);
231 * Reset bonded device to use MAC from primary slave on bonded device and it's
234 * @param bonded_port_id Port ID of bonded device.
237 * 0 on success, negative value otherwise
240 rte_eth_bond_mac_address_reset(uint16_t bonded_port_id);
243 * Set the transmit policy for bonded device to use when it is operating in
244 * balance mode, this parameter is otherwise ignored in other modes of
247 * @param bonded_port_id Port ID of bonded device.
248 * @param policy Balance mode transmission policy.
251 * 0 on success, negative value otherwise.
254 rte_eth_bond_xmit_policy_set(uint16_t bonded_port_id, uint8_t policy);
257 * Get the transmit policy set on bonded device for balance mode operation
259 * @param bonded_port_id Port ID of bonded device.
262 * Balance transmit policy on success, negative value otherwise.
265 rte_eth_bond_xmit_policy_get(uint16_t bonded_port_id);
268 * Set the link monitoring frequency (in ms) for monitoring the link status of
271 * @param bonded_port_id Port ID of bonded device.
272 * @param internal_ms Monitoring interval in milliseconds
275 * 0 on success, negative value otherwise.
279 rte_eth_bond_link_monitoring_set(uint16_t bonded_port_id, uint32_t internal_ms);
282 * Get the current link monitoring frequency (in ms) for monitoring of the link
283 * status of slave devices
285 * @param bonded_port_id Port ID of bonded device.
288 * Monitoring interval on success, negative value otherwise.
291 rte_eth_bond_link_monitoring_get(uint16_t bonded_port_id);
295 * Set the period in milliseconds for delaying the disabling of a bonded link
296 * when the link down status has been detected
298 * @param bonded_port_id Port ID of bonded device.
299 * @param delay_ms Delay period in milliseconds.
302 * 0 on success, negative value otherwise.
305 rte_eth_bond_link_down_prop_delay_set(uint16_t bonded_port_id,
309 * Get the period in milliseconds set for delaying the disabling of a bonded
310 * link when the link down status has been detected
312 * @param bonded_port_id Port ID of bonded device.
315 * Delay period on success, negative value otherwise.
318 rte_eth_bond_link_down_prop_delay_get(uint16_t bonded_port_id);
321 * Set the period in milliseconds for delaying the enabling of a bonded link
322 * when the link up status has been detected
324 * @param bonded_port_id Port ID of bonded device.
325 * @param delay_ms Delay period in milliseconds.
328 * 0 on success, negative value otherwise.
331 rte_eth_bond_link_up_prop_delay_set(uint16_t bonded_port_id,
335 * Get the period in milliseconds set for delaying the enabling of a bonded
336 * link when the link up status has been detected
338 * @param bonded_port_id Port ID of bonded device.
341 * Delay period on success, negative value otherwise.
344 rte_eth_bond_link_up_prop_delay_get(uint16_t bonded_port_id);