4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
37 #include <rte_malloc.h>
38 #include <rte_ethdev.h>
42 #include "rte_eth_bond.h"
43 #include "rte_eth_bond_private.h"
44 #include "rte_eth_bond_8023ad_private.h"
46 #define DEFAULT_POLLING_INTERVAL_10_MS (10)
49 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
51 /* Check valid pointer */
52 if (eth_dev->data->drv_name == NULL)
55 /* return 0 if driver name matches */
56 return eth_dev->data->drv_name != pmd_bond_drv.driver.name;
60 valid_bonded_port_id(uint8_t port_id)
62 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1);
63 return check_for_bonded_ethdev(&rte_eth_devices[port_id]);
67 valid_slave_port_id(uint8_t port_id)
69 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1);
71 /* Verify that port_id refers to a non bonded port */
72 if (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0)
79 activate_slave(struct rte_eth_dev *eth_dev, uint8_t port_id)
81 struct bond_dev_private *internals = eth_dev->data->dev_private;
82 uint8_t active_count = internals->active_slave_count;
84 if (internals->mode == BONDING_MODE_8023AD)
85 bond_mode_8023ad_activate_slave(eth_dev, port_id);
87 if (internals->mode == BONDING_MODE_TLB
88 || internals->mode == BONDING_MODE_ALB) {
90 internals->tlb_slaves_order[active_count] = port_id;
93 RTE_ASSERT(internals->active_slave_count <
94 (RTE_DIM(internals->active_slaves) - 1));
96 internals->active_slaves[internals->active_slave_count] = port_id;
97 internals->active_slave_count++;
99 if (internals->mode == BONDING_MODE_TLB)
100 bond_tlb_activate_slave(internals);
101 if (internals->mode == BONDING_MODE_ALB)
102 bond_mode_alb_client_list_upd(eth_dev);
106 deactivate_slave(struct rte_eth_dev *eth_dev, uint8_t port_id)
109 struct bond_dev_private *internals = eth_dev->data->dev_private;
110 uint8_t active_count = internals->active_slave_count;
112 if (internals->mode == BONDING_MODE_8023AD) {
113 bond_mode_8023ad_stop(eth_dev);
114 bond_mode_8023ad_deactivate_slave(eth_dev, port_id);
115 } else if (internals->mode == BONDING_MODE_TLB
116 || internals->mode == BONDING_MODE_ALB)
117 bond_tlb_disable(internals);
119 slave_pos = find_slave_by_id(internals->active_slaves, active_count,
122 /* If slave was not at the end of the list
123 * shift active slaves up active array list */
124 if (slave_pos < active_count) {
126 memmove(internals->active_slaves + slave_pos,
127 internals->active_slaves + slave_pos + 1,
128 (active_count - slave_pos) *
129 sizeof(internals->active_slaves[0]));
132 RTE_ASSERT(active_count < RTE_DIM(internals->active_slaves));
133 internals->active_slave_count = active_count;
135 if (eth_dev->data->dev_started) {
136 if (internals->mode == BONDING_MODE_8023AD) {
137 bond_mode_8023ad_start(eth_dev);
138 } else if (internals->mode == BONDING_MODE_TLB) {
139 bond_tlb_enable(internals);
140 } else if (internals->mode == BONDING_MODE_ALB) {
141 bond_tlb_enable(internals);
142 bond_mode_alb_client_list_upd(eth_dev);
148 number_of_sockets(void)
152 const struct rte_memseg *ms = rte_eal_get_physmem_layout();
154 for (i = 0; ((i < RTE_MAX_MEMSEG) && (ms[i].addr != NULL)); i++) {
155 if (sockets < ms[i].socket_id)
156 sockets = ms[i].socket_id;
159 /* Number of sockets = maximum socket_id + 1 */
164 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
166 struct bond_dev_private *internals = NULL;
167 struct rte_eth_dev *eth_dev = NULL;
168 uint32_t vlan_filter_bmp_size;
170 /* now do all data allocation - for eth_dev structure, dummy pci driver
171 * and internal (private) data
175 RTE_BOND_LOG(ERR, "Invalid name specified");
179 if (socket_id >= number_of_sockets()) {
181 "Invalid socket id specified to create bonded device on.");
185 internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
186 if (internals == NULL) {
187 RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
191 /* reserve an ethdev entry */
192 eth_dev = rte_eth_dev_allocate(name);
193 if (eth_dev == NULL) {
194 RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
198 eth_dev->data->dev_private = internals;
199 eth_dev->data->nb_rx_queues = (uint16_t)1;
200 eth_dev->data->nb_tx_queues = (uint16_t)1;
202 eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
204 if (eth_dev->data->mac_addrs == NULL) {
205 RTE_BOND_LOG(ERR, "Unable to malloc mac_addrs");
209 eth_dev->dev_ops = &default_dev_ops;
210 eth_dev->data->dev_flags = RTE_ETH_DEV_INTR_LSC |
211 RTE_ETH_DEV_DETACHABLE;
212 eth_dev->driver = NULL;
213 eth_dev->data->kdrv = RTE_KDRV_NONE;
214 eth_dev->data->drv_name = pmd_bond_drv.driver.name;
215 eth_dev->data->numa_node = socket_id;
217 rte_spinlock_init(&internals->lock);
219 internals->port_id = eth_dev->data->port_id;
220 internals->mode = BONDING_MODE_INVALID;
221 internals->current_primary_port = RTE_MAX_ETHPORTS + 1;
222 internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
223 internals->xmit_hash = xmit_l2_hash;
224 internals->user_defined_mac = 0;
225 internals->link_props_set = 0;
227 internals->link_status_polling_enabled = 0;
229 internals->link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS;
230 internals->link_down_delay_ms = 0;
231 internals->link_up_delay_ms = 0;
233 internals->slave_count = 0;
234 internals->active_slave_count = 0;
235 internals->rx_offload_capa = 0;
236 internals->tx_offload_capa = 0;
237 internals->candidate_max_rx_pktlen = 0;
238 internals->max_rx_pktlen = 0;
240 /* Initially allow to choose any offload type */
241 internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK;
243 memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
244 memset(internals->slaves, 0, sizeof(internals->slaves));
246 /* Set mode 4 default configuration */
247 bond_mode_8023ad_setup(eth_dev, NULL);
248 if (bond_ethdev_mode_set(eth_dev, mode)) {
249 RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
250 eth_dev->data->port_id, mode);
254 vlan_filter_bmp_size =
255 rte_bitmap_get_memory_footprint(ETHER_MAX_VLAN_ID + 1);
256 internals->vlan_filter_bmpmem = rte_malloc(name, vlan_filter_bmp_size,
257 RTE_CACHE_LINE_SIZE);
258 if (internals->vlan_filter_bmpmem == NULL) {
260 "Failed to allocate vlan bitmap for bonded device %u\n",
261 eth_dev->data->port_id);
265 internals->vlan_filter_bmp = rte_bitmap_init(ETHER_MAX_VLAN_ID + 1,
266 internals->vlan_filter_bmpmem, vlan_filter_bmp_size);
267 if (internals->vlan_filter_bmp == NULL) {
269 "Failed to init vlan bitmap for bonded device %u\n",
270 eth_dev->data->port_id);
271 rte_free(internals->vlan_filter_bmpmem);
275 return eth_dev->data->port_id;
279 if (eth_dev != NULL) {
280 rte_free(eth_dev->data->mac_addrs);
281 rte_eth_dev_release_port(eth_dev);
287 rte_eth_bond_free(const char *name)
289 struct rte_eth_dev *eth_dev = NULL;
290 struct bond_dev_private *internals;
292 /* now free all data allocation - for eth_dev structure,
293 * dummy pci driver and internal (private) data
296 /* find an ethdev entry */
297 eth_dev = rte_eth_dev_allocated(name);
301 internals = eth_dev->data->dev_private;
302 if (internals->slave_count != 0)
305 if (eth_dev->data->dev_started == 1) {
306 bond_ethdev_stop(eth_dev);
307 bond_ethdev_close(eth_dev);
310 eth_dev->dev_ops = NULL;
311 eth_dev->rx_pkt_burst = NULL;
312 eth_dev->tx_pkt_burst = NULL;
314 internals = eth_dev->data->dev_private;
315 rte_bitmap_free(internals->vlan_filter_bmp);
316 rte_free(internals->vlan_filter_bmpmem);
317 rte_free(eth_dev->data->dev_private);
318 rte_free(eth_dev->data->mac_addrs);
320 rte_eth_dev_release_port(eth_dev);
326 slave_vlan_filter_set(uint8_t bonded_port_id, uint8_t slave_port_id)
328 struct rte_eth_dev *bonded_eth_dev;
329 struct bond_dev_private *internals;
336 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
337 if (bonded_eth_dev->data->dev_conf.rxmode.hw_vlan_filter == 0)
340 internals = bonded_eth_dev->data->dev_private;
341 found = rte_bitmap_scan(internals->vlan_filter_bmp, &pos, &slab);
351 for (i = 0, mask = 1;
352 i < RTE_BITMAP_SLAB_BIT_SIZE;
354 if (unlikely(slab & mask))
355 res = rte_eth_dev_vlan_filter(slave_port_id,
358 found = rte_bitmap_scan(internals->vlan_filter_bmp,
360 } while (found && first != pos && res == 0);
366 __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
368 struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
369 struct bond_dev_private *internals;
370 struct rte_eth_link link_props;
371 struct rte_eth_dev_info dev_info;
373 if (valid_slave_port_id(slave_port_id) != 0)
376 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
377 internals = bonded_eth_dev->data->dev_private;
379 slave_eth_dev = &rte_eth_devices[slave_port_id];
380 if (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_BONDED_SLAVE) {
381 RTE_BOND_LOG(ERR, "Slave device is already a slave of a bonded device");
385 /* Add slave details to bonded device */
386 slave_eth_dev->data->dev_flags |= RTE_ETH_DEV_BONDED_SLAVE;
388 rte_eth_dev_info_get(slave_port_id, &dev_info);
389 if (dev_info.max_rx_pktlen < internals->max_rx_pktlen) {
390 RTE_BOND_LOG(ERR, "Slave (port %u) max_rx_pktlen too small",
395 slave_add(internals, slave_eth_dev);
397 /* We need to store slaves reta_size to be able to synchronize RETA for all
398 * slave devices even if its sizes are different.
400 internals->slaves[internals->slave_count].reta_size = dev_info.reta_size;
402 if (internals->slave_count < 1) {
403 /* if MAC is not user defined then use MAC of first slave add to
405 if (!internals->user_defined_mac)
406 mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs);
408 /* Inherit eth dev link properties from first slave */
409 link_properties_set(bonded_eth_dev,
410 &(slave_eth_dev->data->dev_link));
412 /* Make primary slave */
413 internals->primary_port = slave_port_id;
414 internals->current_primary_port = slave_port_id;
416 /* Inherit queues settings from first slave */
417 internals->nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
418 internals->nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
420 internals->reta_size = dev_info.reta_size;
422 /* Take the first dev's offload capabilities */
423 internals->rx_offload_capa = dev_info.rx_offload_capa;
424 internals->tx_offload_capa = dev_info.tx_offload_capa;
425 internals->flow_type_rss_offloads = dev_info.flow_type_rss_offloads;
427 /* Inherit first slave's max rx packet size */
428 internals->candidate_max_rx_pktlen = dev_info.max_rx_pktlen;
431 internals->rx_offload_capa &= dev_info.rx_offload_capa;
432 internals->tx_offload_capa &= dev_info.tx_offload_capa;
433 internals->flow_type_rss_offloads &= dev_info.flow_type_rss_offloads;
435 /* RETA size is GCD of all slaves RETA sizes, so, if all sizes will be
436 * the power of 2, the lower one is GCD
438 if (internals->reta_size > dev_info.reta_size)
439 internals->reta_size = dev_info.reta_size;
441 if (!internals->max_rx_pktlen &&
442 dev_info.max_rx_pktlen < internals->candidate_max_rx_pktlen)
443 internals->candidate_max_rx_pktlen = dev_info.max_rx_pktlen;
446 bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf &=
447 internals->flow_type_rss_offloads;
449 internals->slave_count++;
451 /* Update all slave devices MACs*/
452 mac_address_slaves_update(bonded_eth_dev);
454 if (bonded_eth_dev->data->dev_started) {
455 if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
456 slave_eth_dev->data->dev_flags &= (~RTE_ETH_DEV_BONDED_SLAVE);
457 RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
463 /* Register link status change callback with bonded device pointer as
465 rte_eth_dev_callback_register(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
466 bond_ethdev_lsc_event_callback, &bonded_eth_dev->data->port_id);
468 /* If bonded device is started then we can add the slave to our active
470 if (bonded_eth_dev->data->dev_started) {
471 rte_eth_link_get_nowait(slave_port_id, &link_props);
473 if (link_props.link_status == ETH_LINK_UP) {
474 if (internals->active_slave_count == 0 &&
475 !internals->user_defined_primary_port)
476 bond_ethdev_primary_set(internals,
479 if (find_slave_by_id(internals->active_slaves,
480 internals->active_slave_count,
481 slave_port_id) == internals->active_slave_count)
482 activate_slave(bonded_eth_dev, slave_port_id);
486 slave_vlan_filter_set(bonded_port_id, slave_port_id);
493 rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
495 struct rte_eth_dev *bonded_eth_dev;
496 struct bond_dev_private *internals;
500 /* Verify that port id's are valid bonded and slave ports */
501 if (valid_bonded_port_id(bonded_port_id) != 0)
504 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
505 internals = bonded_eth_dev->data->dev_private;
507 rte_spinlock_lock(&internals->lock);
509 retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);
511 rte_spinlock_unlock(&internals->lock);
517 __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
519 struct rte_eth_dev *bonded_eth_dev;
520 struct bond_dev_private *internals;
521 struct rte_eth_dev *slave_eth_dev;
524 if (valid_slave_port_id(slave_port_id) != 0)
527 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
528 internals = bonded_eth_dev->data->dev_private;
530 /* first remove from active slave list */
531 slave_idx = find_slave_by_id(internals->active_slaves,
532 internals->active_slave_count, slave_port_id);
534 if (slave_idx < internals->active_slave_count)
535 deactivate_slave(bonded_eth_dev, slave_port_id);
538 /* now find in slave list */
539 for (i = 0; i < internals->slave_count; i++)
540 if (internals->slaves[i].port_id == slave_port_id) {
546 RTE_BOND_LOG(ERR, "Couldn't find slave in port list, slave count %d",
547 internals->slave_count);
551 /* Un-register link status change callback with bonded device pointer as
553 rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
554 bond_ethdev_lsc_event_callback,
555 &rte_eth_devices[bonded_port_id].data->port_id);
557 /* Restore original MAC address of slave device */
558 mac_address_set(&rte_eth_devices[slave_port_id],
559 &(internals->slaves[slave_idx].persisted_mac_addr));
561 slave_eth_dev = &rte_eth_devices[slave_port_id];
562 slave_remove(internals, slave_eth_dev);
563 slave_eth_dev->data->dev_flags &= (~RTE_ETH_DEV_BONDED_SLAVE);
565 /* first slave in the active list will be the primary by default,
566 * otherwise use first device in list */
567 if (internals->current_primary_port == slave_port_id) {
568 if (internals->active_slave_count > 0)
569 internals->current_primary_port = internals->active_slaves[0];
570 else if (internals->slave_count > 0)
571 internals->current_primary_port = internals->slaves[0].port_id;
573 internals->primary_port = 0;
576 if (internals->active_slave_count < 1) {
577 /* reset device link properties as no slaves are active */
578 link_properties_reset(&rte_eth_devices[bonded_port_id]);
580 /* if no slaves are any longer attached to bonded device and MAC is not
581 * user defined then clear MAC of bonded device as it will be reset
582 * when a new slave is added */
583 if (internals->slave_count < 1 && !internals->user_defined_mac)
584 memset(rte_eth_devices[bonded_port_id].data->mac_addrs, 0,
585 sizeof(*(rte_eth_devices[bonded_port_id].data->mac_addrs)));
587 if (internals->slave_count == 0) {
588 internals->rx_offload_capa = 0;
589 internals->tx_offload_capa = 0;
590 internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK;
591 internals->reta_size = 0;
592 internals->candidate_max_rx_pktlen = 0;
593 internals->max_rx_pktlen = 0;
599 rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
601 struct rte_eth_dev *bonded_eth_dev;
602 struct bond_dev_private *internals;
605 if (valid_bonded_port_id(bonded_port_id) != 0)
608 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
609 internals = bonded_eth_dev->data->dev_private;
611 rte_spinlock_lock(&internals->lock);
613 retval = __eth_bond_slave_remove_lock_free(bonded_port_id, slave_port_id);
615 rte_spinlock_unlock(&internals->lock);
621 rte_eth_bond_mode_set(uint8_t bonded_port_id, uint8_t mode)
623 if (valid_bonded_port_id(bonded_port_id) != 0)
626 return bond_ethdev_mode_set(&rte_eth_devices[bonded_port_id], mode);
630 rte_eth_bond_mode_get(uint8_t bonded_port_id)
632 struct bond_dev_private *internals;
634 if (valid_bonded_port_id(bonded_port_id) != 0)
637 internals = rte_eth_devices[bonded_port_id].data->dev_private;
639 return internals->mode;
643 rte_eth_bond_primary_set(uint8_t bonded_port_id, uint8_t slave_port_id)
645 struct bond_dev_private *internals;
647 if (valid_bonded_port_id(bonded_port_id) != 0)
650 if (valid_slave_port_id(slave_port_id) != 0)
653 internals = rte_eth_devices[bonded_port_id].data->dev_private;
655 internals->user_defined_primary_port = 1;
656 internals->primary_port = slave_port_id;
658 bond_ethdev_primary_set(internals, slave_port_id);
664 rte_eth_bond_primary_get(uint8_t bonded_port_id)
666 struct bond_dev_private *internals;
668 if (valid_bonded_port_id(bonded_port_id) != 0)
671 internals = rte_eth_devices[bonded_port_id].data->dev_private;
673 if (internals->slave_count < 1)
676 return internals->current_primary_port;
680 rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
682 struct bond_dev_private *internals;
685 if (valid_bonded_port_id(bonded_port_id) != 0)
691 internals = rte_eth_devices[bonded_port_id].data->dev_private;
693 if (internals->slave_count > len)
696 for (i = 0; i < internals->slave_count; i++)
697 slaves[i] = internals->slaves[i].port_id;
699 return internals->slave_count;
703 rte_eth_bond_active_slaves_get(uint8_t bonded_port_id, uint8_t slaves[],
706 struct bond_dev_private *internals;
708 if (valid_bonded_port_id(bonded_port_id) != 0)
714 internals = rte_eth_devices[bonded_port_id].data->dev_private;
716 if (internals->active_slave_count > len)
719 memcpy(slaves, internals->active_slaves, internals->active_slave_count);
721 return internals->active_slave_count;
725 rte_eth_bond_mac_address_set(uint8_t bonded_port_id,
726 struct ether_addr *mac_addr)
728 struct rte_eth_dev *bonded_eth_dev;
729 struct bond_dev_private *internals;
731 if (valid_bonded_port_id(bonded_port_id) != 0)
734 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
735 internals = bonded_eth_dev->data->dev_private;
737 /* Set MAC Address of Bonded Device */
738 if (mac_address_set(bonded_eth_dev, mac_addr))
741 internals->user_defined_mac = 1;
743 /* Update all slave devices MACs*/
744 if (internals->slave_count > 0)
745 return mac_address_slaves_update(bonded_eth_dev);
751 rte_eth_bond_mac_address_reset(uint8_t bonded_port_id)
753 struct rte_eth_dev *bonded_eth_dev;
754 struct bond_dev_private *internals;
756 if (valid_bonded_port_id(bonded_port_id) != 0)
759 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
760 internals = bonded_eth_dev->data->dev_private;
762 internals->user_defined_mac = 0;
764 if (internals->slave_count > 0) {
765 /* Set MAC Address of Bonded Device */
766 if (mac_address_set(bonded_eth_dev,
767 &internals->slaves[internals->primary_port].persisted_mac_addr)
769 RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
772 /* Update all slave devices MAC addresses */
773 return mac_address_slaves_update(bonded_eth_dev);
775 /* No need to update anything as no slaves present */
780 rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy)
782 struct bond_dev_private *internals;
784 if (valid_bonded_port_id(bonded_port_id) != 0)
787 internals = rte_eth_devices[bonded_port_id].data->dev_private;
790 case BALANCE_XMIT_POLICY_LAYER2:
791 internals->balance_xmit_policy = policy;
792 internals->xmit_hash = xmit_l2_hash;
794 case BALANCE_XMIT_POLICY_LAYER23:
795 internals->balance_xmit_policy = policy;
796 internals->xmit_hash = xmit_l23_hash;
798 case BALANCE_XMIT_POLICY_LAYER34:
799 internals->balance_xmit_policy = policy;
800 internals->xmit_hash = xmit_l34_hash;
810 rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id)
812 struct bond_dev_private *internals;
814 if (valid_bonded_port_id(bonded_port_id) != 0)
817 internals = rte_eth_devices[bonded_port_id].data->dev_private;
819 return internals->balance_xmit_policy;
823 rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms)
825 struct bond_dev_private *internals;
827 if (valid_bonded_port_id(bonded_port_id) != 0)
830 internals = rte_eth_devices[bonded_port_id].data->dev_private;
831 internals->link_status_polling_interval_ms = internal_ms;
837 rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id)
839 struct bond_dev_private *internals;
841 if (valid_bonded_port_id(bonded_port_id) != 0)
844 internals = rte_eth_devices[bonded_port_id].data->dev_private;
846 return internals->link_status_polling_interval_ms;
850 rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
853 struct bond_dev_private *internals;
855 if (valid_bonded_port_id(bonded_port_id) != 0)
858 internals = rte_eth_devices[bonded_port_id].data->dev_private;
859 internals->link_down_delay_ms = delay_ms;
865 rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id)
867 struct bond_dev_private *internals;
869 if (valid_bonded_port_id(bonded_port_id) != 0)
872 internals = rte_eth_devices[bonded_port_id].data->dev_private;
874 return internals->link_down_delay_ms;
878 rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
881 struct bond_dev_private *internals;
883 if (valid_bonded_port_id(bonded_port_id) != 0)
886 internals = rte_eth_devices[bonded_port_id].data->dev_private;
887 internals->link_up_delay_ms = delay_ms;
893 rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id)
895 struct bond_dev_private *internals;
897 if (valid_bonded_port_id(bonded_port_id) != 0)
900 internals = rte_eth_devices[bonded_port_id].data->dev_private;
902 return internals->link_up_delay_ms;