1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2017 Intel Corporation
5 #include <netinet/in.h>
8 #include <rte_malloc.h>
9 #include <rte_ethdev_driver.h>
10 #include <rte_ethdev_vdev.h>
14 #include <rte_ip_frag.h>
15 #include <rte_devargs.h>
16 #include <rte_kvargs.h>
17 #include <rte_bus_vdev.h>
18 #include <rte_alarm.h>
19 #include <rte_cycles.h>
20 #include <rte_string_fns.h>
22 #include "rte_eth_bond.h"
23 #include "rte_eth_bond_private.h"
24 #include "rte_eth_bond_8023ad_private.h"
26 #define REORDER_PERIOD_MS 10
27 #define DEFAULT_POLLING_INTERVAL_10_MS (10)
28 #define BOND_MAX_MAC_ADDRS 16
30 #define HASH_L4_PORTS(h) ((h)->src_port ^ (h)->dst_port)
32 /* Table for statistics in mode 5 TLB */
33 static uint64_t tlb_last_obytets[RTE_MAX_ETHPORTS];
36 get_vlan_offset(struct ether_hdr *eth_hdr, uint16_t *proto)
38 size_t vlan_offset = 0;
40 if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == *proto) {
41 struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1);
43 vlan_offset = sizeof(struct vlan_hdr);
44 *proto = vlan_hdr->eth_proto;
46 if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == *proto) {
47 vlan_hdr = vlan_hdr + 1;
48 *proto = vlan_hdr->eth_proto;
49 vlan_offset += sizeof(struct vlan_hdr);
56 bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
58 struct bond_dev_private *internals;
60 uint16_t num_rx_slave = 0;
61 uint16_t num_rx_total = 0;
65 /* Cast to structure, containing bonded device's port id and queue id */
66 struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
68 internals = bd_rx_q->dev_private;
71 for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
72 /* Offset of pointer to *bufs increases as packets are received
73 * from other slaves */
74 num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
75 bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
77 num_rx_total += num_rx_slave;
78 nb_pkts -= num_rx_slave;
86 bond_ethdev_rx_burst_active_backup(void *queue, struct rte_mbuf **bufs,
89 struct bond_dev_private *internals;
91 /* Cast to structure, containing bonded device's port id and queue id */
92 struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
94 internals = bd_rx_q->dev_private;
96 return rte_eth_rx_burst(internals->current_primary_port,
97 bd_rx_q->queue_id, bufs, nb_pkts);
100 static inline uint8_t
101 is_lacp_packets(uint16_t ethertype, uint8_t subtype, struct rte_mbuf *mbuf)
103 const uint16_t ether_type_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);
105 return !((mbuf->ol_flags & PKT_RX_VLAN) ? mbuf->vlan_tci : 0) &&
106 (ethertype == ether_type_slow_be &&
107 (subtype == SLOW_SUBTYPE_MARKER || subtype == SLOW_SUBTYPE_LACP));
110 /*****************************************************************************
111 * Flow director's setup for mode 4 optimization
114 static struct rte_flow_item_eth flow_item_eth_type_8023ad = {
115 .dst.addr_bytes = { 0 },
116 .src.addr_bytes = { 0 },
117 .type = RTE_BE16(ETHER_TYPE_SLOW),
120 static struct rte_flow_item_eth flow_item_eth_mask_type_8023ad = {
121 .dst.addr_bytes = { 0 },
122 .src.addr_bytes = { 0 },
126 static struct rte_flow_item flow_item_8023ad[] = {
128 .type = RTE_FLOW_ITEM_TYPE_ETH,
129 .spec = &flow_item_eth_type_8023ad,
131 .mask = &flow_item_eth_mask_type_8023ad,
134 .type = RTE_FLOW_ITEM_TYPE_END,
141 const struct rte_flow_attr flow_attr_8023ad = {
150 bond_ethdev_8023ad_flow_verify(struct rte_eth_dev *bond_dev,
151 uint16_t slave_port) {
152 struct rte_eth_dev_info slave_info;
153 struct rte_flow_error error;
154 struct bond_dev_private *internals = (struct bond_dev_private *)
155 (bond_dev->data->dev_private);
157 const struct rte_flow_action_queue lacp_queue_conf = {
161 const struct rte_flow_action actions[] = {
163 .type = RTE_FLOW_ACTION_TYPE_QUEUE,
164 .conf = &lacp_queue_conf
167 .type = RTE_FLOW_ACTION_TYPE_END,
171 int ret = rte_flow_validate(slave_port, &flow_attr_8023ad,
172 flow_item_8023ad, actions, &error);
174 RTE_BOND_LOG(ERR, "%s: %s (slave_port=%d queue_id=%d)",
175 __func__, error.message, slave_port,
176 internals->mode4.dedicated_queues.rx_qid);
180 rte_eth_dev_info_get(slave_port, &slave_info);
181 if (slave_info.max_rx_queues < bond_dev->data->nb_rx_queues ||
182 slave_info.max_tx_queues < bond_dev->data->nb_tx_queues) {
184 "%s: Slave %d capabilities doesn't allow to allocate additional queues",
185 __func__, slave_port);
193 bond_8023ad_slow_pkt_hw_filter_supported(uint16_t port_id) {
194 struct rte_eth_dev *bond_dev = &rte_eth_devices[port_id];
195 struct bond_dev_private *internals = (struct bond_dev_private *)
196 (bond_dev->data->dev_private);
197 struct rte_eth_dev_info bond_info;
200 /* Verify if all slaves in bonding supports flow director and */
201 if (internals->slave_count > 0) {
202 rte_eth_dev_info_get(bond_dev->data->port_id, &bond_info);
204 internals->mode4.dedicated_queues.rx_qid = bond_info.nb_rx_queues;
205 internals->mode4.dedicated_queues.tx_qid = bond_info.nb_tx_queues;
207 for (idx = 0; idx < internals->slave_count; idx++) {
208 if (bond_ethdev_8023ad_flow_verify(bond_dev,
209 internals->slaves[idx].port_id) != 0)
218 bond_ethdev_8023ad_flow_set(struct rte_eth_dev *bond_dev, uint16_t slave_port) {
220 struct rte_flow_error error;
221 struct bond_dev_private *internals = (struct bond_dev_private *)
222 (bond_dev->data->dev_private);
224 struct rte_flow_action_queue lacp_queue_conf = {
225 .index = internals->mode4.dedicated_queues.rx_qid,
228 const struct rte_flow_action actions[] = {
230 .type = RTE_FLOW_ACTION_TYPE_QUEUE,
231 .conf = &lacp_queue_conf
234 .type = RTE_FLOW_ACTION_TYPE_END,
238 internals->mode4.dedicated_queues.flow[slave_port] = rte_flow_create(slave_port,
239 &flow_attr_8023ad, flow_item_8023ad, actions, &error);
240 if (internals->mode4.dedicated_queues.flow[slave_port] == NULL) {
241 RTE_BOND_LOG(ERR, "bond_ethdev_8023ad_flow_set: %s "
242 "(slave_port=%d queue_id=%d)",
243 error.message, slave_port,
244 internals->mode4.dedicated_queues.rx_qid);
252 bond_ethdev_rx_burst_8023ad_fast_queue(void *queue, struct rte_mbuf **bufs,
255 struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
256 struct bond_dev_private *internals = bd_rx_q->dev_private;
257 uint16_t num_rx_total = 0; /* Total number of received packets */
258 uint16_t slaves[RTE_MAX_ETHPORTS];
259 uint16_t slave_count;
263 /* Copy slave list to protect against slave up/down changes during tx
265 slave_count = internals->active_slave_count;
266 memcpy(slaves, internals->active_slaves,
267 sizeof(internals->active_slaves[0]) * slave_count);
269 for (i = 0, idx = internals->active_slave;
270 i < slave_count && num_rx_total < nb_pkts; i++, idx++) {
271 idx = idx % slave_count;
273 /* Read packets from this slave */
274 num_rx_total += rte_eth_rx_burst(slaves[idx], bd_rx_q->queue_id,
275 &bufs[num_rx_total], nb_pkts - num_rx_total);
278 internals->active_slave = idx;
284 bond_ethdev_tx_burst_8023ad_fast_queue(void *queue, struct rte_mbuf **bufs,
287 struct bond_tx_queue *bd_tx_q = (struct bond_tx_queue *)queue;
288 struct bond_dev_private *internals = bd_tx_q->dev_private;
290 uint16_t slave_port_ids[RTE_MAX_ETHPORTS];
291 uint16_t slave_count;
293 uint16_t dist_slave_port_ids[RTE_MAX_ETHPORTS];
294 uint16_t dist_slave_count;
296 /* 2-D array to sort mbufs for transmission on each slave into */
297 struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_bufs];
298 /* Number of mbufs for transmission on each slave */
299 uint16_t slave_nb_bufs[RTE_MAX_ETHPORTS] = { 0 };
300 /* Mapping array generated by hash function to map mbufs to slaves */
301 uint16_t bufs_slave_port_idxs[RTE_MAX_ETHPORTS] = { 0 };
303 uint16_t slave_tx_count, slave_tx_fail_count[RTE_MAX_ETHPORTS] = { 0 };
304 uint16_t total_tx_count = 0, total_tx_fail_count = 0;
308 if (unlikely(nb_bufs == 0))
311 /* Copy slave list to protect against slave up/down changes during tx
313 slave_count = internals->active_slave_count;
314 if (unlikely(slave_count < 1))
317 memcpy(slave_port_ids, internals->active_slaves,
318 sizeof(slave_port_ids[0]) * slave_count);
321 dist_slave_count = 0;
322 for (i = 0; i < slave_count; i++) {
323 struct port *port = &mode_8023ad_ports[slave_port_ids[i]];
325 if (ACTOR_STATE(port, DISTRIBUTING))
326 dist_slave_port_ids[dist_slave_count++] =
330 if (unlikely(dist_slave_count < 1))
334 * Populate slaves mbuf with the packets which are to be sent on it
335 * selecting output slave using hash based on xmit policy
337 internals->burst_xmit_hash(bufs, nb_bufs, dist_slave_count,
338 bufs_slave_port_idxs);
340 for (i = 0; i < nb_bufs; i++) {
341 /* Populate slave mbuf arrays with mbufs for that slave. */
342 uint8_t slave_idx = bufs_slave_port_idxs[i];
344 slave_bufs[slave_idx][slave_nb_bufs[slave_idx]++] = bufs[i];
348 /* Send packet burst on each slave device */
349 for (i = 0; i < dist_slave_count; i++) {
350 if (slave_nb_bufs[i] == 0)
353 slave_tx_count = rte_eth_tx_burst(dist_slave_port_ids[i],
354 bd_tx_q->queue_id, slave_bufs[i],
357 total_tx_count += slave_tx_count;
359 /* If tx burst fails move packets to end of bufs */
360 if (unlikely(slave_tx_count < slave_nb_bufs[i])) {
361 slave_tx_fail_count[i] = slave_nb_bufs[i] -
363 total_tx_fail_count += slave_tx_fail_count[i];
366 * Shift bufs to beginning of array to allow reordering
369 for (j = 0; j < slave_tx_fail_count[i]; j++) {
371 slave_bufs[i][(slave_tx_count - 1) + j];
377 * If there are tx burst failures we move packets to end of bufs to
378 * preserve expected PMD behaviour of all failed transmitted being
379 * at the end of the input mbuf array
381 if (unlikely(total_tx_fail_count > 0)) {
382 int bufs_idx = nb_bufs - total_tx_fail_count - 1;
384 for (i = 0; i < slave_count; i++) {
385 if (slave_tx_fail_count[i] > 0) {
386 for (j = 0; j < slave_tx_fail_count[i]; j++)
387 bufs[bufs_idx++] = slave_bufs[i][j];
392 return total_tx_count;
397 bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf **bufs,
400 /* Cast to structure, containing bonded device's port id and queue id */
401 struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
402 struct bond_dev_private *internals = bd_rx_q->dev_private;
403 struct ether_addr bond_mac;
405 struct ether_hdr *hdr;
407 const uint16_t ether_type_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);
408 uint16_t num_rx_total = 0; /* Total number of received packets */
409 uint16_t slaves[RTE_MAX_ETHPORTS];
410 uint16_t slave_count, idx;
412 uint8_t collecting; /* current slave collecting status */
413 const uint8_t promisc = internals->promiscuous_en;
417 rte_eth_macaddr_get(internals->port_id, &bond_mac);
418 /* Copy slave list to protect against slave up/down changes during tx
420 slave_count = internals->active_slave_count;
421 memcpy(slaves, internals->active_slaves,
422 sizeof(internals->active_slaves[0]) * slave_count);
424 idx = internals->active_slave;
425 if (idx >= slave_count) {
426 internals->active_slave = 0;
429 for (i = 0; i < slave_count && num_rx_total < nb_pkts; i++) {
431 collecting = ACTOR_STATE(&mode_8023ad_ports[slaves[idx]],
434 /* Read packets from this slave */
435 num_rx_total += rte_eth_rx_burst(slaves[idx], bd_rx_q->queue_id,
436 &bufs[num_rx_total], nb_pkts - num_rx_total);
438 for (k = j; k < 2 && k < num_rx_total; k++)
439 rte_prefetch0(rte_pktmbuf_mtod(bufs[k], void *));
441 /* Handle slow protocol packets. */
442 while (j < num_rx_total) {
444 /* If packet is not pure L2 and is known, skip it */
445 if ((bufs[j]->packet_type & ~RTE_PTYPE_L2_ETHER) != 0) {
450 if (j + 3 < num_rx_total)
451 rte_prefetch0(rte_pktmbuf_mtod(bufs[j + 3], void *));
453 hdr = rte_pktmbuf_mtod(bufs[j], struct ether_hdr *);
454 subtype = ((struct slow_protocol_frame *)hdr)->slow_protocol.subtype;
456 /* Remove packet from array if it is slow packet or slave is not
457 * in collecting state or bonding interface is not in promiscuous
458 * mode and packet address does not match. */
459 if (unlikely(is_lacp_packets(hdr->ether_type, subtype, bufs[j]) ||
460 !collecting || (!promisc &&
461 !is_multicast_ether_addr(&hdr->d_addr) &&
462 !is_same_ether_addr(&bond_mac, &hdr->d_addr)))) {
464 if (hdr->ether_type == ether_type_slow_be) {
465 bond_mode_8023ad_handle_slow_pkt(
466 internals, slaves[idx], bufs[j]);
468 rte_pktmbuf_free(bufs[j]);
470 /* Packet is managed by mode 4 or dropped, shift the array */
472 if (j < num_rx_total) {
473 memmove(&bufs[j], &bufs[j + 1], sizeof(bufs[0]) *
479 if (unlikely(++idx == slave_count))
483 internals->active_slave = idx;
487 #if defined(RTE_LIBRTE_BOND_DEBUG_ALB) || defined(RTE_LIBRTE_BOND_DEBUG_ALB_L1)
488 uint32_t burstnumberRX;
489 uint32_t burstnumberTX;
491 #ifdef RTE_LIBRTE_BOND_DEBUG_ALB
494 arp_op_name(uint16_t arp_op, char *buf)
498 snprintf(buf, sizeof("ARP Request"), "%s", "ARP Request");
501 snprintf(buf, sizeof("ARP Reply"), "%s", "ARP Reply");
503 case ARP_OP_REVREQUEST:
504 snprintf(buf, sizeof("Reverse ARP Request"), "%s",
505 "Reverse ARP Request");
507 case ARP_OP_REVREPLY:
508 snprintf(buf, sizeof("Reverse ARP Reply"), "%s",
509 "Reverse ARP Reply");
511 case ARP_OP_INVREQUEST:
512 snprintf(buf, sizeof("Peer Identify Request"), "%s",
513 "Peer Identify Request");
515 case ARP_OP_INVREPLY:
516 snprintf(buf, sizeof("Peer Identify Reply"), "%s",
517 "Peer Identify Reply");
522 snprintf(buf, sizeof("Unknown"), "%s", "Unknown");
526 #define MaxIPv4String 16
528 ipv4_addr_to_dot(uint32_t be_ipv4_addr, char *buf, uint8_t buf_size)
532 ipv4_addr = rte_be_to_cpu_32(be_ipv4_addr);
533 snprintf(buf, buf_size, "%d.%d.%d.%d", (ipv4_addr >> 24) & 0xFF,
534 (ipv4_addr >> 16) & 0xFF, (ipv4_addr >> 8) & 0xFF,
538 #define MAX_CLIENTS_NUMBER 128
539 uint8_t active_clients;
540 struct client_stats_t {
543 uint32_t ipv4_rx_packets;
544 uint32_t ipv4_tx_packets;
546 struct client_stats_t client_stats[MAX_CLIENTS_NUMBER];
549 update_client_stats(uint32_t addr, uint16_t port, uint32_t *TXorRXindicator)
553 for (; i < MAX_CLIENTS_NUMBER; i++) {
554 if ((client_stats[i].ipv4_addr == addr) && (client_stats[i].port == port)) {
555 /* Just update RX packets number for this client */
556 if (TXorRXindicator == &burstnumberRX)
557 client_stats[i].ipv4_rx_packets++;
559 client_stats[i].ipv4_tx_packets++;
563 /* We have a new client. Insert him to the table, and increment stats */
564 if (TXorRXindicator == &burstnumberRX)
565 client_stats[active_clients].ipv4_rx_packets++;
567 client_stats[active_clients].ipv4_tx_packets++;
568 client_stats[active_clients].ipv4_addr = addr;
569 client_stats[active_clients].port = port;
574 #ifdef RTE_LIBRTE_BOND_DEBUG_ALB
575 #define MODE6_DEBUG(info, src_ip, dst_ip, eth_h, arp_op, port, burstnumber) \
576 rte_log(RTE_LOG_DEBUG, bond_logtype, \
577 "%s port:%d SrcMAC:%02X:%02X:%02X:%02X:%02X:%02X SrcIP:%s " \
578 "DstMAC:%02X:%02X:%02X:%02X:%02X:%02X DstIP:%s %s %d\n", \
581 eth_h->s_addr.addr_bytes[0], eth_h->s_addr.addr_bytes[1], \
582 eth_h->s_addr.addr_bytes[2], eth_h->s_addr.addr_bytes[3], \
583 eth_h->s_addr.addr_bytes[4], eth_h->s_addr.addr_bytes[5], \
585 eth_h->d_addr.addr_bytes[0], eth_h->d_addr.addr_bytes[1], \
586 eth_h->d_addr.addr_bytes[2], eth_h->d_addr.addr_bytes[3], \
587 eth_h->d_addr.addr_bytes[4], eth_h->d_addr.addr_bytes[5], \
589 arp_op, ++burstnumber)
593 mode6_debug(const char __attribute__((unused)) *info, struct ether_hdr *eth_h,
594 uint16_t port, uint32_t __attribute__((unused)) *burstnumber)
596 struct ipv4_hdr *ipv4_h;
597 #ifdef RTE_LIBRTE_BOND_DEBUG_ALB
598 struct arp_hdr *arp_h;
605 uint16_t ether_type = eth_h->ether_type;
606 uint16_t offset = get_vlan_offset(eth_h, ðer_type);
608 #ifdef RTE_LIBRTE_BOND_DEBUG_ALB
609 strlcpy(buf, info, 16);
612 if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv4)) {
613 ipv4_h = (struct ipv4_hdr *)((char *)(eth_h + 1) + offset);
614 ipv4_addr_to_dot(ipv4_h->src_addr, src_ip, MaxIPv4String);
615 #ifdef RTE_LIBRTE_BOND_DEBUG_ALB
616 ipv4_addr_to_dot(ipv4_h->dst_addr, dst_ip, MaxIPv4String);
617 MODE6_DEBUG(buf, src_ip, dst_ip, eth_h, "", port, *burstnumber);
619 update_client_stats(ipv4_h->src_addr, port, burstnumber);
621 #ifdef RTE_LIBRTE_BOND_DEBUG_ALB
622 else if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_ARP)) {
623 arp_h = (struct arp_hdr *)((char *)(eth_h + 1) + offset);
624 ipv4_addr_to_dot(arp_h->arp_data.arp_sip, src_ip, MaxIPv4String);
625 ipv4_addr_to_dot(arp_h->arp_data.arp_tip, dst_ip, MaxIPv4String);
626 arp_op_name(rte_be_to_cpu_16(arp_h->arp_op), ArpOp);
627 MODE6_DEBUG(buf, src_ip, dst_ip, eth_h, ArpOp, port, *burstnumber);
634 bond_ethdev_rx_burst_alb(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
636 struct bond_tx_queue *bd_tx_q = (struct bond_tx_queue *)queue;
637 struct bond_dev_private *internals = bd_tx_q->dev_private;
638 struct ether_hdr *eth_h;
639 uint16_t ether_type, offset;
640 uint16_t nb_recv_pkts;
643 nb_recv_pkts = bond_ethdev_rx_burst(queue, bufs, nb_pkts);
645 for (i = 0; i < nb_recv_pkts; i++) {
646 eth_h = rte_pktmbuf_mtod(bufs[i], struct ether_hdr *);
647 ether_type = eth_h->ether_type;
648 offset = get_vlan_offset(eth_h, ðer_type);
650 if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_ARP)) {
651 #if defined(RTE_LIBRTE_BOND_DEBUG_ALB) || defined(RTE_LIBRTE_BOND_DEBUG_ALB_L1)
652 mode6_debug("RX ARP:", eth_h, bufs[i]->port, &burstnumberRX);
654 bond_mode_alb_arp_recv(eth_h, offset, internals);
656 #if defined(RTE_LIBRTE_BOND_DEBUG_ALB) || defined(RTE_LIBRTE_BOND_DEBUG_ALB_L1)
657 else if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv4))
658 mode6_debug("RX IPv4:", eth_h, bufs[i]->port, &burstnumberRX);
666 bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
669 struct bond_dev_private *internals;
670 struct bond_tx_queue *bd_tx_q;
672 struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_pkts];
673 uint16_t slave_nb_pkts[RTE_MAX_ETHPORTS] = { 0 };
675 uint16_t num_of_slaves;
676 uint16_t slaves[RTE_MAX_ETHPORTS];
678 uint16_t num_tx_total = 0, num_tx_slave;
680 static int slave_idx = 0;
681 int i, cslave_idx = 0, tx_fail_total = 0;
683 bd_tx_q = (struct bond_tx_queue *)queue;
684 internals = bd_tx_q->dev_private;
686 /* Copy slave list to protect against slave up/down changes during tx
688 num_of_slaves = internals->active_slave_count;
689 memcpy(slaves, internals->active_slaves,
690 sizeof(internals->active_slaves[0]) * num_of_slaves);
692 if (num_of_slaves < 1)
695 /* Populate slaves mbuf with which packets are to be sent on it */
696 for (i = 0; i < nb_pkts; i++) {
697 cslave_idx = (slave_idx + i) % num_of_slaves;
698 slave_bufs[cslave_idx][(slave_nb_pkts[cslave_idx])++] = bufs[i];
701 /* increment current slave index so the next call to tx burst starts on the
703 slave_idx = ++cslave_idx;
705 /* Send packet burst on each slave device */
706 for (i = 0; i < num_of_slaves; i++) {
707 if (slave_nb_pkts[i] > 0) {
708 num_tx_slave = rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id,
709 slave_bufs[i], slave_nb_pkts[i]);
711 /* if tx burst fails move packets to end of bufs */
712 if (unlikely(num_tx_slave < slave_nb_pkts[i])) {
713 int tx_fail_slave = slave_nb_pkts[i] - num_tx_slave;
715 tx_fail_total += tx_fail_slave;
717 memcpy(&bufs[nb_pkts - tx_fail_total],
718 &slave_bufs[i][num_tx_slave],
719 tx_fail_slave * sizeof(bufs[0]));
721 num_tx_total += num_tx_slave;
729 bond_ethdev_tx_burst_active_backup(void *queue,
730 struct rte_mbuf **bufs, uint16_t nb_pkts)
732 struct bond_dev_private *internals;
733 struct bond_tx_queue *bd_tx_q;
735 bd_tx_q = (struct bond_tx_queue *)queue;
736 internals = bd_tx_q->dev_private;
738 if (internals->active_slave_count < 1)
741 return rte_eth_tx_burst(internals->current_primary_port, bd_tx_q->queue_id,
745 static inline uint16_t
746 ether_hash(struct ether_hdr *eth_hdr)
748 unaligned_uint16_t *word_src_addr =
749 (unaligned_uint16_t *)eth_hdr->s_addr.addr_bytes;
750 unaligned_uint16_t *word_dst_addr =
751 (unaligned_uint16_t *)eth_hdr->d_addr.addr_bytes;
753 return (word_src_addr[0] ^ word_dst_addr[0]) ^
754 (word_src_addr[1] ^ word_dst_addr[1]) ^
755 (word_src_addr[2] ^ word_dst_addr[2]);
758 static inline uint32_t
759 ipv4_hash(struct ipv4_hdr *ipv4_hdr)
761 return ipv4_hdr->src_addr ^ ipv4_hdr->dst_addr;
764 static inline uint32_t
765 ipv6_hash(struct ipv6_hdr *ipv6_hdr)
767 unaligned_uint32_t *word_src_addr =
768 (unaligned_uint32_t *)&(ipv6_hdr->src_addr[0]);
769 unaligned_uint32_t *word_dst_addr =
770 (unaligned_uint32_t *)&(ipv6_hdr->dst_addr[0]);
772 return (word_src_addr[0] ^ word_dst_addr[0]) ^
773 (word_src_addr[1] ^ word_dst_addr[1]) ^
774 (word_src_addr[2] ^ word_dst_addr[2]) ^
775 (word_src_addr[3] ^ word_dst_addr[3]);
780 burst_xmit_l2_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
781 uint8_t slave_count, uint16_t *slaves)
783 struct ether_hdr *eth_hdr;
787 for (i = 0; i < nb_pkts; i++) {
788 eth_hdr = rte_pktmbuf_mtod(buf[i], struct ether_hdr *);
790 hash = ether_hash(eth_hdr);
792 slaves[i] = (hash ^= hash >> 8) % slave_count;
797 burst_xmit_l23_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
798 uint8_t slave_count, uint16_t *slaves)
801 struct ether_hdr *eth_hdr;
804 uint32_t hash, l3hash;
806 for (i = 0; i < nb_pkts; i++) {
807 eth_hdr = rte_pktmbuf_mtod(buf[i], struct ether_hdr *);
810 proto = eth_hdr->ether_type;
811 hash = ether_hash(eth_hdr);
813 vlan_offset = get_vlan_offset(eth_hdr, &proto);
815 if (rte_cpu_to_be_16(ETHER_TYPE_IPv4) == proto) {
816 struct ipv4_hdr *ipv4_hdr = (struct ipv4_hdr *)
817 ((char *)(eth_hdr + 1) + vlan_offset);
818 l3hash = ipv4_hash(ipv4_hdr);
820 } else if (rte_cpu_to_be_16(ETHER_TYPE_IPv6) == proto) {
821 struct ipv6_hdr *ipv6_hdr = (struct ipv6_hdr *)
822 ((char *)(eth_hdr + 1) + vlan_offset);
823 l3hash = ipv6_hash(ipv6_hdr);
826 hash = hash ^ l3hash;
830 slaves[i] = hash % slave_count;
835 burst_xmit_l34_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
836 uint8_t slave_count, uint16_t *slaves)
838 struct ether_hdr *eth_hdr;
843 struct udp_hdr *udp_hdr;
844 struct tcp_hdr *tcp_hdr;
845 uint32_t hash, l3hash, l4hash;
847 for (i = 0; i < nb_pkts; i++) {
848 eth_hdr = rte_pktmbuf_mtod(buf[i], struct ether_hdr *);
849 proto = eth_hdr->ether_type;
850 vlan_offset = get_vlan_offset(eth_hdr, &proto);
854 if (rte_cpu_to_be_16(ETHER_TYPE_IPv4) == proto) {
855 struct ipv4_hdr *ipv4_hdr = (struct ipv4_hdr *)
856 ((char *)(eth_hdr + 1) + vlan_offset);
857 size_t ip_hdr_offset;
859 l3hash = ipv4_hash(ipv4_hdr);
861 /* there is no L4 header in fragmented packet */
862 if (likely(rte_ipv4_frag_pkt_is_fragmented(ipv4_hdr)
864 ip_hdr_offset = (ipv4_hdr->version_ihl
865 & IPV4_HDR_IHL_MASK) *
868 if (ipv4_hdr->next_proto_id == IPPROTO_TCP) {
869 tcp_hdr = (struct tcp_hdr *)
872 l4hash = HASH_L4_PORTS(tcp_hdr);
873 } else if (ipv4_hdr->next_proto_id ==
875 udp_hdr = (struct udp_hdr *)
878 l4hash = HASH_L4_PORTS(udp_hdr);
881 } else if (rte_cpu_to_be_16(ETHER_TYPE_IPv6) == proto) {
882 struct ipv6_hdr *ipv6_hdr = (struct ipv6_hdr *)
883 ((char *)(eth_hdr + 1) + vlan_offset);
884 l3hash = ipv6_hash(ipv6_hdr);
886 if (ipv6_hdr->proto == IPPROTO_TCP) {
887 tcp_hdr = (struct tcp_hdr *)(ipv6_hdr + 1);
888 l4hash = HASH_L4_PORTS(tcp_hdr);
889 } else if (ipv6_hdr->proto == IPPROTO_UDP) {
890 udp_hdr = (struct udp_hdr *)(ipv6_hdr + 1);
891 l4hash = HASH_L4_PORTS(udp_hdr);
895 hash = l3hash ^ l4hash;
899 slaves[i] = hash % slave_count;
904 uint64_t bwg_left_int;
905 uint64_t bwg_left_remainder;
910 bond_tlb_activate_slave(struct bond_dev_private *internals) {
913 for (i = 0; i < internals->active_slave_count; i++) {
914 tlb_last_obytets[internals->active_slaves[i]] = 0;
919 bandwidth_cmp(const void *a, const void *b)
921 const struct bwg_slave *bwg_a = a;
922 const struct bwg_slave *bwg_b = b;
923 int64_t diff = (int64_t)bwg_b->bwg_left_int - (int64_t)bwg_a->bwg_left_int;
924 int64_t diff2 = (int64_t)bwg_b->bwg_left_remainder -
925 (int64_t)bwg_a->bwg_left_remainder;
939 bandwidth_left(uint16_t port_id, uint64_t load, uint8_t update_idx,
940 struct bwg_slave *bwg_slave)
942 struct rte_eth_link link_status;
944 rte_eth_link_get_nowait(port_id, &link_status);
945 uint64_t link_bwg = link_status.link_speed * 1000000ULL / 8;
948 link_bwg = link_bwg * (update_idx+1) * REORDER_PERIOD_MS;
949 bwg_slave->bwg_left_int = (link_bwg - 1000*load) / link_bwg;
950 bwg_slave->bwg_left_remainder = (link_bwg - 1000*load) % link_bwg;
954 bond_ethdev_update_tlb_slave_cb(void *arg)
956 struct bond_dev_private *internals = arg;
957 struct rte_eth_stats slave_stats;
958 struct bwg_slave bwg_array[RTE_MAX_ETHPORTS];
962 uint8_t update_stats = 0;
965 internals->slave_update_idx++;
968 if (internals->slave_update_idx >= REORDER_PERIOD_MS)
971 for (i = 0; i < internals->active_slave_count; i++) {
972 slave_id = internals->active_slaves[i];
973 rte_eth_stats_get(slave_id, &slave_stats);
974 tx_bytes = slave_stats.obytes - tlb_last_obytets[slave_id];
975 bandwidth_left(slave_id, tx_bytes,
976 internals->slave_update_idx, &bwg_array[i]);
977 bwg_array[i].slave = slave_id;
980 tlb_last_obytets[slave_id] = slave_stats.obytes;
984 if (update_stats == 1)
985 internals->slave_update_idx = 0;
988 qsort(bwg_array, slave_count, sizeof(bwg_array[0]), bandwidth_cmp);
989 for (i = 0; i < slave_count; i++)
990 internals->tlb_slaves_order[i] = bwg_array[i].slave;
992 rte_eal_alarm_set(REORDER_PERIOD_MS * 1000, bond_ethdev_update_tlb_slave_cb,
993 (struct bond_dev_private *)internals);
997 bond_ethdev_tx_burst_tlb(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
999 struct bond_tx_queue *bd_tx_q = (struct bond_tx_queue *)queue;
1000 struct bond_dev_private *internals = bd_tx_q->dev_private;
1002 struct rte_eth_dev *primary_port =
1003 &rte_eth_devices[internals->primary_port];
1004 uint16_t num_tx_total = 0;
1007 uint16_t num_of_slaves = internals->active_slave_count;
1008 uint16_t slaves[RTE_MAX_ETHPORTS];
1010 struct ether_hdr *ether_hdr;
1011 struct ether_addr primary_slave_addr;
1012 struct ether_addr active_slave_addr;
1014 if (num_of_slaves < 1)
1015 return num_tx_total;
1017 memcpy(slaves, internals->tlb_slaves_order,
1018 sizeof(internals->tlb_slaves_order[0]) * num_of_slaves);
1021 ether_addr_copy(primary_port->data->mac_addrs, &primary_slave_addr);
1024 for (i = 0; i < 3; i++)
1025 rte_prefetch0(rte_pktmbuf_mtod(bufs[i], void*));
1028 for (i = 0; i < num_of_slaves; i++) {
1029 rte_eth_macaddr_get(slaves[i], &active_slave_addr);
1030 for (j = num_tx_total; j < nb_pkts; j++) {
1031 if (j + 3 < nb_pkts)
1032 rte_prefetch0(rte_pktmbuf_mtod(bufs[j+3], void*));
1034 ether_hdr = rte_pktmbuf_mtod(bufs[j], struct ether_hdr *);
1035 if (is_same_ether_addr(ðer_hdr->s_addr, &primary_slave_addr))
1036 ether_addr_copy(&active_slave_addr, ðer_hdr->s_addr);
1037 #if defined(RTE_LIBRTE_BOND_DEBUG_ALB) || defined(RTE_LIBRTE_BOND_DEBUG_ALB_L1)
1038 mode6_debug("TX IPv4:", ether_hdr, slaves[i], &burstnumberTX);
1042 num_tx_total += rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id,
1043 bufs + num_tx_total, nb_pkts - num_tx_total);
1045 if (num_tx_total == nb_pkts)
1049 return num_tx_total;
1053 bond_tlb_disable(struct bond_dev_private *internals)
1055 rte_eal_alarm_cancel(bond_ethdev_update_tlb_slave_cb, internals);
1059 bond_tlb_enable(struct bond_dev_private *internals)
1061 bond_ethdev_update_tlb_slave_cb(internals);
1065 bond_ethdev_tx_burst_alb(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
1067 struct bond_tx_queue *bd_tx_q = (struct bond_tx_queue *)queue;
1068 struct bond_dev_private *internals = bd_tx_q->dev_private;
1070 struct ether_hdr *eth_h;
1071 uint16_t ether_type, offset;
1073 struct client_data *client_info;
1076 * We create transmit buffers for every slave and one additional to send
1077 * through tlb. In worst case every packet will be send on one port.
1079 struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS + 1][nb_pkts];
1080 uint16_t slave_bufs_pkts[RTE_MAX_ETHPORTS + 1] = { 0 };
1083 * We create separate transmit buffers for update packets as they won't
1084 * be counted in num_tx_total.
1086 struct rte_mbuf *update_bufs[RTE_MAX_ETHPORTS][ALB_HASH_TABLE_SIZE];
1087 uint16_t update_bufs_pkts[RTE_MAX_ETHPORTS] = { 0 };
1089 struct rte_mbuf *upd_pkt;
1092 uint16_t num_send, num_not_send = 0;
1093 uint16_t num_tx_total = 0;
1098 /* Search tx buffer for ARP packets and forward them to alb */
1099 for (i = 0; i < nb_pkts; i++) {
1100 eth_h = rte_pktmbuf_mtod(bufs[i], struct ether_hdr *);
1101 ether_type = eth_h->ether_type;
1102 offset = get_vlan_offset(eth_h, ðer_type);
1104 if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_ARP)) {
1105 slave_idx = bond_mode_alb_arp_xmit(eth_h, offset, internals);
1107 /* Change src mac in eth header */
1108 rte_eth_macaddr_get(slave_idx, ð_h->s_addr);
1110 /* Add packet to slave tx buffer */
1111 slave_bufs[slave_idx][slave_bufs_pkts[slave_idx]] = bufs[i];
1112 slave_bufs_pkts[slave_idx]++;
1114 /* If packet is not ARP, send it with TLB policy */
1115 slave_bufs[RTE_MAX_ETHPORTS][slave_bufs_pkts[RTE_MAX_ETHPORTS]] =
1117 slave_bufs_pkts[RTE_MAX_ETHPORTS]++;
1121 /* Update connected client ARP tables */
1122 if (internals->mode6.ntt) {
1123 for (i = 0; i < ALB_HASH_TABLE_SIZE; i++) {
1124 client_info = &internals->mode6.client_table[i];
1126 if (client_info->in_use) {
1127 /* Allocate new packet to send ARP update on current slave */
1128 upd_pkt = rte_pktmbuf_alloc(internals->mode6.mempool);
1129 if (upd_pkt == NULL) {
1131 "Failed to allocate ARP packet from pool");
1134 pkt_size = sizeof(struct ether_hdr) + sizeof(struct arp_hdr)
1135 + client_info->vlan_count * sizeof(struct vlan_hdr);
1136 upd_pkt->data_len = pkt_size;
1137 upd_pkt->pkt_len = pkt_size;
1139 slave_idx = bond_mode_alb_arp_upd(client_info, upd_pkt,
1142 /* Add packet to update tx buffer */
1143 update_bufs[slave_idx][update_bufs_pkts[slave_idx]] = upd_pkt;
1144 update_bufs_pkts[slave_idx]++;
1147 internals->mode6.ntt = 0;
1150 /* Send ARP packets on proper slaves */
1151 for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
1152 if (slave_bufs_pkts[i] > 0) {
1153 num_send = rte_eth_tx_burst(i, bd_tx_q->queue_id,
1154 slave_bufs[i], slave_bufs_pkts[i]);
1155 for (j = 0; j < slave_bufs_pkts[i] - num_send; j++) {
1156 bufs[nb_pkts - 1 - num_not_send - j] =
1157 slave_bufs[i][nb_pkts - 1 - j];
1160 num_tx_total += num_send;
1161 num_not_send += slave_bufs_pkts[i] - num_send;
1163 #if defined(RTE_LIBRTE_BOND_DEBUG_ALB) || defined(RTE_LIBRTE_BOND_DEBUG_ALB_L1)
1164 /* Print TX stats including update packets */
1165 for (j = 0; j < slave_bufs_pkts[i]; j++) {
1166 eth_h = rte_pktmbuf_mtod(slave_bufs[i][j], struct ether_hdr *);
1167 mode6_debug("TX ARP:", eth_h, i, &burstnumberTX);
1173 /* Send update packets on proper slaves */
1174 for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
1175 if (update_bufs_pkts[i] > 0) {
1176 num_send = rte_eth_tx_burst(i, bd_tx_q->queue_id, update_bufs[i],
1177 update_bufs_pkts[i]);
1178 for (j = num_send; j < update_bufs_pkts[i]; j++) {
1179 rte_pktmbuf_free(update_bufs[i][j]);
1181 #if defined(RTE_LIBRTE_BOND_DEBUG_ALB) || defined(RTE_LIBRTE_BOND_DEBUG_ALB_L1)
1182 for (j = 0; j < update_bufs_pkts[i]; j++) {
1183 eth_h = rte_pktmbuf_mtod(update_bufs[i][j], struct ether_hdr *);
1184 mode6_debug("TX ARPupd:", eth_h, i, &burstnumberTX);
1190 /* Send non-ARP packets using tlb policy */
1191 if (slave_bufs_pkts[RTE_MAX_ETHPORTS] > 0) {
1192 num_send = bond_ethdev_tx_burst_tlb(queue,
1193 slave_bufs[RTE_MAX_ETHPORTS],
1194 slave_bufs_pkts[RTE_MAX_ETHPORTS]);
1196 for (j = 0; j < slave_bufs_pkts[RTE_MAX_ETHPORTS]; j++) {
1197 bufs[nb_pkts - 1 - num_not_send - j] =
1198 slave_bufs[RTE_MAX_ETHPORTS][nb_pkts - 1 - j];
1201 num_tx_total += num_send;
1204 return num_tx_total;
1208 bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
1211 struct bond_tx_queue *bd_tx_q = (struct bond_tx_queue *)queue;
1212 struct bond_dev_private *internals = bd_tx_q->dev_private;
1214 uint16_t slave_port_ids[RTE_MAX_ETHPORTS];
1215 uint16_t slave_count;
1217 /* Array to sort mbufs for transmission on each slave into */
1218 struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_bufs];
1219 /* Number of mbufs for transmission on each slave */
1220 uint16_t slave_nb_bufs[RTE_MAX_ETHPORTS] = { 0 };
1221 /* Mapping array generated by hash function to map mbufs to slaves */
1222 uint16_t bufs_slave_port_idxs[nb_bufs];
1224 uint16_t slave_tx_count, slave_tx_fail_count[RTE_MAX_ETHPORTS] = { 0 };
1225 uint16_t total_tx_count = 0, total_tx_fail_count = 0;
1229 if (unlikely(nb_bufs == 0))
1232 /* Copy slave list to protect against slave up/down changes during tx
1234 slave_count = internals->active_slave_count;
1235 if (unlikely(slave_count < 1))
1238 memcpy(slave_port_ids, internals->active_slaves,
1239 sizeof(slave_port_ids[0]) * slave_count);
1242 * Populate slaves mbuf with the packets which are to be sent on it
1243 * selecting output slave using hash based on xmit policy
1245 internals->burst_xmit_hash(bufs, nb_bufs, slave_count,
1246 bufs_slave_port_idxs);
1248 for (i = 0; i < nb_bufs; i++) {
1249 /* Populate slave mbuf arrays with mbufs for that slave. */
1250 uint8_t slave_idx = bufs_slave_port_idxs[i];
1252 slave_bufs[slave_idx][slave_nb_bufs[slave_idx]++] = bufs[i];
1255 /* Send packet burst on each slave device */
1256 for (i = 0; i < slave_count; i++) {
1257 if (slave_nb_bufs[i] == 0)
1260 slave_tx_count = rte_eth_tx_burst(slave_port_ids[i],
1261 bd_tx_q->queue_id, slave_bufs[i],
1264 total_tx_count += slave_tx_count;
1266 /* If tx burst fails move packets to end of bufs */
1267 if (unlikely(slave_tx_count < slave_nb_bufs[i])) {
1268 slave_tx_fail_count[i] = slave_nb_bufs[i] -
1270 total_tx_fail_count += slave_tx_fail_count[i];
1273 * Shift bufs to beginning of array to allow reordering
1276 for (j = 0; j < slave_tx_fail_count[i]; j++) {
1278 slave_bufs[i][(slave_tx_count - 1) + j];
1284 * If there are tx burst failures we move packets to end of bufs to
1285 * preserve expected PMD behaviour of all failed transmitted being
1286 * at the end of the input mbuf array
1288 if (unlikely(total_tx_fail_count > 0)) {
1289 int bufs_idx = nb_bufs - total_tx_fail_count - 1;
1291 for (i = 0; i < slave_count; i++) {
1292 if (slave_tx_fail_count[i] > 0) {
1293 for (j = 0; j < slave_tx_fail_count[i]; j++)
1294 bufs[bufs_idx++] = slave_bufs[i][j];
1299 return total_tx_count;
1303 bond_ethdev_tx_burst_8023ad(void *queue, struct rte_mbuf **bufs,
1306 struct bond_tx_queue *bd_tx_q = (struct bond_tx_queue *)queue;
1307 struct bond_dev_private *internals = bd_tx_q->dev_private;
1309 uint16_t slave_port_ids[RTE_MAX_ETHPORTS];
1310 uint16_t slave_count;
1312 uint16_t dist_slave_port_ids[RTE_MAX_ETHPORTS];
1313 uint16_t dist_slave_count;
1315 /* 2-D array to sort mbufs for transmission on each slave into */
1316 struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_bufs];
1317 /* Number of mbufs for transmission on each slave */
1318 uint16_t slave_nb_bufs[RTE_MAX_ETHPORTS] = { 0 };
1319 /* Mapping array generated by hash function to map mbufs to slaves */
1320 uint16_t bufs_slave_port_idxs[RTE_MAX_ETHPORTS] = { 0 };
1322 uint16_t slave_tx_count, slave_tx_fail_count[RTE_MAX_ETHPORTS] = { 0 };
1323 uint16_t total_tx_count = 0, total_tx_fail_count = 0;
1327 if (unlikely(nb_bufs == 0))
1330 /* Copy slave list to protect against slave up/down changes during tx
1332 slave_count = internals->active_slave_count;
1333 if (unlikely(slave_count < 1))
1336 memcpy(slave_port_ids, internals->active_slaves,
1337 sizeof(slave_port_ids[0]) * slave_count);
1339 dist_slave_count = 0;
1340 for (i = 0; i < slave_count; i++) {
1341 struct port *port = &mode_8023ad_ports[slave_port_ids[i]];
1343 if (ACTOR_STATE(port, DISTRIBUTING))
1344 dist_slave_port_ids[dist_slave_count++] =
1348 if (likely(dist_slave_count > 1)) {
1351 * Populate slaves mbuf with the packets which are to be sent
1352 * on it, selecting output slave using hash based on xmit policy
1354 internals->burst_xmit_hash(bufs, nb_bufs, dist_slave_count,
1355 bufs_slave_port_idxs);
1357 for (i = 0; i < nb_bufs; i++) {
1359 * Populate slave mbuf arrays with mbufs for that
1362 uint8_t slave_idx = bufs_slave_port_idxs[i];
1364 slave_bufs[slave_idx][slave_nb_bufs[slave_idx]++] =
1369 /* Send packet burst on each slave device */
1370 for (i = 0; i < dist_slave_count; i++) {
1371 if (slave_nb_bufs[i] == 0)
1374 slave_tx_count = rte_eth_tx_burst(
1375 dist_slave_port_ids[i],
1376 bd_tx_q->queue_id, slave_bufs[i],
1379 total_tx_count += slave_tx_count;
1381 /* If tx burst fails move packets to end of bufs */
1382 if (unlikely(slave_tx_count < slave_nb_bufs[i])) {
1383 slave_tx_fail_count[i] = slave_nb_bufs[i] -
1385 total_tx_fail_count += slave_tx_fail_count[i];
1388 * Shift bufs to beginning of array to allow
1391 for (j = 0; j < slave_tx_fail_count[i]; j++)
1394 [(slave_tx_count - 1)
1400 * If there are tx burst failures we move packets to end of
1401 * bufs to preserve expected PMD behaviour of all failed
1402 * transmitted being at the end of the input mbuf array
1404 if (unlikely(total_tx_fail_count > 0)) {
1405 int bufs_idx = nb_bufs - total_tx_fail_count - 1;
1407 for (i = 0; i < slave_count; i++) {
1408 if (slave_tx_fail_count[i] > 0) {
1410 j < slave_tx_fail_count[i];
1420 /* Check for LACP control packets and send if available */
1421 for (i = 0; i < slave_count; i++) {
1422 struct port *port = &mode_8023ad_ports[slave_port_ids[i]];
1423 struct rte_mbuf *ctrl_pkt = NULL;
1425 if (likely(rte_ring_empty(port->tx_ring)))
1428 if (rte_ring_dequeue(port->tx_ring,
1429 (void **)&ctrl_pkt) != -ENOENT) {
1430 slave_tx_count = rte_eth_tx_burst(slave_port_ids[i],
1431 bd_tx_q->queue_id, &ctrl_pkt, 1);
1433 * re-enqueue LAG control plane packets to buffering
1434 * ring if transmission fails so the packet isn't lost.
1436 if (slave_tx_count != 1)
1437 rte_ring_enqueue(port->tx_ring, ctrl_pkt);
1441 return total_tx_count;
1445 bond_ethdev_tx_burst_broadcast(void *queue, struct rte_mbuf **bufs,
1448 struct bond_dev_private *internals;
1449 struct bond_tx_queue *bd_tx_q;
1451 uint8_t tx_failed_flag = 0, num_of_slaves;
1452 uint16_t slaves[RTE_MAX_ETHPORTS];
1454 uint16_t max_nb_of_tx_pkts = 0;
1456 int slave_tx_total[RTE_MAX_ETHPORTS];
1457 int i, most_successful_tx_slave = -1;
1459 bd_tx_q = (struct bond_tx_queue *)queue;
1460 internals = bd_tx_q->dev_private;
1462 /* Copy slave list to protect against slave up/down changes during tx
1464 num_of_slaves = internals->active_slave_count;
1465 memcpy(slaves, internals->active_slaves,
1466 sizeof(internals->active_slaves[0]) * num_of_slaves);
1468 if (num_of_slaves < 1)
1471 /* Increment reference count on mbufs */
1472 for (i = 0; i < nb_pkts; i++)
1473 rte_mbuf_refcnt_update(bufs[i], num_of_slaves - 1);
1475 /* Transmit burst on each active slave */
1476 for (i = 0; i < num_of_slaves; i++) {
1477 slave_tx_total[i] = rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id,
1480 if (unlikely(slave_tx_total[i] < nb_pkts))
1483 /* record the value and slave index for the slave which transmits the
1484 * maximum number of packets */
1485 if (slave_tx_total[i] > max_nb_of_tx_pkts) {
1486 max_nb_of_tx_pkts = slave_tx_total[i];
1487 most_successful_tx_slave = i;
1491 /* if slaves fail to transmit packets from burst, the calling application
1492 * is not expected to know about multiple references to packets so we must
1493 * handle failures of all packets except those of the most successful slave
1495 if (unlikely(tx_failed_flag))
1496 for (i = 0; i < num_of_slaves; i++)
1497 if (i != most_successful_tx_slave)
1498 while (slave_tx_total[i] < nb_pkts)
1499 rte_pktmbuf_free(bufs[slave_tx_total[i]++]);
1501 return max_nb_of_tx_pkts;
1505 link_properties_set(struct rte_eth_dev *ethdev, struct rte_eth_link *slave_link)
1507 struct bond_dev_private *bond_ctx = ethdev->data->dev_private;
1509 if (bond_ctx->mode == BONDING_MODE_8023AD) {
1511 * If in mode 4 then save the link properties of the first
1512 * slave, all subsequent slaves must match these properties
1514 struct rte_eth_link *bond_link = &bond_ctx->mode4.slave_link;
1516 bond_link->link_autoneg = slave_link->link_autoneg;
1517 bond_link->link_duplex = slave_link->link_duplex;
1518 bond_link->link_speed = slave_link->link_speed;
1521 * In any other mode the link properties are set to default
1522 * values of AUTONEG/DUPLEX
1524 ethdev->data->dev_link.link_autoneg = ETH_LINK_AUTONEG;
1525 ethdev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
1530 link_properties_valid(struct rte_eth_dev *ethdev,
1531 struct rte_eth_link *slave_link)
1533 struct bond_dev_private *bond_ctx = ethdev->data->dev_private;
1535 if (bond_ctx->mode == BONDING_MODE_8023AD) {
1536 struct rte_eth_link *bond_link = &bond_ctx->mode4.slave_link;
1538 if (bond_link->link_duplex != slave_link->link_duplex ||
1539 bond_link->link_autoneg != slave_link->link_autoneg ||
1540 bond_link->link_speed != slave_link->link_speed)
1548 mac_address_get(struct rte_eth_dev *eth_dev, struct ether_addr *dst_mac_addr)
1550 struct ether_addr *mac_addr;
1552 if (eth_dev == NULL) {
1553 RTE_BOND_LOG(ERR, "NULL pointer eth_dev specified");
1557 if (dst_mac_addr == NULL) {
1558 RTE_BOND_LOG(ERR, "NULL pointer MAC specified");
1562 mac_addr = eth_dev->data->mac_addrs;
1564 ether_addr_copy(mac_addr, dst_mac_addr);
1569 mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr)
1571 struct ether_addr *mac_addr;
1573 if (eth_dev == NULL) {
1574 RTE_BOND_LOG(ERR, "NULL pointer eth_dev specified");
1578 if (new_mac_addr == NULL) {
1579 RTE_BOND_LOG(ERR, "NULL pointer MAC specified");
1583 mac_addr = eth_dev->data->mac_addrs;
1585 /* If new MAC is different to current MAC then update */
1586 if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0)
1587 memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr));
1592 static const struct ether_addr null_mac_addr;
1595 * Add additional MAC addresses to the slave
1598 slave_add_mac_addresses(struct rte_eth_dev *bonded_eth_dev,
1599 uint16_t slave_port_id)
1602 struct ether_addr *mac_addr;
1604 for (i = 1; i < BOND_MAX_MAC_ADDRS; i++) {
1605 mac_addr = &bonded_eth_dev->data->mac_addrs[i];
1606 if (is_same_ether_addr(mac_addr, &null_mac_addr))
1609 ret = rte_eth_dev_mac_addr_add(slave_port_id, mac_addr, 0);
1612 for (i--; i > 0; i--)
1613 rte_eth_dev_mac_addr_remove(slave_port_id,
1614 &bonded_eth_dev->data->mac_addrs[i]);
1623 * Remove additional MAC addresses from the slave
1626 slave_remove_mac_addresses(struct rte_eth_dev *bonded_eth_dev,
1627 uint16_t slave_port_id)
1630 struct ether_addr *mac_addr;
1633 for (i = 1; i < BOND_MAX_MAC_ADDRS; i++) {
1634 mac_addr = &bonded_eth_dev->data->mac_addrs[i];
1635 if (is_same_ether_addr(mac_addr, &null_mac_addr))
1638 ret = rte_eth_dev_mac_addr_remove(slave_port_id, mac_addr);
1639 /* save only the first error */
1640 if (ret < 0 && rc == 0)
1648 mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
1650 struct bond_dev_private *internals = bonded_eth_dev->data->dev_private;
1653 /* Update slave devices MAC addresses */
1654 if (internals->slave_count < 1)
1657 switch (internals->mode) {
1658 case BONDING_MODE_ROUND_ROBIN:
1659 case BONDING_MODE_BALANCE:
1660 case BONDING_MODE_BROADCAST:
1661 for (i = 0; i < internals->slave_count; i++) {
1662 if (rte_eth_dev_default_mac_addr_set(
1663 internals->slaves[i].port_id,
1664 bonded_eth_dev->data->mac_addrs)) {
1665 RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
1666 internals->slaves[i].port_id);
1671 case BONDING_MODE_8023AD:
1672 bond_mode_8023ad_mac_address_update(bonded_eth_dev);
1674 case BONDING_MODE_ACTIVE_BACKUP:
1675 case BONDING_MODE_TLB:
1676 case BONDING_MODE_ALB:
1678 for (i = 0; i < internals->slave_count; i++) {
1679 if (internals->slaves[i].port_id ==
1680 internals->current_primary_port) {
1681 if (rte_eth_dev_default_mac_addr_set(
1682 internals->primary_port,
1683 bonded_eth_dev->data->mac_addrs)) {
1684 RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
1685 internals->current_primary_port);
1689 if (rte_eth_dev_default_mac_addr_set(
1690 internals->slaves[i].port_id,
1691 &internals->slaves[i].persisted_mac_addr)) {
1692 RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
1693 internals->slaves[i].port_id);
1704 bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int mode)
1706 struct bond_dev_private *internals;
1708 internals = eth_dev->data->dev_private;
1711 case BONDING_MODE_ROUND_ROBIN:
1712 eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_round_robin;
1713 eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
1715 case BONDING_MODE_ACTIVE_BACKUP:
1716 eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_active_backup;
1717 eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup;
1719 case BONDING_MODE_BALANCE:
1720 eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_balance;
1721 eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
1723 case BONDING_MODE_BROADCAST:
1724 eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
1725 eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
1727 case BONDING_MODE_8023AD:
1728 if (bond_mode_8023ad_enable(eth_dev) != 0)
1731 if (internals->mode4.dedicated_queues.enabled == 0) {
1732 eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_8023ad;
1733 eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_8023ad;
1734 RTE_BOND_LOG(WARNING,
1735 "Using mode 4, it is necessary to do TX burst "
1736 "and RX burst at least every 100ms.");
1738 /* Use flow director's optimization */
1739 eth_dev->rx_pkt_burst =
1740 bond_ethdev_rx_burst_8023ad_fast_queue;
1741 eth_dev->tx_pkt_burst =
1742 bond_ethdev_tx_burst_8023ad_fast_queue;
1745 case BONDING_MODE_TLB:
1746 eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_tlb;
1747 eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup;
1749 case BONDING_MODE_ALB:
1750 if (bond_mode_alb_enable(eth_dev) != 0)
1753 eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_alb;
1754 eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_alb;
1760 internals->mode = mode;
1767 slave_configure_slow_queue(struct rte_eth_dev *bonded_eth_dev,
1768 struct rte_eth_dev *slave_eth_dev)
1771 struct bond_dev_private *internals = (struct bond_dev_private *)
1772 bonded_eth_dev->data->dev_private;
1773 struct port *port = &mode_8023ad_ports[slave_eth_dev->data->port_id];
1775 if (port->slow_pool == NULL) {
1777 int slave_id = slave_eth_dev->data->port_id;
1779 snprintf(mem_name, RTE_DIM(mem_name), "slave_port%u_slow_pool",
1781 port->slow_pool = rte_pktmbuf_pool_create(mem_name, 8191,
1782 250, 0, RTE_MBUF_DEFAULT_BUF_SIZE,
1783 slave_eth_dev->data->numa_node);
1785 /* Any memory allocation failure in initialization is critical because
1786 * resources can't be free, so reinitialization is impossible. */
1787 if (port->slow_pool == NULL) {
1788 rte_panic("Slave %u: Failed to create memory pool '%s': %s\n",
1789 slave_id, mem_name, rte_strerror(rte_errno));
1793 if (internals->mode4.dedicated_queues.enabled == 1) {
1794 /* Configure slow Rx queue */
1796 errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id,
1797 internals->mode4.dedicated_queues.rx_qid, 128,
1798 rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
1799 NULL, port->slow_pool);
1802 "rte_eth_rx_queue_setup: port=%d queue_id %d, err (%d)",
1803 slave_eth_dev->data->port_id,
1804 internals->mode4.dedicated_queues.rx_qid,
1809 errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id,
1810 internals->mode4.dedicated_queues.tx_qid, 512,
1811 rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
1815 "rte_eth_tx_queue_setup: port=%d queue_id %d, err (%d)",
1816 slave_eth_dev->data->port_id,
1817 internals->mode4.dedicated_queues.tx_qid,
1826 slave_configure(struct rte_eth_dev *bonded_eth_dev,
1827 struct rte_eth_dev *slave_eth_dev)
1829 struct bond_rx_queue *bd_rx_q;
1830 struct bond_tx_queue *bd_tx_q;
1831 uint16_t nb_rx_queues;
1832 uint16_t nb_tx_queues;
1836 struct rte_flow_error flow_error;
1838 struct bond_dev_private *internals = (struct bond_dev_private *)
1839 bonded_eth_dev->data->dev_private;
1842 rte_eth_dev_stop(slave_eth_dev->data->port_id);
1844 /* Enable interrupts on slave device if supported */
1845 if (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
1846 slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
1848 /* If RSS is enabled for bonding, try to enable it for slaves */
1849 if (bonded_eth_dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
1850 if (bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len
1852 slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len =
1853 bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len;
1854 slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key =
1855 bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key;
1857 slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL;
1860 slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf =
1861 bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf;
1862 slave_eth_dev->data->dev_conf.rxmode.mq_mode =
1863 bonded_eth_dev->data->dev_conf.rxmode.mq_mode;
1866 if (bonded_eth_dev->data->dev_conf.rxmode.offloads &
1867 DEV_RX_OFFLOAD_VLAN_FILTER)
1868 slave_eth_dev->data->dev_conf.rxmode.offloads |=
1869 DEV_RX_OFFLOAD_VLAN_FILTER;
1871 slave_eth_dev->data->dev_conf.rxmode.offloads &=
1872 ~DEV_RX_OFFLOAD_VLAN_FILTER;
1874 nb_rx_queues = bonded_eth_dev->data->nb_rx_queues;
1875 nb_tx_queues = bonded_eth_dev->data->nb_tx_queues;
1877 if (internals->mode == BONDING_MODE_8023AD) {
1878 if (internals->mode4.dedicated_queues.enabled == 1) {
1884 errval = rte_eth_dev_set_mtu(slave_eth_dev->data->port_id,
1885 bonded_eth_dev->data->mtu);
1886 if (errval != 0 && errval != -ENOTSUP) {
1887 RTE_BOND_LOG(ERR, "rte_eth_dev_set_mtu: port %u, err (%d)",
1888 slave_eth_dev->data->port_id, errval);
1892 /* Configure device */
1893 errval = rte_eth_dev_configure(slave_eth_dev->data->port_id,
1894 nb_rx_queues, nb_tx_queues,
1895 &(slave_eth_dev->data->dev_conf));
1897 RTE_BOND_LOG(ERR, "Cannot configure slave device: port %u, err (%d)",
1898 slave_eth_dev->data->port_id, errval);
1902 /* Setup Rx Queues */
1903 for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
1904 bd_rx_q = (struct bond_rx_queue *)bonded_eth_dev->data->rx_queues[q_id];
1906 errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
1907 bd_rx_q->nb_rx_desc,
1908 rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
1909 &(bd_rx_q->rx_conf), bd_rx_q->mb_pool);
1912 "rte_eth_rx_queue_setup: port=%d queue_id %d, err (%d)",
1913 slave_eth_dev->data->port_id, q_id, errval);
1918 /* Setup Tx Queues */
1919 for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
1920 bd_tx_q = (struct bond_tx_queue *)bonded_eth_dev->data->tx_queues[q_id];
1922 errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
1923 bd_tx_q->nb_tx_desc,
1924 rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
1928 "rte_eth_tx_queue_setup: port=%d queue_id %d, err (%d)",
1929 slave_eth_dev->data->port_id, q_id, errval);
1934 if (internals->mode == BONDING_MODE_8023AD &&
1935 internals->mode4.dedicated_queues.enabled == 1) {
1936 if (slave_configure_slow_queue(bonded_eth_dev, slave_eth_dev)
1940 if (bond_ethdev_8023ad_flow_verify(bonded_eth_dev,
1941 slave_eth_dev->data->port_id) != 0) {
1943 "rte_eth_tx_queue_setup: port=%d queue_id %d, err (%d)",
1944 slave_eth_dev->data->port_id, q_id, errval);
1948 if (internals->mode4.dedicated_queues.flow[slave_eth_dev->data->port_id] != NULL)
1949 rte_flow_destroy(slave_eth_dev->data->port_id,
1950 internals->mode4.dedicated_queues.flow[slave_eth_dev->data->port_id],
1953 bond_ethdev_8023ad_flow_set(bonded_eth_dev,
1954 slave_eth_dev->data->port_id);
1958 errval = rte_eth_dev_start(slave_eth_dev->data->port_id);
1960 RTE_BOND_LOG(ERR, "rte_eth_dev_start: port=%u, err (%d)",
1961 slave_eth_dev->data->port_id, errval);
1965 /* If RSS is enabled for bonding, synchronize RETA */
1966 if (bonded_eth_dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS) {
1968 struct bond_dev_private *internals;
1970 internals = bonded_eth_dev->data->dev_private;
1972 for (i = 0; i < internals->slave_count; i++) {
1973 if (internals->slaves[i].port_id == slave_eth_dev->data->port_id) {
1974 errval = rte_eth_dev_rss_reta_update(
1975 slave_eth_dev->data->port_id,
1976 &internals->reta_conf[0],
1977 internals->slaves[i].reta_size);
1979 RTE_BOND_LOG(WARNING,
1980 "rte_eth_dev_rss_reta_update on slave port %d fails (err %d)."
1981 " RSS Configuration for bonding may be inconsistent.",
1982 slave_eth_dev->data->port_id, errval);
1989 /* If lsc interrupt is set, check initial slave's link status */
1990 if (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
1991 slave_eth_dev->dev_ops->link_update(slave_eth_dev, 0);
1992 bond_ethdev_lsc_event_callback(slave_eth_dev->data->port_id,
1993 RTE_ETH_EVENT_INTR_LSC, &bonded_eth_dev->data->port_id,
2001 slave_remove(struct bond_dev_private *internals,
2002 struct rte_eth_dev *slave_eth_dev)
2006 for (i = 0; i < internals->slave_count; i++)
2007 if (internals->slaves[i].port_id ==
2008 slave_eth_dev->data->port_id)
2011 if (i < (internals->slave_count - 1)) {
2012 struct rte_flow *flow;
2014 memmove(&internals->slaves[i], &internals->slaves[i + 1],
2015 sizeof(internals->slaves[0]) *
2016 (internals->slave_count - i - 1));
2017 TAILQ_FOREACH(flow, &internals->flow_list, next) {
2018 memmove(&flow->flows[i], &flow->flows[i + 1],
2019 sizeof(flow->flows[0]) *
2020 (internals->slave_count - i - 1));
2021 flow->flows[internals->slave_count - 1] = NULL;
2025 internals->slave_count--;
2027 /* force reconfiguration of slave interfaces */
2028 _rte_eth_dev_reset(slave_eth_dev);
2032 bond_ethdev_slave_link_status_change_monitor(void *cb_arg);
2035 slave_add(struct bond_dev_private *internals,
2036 struct rte_eth_dev *slave_eth_dev)
2038 struct bond_slave_details *slave_details =
2039 &internals->slaves[internals->slave_count];
2041 slave_details->port_id = slave_eth_dev->data->port_id;
2042 slave_details->last_link_status = 0;
2044 /* Mark slave devices that don't support interrupts so we can
2045 * compensate when we start the bond
2047 if (!(slave_eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)) {
2048 slave_details->link_status_poll_enabled = 1;
2051 slave_details->link_status_wait_to_complete = 0;
2052 /* clean tlb_last_obytes when adding port for bonding device */
2053 memcpy(&(slave_details->persisted_mac_addr), slave_eth_dev->data->mac_addrs,
2054 sizeof(struct ether_addr));
2058 bond_ethdev_primary_set(struct bond_dev_private *internals,
2059 uint16_t slave_port_id)
2063 if (internals->active_slave_count < 1)
2064 internals->current_primary_port = slave_port_id;
2066 /* Search bonded device slave ports for new proposed primary port */
2067 for (i = 0; i < internals->active_slave_count; i++) {
2068 if (internals->active_slaves[i] == slave_port_id)
2069 internals->current_primary_port = slave_port_id;
2074 bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev);
2077 bond_ethdev_start(struct rte_eth_dev *eth_dev)
2079 struct bond_dev_private *internals;
2082 /* slave eth dev will be started by bonded device */
2083 if (check_for_bonded_ethdev(eth_dev)) {
2084 RTE_BOND_LOG(ERR, "User tried to explicitly start a slave eth_dev (%d)",
2085 eth_dev->data->port_id);
2089 eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
2090 eth_dev->data->dev_started = 1;
2092 internals = eth_dev->data->dev_private;
2094 if (internals->slave_count == 0) {
2095 RTE_BOND_LOG(ERR, "Cannot start port since there are no slave devices");
2099 if (internals->user_defined_mac == 0) {
2100 struct ether_addr *new_mac_addr = NULL;
2102 for (i = 0; i < internals->slave_count; i++)
2103 if (internals->slaves[i].port_id == internals->primary_port)
2104 new_mac_addr = &internals->slaves[i].persisted_mac_addr;
2106 if (new_mac_addr == NULL)
2109 if (mac_address_set(eth_dev, new_mac_addr) != 0) {
2110 RTE_BOND_LOG(ERR, "bonded port (%d) failed to update MAC address",
2111 eth_dev->data->port_id);
2116 /* Update all slave devices MACs*/
2117 if (mac_address_slaves_update(eth_dev) != 0)
2120 /* If bonded device is configure in promiscuous mode then re-apply config */
2121 if (internals->promiscuous_en)
2122 bond_ethdev_promiscuous_enable(eth_dev);
2124 if (internals->mode == BONDING_MODE_8023AD) {
2125 if (internals->mode4.dedicated_queues.enabled == 1) {
2126 internals->mode4.dedicated_queues.rx_qid =
2127 eth_dev->data->nb_rx_queues;
2128 internals->mode4.dedicated_queues.tx_qid =
2129 eth_dev->data->nb_tx_queues;
2134 /* Reconfigure each slave device if starting bonded device */
2135 for (i = 0; i < internals->slave_count; i++) {
2136 struct rte_eth_dev *slave_ethdev =
2137 &(rte_eth_devices[internals->slaves[i].port_id]);
2138 if (slave_configure(eth_dev, slave_ethdev) != 0) {
2140 "bonded port (%d) failed to reconfigure slave device (%d)",
2141 eth_dev->data->port_id,
2142 internals->slaves[i].port_id);
2145 /* We will need to poll for link status if any slave doesn't
2146 * support interrupts
2148 if (internals->slaves[i].link_status_poll_enabled)
2149 internals->link_status_polling_enabled = 1;
2152 /* start polling if needed */
2153 if (internals->link_status_polling_enabled) {
2155 internals->link_status_polling_interval_ms * 1000,
2156 bond_ethdev_slave_link_status_change_monitor,
2157 (void *)&rte_eth_devices[internals->port_id]);
2160 if (internals->user_defined_primary_port)
2161 bond_ethdev_primary_set(internals, internals->primary_port);
2163 if (internals->mode == BONDING_MODE_8023AD)
2164 bond_mode_8023ad_start(eth_dev);
2166 if (internals->mode == BONDING_MODE_TLB ||
2167 internals->mode == BONDING_MODE_ALB)
2168 bond_tlb_enable(internals);
2173 eth_dev->data->dev_started = 0;
2178 bond_ethdev_free_queues(struct rte_eth_dev *dev)
2182 if (dev->data->rx_queues != NULL) {
2183 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2184 rte_free(dev->data->rx_queues[i]);
2185 dev->data->rx_queues[i] = NULL;
2187 dev->data->nb_rx_queues = 0;
2190 if (dev->data->tx_queues != NULL) {
2191 for (i = 0; i < dev->data->nb_tx_queues; i++) {
2192 rte_free(dev->data->tx_queues[i]);
2193 dev->data->tx_queues[i] = NULL;
2195 dev->data->nb_tx_queues = 0;
2200 bond_ethdev_stop(struct rte_eth_dev *eth_dev)
2202 struct bond_dev_private *internals = eth_dev->data->dev_private;
2205 if (internals->mode == BONDING_MODE_8023AD) {
2209 bond_mode_8023ad_stop(eth_dev);
2211 /* Discard all messages to/from mode 4 state machines */
2212 for (i = 0; i < internals->active_slave_count; i++) {
2213 port = &mode_8023ad_ports[internals->active_slaves[i]];
2215 RTE_ASSERT(port->rx_ring != NULL);
2216 while (rte_ring_dequeue(port->rx_ring, &pkt) != -ENOENT)
2217 rte_pktmbuf_free(pkt);
2219 RTE_ASSERT(port->tx_ring != NULL);
2220 while (rte_ring_dequeue(port->tx_ring, &pkt) != -ENOENT)
2221 rte_pktmbuf_free(pkt);
2225 if (internals->mode == BONDING_MODE_TLB ||
2226 internals->mode == BONDING_MODE_ALB) {
2227 bond_tlb_disable(internals);
2228 for (i = 0; i < internals->active_slave_count; i++)
2229 tlb_last_obytets[internals->active_slaves[i]] = 0;
2232 internals->link_status_polling_enabled = 0;
2233 for (i = 0; i < internals->slave_count; i++)
2234 internals->slaves[i].last_link_status = 0;
2236 eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
2237 eth_dev->data->dev_started = 0;
2241 bond_ethdev_close(struct rte_eth_dev *dev)
2243 struct bond_dev_private *internals = dev->data->dev_private;
2244 uint8_t bond_port_id = internals->port_id;
2246 struct rte_flow_error ferror;
2248 RTE_BOND_LOG(INFO, "Closing bonded device %s", dev->device->name);
2249 while (internals->slave_count != skipped) {
2250 uint16_t port_id = internals->slaves[skipped].port_id;
2252 rte_eth_dev_stop(port_id);
2254 if (rte_eth_bond_slave_remove(bond_port_id, port_id) != 0) {
2256 "Failed to remove port %d from bonded device %s",
2257 port_id, dev->device->name);
2261 bond_flow_ops.flush(dev, &ferror);
2262 bond_ethdev_free_queues(dev);
2263 rte_bitmap_reset(internals->vlan_filter_bmp);
2266 /* forward declaration */
2267 static int bond_ethdev_configure(struct rte_eth_dev *dev);
2270 bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
2272 struct bond_dev_private *internals = dev->data->dev_private;
2274 uint16_t max_nb_rx_queues = UINT16_MAX;
2275 uint16_t max_nb_tx_queues = UINT16_MAX;
2277 dev_info->max_mac_addrs = BOND_MAX_MAC_ADDRS;
2279 dev_info->max_rx_pktlen = internals->candidate_max_rx_pktlen ?
2280 internals->candidate_max_rx_pktlen :
2281 ETHER_MAX_JUMBO_FRAME_LEN;
2283 /* Max number of tx/rx queues that the bonded device can support is the
2284 * minimum values of the bonded slaves, as all slaves must be capable
2285 * of supporting the same number of tx/rx queues.
2287 if (internals->slave_count > 0) {
2288 struct rte_eth_dev_info slave_info;
2291 for (idx = 0; idx < internals->slave_count; idx++) {
2292 rte_eth_dev_info_get(internals->slaves[idx].port_id,
2295 if (slave_info.max_rx_queues < max_nb_rx_queues)
2296 max_nb_rx_queues = slave_info.max_rx_queues;
2298 if (slave_info.max_tx_queues < max_nb_tx_queues)
2299 max_nb_tx_queues = slave_info.max_tx_queues;
2303 dev_info->max_rx_queues = max_nb_rx_queues;
2304 dev_info->max_tx_queues = max_nb_tx_queues;
2307 * If dedicated hw queues enabled for link bonding device in LACP mode
2308 * then we need to reduce the maximum number of data path queues by 1.
2310 if (internals->mode == BONDING_MODE_8023AD &&
2311 internals->mode4.dedicated_queues.enabled == 1) {
2312 dev_info->max_rx_queues--;
2313 dev_info->max_tx_queues--;
2316 dev_info->min_rx_bufsize = 0;
2318 dev_info->rx_offload_capa = internals->rx_offload_capa;
2319 dev_info->tx_offload_capa = internals->tx_offload_capa;
2320 dev_info->rx_queue_offload_capa = internals->rx_queue_offload_capa;
2321 dev_info->tx_queue_offload_capa = internals->tx_queue_offload_capa;
2322 dev_info->flow_type_rss_offloads = internals->flow_type_rss_offloads;
2324 dev_info->reta_size = internals->reta_size;
2328 bond_ethdev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
2332 struct bond_dev_private *internals = dev->data->dev_private;
2334 /* don't do this while a slave is being added */
2335 rte_spinlock_lock(&internals->lock);
2338 rte_bitmap_set(internals->vlan_filter_bmp, vlan_id);
2340 rte_bitmap_clear(internals->vlan_filter_bmp, vlan_id);
2342 for (i = 0; i < internals->slave_count; i++) {
2343 uint16_t port_id = internals->slaves[i].port_id;
2345 res = rte_eth_dev_vlan_filter(port_id, vlan_id, on);
2347 RTE_BOND_LOG(WARNING,
2348 "Setting VLAN filter on slave port %u not supported.",
2352 rte_spinlock_unlock(&internals->lock);
2357 bond_ethdev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
2358 uint16_t nb_rx_desc, unsigned int socket_id __rte_unused,
2359 const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mb_pool)
2361 struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)
2362 rte_zmalloc_socket(NULL, sizeof(struct bond_rx_queue),
2363 0, dev->data->numa_node);
2364 if (bd_rx_q == NULL)
2367 bd_rx_q->queue_id = rx_queue_id;
2368 bd_rx_q->dev_private = dev->data->dev_private;
2370 bd_rx_q->nb_rx_desc = nb_rx_desc;
2372 memcpy(&(bd_rx_q->rx_conf), rx_conf, sizeof(struct rte_eth_rxconf));
2373 bd_rx_q->mb_pool = mb_pool;
2375 dev->data->rx_queues[rx_queue_id] = bd_rx_q;
2381 bond_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
2382 uint16_t nb_tx_desc, unsigned int socket_id __rte_unused,
2383 const struct rte_eth_txconf *tx_conf)
2385 struct bond_tx_queue *bd_tx_q = (struct bond_tx_queue *)
2386 rte_zmalloc_socket(NULL, sizeof(struct bond_tx_queue),
2387 0, dev->data->numa_node);
2389 if (bd_tx_q == NULL)
2392 bd_tx_q->queue_id = tx_queue_id;
2393 bd_tx_q->dev_private = dev->data->dev_private;
2395 bd_tx_q->nb_tx_desc = nb_tx_desc;
2396 memcpy(&(bd_tx_q->tx_conf), tx_conf, sizeof(bd_tx_q->tx_conf));
2398 dev->data->tx_queues[tx_queue_id] = bd_tx_q;
2404 bond_ethdev_rx_queue_release(void *queue)
2413 bond_ethdev_tx_queue_release(void *queue)
2422 bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
2424 struct rte_eth_dev *bonded_ethdev, *slave_ethdev;
2425 struct bond_dev_private *internals;
2427 /* Default value for polling slave found is true as we don't want to
2428 * disable the polling thread if we cannot get the lock */
2429 int i, polling_slave_found = 1;
2434 bonded_ethdev = (struct rte_eth_dev *)cb_arg;
2435 internals = (struct bond_dev_private *)bonded_ethdev->data->dev_private;
2437 if (!bonded_ethdev->data->dev_started ||
2438 !internals->link_status_polling_enabled)
2441 /* If device is currently being configured then don't check slaves link
2442 * status, wait until next period */
2443 if (rte_spinlock_trylock(&internals->lock)) {
2444 if (internals->slave_count > 0)
2445 polling_slave_found = 0;
2447 for (i = 0; i < internals->slave_count; i++) {
2448 if (!internals->slaves[i].link_status_poll_enabled)
2451 slave_ethdev = &rte_eth_devices[internals->slaves[i].port_id];
2452 polling_slave_found = 1;
2454 /* Update slave link status */
2455 (*slave_ethdev->dev_ops->link_update)(slave_ethdev,
2456 internals->slaves[i].link_status_wait_to_complete);
2458 /* if link status has changed since last checked then call lsc
2460 if (slave_ethdev->data->dev_link.link_status !=
2461 internals->slaves[i].last_link_status) {
2462 internals->slaves[i].last_link_status =
2463 slave_ethdev->data->dev_link.link_status;
2465 bond_ethdev_lsc_event_callback(internals->slaves[i].port_id,
2466 RTE_ETH_EVENT_INTR_LSC,
2467 &bonded_ethdev->data->port_id,
2471 rte_spinlock_unlock(&internals->lock);
2474 if (polling_slave_found)
2475 /* Set alarm to continue monitoring link status of slave ethdev's */
2476 rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
2477 bond_ethdev_slave_link_status_change_monitor, cb_arg);
2481 bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete)
2483 void (*link_update)(uint16_t port_id, struct rte_eth_link *eth_link);
2485 struct bond_dev_private *bond_ctx;
2486 struct rte_eth_link slave_link;
2490 bond_ctx = ethdev->data->dev_private;
2492 ethdev->data->dev_link.link_speed = ETH_SPEED_NUM_NONE;
2494 if (ethdev->data->dev_started == 0 ||
2495 bond_ctx->active_slave_count == 0) {
2496 ethdev->data->dev_link.link_status = ETH_LINK_DOWN;
2500 ethdev->data->dev_link.link_status = ETH_LINK_UP;
2502 if (wait_to_complete)
2503 link_update = rte_eth_link_get;
2505 link_update = rte_eth_link_get_nowait;
2507 switch (bond_ctx->mode) {
2508 case BONDING_MODE_BROADCAST:
2510 * Setting link speed to UINT32_MAX to ensure we pick up the
2511 * value of the first active slave
2513 ethdev->data->dev_link.link_speed = UINT32_MAX;
2516 * link speed is minimum value of all the slaves link speed as
2517 * packet loss will occur on this slave if transmission at rates
2518 * greater than this are attempted
2520 for (idx = 1; idx < bond_ctx->active_slave_count; idx++) {
2521 link_update(bond_ctx->active_slaves[0], &slave_link);
2523 if (slave_link.link_speed <
2524 ethdev->data->dev_link.link_speed)
2525 ethdev->data->dev_link.link_speed =
2526 slave_link.link_speed;
2529 case BONDING_MODE_ACTIVE_BACKUP:
2530 /* Current primary slave */
2531 link_update(bond_ctx->current_primary_port, &slave_link);
2533 ethdev->data->dev_link.link_speed = slave_link.link_speed;
2535 case BONDING_MODE_8023AD:
2536 ethdev->data->dev_link.link_autoneg =
2537 bond_ctx->mode4.slave_link.link_autoneg;
2538 ethdev->data->dev_link.link_duplex =
2539 bond_ctx->mode4.slave_link.link_duplex;
2540 /* fall through to update link speed */
2541 case BONDING_MODE_ROUND_ROBIN:
2542 case BONDING_MODE_BALANCE:
2543 case BONDING_MODE_TLB:
2544 case BONDING_MODE_ALB:
2547 * In theses mode the maximum theoretical link speed is the sum
2550 ethdev->data->dev_link.link_speed = ETH_SPEED_NUM_NONE;
2552 for (idx = 0; idx < bond_ctx->active_slave_count; idx++) {
2553 link_update(bond_ctx->active_slaves[idx], &slave_link);
2555 ethdev->data->dev_link.link_speed +=
2556 slave_link.link_speed;
2566 bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
2568 struct bond_dev_private *internals = dev->data->dev_private;
2569 struct rte_eth_stats slave_stats;
2572 for (i = 0; i < internals->slave_count; i++) {
2573 rte_eth_stats_get(internals->slaves[i].port_id, &slave_stats);
2575 stats->ipackets += slave_stats.ipackets;
2576 stats->opackets += slave_stats.opackets;
2577 stats->ibytes += slave_stats.ibytes;
2578 stats->obytes += slave_stats.obytes;
2579 stats->imissed += slave_stats.imissed;
2580 stats->ierrors += slave_stats.ierrors;
2581 stats->oerrors += slave_stats.oerrors;
2582 stats->rx_nombuf += slave_stats.rx_nombuf;
2584 for (j = 0; j < RTE_ETHDEV_QUEUE_STAT_CNTRS; j++) {
2585 stats->q_ipackets[j] += slave_stats.q_ipackets[j];
2586 stats->q_opackets[j] += slave_stats.q_opackets[j];
2587 stats->q_ibytes[j] += slave_stats.q_ibytes[j];
2588 stats->q_obytes[j] += slave_stats.q_obytes[j];
2589 stats->q_errors[j] += slave_stats.q_errors[j];
2598 bond_ethdev_stats_reset(struct rte_eth_dev *dev)
2600 struct bond_dev_private *internals = dev->data->dev_private;
2603 for (i = 0; i < internals->slave_count; i++)
2604 rte_eth_stats_reset(internals->slaves[i].port_id);
2608 bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)
2610 struct bond_dev_private *internals = eth_dev->data->dev_private;
2613 internals->promiscuous_en = 1;
2615 switch (internals->mode) {
2616 /* Promiscuous mode is propagated to all slaves */
2617 case BONDING_MODE_ROUND_ROBIN:
2618 case BONDING_MODE_BALANCE:
2619 case BONDING_MODE_BROADCAST:
2620 for (i = 0; i < internals->slave_count; i++)
2621 rte_eth_promiscuous_enable(internals->slaves[i].port_id);
2623 /* In mode4 promiscus mode is managed when slave is added/removed */
2624 case BONDING_MODE_8023AD:
2626 /* Promiscuous mode is propagated only to primary slave */
2627 case BONDING_MODE_ACTIVE_BACKUP:
2628 case BONDING_MODE_TLB:
2629 case BONDING_MODE_ALB:
2631 rte_eth_promiscuous_enable(internals->current_primary_port);
2636 bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
2638 struct bond_dev_private *internals = dev->data->dev_private;
2641 internals->promiscuous_en = 0;
2643 switch (internals->mode) {
2644 /* Promiscuous mode is propagated to all slaves */
2645 case BONDING_MODE_ROUND_ROBIN:
2646 case BONDING_MODE_BALANCE:
2647 case BONDING_MODE_BROADCAST:
2648 for (i = 0; i < internals->slave_count; i++)
2649 rte_eth_promiscuous_disable(internals->slaves[i].port_id);
2651 /* In mode4 promiscus mode is set managed when slave is added/removed */
2652 case BONDING_MODE_8023AD:
2654 /* Promiscuous mode is propagated only to primary slave */
2655 case BONDING_MODE_ACTIVE_BACKUP:
2656 case BONDING_MODE_TLB:
2657 case BONDING_MODE_ALB:
2659 rte_eth_promiscuous_disable(internals->current_primary_port);
2664 bond_ethdev_delayed_lsc_propagation(void *arg)
2669 _rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
2670 RTE_ETH_EVENT_INTR_LSC, NULL);
2674 bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
2675 void *param, void *ret_param __rte_unused)
2677 struct rte_eth_dev *bonded_eth_dev;
2678 struct bond_dev_private *internals;
2679 struct rte_eth_link link;
2682 int i, valid_slave = 0;
2684 uint8_t lsc_flag = 0;
2686 if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
2689 bonded_eth_dev = &rte_eth_devices[*(uint8_t *)param];
2691 if (check_for_bonded_ethdev(bonded_eth_dev))
2694 internals = bonded_eth_dev->data->dev_private;
2696 /* If the device isn't started don't handle interrupts */
2697 if (!bonded_eth_dev->data->dev_started)
2700 /* verify that port_id is a valid slave of bonded port */
2701 for (i = 0; i < internals->slave_count; i++) {
2702 if (internals->slaves[i].port_id == port_id) {
2711 /* Synchronize lsc callback parallel calls either by real link event
2712 * from the slaves PMDs or by the bonding PMD itself.
2714 rte_spinlock_lock(&internals->lsc_lock);
2716 /* Search for port in active port list */
2717 active_pos = find_slave_by_id(internals->active_slaves,
2718 internals->active_slave_count, port_id);
2720 rte_eth_link_get_nowait(port_id, &link);
2721 if (link.link_status) {
2722 if (active_pos < internals->active_slave_count)
2725 /* if no active slave ports then set this port to be primary port */
2726 if (internals->active_slave_count < 1) {
2727 /* If first active slave, then change link status */
2728 bonded_eth_dev->data->dev_link.link_status = ETH_LINK_UP;
2729 internals->current_primary_port = port_id;
2732 mac_address_slaves_update(bonded_eth_dev);
2735 activate_slave(bonded_eth_dev, port_id);
2737 /* If user has defined the primary port then default to using it */
2738 if (internals->user_defined_primary_port &&
2739 internals->primary_port == port_id)
2740 bond_ethdev_primary_set(internals, port_id);
2742 if (active_pos == internals->active_slave_count)
2745 /* Remove from active slave list */
2746 deactivate_slave(bonded_eth_dev, port_id);
2748 if (internals->active_slave_count < 1)
2751 /* Update primary id, take first active slave from list or if none
2752 * available set to -1 */
2753 if (port_id == internals->current_primary_port) {
2754 if (internals->active_slave_count > 0)
2755 bond_ethdev_primary_set(internals,
2756 internals->active_slaves[0]);
2758 internals->current_primary_port = internals->primary_port;
2764 * Update bonded device link properties after any change to active
2767 bond_ethdev_link_update(bonded_eth_dev, 0);
2770 /* Cancel any possible outstanding interrupts if delays are enabled */
2771 if (internals->link_up_delay_ms > 0 ||
2772 internals->link_down_delay_ms > 0)
2773 rte_eal_alarm_cancel(bond_ethdev_delayed_lsc_propagation,
2776 if (bonded_eth_dev->data->dev_link.link_status) {
2777 if (internals->link_up_delay_ms > 0)
2778 rte_eal_alarm_set(internals->link_up_delay_ms * 1000,
2779 bond_ethdev_delayed_lsc_propagation,
2780 (void *)bonded_eth_dev);
2782 _rte_eth_dev_callback_process(bonded_eth_dev,
2783 RTE_ETH_EVENT_INTR_LSC,
2787 if (internals->link_down_delay_ms > 0)
2788 rte_eal_alarm_set(internals->link_down_delay_ms * 1000,
2789 bond_ethdev_delayed_lsc_propagation,
2790 (void *)bonded_eth_dev);
2792 _rte_eth_dev_callback_process(bonded_eth_dev,
2793 RTE_ETH_EVENT_INTR_LSC,
2798 rte_spinlock_unlock(&internals->lsc_lock);
2804 bond_ethdev_rss_reta_update(struct rte_eth_dev *dev,
2805 struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size)
2809 int slave_reta_size;
2810 unsigned reta_count;
2811 struct bond_dev_private *internals = dev->data->dev_private;
2813 if (reta_size != internals->reta_size)
2816 /* Copy RETA table */
2817 reta_count = reta_size / RTE_RETA_GROUP_SIZE;
2819 for (i = 0; i < reta_count; i++) {
2820 internals->reta_conf[i].mask = reta_conf[i].mask;
2821 for (j = 0; j < RTE_RETA_GROUP_SIZE; j++)
2822 if ((reta_conf[i].mask >> j) & 0x01)
2823 internals->reta_conf[i].reta[j] = reta_conf[i].reta[j];
2826 /* Fill rest of array */
2827 for (; i < RTE_DIM(internals->reta_conf); i += reta_count)
2828 memcpy(&internals->reta_conf[i], &internals->reta_conf[0],
2829 sizeof(internals->reta_conf[0]) * reta_count);
2831 /* Propagate RETA over slaves */
2832 for (i = 0; i < internals->slave_count; i++) {
2833 slave_reta_size = internals->slaves[i].reta_size;
2834 result = rte_eth_dev_rss_reta_update(internals->slaves[i].port_id,
2835 &internals->reta_conf[0], slave_reta_size);
2844 bond_ethdev_rss_reta_query(struct rte_eth_dev *dev,
2845 struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size)
2848 struct bond_dev_private *internals = dev->data->dev_private;
2850 if (reta_size != internals->reta_size)
2853 /* Copy RETA table */
2854 for (i = 0; i < reta_size / RTE_RETA_GROUP_SIZE; i++)
2855 for (j = 0; j < RTE_RETA_GROUP_SIZE; j++)
2856 if ((reta_conf[i].mask >> j) & 0x01)
2857 reta_conf[i].reta[j] = internals->reta_conf[i].reta[j];
2863 bond_ethdev_rss_hash_update(struct rte_eth_dev *dev,
2864 struct rte_eth_rss_conf *rss_conf)
2867 struct bond_dev_private *internals = dev->data->dev_private;
2868 struct rte_eth_rss_conf bond_rss_conf;
2870 memcpy(&bond_rss_conf, rss_conf, sizeof(struct rte_eth_rss_conf));
2872 bond_rss_conf.rss_hf &= internals->flow_type_rss_offloads;
2874 if (bond_rss_conf.rss_hf != 0)
2875 dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf = bond_rss_conf.rss_hf;
2877 if (bond_rss_conf.rss_key && bond_rss_conf.rss_key_len <
2878 sizeof(internals->rss_key)) {
2879 if (bond_rss_conf.rss_key_len == 0)
2880 bond_rss_conf.rss_key_len = 40;
2881 internals->rss_key_len = bond_rss_conf.rss_key_len;
2882 memcpy(internals->rss_key, bond_rss_conf.rss_key,
2883 internals->rss_key_len);
2886 for (i = 0; i < internals->slave_count; i++) {
2887 result = rte_eth_dev_rss_hash_update(internals->slaves[i].port_id,
2897 bond_ethdev_rss_hash_conf_get(struct rte_eth_dev *dev,
2898 struct rte_eth_rss_conf *rss_conf)
2900 struct bond_dev_private *internals = dev->data->dev_private;
2902 rss_conf->rss_hf = dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf;
2903 rss_conf->rss_key_len = internals->rss_key_len;
2904 if (rss_conf->rss_key)
2905 memcpy(rss_conf->rss_key, internals->rss_key, internals->rss_key_len);
2911 bond_ethdev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
2913 struct rte_eth_dev *slave_eth_dev;
2914 struct bond_dev_private *internals = dev->data->dev_private;
2917 rte_spinlock_lock(&internals->lock);
2919 for (i = 0; i < internals->slave_count; i++) {
2920 slave_eth_dev = &rte_eth_devices[internals->slaves[i].port_id];
2921 if (*slave_eth_dev->dev_ops->mtu_set == NULL) {
2922 rte_spinlock_unlock(&internals->lock);
2926 for (i = 0; i < internals->slave_count; i++) {
2927 ret = rte_eth_dev_set_mtu(internals->slaves[i].port_id, mtu);
2929 rte_spinlock_unlock(&internals->lock);
2934 rte_spinlock_unlock(&internals->lock);
2939 bond_ethdev_mac_address_set(struct rte_eth_dev *dev, struct ether_addr *addr)
2941 if (mac_address_set(dev, addr)) {
2942 RTE_BOND_LOG(ERR, "Failed to update MAC address");
2950 bond_filter_ctrl(struct rte_eth_dev *dev __rte_unused,
2951 enum rte_filter_type type, enum rte_filter_op op, void *arg)
2953 if (type == RTE_ETH_FILTER_GENERIC && op == RTE_ETH_FILTER_GET) {
2954 *(const void **)arg = &bond_flow_ops;
2961 bond_ethdev_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
2962 __rte_unused uint32_t index, uint32_t vmdq)
2964 struct rte_eth_dev *slave_eth_dev;
2965 struct bond_dev_private *internals = dev->data->dev_private;
2968 rte_spinlock_lock(&internals->lock);
2970 for (i = 0; i < internals->slave_count; i++) {
2971 slave_eth_dev = &rte_eth_devices[internals->slaves[i].port_id];
2972 if (*slave_eth_dev->dev_ops->mac_addr_add == NULL ||
2973 *slave_eth_dev->dev_ops->mac_addr_remove == NULL) {
2979 for (i = 0; i < internals->slave_count; i++) {
2980 ret = rte_eth_dev_mac_addr_add(internals->slaves[i].port_id,
2984 for (i--; i >= 0; i--)
2985 rte_eth_dev_mac_addr_remove(
2986 internals->slaves[i].port_id, mac_addr);
2993 rte_spinlock_unlock(&internals->lock);
2998 bond_ethdev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
3000 struct rte_eth_dev *slave_eth_dev;
3001 struct bond_dev_private *internals = dev->data->dev_private;
3004 rte_spinlock_lock(&internals->lock);
3006 for (i = 0; i < internals->slave_count; i++) {
3007 slave_eth_dev = &rte_eth_devices[internals->slaves[i].port_id];
3008 if (*slave_eth_dev->dev_ops->mac_addr_remove == NULL)
3012 struct ether_addr *mac_addr = &dev->data->mac_addrs[index];
3014 for (i = 0; i < internals->slave_count; i++)
3015 rte_eth_dev_mac_addr_remove(internals->slaves[i].port_id,
3019 rte_spinlock_unlock(&internals->lock);
3022 const struct eth_dev_ops default_dev_ops = {
3023 .dev_start = bond_ethdev_start,
3024 .dev_stop = bond_ethdev_stop,
3025 .dev_close = bond_ethdev_close,
3026 .dev_configure = bond_ethdev_configure,
3027 .dev_infos_get = bond_ethdev_info,
3028 .vlan_filter_set = bond_ethdev_vlan_filter_set,
3029 .rx_queue_setup = bond_ethdev_rx_queue_setup,
3030 .tx_queue_setup = bond_ethdev_tx_queue_setup,
3031 .rx_queue_release = bond_ethdev_rx_queue_release,
3032 .tx_queue_release = bond_ethdev_tx_queue_release,
3033 .link_update = bond_ethdev_link_update,
3034 .stats_get = bond_ethdev_stats_get,
3035 .stats_reset = bond_ethdev_stats_reset,
3036 .promiscuous_enable = bond_ethdev_promiscuous_enable,
3037 .promiscuous_disable = bond_ethdev_promiscuous_disable,
3038 .reta_update = bond_ethdev_rss_reta_update,
3039 .reta_query = bond_ethdev_rss_reta_query,
3040 .rss_hash_update = bond_ethdev_rss_hash_update,
3041 .rss_hash_conf_get = bond_ethdev_rss_hash_conf_get,
3042 .mtu_set = bond_ethdev_mtu_set,
3043 .mac_addr_set = bond_ethdev_mac_address_set,
3044 .mac_addr_add = bond_ethdev_mac_addr_add,
3045 .mac_addr_remove = bond_ethdev_mac_addr_remove,
3046 .filter_ctrl = bond_filter_ctrl
3050 bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
3052 const char *name = rte_vdev_device_name(dev);
3053 uint8_t socket_id = dev->device.numa_node;
3054 struct bond_dev_private *internals = NULL;
3055 struct rte_eth_dev *eth_dev = NULL;
3056 uint32_t vlan_filter_bmp_size;
3058 /* now do all data allocation - for eth_dev structure, dummy pci driver
3059 * and internal (private) data
3062 /* reserve an ethdev entry */
3063 eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internals));
3064 if (eth_dev == NULL) {
3065 RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
3069 internals = eth_dev->data->dev_private;
3070 eth_dev->data->nb_rx_queues = (uint16_t)1;
3071 eth_dev->data->nb_tx_queues = (uint16_t)1;
3073 /* Allocate memory for storing MAC addresses */
3074 eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN *
3075 BOND_MAX_MAC_ADDRS, 0, socket_id);
3076 if (eth_dev->data->mac_addrs == NULL) {
3078 "Failed to allocate %u bytes needed to store MAC addresses",
3079 ETHER_ADDR_LEN * BOND_MAX_MAC_ADDRS);
3083 eth_dev->dev_ops = &default_dev_ops;
3084 eth_dev->data->dev_flags = RTE_ETH_DEV_INTR_LSC;
3086 rte_spinlock_init(&internals->lock);
3087 rte_spinlock_init(&internals->lsc_lock);
3089 internals->port_id = eth_dev->data->port_id;
3090 internals->mode = BONDING_MODE_INVALID;
3091 internals->current_primary_port = RTE_MAX_ETHPORTS + 1;
3092 internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
3093 internals->burst_xmit_hash = burst_xmit_l2_hash;
3094 internals->user_defined_mac = 0;
3096 internals->link_status_polling_enabled = 0;
3098 internals->link_status_polling_interval_ms =
3099 DEFAULT_POLLING_INTERVAL_10_MS;
3100 internals->link_down_delay_ms = 0;
3101 internals->link_up_delay_ms = 0;
3103 internals->slave_count = 0;
3104 internals->active_slave_count = 0;
3105 internals->rx_offload_capa = 0;
3106 internals->tx_offload_capa = 0;
3107 internals->rx_queue_offload_capa = 0;
3108 internals->tx_queue_offload_capa = 0;
3109 internals->candidate_max_rx_pktlen = 0;
3110 internals->max_rx_pktlen = 0;
3112 /* Initially allow to choose any offload type */
3113 internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK;
3115 memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
3116 memset(internals->slaves, 0, sizeof(internals->slaves));
3118 TAILQ_INIT(&internals->flow_list);
3119 internals->flow_isolated_valid = 0;
3121 /* Set mode 4 default configuration */
3122 bond_mode_8023ad_setup(eth_dev, NULL);
3123 if (bond_ethdev_mode_set(eth_dev, mode)) {
3124 RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode to %d",
3125 eth_dev->data->port_id, mode);
3129 vlan_filter_bmp_size =
3130 rte_bitmap_get_memory_footprint(ETHER_MAX_VLAN_ID + 1);
3131 internals->vlan_filter_bmpmem = rte_malloc(name, vlan_filter_bmp_size,
3132 RTE_CACHE_LINE_SIZE);
3133 if (internals->vlan_filter_bmpmem == NULL) {
3135 "Failed to allocate vlan bitmap for bonded device %u",
3136 eth_dev->data->port_id);
3140 internals->vlan_filter_bmp = rte_bitmap_init(ETHER_MAX_VLAN_ID + 1,
3141 internals->vlan_filter_bmpmem, vlan_filter_bmp_size);
3142 if (internals->vlan_filter_bmp == NULL) {
3144 "Failed to init vlan bitmap for bonded device %u",
3145 eth_dev->data->port_id);
3146 rte_free(internals->vlan_filter_bmpmem);
3150 return eth_dev->data->port_id;
3153 rte_free(internals);
3154 if (eth_dev != NULL) {
3155 rte_free(eth_dev->data->mac_addrs);
3156 rte_eth_dev_release_port(eth_dev);
3162 bond_probe(struct rte_vdev_device *dev)
3165 struct bond_dev_private *internals;
3166 struct rte_kvargs *kvlist;
3167 uint8_t bonding_mode, socket_id/*, agg_mode*/;
3168 int arg_count, port_id;
3170 struct rte_eth_dev *eth_dev;
3175 name = rte_vdev_device_name(dev);
3176 RTE_BOND_LOG(INFO, "Initializing pmd_bond for %s", name);
3178 if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
3179 strlen(rte_vdev_device_args(dev)) == 0) {
3180 eth_dev = rte_eth_dev_attach_secondary(name);
3182 RTE_BOND_LOG(ERR, "Failed to probe %s", name);
3185 /* TODO: request info from primary to set up Rx and Tx */
3186 eth_dev->dev_ops = &default_dev_ops;
3187 rte_eth_dev_probing_finish(eth_dev);
3191 kvlist = rte_kvargs_parse(rte_vdev_device_args(dev),
3192 pmd_bond_init_valid_arguments);
3196 /* Parse link bonding mode */
3197 if (rte_kvargs_count(kvlist, PMD_BOND_MODE_KVARG) == 1) {
3198 if (rte_kvargs_process(kvlist, PMD_BOND_MODE_KVARG,
3199 &bond_ethdev_parse_slave_mode_kvarg,
3200 &bonding_mode) != 0) {
3201 RTE_BOND_LOG(ERR, "Invalid mode for bonded device %s",
3206 RTE_BOND_LOG(ERR, "Mode must be specified only once for bonded "
3211 /* Parse socket id to create bonding device on */
3212 arg_count = rte_kvargs_count(kvlist, PMD_BOND_SOCKET_ID_KVARG);
3213 if (arg_count == 1) {
3214 if (rte_kvargs_process(kvlist, PMD_BOND_SOCKET_ID_KVARG,
3215 &bond_ethdev_parse_socket_id_kvarg, &socket_id)
3217 RTE_BOND_LOG(ERR, "Invalid socket Id specified for "
3218 "bonded device %s", name);
3221 } else if (arg_count > 1) {
3222 RTE_BOND_LOG(ERR, "Socket Id can be specified only once for "
3223 "bonded device %s", name);
3226 socket_id = rte_socket_id();
3229 dev->device.numa_node = socket_id;
3231 /* Create link bonding eth device */
3232 port_id = bond_alloc(dev, bonding_mode);
3234 RTE_BOND_LOG(ERR, "Failed to create socket %s in mode %u on "
3235 "socket %u.", name, bonding_mode, socket_id);
3238 internals = rte_eth_devices[port_id].data->dev_private;
3239 internals->kvlist = kvlist;
3242 if (rte_kvargs_count(kvlist, PMD_BOND_AGG_MODE_KVARG) == 1) {
3243 if (rte_kvargs_process(kvlist,
3244 PMD_BOND_AGG_MODE_KVARG,
3245 &bond_ethdev_parse_slave_agg_mode_kvarg,
3248 "Failed to parse agg selection mode for bonded device %s",
3253 if (internals->mode == BONDING_MODE_8023AD)
3254 rte_eth_bond_8023ad_agg_selection_set(port_id,
3257 rte_eth_bond_8023ad_agg_selection_set(port_id, AGG_STABLE);
3260 rte_eth_dev_probing_finish(&rte_eth_devices[port_id]);
3261 RTE_BOND_LOG(INFO, "Create bonded device %s on port %d in mode %u on "
3262 "socket %u.", name, port_id, bonding_mode, socket_id);
3266 rte_kvargs_free(kvlist);
3272 bond_remove(struct rte_vdev_device *dev)
3274 struct rte_eth_dev *eth_dev;
3275 struct bond_dev_private *internals;
3281 name = rte_vdev_device_name(dev);
3282 RTE_BOND_LOG(INFO, "Uninitializing pmd_bond for %s", name);
3284 /* now free all data allocation - for eth_dev structure,
3285 * dummy pci driver and internal (private) data
3288 /* find an ethdev entry */
3289 eth_dev = rte_eth_dev_allocated(name);
3290 if (eth_dev == NULL)
3293 RTE_ASSERT(eth_dev->device == &dev->device);
3295 internals = eth_dev->data->dev_private;
3296 if (internals->slave_count != 0)
3299 if (eth_dev->data->dev_started == 1) {
3300 bond_ethdev_stop(eth_dev);
3301 bond_ethdev_close(eth_dev);
3304 eth_dev->dev_ops = NULL;
3305 eth_dev->rx_pkt_burst = NULL;
3306 eth_dev->tx_pkt_burst = NULL;
3308 internals = eth_dev->data->dev_private;
3309 /* Try to release mempool used in mode6. If the bond
3310 * device is not mode6, free the NULL is not problem.
3312 rte_mempool_free(internals->mode6.mempool);
3313 rte_bitmap_free(internals->vlan_filter_bmp);
3314 rte_free(internals->vlan_filter_bmpmem);
3315 rte_free(eth_dev->data->dev_private);
3316 rte_free(eth_dev->data->mac_addrs);
3318 rte_eth_dev_release_port(eth_dev);
3323 /* this part will resolve the slave portids after all the other pdev and vdev
3324 * have been allocated */
3326 bond_ethdev_configure(struct rte_eth_dev *dev)
3328 const char *name = dev->device->name;
3329 struct bond_dev_private *internals = dev->data->dev_private;
3330 struct rte_kvargs *kvlist = internals->kvlist;
3332 uint16_t port_id = dev - rte_eth_devices;
3335 static const uint8_t default_rss_key[40] = {
3336 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, 0x41, 0x67, 0x25, 0x3D,
3337 0x43, 0xA3, 0x8F, 0xB0, 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
3338 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C, 0x6A, 0x42, 0xB7, 0x3B,
3339 0xBE, 0xAC, 0x01, 0xFA
3344 /* If RSS is enabled, fill table and key with default values */
3345 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS) {
3346 dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key = internals->rss_key;
3347 dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len = 0;
3348 memcpy(internals->rss_key, default_rss_key, 40);
3350 for (i = 0; i < RTE_DIM(internals->reta_conf); i++) {
3351 internals->reta_conf[i].mask = ~0LL;
3352 for (j = 0; j < RTE_RETA_GROUP_SIZE; j++)
3353 internals->reta_conf[i].reta[j] = j % dev->data->nb_rx_queues;
3357 /* set the max_rx_pktlen */
3358 internals->max_rx_pktlen = internals->candidate_max_rx_pktlen;
3361 * if no kvlist, it means that this bonded device has been created
3362 * through the bonding api.
3367 /* Parse MAC address for bonded device */
3368 arg_count = rte_kvargs_count(kvlist, PMD_BOND_MAC_ADDR_KVARG);
3369 if (arg_count == 1) {
3370 struct ether_addr bond_mac;
3372 if (rte_kvargs_process(kvlist, PMD_BOND_MAC_ADDR_KVARG,
3373 &bond_ethdev_parse_bond_mac_addr_kvarg, &bond_mac) < 0) {
3374 RTE_BOND_LOG(INFO, "Invalid mac address for bonded device %s",
3379 /* Set MAC address */
3380 if (rte_eth_bond_mac_address_set(port_id, &bond_mac) != 0) {
3382 "Failed to set mac address on bonded device %s",
3386 } else if (arg_count > 1) {
3388 "MAC address can be specified only once for bonded device %s",
3393 /* Parse/set balance mode transmit policy */
3394 arg_count = rte_kvargs_count(kvlist, PMD_BOND_XMIT_POLICY_KVARG);
3395 if (arg_count == 1) {
3396 uint8_t xmit_policy;
3398 if (rte_kvargs_process(kvlist, PMD_BOND_XMIT_POLICY_KVARG,
3399 &bond_ethdev_parse_balance_xmit_policy_kvarg, &xmit_policy) !=
3402 "Invalid xmit policy specified for bonded device %s",
3407 /* Set balance mode transmit policy*/
3408 if (rte_eth_bond_xmit_policy_set(port_id, xmit_policy) != 0) {
3410 "Failed to set balance xmit policy on bonded device %s",
3414 } else if (arg_count > 1) {
3416 "Transmit policy can be specified only once for bonded device %s",
3421 if (rte_kvargs_count(kvlist, PMD_BOND_AGG_MODE_KVARG) == 1) {
3422 if (rte_kvargs_process(kvlist,
3423 PMD_BOND_AGG_MODE_KVARG,
3424 &bond_ethdev_parse_slave_agg_mode_kvarg,
3427 "Failed to parse agg selection mode for bonded device %s",
3430 if (internals->mode == BONDING_MODE_8023AD)
3431 rte_eth_bond_8023ad_agg_selection_set(port_id,
3435 /* Parse/add slave ports to bonded device */
3436 if (rte_kvargs_count(kvlist, PMD_BOND_SLAVE_PORT_KVARG) > 0) {
3437 struct bond_ethdev_slave_ports slave_ports;
3440 memset(&slave_ports, 0, sizeof(slave_ports));
3442 if (rte_kvargs_process(kvlist, PMD_BOND_SLAVE_PORT_KVARG,
3443 &bond_ethdev_parse_slave_port_kvarg, &slave_ports) != 0) {
3445 "Failed to parse slave ports for bonded device %s",
3450 for (i = 0; i < slave_ports.slave_count; i++) {
3451 if (rte_eth_bond_slave_add(port_id, slave_ports.slaves[i]) != 0) {
3453 "Failed to add port %d as slave to bonded device %s",
3454 slave_ports.slaves[i], name);
3459 RTE_BOND_LOG(INFO, "No slaves specified for bonded device %s", name);
3463 /* Parse/set primary slave port id*/
3464 arg_count = rte_kvargs_count(kvlist, PMD_BOND_PRIMARY_SLAVE_KVARG);
3465 if (arg_count == 1) {
3466 uint16_t primary_slave_port_id;
3468 if (rte_kvargs_process(kvlist,
3469 PMD_BOND_PRIMARY_SLAVE_KVARG,
3470 &bond_ethdev_parse_primary_slave_port_id_kvarg,
3471 &primary_slave_port_id) < 0) {
3473 "Invalid primary slave port id specified for bonded device %s",
3478 /* Set balance mode transmit policy*/
3479 if (rte_eth_bond_primary_set(port_id, primary_slave_port_id)
3482 "Failed to set primary slave port %d on bonded device %s",
3483 primary_slave_port_id, name);
3486 } else if (arg_count > 1) {
3488 "Primary slave can be specified only once for bonded device %s",
3493 /* Parse link status monitor polling interval */
3494 arg_count = rte_kvargs_count(kvlist, PMD_BOND_LSC_POLL_PERIOD_KVARG);
3495 if (arg_count == 1) {
3496 uint32_t lsc_poll_interval_ms;
3498 if (rte_kvargs_process(kvlist,
3499 PMD_BOND_LSC_POLL_PERIOD_KVARG,
3500 &bond_ethdev_parse_time_ms_kvarg,
3501 &lsc_poll_interval_ms) < 0) {
3503 "Invalid lsc polling interval value specified for bonded"
3504 " device %s", name);
3508 if (rte_eth_bond_link_monitoring_set(port_id, lsc_poll_interval_ms)
3511 "Failed to set lsc monitor polling interval (%u ms) on bonded device %s",
3512 lsc_poll_interval_ms, name);
3515 } else if (arg_count > 1) {
3517 "LSC polling interval can be specified only once for bonded"
3518 " device %s", name);
3522 /* Parse link up interrupt propagation delay */
3523 arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_UP_PROP_DELAY_KVARG);
3524 if (arg_count == 1) {
3525 uint32_t link_up_delay_ms;
3527 if (rte_kvargs_process(kvlist,
3528 PMD_BOND_LINK_UP_PROP_DELAY_KVARG,
3529 &bond_ethdev_parse_time_ms_kvarg,
3530 &link_up_delay_ms) < 0) {
3532 "Invalid link up propagation delay value specified for"
3533 " bonded device %s", name);
3537 /* Set balance mode transmit policy*/
3538 if (rte_eth_bond_link_up_prop_delay_set(port_id, link_up_delay_ms)
3541 "Failed to set link up propagation delay (%u ms) on bonded"
3542 " device %s", link_up_delay_ms, name);
3545 } else if (arg_count > 1) {
3547 "Link up propagation delay can be specified only once for"
3548 " bonded device %s", name);
3552 /* Parse link down interrupt propagation delay */
3553 arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG);
3554 if (arg_count == 1) {
3555 uint32_t link_down_delay_ms;
3557 if (rte_kvargs_process(kvlist,
3558 PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG,
3559 &bond_ethdev_parse_time_ms_kvarg,
3560 &link_down_delay_ms) < 0) {
3562 "Invalid link down propagation delay value specified for"
3563 " bonded device %s", name);
3567 /* Set balance mode transmit policy*/
3568 if (rte_eth_bond_link_down_prop_delay_set(port_id, link_down_delay_ms)
3571 "Failed to set link down propagation delay (%u ms) on bonded device %s",
3572 link_down_delay_ms, name);
3575 } else if (arg_count > 1) {
3577 "Link down propagation delay can be specified only once for bonded device %s",
3585 struct rte_vdev_driver pmd_bond_drv = {
3586 .probe = bond_probe,
3587 .remove = bond_remove,
3590 RTE_PMD_REGISTER_VDEV(net_bonding, pmd_bond_drv);
3591 RTE_PMD_REGISTER_ALIAS(net_bonding, eth_bond);
3593 RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
3597 "xmit_policy=[l2 | l23 | l34] "
3598 "agg_mode=[count | stable | bandwidth] "
3601 "lsc_poll_period_ms=<int> "
3603 "down_delay=<int>");
3607 RTE_INIT(bond_init_log)
3609 bond_logtype = rte_log_register("pmd.net.bon");
3610 if (bond_logtype >= 0)
3611 rte_log_set_level(bond_logtype, RTE_LOG_NOTICE);