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>
41 #include "rte_eth_bond.h"
42 #include "rte_eth_bond_private.h"
43 #include "rte_eth_bond_8023ad_private.h"
45 #define DEFAULT_POLLING_INTERVAL_10_MS (10)
47 const char pmd_bond_driver_name[] = "rte_bond_pmd";
50 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
52 /* Check valid pointer */
53 if (eth_dev->data->drv_name == NULL)
56 /* return 0 if driver name matches */
57 return eth_dev->data->drv_name != pmd_bond_driver_name;
61 valid_bonded_port_id(uint8_t port_id)
63 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1);
64 return check_for_bonded_ethdev(&rte_eth_devices[port_id]);
68 valid_slave_port_id(uint8_t port_id)
70 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1);
72 /* Verify that port_id refers to a non bonded port */
73 if (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0)
80 activate_slave(struct rte_eth_dev *eth_dev, uint8_t port_id)
82 struct bond_dev_private *internals = eth_dev->data->dev_private;
83 uint8_t active_count = internals->active_slave_count;
85 if (internals->mode == BONDING_MODE_8023AD)
86 bond_mode_8023ad_activate_slave(eth_dev, port_id);
88 if (internals->mode == BONDING_MODE_TLB
89 || internals->mode == BONDING_MODE_ALB) {
91 internals->tlb_slaves_order[active_count] = port_id;
94 RTE_ASSERT(internals->active_slave_count <
95 (RTE_DIM(internals->active_slaves) - 1));
97 internals->active_slaves[internals->active_slave_count] = port_id;
98 internals->active_slave_count++;
100 if (internals->mode == BONDING_MODE_TLB)
101 bond_tlb_activate_slave(internals);
102 if (internals->mode == BONDING_MODE_ALB)
103 bond_mode_alb_client_list_upd(eth_dev);
107 deactivate_slave(struct rte_eth_dev *eth_dev, uint8_t port_id)
110 struct bond_dev_private *internals = eth_dev->data->dev_private;
111 uint8_t active_count = internals->active_slave_count;
113 if (internals->mode == BONDING_MODE_8023AD) {
114 bond_mode_8023ad_stop(eth_dev);
115 bond_mode_8023ad_deactivate_slave(eth_dev, port_id);
116 } else if (internals->mode == BONDING_MODE_TLB
117 || internals->mode == BONDING_MODE_ALB)
118 bond_tlb_disable(internals);
120 slave_pos = find_slave_by_id(internals->active_slaves, active_count,
123 /* If slave was not at the end of the list
124 * shift active slaves up active array list */
125 if (slave_pos < active_count) {
127 memmove(internals->active_slaves + slave_pos,
128 internals->active_slaves + slave_pos + 1,
129 (active_count - slave_pos) *
130 sizeof(internals->active_slaves[0]));
133 RTE_ASSERT(active_count < RTE_DIM(internals->active_slaves));
134 internals->active_slave_count = active_count;
136 if (eth_dev->data->dev_started) {
137 if (internals->mode == BONDING_MODE_8023AD) {
138 bond_mode_8023ad_start(eth_dev);
139 } else if (internals->mode == BONDING_MODE_TLB) {
140 bond_tlb_enable(internals);
141 } else if (internals->mode == BONDING_MODE_ALB) {
142 bond_tlb_enable(internals);
143 bond_mode_alb_client_list_upd(eth_dev);
149 number_of_sockets(void)
153 const struct rte_memseg *ms = rte_eal_get_physmem_layout();
155 for (i = 0; ((i < RTE_MAX_MEMSEG) && (ms[i].addr != NULL)); i++) {
156 if (sockets < ms[i].socket_id)
157 sockets = ms[i].socket_id;
160 /* Number of sockets = maximum socket_id + 1 */
165 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
167 struct bond_dev_private *internals = NULL;
168 struct rte_eth_dev *eth_dev = NULL;
169 uint32_t vlan_filter_bmp_size;
171 /* now do all data allocation - for eth_dev structure, dummy pci driver
172 * and internal (private) data
176 RTE_BOND_LOG(ERR, "Invalid name specified");
180 if (socket_id >= number_of_sockets()) {
182 "Invalid socket id specified to create bonded device on.");
186 internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
187 if (internals == NULL) {
188 RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
192 /* reserve an ethdev entry */
193 eth_dev = rte_eth_dev_allocate(name);
194 if (eth_dev == NULL) {
195 RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
199 eth_dev->data->dev_private = internals;
200 eth_dev->data->nb_rx_queues = (uint16_t)1;
201 eth_dev->data->nb_tx_queues = (uint16_t)1;
203 eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
205 if (eth_dev->data->mac_addrs == NULL) {
206 RTE_BOND_LOG(ERR, "Unable to malloc mac_addrs");
210 eth_dev->dev_ops = &default_dev_ops;
211 eth_dev->data->dev_flags = RTE_ETH_DEV_INTR_LSC |
212 RTE_ETH_DEV_DETACHABLE;
213 eth_dev->driver = NULL;
214 eth_dev->data->kdrv = RTE_KDRV_NONE;
215 eth_dev->data->drv_name = pmd_bond_driver_name;
216 eth_dev->data->numa_node = socket_id;
218 rte_spinlock_init(&internals->lock);
220 internals->port_id = eth_dev->data->port_id;
221 internals->mode = BONDING_MODE_INVALID;
222 internals->current_primary_port = RTE_MAX_ETHPORTS + 1;
223 internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
224 internals->xmit_hash = xmit_l2_hash;
225 internals->user_defined_mac = 0;
226 internals->link_props_set = 0;
228 internals->link_status_polling_enabled = 0;
230 internals->link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS;
231 internals->link_down_delay_ms = 0;
232 internals->link_up_delay_ms = 0;
234 internals->slave_count = 0;
235 internals->active_slave_count = 0;
236 internals->rx_offload_capa = 0;
237 internals->tx_offload_capa = 0;
238 internals->candidate_max_rx_pktlen = 0;
239 internals->max_rx_pktlen = 0;
241 /* Initially allow to choose any offload type */
242 internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK;
244 memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
245 memset(internals->slaves, 0, sizeof(internals->slaves));
247 /* Set mode 4 default configuration */
248 bond_mode_8023ad_setup(eth_dev, NULL);
249 if (bond_ethdev_mode_set(eth_dev, mode)) {
250 RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
251 eth_dev->data->port_id, mode);
255 vlan_filter_bmp_size =
256 rte_bitmap_get_memory_footprint(ETHER_MAX_VLAN_ID + 1);
257 internals->vlan_filter_bmpmem = rte_malloc(name, vlan_filter_bmp_size,
258 RTE_CACHE_LINE_SIZE);
259 if (internals->vlan_filter_bmpmem == NULL) {
261 "Failed to allocate vlan bitmap for bonded device %u\n",
262 eth_dev->data->port_id);
266 internals->vlan_filter_bmp = rte_bitmap_init(ETHER_MAX_VLAN_ID + 1,
267 internals->vlan_filter_bmpmem, vlan_filter_bmp_size);
268 if (internals->vlan_filter_bmp == NULL) {
270 "Failed to init vlan bitmap for bonded device %u\n",
271 eth_dev->data->port_id);
272 rte_free(internals->vlan_filter_bmpmem);
276 return eth_dev->data->port_id;
280 if (eth_dev != NULL) {
281 rte_free(eth_dev->data->mac_addrs);
282 rte_eth_dev_release_port(eth_dev);
288 rte_eth_bond_free(const char *name)
290 struct rte_eth_dev *eth_dev = NULL;
291 struct bond_dev_private *internals;
293 /* now free all data allocation - for eth_dev structure,
294 * dummy pci driver and internal (private) data
297 /* find an ethdev entry */
298 eth_dev = rte_eth_dev_allocated(name);
302 internals = eth_dev->data->dev_private;
303 if (internals->slave_count != 0)
306 if (eth_dev->data->dev_started == 1) {
307 bond_ethdev_stop(eth_dev);
308 bond_ethdev_close(eth_dev);
311 eth_dev->dev_ops = NULL;
312 eth_dev->rx_pkt_burst = NULL;
313 eth_dev->tx_pkt_burst = NULL;
315 internals = eth_dev->data->dev_private;
316 rte_bitmap_free(internals->vlan_filter_bmp);
317 rte_free(internals->vlan_filter_bmpmem);
318 rte_free(eth_dev->data->dev_private);
319 rte_free(eth_dev->data->mac_addrs);
321 rte_eth_dev_release_port(eth_dev);
327 slave_vlan_filter_set(uint8_t bonded_port_id, uint8_t slave_port_id)
329 struct rte_eth_dev *bonded_eth_dev;
330 struct bond_dev_private *internals;
337 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
338 if (bonded_eth_dev->data->dev_conf.rxmode.hw_vlan_filter == 0)
341 internals = bonded_eth_dev->data->dev_private;
342 found = rte_bitmap_scan(internals->vlan_filter_bmp, &pos, &slab);
352 for (i = 0, mask = 1;
353 i < RTE_BITMAP_SLAB_BIT_SIZE;
355 if (unlikely(slab & mask))
356 res = rte_eth_dev_vlan_filter(slave_port_id,
359 found = rte_bitmap_scan(internals->vlan_filter_bmp,
361 } while (found && first != pos && res == 0);
367 __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
369 struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
370 struct bond_dev_private *internals;
371 struct rte_eth_link link_props;
372 struct rte_eth_dev_info dev_info;
374 if (valid_slave_port_id(slave_port_id) != 0)
377 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
378 internals = bonded_eth_dev->data->dev_private;
380 slave_eth_dev = &rte_eth_devices[slave_port_id];
381 if (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_BONDED_SLAVE) {
382 RTE_BOND_LOG(ERR, "Slave device is already a slave of a bonded device");
386 /* Add slave details to bonded device */
387 slave_eth_dev->data->dev_flags |= RTE_ETH_DEV_BONDED_SLAVE;
389 rte_eth_dev_info_get(slave_port_id, &dev_info);
390 if (dev_info.max_rx_pktlen < internals->max_rx_pktlen) {
391 RTE_BOND_LOG(ERR, "Slave (port %u) max_rx_pktlen too small",
396 slave_add(internals, slave_eth_dev);
398 /* We need to store slaves reta_size to be able to synchronize RETA for all
399 * slave devices even if its sizes are different.
401 internals->slaves[internals->slave_count].reta_size = dev_info.reta_size;
403 if (internals->slave_count < 1) {
404 /* if MAC is not user defined then use MAC of first slave add to
406 if (!internals->user_defined_mac)
407 mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs);
409 /* Inherit eth dev link properties from first slave */
410 link_properties_set(bonded_eth_dev,
411 &(slave_eth_dev->data->dev_link));
413 /* Make primary slave */
414 internals->primary_port = slave_port_id;
415 internals->current_primary_port = slave_port_id;
417 /* Inherit queues settings from first slave */
418 internals->nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
419 internals->nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
421 internals->reta_size = dev_info.reta_size;
423 /* Take the first dev's offload capabilities */
424 internals->rx_offload_capa = dev_info.rx_offload_capa;
425 internals->tx_offload_capa = dev_info.tx_offload_capa;
426 internals->flow_type_rss_offloads = dev_info.flow_type_rss_offloads;
428 /* Inherit first slave's max rx packet size */
429 internals->candidate_max_rx_pktlen = dev_info.max_rx_pktlen;
432 internals->rx_offload_capa &= dev_info.rx_offload_capa;
433 internals->tx_offload_capa &= dev_info.tx_offload_capa;
434 internals->flow_type_rss_offloads &= dev_info.flow_type_rss_offloads;
436 /* RETA size is GCD of all slaves RETA sizes, so, if all sizes will be
437 * the power of 2, the lower one is GCD
439 if (internals->reta_size > dev_info.reta_size)
440 internals->reta_size = dev_info.reta_size;
442 if (!internals->max_rx_pktlen &&
443 dev_info.max_rx_pktlen < internals->candidate_max_rx_pktlen)
444 internals->candidate_max_rx_pktlen = dev_info.max_rx_pktlen;
447 bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf &=
448 internals->flow_type_rss_offloads;
450 internals->slave_count++;
452 /* Update all slave devices MACs*/
453 mac_address_slaves_update(bonded_eth_dev);
455 if (bonded_eth_dev->data->dev_started) {
456 if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
457 slave_eth_dev->data->dev_flags &= (~RTE_ETH_DEV_BONDED_SLAVE);
458 RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
464 /* Register link status change callback with bonded device pointer as
466 rte_eth_dev_callback_register(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
467 bond_ethdev_lsc_event_callback, &bonded_eth_dev->data->port_id);
469 /* If bonded device is started then we can add the slave to our active
471 if (bonded_eth_dev->data->dev_started) {
472 rte_eth_link_get_nowait(slave_port_id, &link_props);
474 if (link_props.link_status == ETH_LINK_UP) {
475 if (internals->active_slave_count == 0 &&
476 !internals->user_defined_primary_port)
477 bond_ethdev_primary_set(internals,
480 if (find_slave_by_id(internals->active_slaves,
481 internals->active_slave_count,
482 slave_port_id) == internals->active_slave_count)
483 activate_slave(bonded_eth_dev, slave_port_id);
487 slave_vlan_filter_set(bonded_port_id, slave_port_id);
494 rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
496 struct rte_eth_dev *bonded_eth_dev;
497 struct bond_dev_private *internals;
501 /* Verify that port id's are valid bonded and slave ports */
502 if (valid_bonded_port_id(bonded_port_id) != 0)
505 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
506 internals = bonded_eth_dev->data->dev_private;
508 rte_spinlock_lock(&internals->lock);
510 retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);
512 rte_spinlock_unlock(&internals->lock);
518 __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
520 struct rte_eth_dev *bonded_eth_dev;
521 struct bond_dev_private *internals;
522 struct rte_eth_dev *slave_eth_dev;
525 if (valid_slave_port_id(slave_port_id) != 0)
528 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
529 internals = bonded_eth_dev->data->dev_private;
531 /* first remove from active slave list */
532 slave_idx = find_slave_by_id(internals->active_slaves,
533 internals->active_slave_count, slave_port_id);
535 if (slave_idx < internals->active_slave_count)
536 deactivate_slave(bonded_eth_dev, slave_port_id);
539 /* now find in slave list */
540 for (i = 0; i < internals->slave_count; i++)
541 if (internals->slaves[i].port_id == slave_port_id) {
547 RTE_BOND_LOG(ERR, "Couldn't find slave in port list, slave count %d",
548 internals->slave_count);
552 /* Un-register link status change callback with bonded device pointer as
554 rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
555 bond_ethdev_lsc_event_callback,
556 &rte_eth_devices[bonded_port_id].data->port_id);
558 /* Restore original MAC address of slave device */
559 mac_address_set(&rte_eth_devices[slave_port_id],
560 &(internals->slaves[slave_idx].persisted_mac_addr));
562 slave_eth_dev = &rte_eth_devices[slave_port_id];
563 slave_remove(internals, slave_eth_dev);
564 slave_eth_dev->data->dev_flags &= (~RTE_ETH_DEV_BONDED_SLAVE);
566 /* first slave in the active list will be the primary by default,
567 * otherwise use first device in list */
568 if (internals->current_primary_port == slave_port_id) {
569 if (internals->active_slave_count > 0)
570 internals->current_primary_port = internals->active_slaves[0];
571 else if (internals->slave_count > 0)
572 internals->current_primary_port = internals->slaves[0].port_id;
574 internals->primary_port = 0;
577 if (internals->active_slave_count < 1) {
578 /* reset device link properties as no slaves are active */
579 link_properties_reset(&rte_eth_devices[bonded_port_id]);
581 /* if no slaves are any longer attached to bonded device and MAC is not
582 * user defined then clear MAC of bonded device as it will be reset
583 * when a new slave is added */
584 if (internals->slave_count < 1 && !internals->user_defined_mac)
585 memset(rte_eth_devices[bonded_port_id].data->mac_addrs, 0,
586 sizeof(*(rte_eth_devices[bonded_port_id].data->mac_addrs)));
588 if (internals->slave_count == 0) {
589 internals->rx_offload_capa = 0;
590 internals->tx_offload_capa = 0;
591 internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK;
592 internals->reta_size = 0;
593 internals->candidate_max_rx_pktlen = 0;
594 internals->max_rx_pktlen = 0;
600 rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
602 struct rte_eth_dev *bonded_eth_dev;
603 struct bond_dev_private *internals;
606 if (valid_bonded_port_id(bonded_port_id) != 0)
609 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
610 internals = bonded_eth_dev->data->dev_private;
612 rte_spinlock_lock(&internals->lock);
614 retval = __eth_bond_slave_remove_lock_free(bonded_port_id, slave_port_id);
616 rte_spinlock_unlock(&internals->lock);
622 rte_eth_bond_mode_set(uint8_t bonded_port_id, uint8_t mode)
624 if (valid_bonded_port_id(bonded_port_id) != 0)
627 return bond_ethdev_mode_set(&rte_eth_devices[bonded_port_id], mode);
631 rte_eth_bond_mode_get(uint8_t bonded_port_id)
633 struct bond_dev_private *internals;
635 if (valid_bonded_port_id(bonded_port_id) != 0)
638 internals = rte_eth_devices[bonded_port_id].data->dev_private;
640 return internals->mode;
644 rte_eth_bond_primary_set(uint8_t bonded_port_id, uint8_t slave_port_id)
646 struct bond_dev_private *internals;
648 if (valid_bonded_port_id(bonded_port_id) != 0)
651 if (valid_slave_port_id(slave_port_id) != 0)
654 internals = rte_eth_devices[bonded_port_id].data->dev_private;
656 internals->user_defined_primary_port = 1;
657 internals->primary_port = slave_port_id;
659 bond_ethdev_primary_set(internals, slave_port_id);
665 rte_eth_bond_primary_get(uint8_t bonded_port_id)
667 struct bond_dev_private *internals;
669 if (valid_bonded_port_id(bonded_port_id) != 0)
672 internals = rte_eth_devices[bonded_port_id].data->dev_private;
674 if (internals->slave_count < 1)
677 return internals->current_primary_port;
681 rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
683 struct bond_dev_private *internals;
686 if (valid_bonded_port_id(bonded_port_id) != 0)
692 internals = rte_eth_devices[bonded_port_id].data->dev_private;
694 if (internals->slave_count > len)
697 for (i = 0; i < internals->slave_count; i++)
698 slaves[i] = internals->slaves[i].port_id;
700 return internals->slave_count;
704 rte_eth_bond_active_slaves_get(uint8_t bonded_port_id, uint8_t slaves[],
707 struct bond_dev_private *internals;
709 if (valid_bonded_port_id(bonded_port_id) != 0)
715 internals = rte_eth_devices[bonded_port_id].data->dev_private;
717 if (internals->active_slave_count > len)
720 memcpy(slaves, internals->active_slaves, internals->active_slave_count);
722 return internals->active_slave_count;
726 rte_eth_bond_mac_address_set(uint8_t bonded_port_id,
727 struct ether_addr *mac_addr)
729 struct rte_eth_dev *bonded_eth_dev;
730 struct bond_dev_private *internals;
732 if (valid_bonded_port_id(bonded_port_id) != 0)
735 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
736 internals = bonded_eth_dev->data->dev_private;
738 /* Set MAC Address of Bonded Device */
739 if (mac_address_set(bonded_eth_dev, mac_addr))
742 internals->user_defined_mac = 1;
744 /* Update all slave devices MACs*/
745 if (internals->slave_count > 0)
746 return mac_address_slaves_update(bonded_eth_dev);
752 rte_eth_bond_mac_address_reset(uint8_t bonded_port_id)
754 struct rte_eth_dev *bonded_eth_dev;
755 struct bond_dev_private *internals;
757 if (valid_bonded_port_id(bonded_port_id) != 0)
760 bonded_eth_dev = &rte_eth_devices[bonded_port_id];
761 internals = bonded_eth_dev->data->dev_private;
763 internals->user_defined_mac = 0;
765 if (internals->slave_count > 0) {
766 /* Set MAC Address of Bonded Device */
767 if (mac_address_set(bonded_eth_dev,
768 &internals->slaves[internals->primary_port].persisted_mac_addr)
770 RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
773 /* Update all slave devices MAC addresses */
774 return mac_address_slaves_update(bonded_eth_dev);
776 /* No need to update anything as no slaves present */
781 rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy)
783 struct bond_dev_private *internals;
785 if (valid_bonded_port_id(bonded_port_id) != 0)
788 internals = rte_eth_devices[bonded_port_id].data->dev_private;
791 case BALANCE_XMIT_POLICY_LAYER2:
792 internals->balance_xmit_policy = policy;
793 internals->xmit_hash = xmit_l2_hash;
795 case BALANCE_XMIT_POLICY_LAYER23:
796 internals->balance_xmit_policy = policy;
797 internals->xmit_hash = xmit_l23_hash;
799 case BALANCE_XMIT_POLICY_LAYER34:
800 internals->balance_xmit_policy = policy;
801 internals->xmit_hash = xmit_l34_hash;
811 rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id)
813 struct bond_dev_private *internals;
815 if (valid_bonded_port_id(bonded_port_id) != 0)
818 internals = rte_eth_devices[bonded_port_id].data->dev_private;
820 return internals->balance_xmit_policy;
824 rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms)
826 struct bond_dev_private *internals;
828 if (valid_bonded_port_id(bonded_port_id) != 0)
831 internals = rte_eth_devices[bonded_port_id].data->dev_private;
832 internals->link_status_polling_interval_ms = internal_ms;
838 rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id)
840 struct bond_dev_private *internals;
842 if (valid_bonded_port_id(bonded_port_id) != 0)
845 internals = rte_eth_devices[bonded_port_id].data->dev_private;
847 return internals->link_status_polling_interval_ms;
851 rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
854 struct bond_dev_private *internals;
856 if (valid_bonded_port_id(bonded_port_id) != 0)
859 internals = rte_eth_devices[bonded_port_id].data->dev_private;
860 internals->link_down_delay_ms = delay_ms;
866 rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id)
868 struct bond_dev_private *internals;
870 if (valid_bonded_port_id(bonded_port_id) != 0)
873 internals = rte_eth_devices[bonded_port_id].data->dev_private;
875 return internals->link_down_delay_ms;
879 rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
882 struct bond_dev_private *internals;
884 if (valid_bonded_port_id(bonded_port_id) != 0)
887 internals = rte_eth_devices[bonded_port_id].data->dev_private;
888 internals->link_up_delay_ms = delay_ms;
894 rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id)
896 struct bond_dev_private *internals;
898 if (valid_bonded_port_id(bonded_port_id) != 0)
901 internals = rte_eth_devices[bonded_port_id].data->dev_private;
903 return internals->link_up_delay_ms;