bond: disable broadcast mode if mbuf refcnt is disabled
[dpdk.git] / lib / librte_pmd_bond / rte_eth_bond.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef _RTE_ETH_BOND_H_
35 #define _RTE_ETH_BOND_H_
36
37 /**
38  * @file rte_eth_bond.h
39  *
40  * RTE Link Bonding Ethernet Device
41  * Link Bonding for 1GbE and 10GbE ports to allow the aggregation of multiple
42  * (slave) NICs into a single logical interface. The bonded device processes
43  * these interfaces based on the mode of operation specified and supported.
44  * This implementation supports 4 modes of operation round robin, active backup
45  * balance and broadcast. Providing redundant links, fault tolerance and/or
46  * load balancing of network ports
47  */
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52
53 #include <rte_ether.h>
54
55 /* Supported modes of operation of link bonding library  */
56
57 #define BONDING_MODE_ROUND_ROBIN                (0)
58 /**< Round Robin (Mode 0).
59  * In this mode all transmitted packets will be balanced equally across all
60  * active slaves of the bonded in a round robin fashion. */
61 #define BONDING_MODE_ACTIVE_BACKUP              (1)
62 /**< Active Backup (Mode 1).
63  * In this mode all packets transmitted will be transmitted on the primary
64  * slave until such point as the primary slave is no longer available and then
65  * transmitted packets will be sent on the next available slaves. The primary
66  * slave can be defined by the user but defaults to the first active slave
67  * available if not specified. */
68 #define BONDING_MODE_BALANCE                    (2)
69 /**< Balance (Mode 2).
70  * In this mode all packets transmitted will be balanced across the available
71  * slaves using one of three available transmit policies - l2, l2+3 or l3+4.
72  * See BALANCE_XMIT_POLICY macros definitions for further details on transmit
73  * policies. */
74 #ifdef RTE_MBUF_REFCNT
75 #define BONDING_MODE_BROADCAST                  (3)
76 /**< Broadcast (Mode 3).
77  * In this mode all transmitted packets will be transmitted on all available
78  * active slaves of the bonded. */
79 #endif
80 /* Balance Mode Transmit Policies */
81 #define BALANCE_XMIT_POLICY_LAYER2              (0)
82 /**< Layer 2 (Ethernet MAC) */
83 #define BALANCE_XMIT_POLICY_LAYER23             (1)
84 /**< Layer 2+3 (Ethernet MAC + IP Addresses) transmit load balancing */
85 #define BALANCE_XMIT_POLICY_LAYER34             (2)
86 /**< Layer 3+4 (IP Addresses + UDP Ports) transmit load balancing */
87
88 /**
89  * Create a bonded rte_eth_dev device
90  *
91  * @param name                  Name of new link bonding device.
92  * @param mode                  Mode to initialize bonding device in.
93  * @param socket_id             Socket Id on which to allocate eth_dev resources.
94  *
95  * @return
96  *      Port Id of created rte_eth_dev on success, negative value otherwise
97  */
98 int
99 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id);
100
101 /**
102  * Add a rte_eth_dev device as a slave to the bonded device
103  *
104  * @param bonded_port_id        Port ID of bonded device.
105  * @param slave_port_id         Port ID of slave device.
106  *
107  * @return
108  *      0 on success, negative value otherwise
109  */
110 int
111 rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id);
112
113 /**
114  * Remove a slave rte_eth_dev device from the bonded device
115  *
116  * @param bonded_port_id        Port ID of bonded device.
117  * @param slave_port_id         Port ID of slave device.
118  *
119  * @return
120  *      0 on success, negative value otherwise
121  */
122 int
123 rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id);
124
125 /**
126  * Set link bonding mode of bonded device
127  *
128  * @param bonded_port_id        Port ID of bonded device.
129  * @param mode                          Bonding mode to set
130  *
131  * @return
132  *      0 on success, negative value otherwise
133  */
134 int
135 rte_eth_bond_mode_set(uint8_t bonded_port_id, uint8_t mode);
136
137 /**
138  * Get link bonding mode of bonded device
139  *
140  * @param bonded_port_id        Port ID of bonded device.
141  *
142  * @return
143  *      link bonding mode on success, negative value otherwise
144  */
145 int
146 rte_eth_bond_mode_get(uint8_t bonded_port_id);
147
148 /**
149  * Set slave rte_eth_dev as primary slave of bonded device
150  *
151  * @param bonded_port_id        Port ID of bonded device.
152  * @param slave_port_id         Port ID of slave device.
153  *
154  * @return
155  *      0 on success, negative value otherwise
156  */
157 int
158 rte_eth_bond_primary_set(uint8_t bonded_port_id, uint8_t slave_port_id);
159
160 /**
161  * Get primary slave of bonded device
162  *
163  * @param bonded_port_id        Port ID of bonded device.
164  *
165  * @return
166  *      Port Id of primary slave on success, -1 on failure
167  */
168 int
169 rte_eth_bond_primary_get(uint8_t bonded_port_id);
170
171 /**
172  * Populate an array with list of the slaves port id's of the bonded device
173  *
174  * @param bonded_port_id        Port ID of bonded eth_dev to interrogate
175  * @param slaves                        Array to be populated with the current active slaves
176  * @param len                           Length of slaves array
177  *
178  * @return
179  *      Number of slaves associated with bonded device on success,
180  *      negative value otherwise
181  */
182 int
183 rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len);
184
185 /**
186  * Populate an array with list of the active slaves port id's of the bonded
187  * device.
188  *
189  * @param bonded_port_id        Port ID of bonded eth_dev to interrogate
190  * @param slaves                        Array to be populated with the current active slaves
191  * @param len                           Length of slaves array
192  *
193  * @return
194  *      Number of active slaves associated with bonded device on success,
195  *      negative value otherwise
196  */
197 int
198 rte_eth_bond_active_slaves_get(uint8_t bonded_port_id, uint8_t slaves[],
199                 uint8_t len);
200
201 /**
202  * Set explicit MAC address to use on bonded device and it's slaves.
203  *
204  * @param bonded_port_id        Port ID of bonded device.
205  * @param mac_addr                      MAC Address to use on bonded device overriding
206  *                                                      slaves MAC addresses
207  *
208  * @return
209  *      0 on success, negative value otherwise
210  */
211 int
212 rte_eth_bond_mac_address_set(uint8_t bonded_port_id,
213                 struct ether_addr *mac_addr);
214
215 /**
216  * Reset bonded device to use MAC from primary slave on bonded device and it's
217  * slaves.
218  *
219  * @param bonded_port_id        Port ID of bonded device.
220  *
221  * @return
222  *      0 on success, negative value otherwise
223  */
224 int
225 rte_eth_bond_mac_address_reset(uint8_t bonded_port_id);
226
227 /**
228  * Set the transmit policy for bonded device to use when it is operating in
229  * balance mode, this parameter is otherwise ignored in other modes of
230  * operation.
231  *
232  * @param bonded_port_id        Port ID of bonded device.
233  * @param policy                        Balance mode transmission policy.
234  *
235  * @return
236  *      0 on success, negative value otherwise.
237  */
238 int
239 rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy);
240
241 /**
242  * Get the transmit policy set on bonded device for balance mode operation
243  *
244  * @param bonded_port_id        Port ID of bonded device.
245  *
246  * @return
247  *      Balance transmit policy on success, negative value otherwise.
248  */
249 int
250 rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id);
251
252 #ifdef __cplusplus
253 }
254 #endif
255
256 #endif