4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #include <rte_cycles.h>
42 #include <sys/queue.h>
44 #include <rte_byteorder.h>
45 #include <rte_common.h>
46 #include <rte_debug.h>
47 #include <rte_ethdev.h>
49 #include <rte_lcore.h>
50 #include <rte_memory.h>
52 #include <rte_string_fns.h>
54 #include <rte_eth_ring.h>
55 #include <rte_errno.h>
56 #include <rte_eth_bond.h>
57 #include <rte_eth_bond_8023ad.h>
59 #include "packet_burst_generator.h"
63 #define SLAVE_COUNT (4)
65 #define RX_RING_SIZE 128
66 #define TX_RING_SIZE 512
68 #define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM)
69 #define MBUF_CACHE_SIZE (250)
70 #define BURST_SIZE (32)
72 #define DEFAULT_MBUF_DATA_SIZE (2048)
73 #define TEST_RX_DESC_MAX (2048)
74 #define TEST_TX_DESC_MAX (2048)
75 #define MAX_PKT_BURST (32)
76 #define DEF_PKT_BURST (16)
78 #define BONDED_DEV_NAME ("unit_test_mode4_bond_dev")
80 #define SLAVE_DEV_NAME_FMT ("unit_test_mode4_slave_%d")
81 #define SLAVE_RX_QUEUE_FMT ("unit_test_mode4_slave_%d_rx")
82 #define SLAVE_TX_QUEUE_FMT ("unit_test_mode4_slave_%d_tx")
84 #define INVALID_SOCKET_ID (-1)
85 #define INVALID_PORT_ID (0xFF)
86 #define INVALID_BONDING_MODE (-1)
88 static const struct ether_addr slave_mac_default = {
89 { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 }
92 static const struct ether_addr parnter_mac_default = {
93 { 0x22, 0xBB, 0xFF, 0xBB, 0x00, 0x00 }
96 static const struct ether_addr parnter_system = {
97 { 0x33, 0xFF, 0xBB, 0xFF, 0x00, 0x00 }
100 static const struct ether_addr slow_protocol_mac_addr = {
101 { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x02 }
105 struct rte_ring *rx_queue;
106 struct rte_ring *tx_queue;
110 uint8_t lacp_parnter_state;
113 struct ether_vlan_hdr {
114 struct ether_hdr pkt_eth_hdr;
115 struct vlan_hdr vlan_hdr;
118 struct link_bonding_unittest_params {
119 uint8_t bonded_port_id;
120 struct slave_conf slave_ports[SLAVE_COUNT];
122 struct rte_mempool *mbuf_pool;
125 #define TEST_DEFAULT_SLAVE_COUNT RTE_DIM(test_params.slave_ports)
126 #define TEST_RX_SLAVE_COUT TEST_DEFAULT_SLAVE_COUNT
127 #define TEST_TX_SLAVE_COUNT TEST_DEFAULT_SLAVE_COUNT
128 #define TEST_MARKER_SLAVE_COUT TEST_DEFAULT_SLAVE_COUNT
129 #define TEST_EXPIRED_SLAVE_COUNT TEST_DEFAULT_SLAVE_COUNT
130 #define TEST_PROMISC_SLAVE_COUNT TEST_DEFAULT_SLAVE_COUNT
132 static struct link_bonding_unittest_params test_params = {
133 .bonded_port_id = INVALID_PORT_ID,
134 .slave_ports = { [0 ... SLAVE_COUNT - 1] = { .port_id = INVALID_PORT_ID} },
139 static struct rte_eth_conf default_pmd_conf = {
141 .mq_mode = ETH_MQ_RX_NONE,
142 .max_rx_pkt_len = ETHER_MAX_LEN,
144 .header_split = 0, /**< Header Split disabled */
145 .hw_ip_checksum = 0, /**< IP checksum offload enabled */
146 .hw_vlan_filter = 0, /**< VLAN filtering disabled */
147 .jumbo_frame = 0, /**< Jumbo Frame Support disabled */
148 .hw_strip_crc = 0, /**< CRC stripped by hardware */
151 .mq_mode = ETH_MQ_TX_NONE,
156 #define FOR_EACH(_i, _item, _array, _size) \
157 for (_i = 0, _item = &_array[0]; _i < _size && (_item = &_array[_i]); _i++)
159 /* Macro for iterating over every port that can be used as a slave
161 * _i variable used as an index in test_params->slave_ports
162 * _slave pointer to &test_params->slave_ports[_idx]
164 #define FOR_EACH_PORT(_i, _port) \
165 FOR_EACH(_i, _port, test_params.slave_ports, \
166 RTE_DIM(test_params.slave_ports))
168 /* Macro for iterating over every port that can be used as a slave
169 * in this test and satisfy given condition.
171 * _i variable used as an index in test_params->slave_ports
172 * _slave pointer to &test_params->slave_ports[_idx]
173 * _condition condition that need to be checked
175 #define FOR_EACH_PORT_IF(_i, _port, _condition) FOR_EACH_PORT((_i), (_port)) \
178 /* Macro for iterating over every port that is currently a slave of a bonded
180 * _i variable used as an index in test_params->slave_ports
181 * _slave pointer to &test_params->slave_ports[_idx]
183 #define FOR_EACH_SLAVE(_i, _slave) \
184 FOR_EACH_PORT_IF(_i, _slave, (_slave)->bonded != 0)
187 * Returns packets from slaves TX queue.
190 * size size of buffer
191 * return number of packets or negative error number
194 slave_get_pkts(struct slave_conf *slave, struct rte_mbuf **buf, uint16_t size)
196 return rte_ring_dequeue_burst(slave->tx_queue, (void **)buf, size);
200 * Injects given packets into slaves RX queue.
203 * size number of packets to be injected
204 * return number of queued packets or negative error number
207 slave_put_pkts(struct slave_conf *slave, struct rte_mbuf **buf, uint16_t size)
209 return rte_ring_enqueue_burst(slave->rx_queue, (void **)buf, size);
213 bond_rx(struct rte_mbuf **buf, uint16_t size)
215 return rte_eth_rx_burst(test_params.bonded_port_id, 0, buf, size);
219 bond_tx(struct rte_mbuf **buf, uint16_t size)
221 return rte_eth_tx_burst(test_params.bonded_port_id, 0, buf, size);
225 free_pkts(struct rte_mbuf **pkts, uint16_t count)
229 for (i = 0; i < count; i++) {
231 rte_pktmbuf_free(pkts[i]);
236 configure_ethdev(uint8_t port_id, uint8_t start)
238 TEST_ASSERT(rte_eth_dev_configure(port_id, 1, 1, &default_pmd_conf) == 0,
239 "Failed to configure device %u", port_id);
241 TEST_ASSERT(rte_eth_rx_queue_setup(port_id, 0, RX_RING_SIZE,
242 rte_eth_dev_socket_id(port_id), NULL, test_params.mbuf_pool) == 0,
243 "Failed to setup rx queue.");
245 TEST_ASSERT(rte_eth_tx_queue_setup(port_id, 0, TX_RING_SIZE,
246 rte_eth_dev_socket_id(port_id), NULL) == 0,
247 "Failed to setup tx queue.");
250 TEST_ASSERT(rte_eth_dev_start(port_id) == 0,
251 "Failed to start device (%d).", port_id);
257 add_slave(struct slave_conf *slave, uint8_t start)
259 struct ether_addr addr, addr_check;
261 /* Some sanity check */
262 RTE_VERIFY(test_params.slave_ports <= slave &&
263 slave - test_params.slave_ports < (int)RTE_DIM(test_params.slave_ports));
264 RTE_VERIFY(slave->bonded == 0);
265 RTE_VERIFY(slave->port_id != INVALID_PORT_ID);
267 ether_addr_copy(&slave_mac_default, &addr);
268 addr.addr_bytes[ETHER_ADDR_LEN - 1] = slave->port_id;
270 rte_eth_dev_mac_addr_remove(slave->port_id, &addr);
272 TEST_ASSERT_SUCCESS(rte_eth_dev_mac_addr_add(slave->port_id, &addr, 0),
273 "Failed to set slave MAC address");
275 TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params.bonded_port_id,
277 "Failed to add slave (idx=%u, id=%u) to bonding (id=%u)",
278 (uint8_t)(slave - test_params.slave_ports), slave->port_id,
279 test_params.bonded_port_id);
283 TEST_ASSERT_SUCCESS(rte_eth_dev_start(slave->port_id),
284 "Failed to start slave %u", slave->port_id);
287 rte_eth_macaddr_get(slave->port_id, &addr_check);
288 TEST_ASSERT_EQUAL(is_same_ether_addr(&addr, &addr_check), 1,
289 "Slave MAC address is not as expected");
291 RTE_VERIFY(slave->lacp_parnter_state == 0);
296 remove_slave(struct slave_conf *slave)
298 ptrdiff_t slave_idx = slave - test_params.slave_ports;
300 RTE_VERIFY(test_params.slave_ports <= slave &&
301 slave_idx < (ptrdiff_t)RTE_DIM(test_params.slave_ports));
303 RTE_VERIFY(slave->bonded == 1);
304 RTE_VERIFY(slave->port_id != INVALID_PORT_ID);
306 TEST_ASSERT_EQUAL(rte_ring_count(slave->rx_queue), 0,
307 "Slave %u tx queue not empty while removing from bonding.",
310 TEST_ASSERT_EQUAL(rte_ring_count(slave->rx_queue), 0,
311 "Slave %u tx queue not empty while removing from bonding.",
314 TEST_ASSERT_EQUAL(rte_eth_bond_slave_remove(test_params.bonded_port_id,
316 "Failed to remove slave (idx=%u, id=%u) from bonding (id=%u)",
317 (uint8_t)slave_idx, slave->port_id,
318 test_params.bonded_port_id);
321 slave->lacp_parnter_state = 0;
326 initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
330 RTE_VERIFY(test_params.bonded_port_id != INVALID_PORT_ID);
332 for (i = 0; i < slave_count; i++) {
333 TEST_ASSERT_SUCCESS(add_slave(&test_params.slave_ports[i], 1),
334 "Failed to add port %u to bonded device.\n",
335 test_params.slave_ports[i].port_id);
338 /* Reset mode 4 configuration */
339 rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
340 rte_eth_promiscuous_disable(test_params.bonded_port_id);
343 TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
344 "Failed to start bonded device");
350 remove_slaves_and_stop_bonded_device(void)
352 struct slave_conf *slave;
354 uint8_t slaves[RTE_MAX_ETHPORTS];
357 rte_eth_dev_stop(test_params.bonded_port_id);
359 FOR_EACH_SLAVE(i, slave)
362 retval = rte_eth_bond_slaves_get(test_params.bonded_port_id, slaves,
365 TEST_ASSERT_EQUAL(retval, 0,
366 "Expected bonded device %u have 0 slaves but returned %d.",
367 test_params.bonded_port_id, retval);
369 FOR_EACH_PORT(i, slave) {
370 rte_eth_dev_stop(slave->port_id);
372 TEST_ASSERT(slave->bonded == 0,
373 "Port id=%u is still marked as enslaved.", slave->port_id);
382 int retval, nb_mbuf_per_pool;
383 char name[RTE_ETH_NAME_MAX_LEN];
384 struct slave_conf *port;
385 const uint8_t socket_id = rte_socket_id();
388 if (test_params.mbuf_pool == NULL) {
389 nb_mbuf_per_pool = TEST_RX_DESC_MAX + DEF_PKT_BURST +
390 TEST_TX_DESC_MAX + MAX_PKT_BURST;
391 test_params.mbuf_pool = rte_pktmbuf_pool_create("TEST_MODE4",
392 nb_mbuf_per_pool, MBUF_CACHE_SIZE, 0, MBUF_DATA_SIZE,
395 TEST_ASSERT(test_params.mbuf_pool != NULL,
396 "rte_mempool_create failed\n");
399 /* Create / initialize ring eth devs. */
400 FOR_EACH_PORT(i, port) {
401 port = &test_params.slave_ports[i];
403 if (port->rx_queue == NULL) {
404 retval = snprintf(name, RTE_DIM(name), SLAVE_RX_QUEUE_FMT, i);
405 TEST_ASSERT(retval <= (int)RTE_DIM(name) - 1, "Name too long");
406 port->rx_queue = rte_ring_create(name, RX_RING_SIZE, socket_id, 0);
407 TEST_ASSERT(port->rx_queue != NULL,
408 "Failed to allocate rx ring '%s': %s", name,
409 rte_strerror(rte_errno));
412 if (port->tx_queue == NULL) {
413 retval = snprintf(name, RTE_DIM(name), SLAVE_TX_QUEUE_FMT, i);
414 TEST_ASSERT(retval <= (int)RTE_DIM(name) - 1, "Name too long");
415 port->tx_queue = rte_ring_create(name, TX_RING_SIZE, socket_id, 0);
416 TEST_ASSERT_NOT_NULL(port->tx_queue,
417 "Failed to allocate tx ring '%s': %s", name,
418 rte_strerror(rte_errno));
421 if (port->port_id == INVALID_PORT_ID) {
422 retval = snprintf(name, RTE_DIM(name), SLAVE_DEV_NAME_FMT, i);
423 TEST_ASSERT(retval < (int)RTE_DIM(name) - 1, "Name too long");
424 retval = rte_eth_from_rings(name, &port->rx_queue, 1,
425 &port->tx_queue, 1, socket_id);
426 TEST_ASSERT(retval >= 0,
427 "Failed to create ring ethdev '%s'\n", name);
429 port->port_id = rte_eth_dev_count() - 1;
432 retval = configure_ethdev(port->port_id, 1);
433 TEST_ASSERT_SUCCESS(retval, "Failed to configure virtual ethdev %s\n",
437 if (test_params.bonded_port_id == INVALID_PORT_ID) {
438 retval = rte_eth_bond_create(BONDED_DEV_NAME, BONDING_MODE_8023AD,
441 TEST_ASSERT(retval >= 0, "Failed to create bonded ethdev %s",
444 test_params.bonded_port_id = retval;
445 TEST_ASSERT_SUCCESS(configure_ethdev(test_params.bonded_port_id, 0),
446 "Failed to configure bonded ethdev %s", BONDED_DEV_NAME);
447 } else if (rte_eth_bond_mode_get(test_params.bonded_port_id) !=
448 BONDING_MODE_8023AD) {
449 TEST_ASSERT(rte_eth_bond_mode_set(test_params.bonded_port_id,
450 BONDING_MODE_8023AD) == 0,
451 "Failed to set ethdev %d to mode %d",
452 test_params.bonded_port_id, BONDING_MODE_8023AD);
459 testsuite_teardown(void)
461 struct slave_conf *port;
465 * Any cleanup/reset state is done when particular test is
468 rte_eth_dev_stop(test_params.bonded_port_id);
470 FOR_EACH_PORT(i, port)
471 rte_eth_dev_stop(port->port_id);
477 * Check if given LACP packet. If it is, make make replay packet to force
479 * return 0 when pkt is LACP frame, 1 if it is not slow frame, 2 if it is slow
483 make_lacp_reply(struct slave_conf *slave, struct rte_mbuf *pkt)
485 struct ether_hdr *hdr;
486 struct slow_protocol_frame *slow_hdr;
490 hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *);
491 if (hdr->ether_type != rte_cpu_to_be_16(ETHER_TYPE_SLOW))
494 slow_hdr = rte_pktmbuf_mtod(pkt, struct slow_protocol_frame *);
495 /* ignore packets of other types */
496 if (slow_hdr->slow_protocol.subtype != SLOW_SUBTYPE_LACP)
499 slow_hdr = rte_pktmbuf_mtod(pkt, struct slow_protocol_frame *);
501 /* Change source address to partner address */
502 ether_addr_copy(&parnter_mac_default, &slow_hdr->eth_hdr.s_addr);
503 slow_hdr->eth_hdr.s_addr.addr_bytes[ETHER_ADDR_LEN - 1] = slave->port_id;
505 lacp = (struct lacpdu *) &slow_hdr->slow_protocol;
506 /* Save last received state */
507 slave->lacp_parnter_state = lacp->actor.state;
508 /* Change it into LACP replay by matching parameters. */
509 memcpy(&lacp->partner.port_params, &lacp->actor.port_params,
510 sizeof(struct port_params));
512 lacp->partner.state = lacp->actor.state;
514 ether_addr_copy(&parnter_system, &lacp->actor.port_params.system);
515 lacp->actor.state = STATE_LACP_ACTIVE |
516 STATE_SYNCHRONIZATION |
525 * Reads packets from given slave, search for LACP packet and reply them.
527 * Receives burst of packets from slave. Looks for LACP packet. Drops
528 * all other packets. Prepares response LACP and sends it back.
530 * return number of LACP received and replied, -1 on error.
533 bond_handshake_reply(struct slave_conf *slave)
536 struct rte_mbuf *rx_buf[MAX_PKT_BURST];
537 struct rte_mbuf *lacp_tx_buf[MAX_PKT_BURST];
538 uint16_t lacp_tx_buf_cnt = 0, i;
540 retval = slave_get_pkts(slave, rx_buf, RTE_DIM(rx_buf));
541 TEST_ASSERT(retval >= 0, "Getting slave %u packets failed.",
544 for (i = 0; i < (uint16_t)retval; i++) {
545 if (make_lacp_reply(slave, rx_buf[i]) == 0) {
546 /* reply with actor's LACP */
547 lacp_tx_buf[lacp_tx_buf_cnt++] = rx_buf[i];
549 rte_pktmbuf_free(rx_buf[i]);
552 if (lacp_tx_buf_cnt == 0)
555 retval = slave_put_pkts(slave, lacp_tx_buf, lacp_tx_buf_cnt);
556 if (retval <= lacp_tx_buf_cnt) {
557 /* retval might be negative */
558 for (i = RTE_MAX(0, retval); retval < lacp_tx_buf_cnt; retval++)
559 rte_pktmbuf_free(lacp_tx_buf[i]);
562 TEST_ASSERT_EQUAL(retval, lacp_tx_buf_cnt,
563 "Failed to equeue lacp packets into slave %u tx queue.",
566 return lacp_tx_buf_cnt;
570 * Function check if given slave tx queue contains packets that make mode 4
571 * handshake complete. It will drain slave queue.
572 * return 0 if handshake not completed, 1 if handshake was complete,
575 bond_handshake_done(struct slave_conf *slave)
577 const uint8_t expected_state = STATE_LACP_ACTIVE | STATE_SYNCHRONIZATION |
578 STATE_AGGREGATION | STATE_COLLECTING | STATE_DISTRIBUTING;
580 return slave->lacp_parnter_state == expected_state;
584 bond_get_update_timeout_ms(void)
586 struct rte_eth_bond_8023ad_conf conf;
588 rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
589 return conf.update_timeout_ms;
593 * Exchanges LACP packets with partner to achieve dynamic port configuration.
594 * return TEST_SUCCESS if initial handshake succeed, TEST_FAILED otherwise.
599 struct slave_conf *slave;
600 struct rte_mbuf *buf[MAX_PKT_BURST];
602 uint8_t all_slaves_done, i, j;
603 uint8_t status[RTE_DIM(test_params.slave_ports)] = { 0 };
604 const unsigned delay = bond_get_update_timeout_ms();
606 /* Exchange LACP frames */
608 for (i = 0; i < 30 && all_slaves_done == 0; ++i) {
612 FOR_EACH_SLAVE(j, slave) {
613 /* If response already send, skip slave */
617 if (bond_handshake_reply(slave) < 0) {
622 status[j] = bond_handshake_done(slave);
627 nb_pkts = bond_tx(NULL, 0);
628 TEST_ASSERT_EQUAL(nb_pkts, 0, "Packets transmitted unexpectedly");
630 nb_pkts = bond_rx(buf, RTE_DIM(buf));
631 free_pkts(buf, nb_pkts);
632 TEST_ASSERT_EQUAL(nb_pkts, 0, "Packets received unexpectedly");
634 /* If response didn't send - report failure */
635 TEST_ASSERT_EQUAL(all_slaves_done, 1, "Bond handshake failed\n");
637 /* If flags doesn't match - report failure */
638 return all_slaves_done = 1 ? TEST_SUCCESS : TEST_FAILED;
641 #define TEST_LACP_SLAVE_COUT RTE_DIM(test_params.slave_ports)
643 test_mode4_lacp(void)
647 retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 1);
648 TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
650 /* Test LACP handshake function */
651 retval = bond_handshake();
652 TEST_ASSERT_SUCCESS(retval, "Initial handshake failed");
654 retval = remove_slaves_and_stop_bonded_device();
655 TEST_ASSERT_SUCCESS(retval, "Test cleanup failed.");
661 generate_packets(struct ether_addr *src_mac,
662 struct ether_addr *dst_mac, uint16_t count, struct rte_mbuf **buf)
664 uint16_t pktlen = PACKET_BURST_GEN_PKT_LEN;
665 uint8_t vlan_enable = 0;
666 uint16_t vlan_id = 0;
667 uint8_t ip4_type = 1; /* 0 - ipv6 */
669 uint16_t src_port = 10, dst_port = 20;
671 uint32_t ip_src[4] = { [0 ... 2] = 0xDEADBEEF, [3] = IPv4(192, 168, 0, 1) };
672 uint32_t ip_dst[4] = { [0 ... 2] = 0xFEEDFACE, [3] = IPv4(192, 168, 0, 2) };
674 struct ether_hdr pkt_eth_hdr;
675 struct udp_hdr pkt_udp_hdr;
683 initialize_eth_header(&pkt_eth_hdr, src_mac, dst_mac, ip4_type,
684 vlan_enable, vlan_id);
687 initialize_ipv4_header(&pkt_ip_hdr.v4, ip_src[3], ip_dst[3], pktlen);
689 initialize_ipv6_header(&pkt_ip_hdr.v6, (uint8_t *)ip_src,
690 (uint8_t *)&ip_dst, pktlen);
692 initialize_udp_header(&pkt_udp_hdr, src_port, dst_port, 16);
694 retval = generate_packet_burst(test_params.mbuf_pool, buf,
695 &pkt_eth_hdr, vlan_enable, &pkt_ip_hdr, 1, &pkt_udp_hdr,
698 if (retval > 0 && retval != count)
699 free_pkts(&buf[count - retval], retval);
701 TEST_ASSERT_EQUAL(retval, count, "Failed to generate %u packets",
708 generate_and_put_packets(struct slave_conf *slave, struct ether_addr *src_mac,
709 struct ether_addr *dst_mac, uint16_t count)
711 struct rte_mbuf *pkts[MAX_PKT_BURST];
714 retval = generate_packets(src_mac, dst_mac, count, pkts);
715 if (retval != (int)count)
718 retval = slave_put_pkts(slave, pkts, count);
719 if (retval > 0 && retval != count)
720 free_pkts(&pkts[retval], count - retval);
722 TEST_ASSERT_EQUAL(retval, count,
723 "Failed to enqueue packets into slave %u RX queue", slave->port_id);
731 struct slave_conf *slave;
734 uint16_t expected_pkts_cnt;
735 struct rte_mbuf *pkts[MAX_PKT_BURST];
739 struct ether_hdr *hdr;
741 struct ether_addr src_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
742 struct ether_addr dst_mac;
743 struct ether_addr bonded_mac;
745 retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 1);
746 TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
748 retval = bond_handshake();
749 TEST_ASSERT_SUCCESS(retval, "Initial handshake failed");
751 rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
752 ether_addr_copy(&bonded_mac, &dst_mac);
754 /* Assert that dst address is not bonding address */
755 dst_mac.addr_bytes[0]++;
757 /* First try with promiscuous mode enabled.
758 * Add 2 packets to each slave. First with bonding MAC address, second with
759 * different. Check if we received all of them. */
760 rte_eth_promiscuous_enable(test_params.bonded_port_id);
762 expected_pkts_cnt = 0;
763 FOR_EACH_SLAVE(i, slave) {
764 retval = generate_and_put_packets(slave, &src_mac, &bonded_mac, 1);
765 TEST_ASSERT_SUCCESS(retval, "Failed to enqueue packets to slave %u",
768 retval = generate_and_put_packets(slave, &src_mac, &dst_mac, 1);
769 TEST_ASSERT_SUCCESS(retval, "Failed to enqueue packets to slave %u",
772 /* Expect 2 packets per slave */
773 expected_pkts_cnt += 2;
776 retval = rte_eth_rx_burst(test_params.bonded_port_id, 0, pkts,
779 if (retval == expected_pkts_cnt) {
780 int cnt[2] = { 0, 0 };
782 for (i = 0; i < expected_pkts_cnt; i++) {
783 hdr = rte_pktmbuf_mtod(pkts[i], struct ether_hdr *);
784 cnt[is_same_ether_addr(&hdr->d_addr, &bonded_mac)]++;
787 free_pkts(pkts, expected_pkts_cnt);
789 /* For division by 2 expected_pkts_cnt must be even */
790 RTE_VERIFY((expected_pkts_cnt & 1) == 0);
791 TEST_ASSERT(cnt[0] == expected_pkts_cnt / 2 &&
792 cnt[1] == expected_pkts_cnt / 2,
793 "Expected %u packets with the same MAC and %u with different but "
794 "got %u with the same and %u with diffrent MAC",
795 expected_pkts_cnt / 2, expected_pkts_cnt / 2, cnt[1], cnt[0]);
796 } else if (retval > 0)
797 free_pkts(pkts, retval);
799 TEST_ASSERT_EQUAL(retval, expected_pkts_cnt,
800 "Expected %u packets but received only %d", expected_pkts_cnt, retval);
802 /* Now, disable promiscuous mode. When promiscuous mode is disabled we
803 * expect to receive only packets that are directed to bonding port. */
804 rte_eth_promiscuous_disable(test_params.bonded_port_id);
806 expected_pkts_cnt = 0;
807 FOR_EACH_SLAVE(i, slave) {
808 retval = generate_and_put_packets(slave, &src_mac, &bonded_mac, 1);
809 TEST_ASSERT_SUCCESS(retval, "Failed to enqueue packets to slave %u",
812 retval = generate_and_put_packets(slave, &src_mac, &dst_mac, 1);
813 TEST_ASSERT_SUCCESS(retval, "Failed to enqueue packets to slave %u",
816 /* Expect only one packet per slave */
817 expected_pkts_cnt += 1;
820 retval = rte_eth_rx_burst(test_params.bonded_port_id, 0, pkts,
823 if (retval == expected_pkts_cnt) {
826 for (i = 0; i < expected_pkts_cnt; i++) {
827 hdr = rte_pktmbuf_mtod(pkts[i], struct ether_hdr *);
828 eq_cnt += is_same_ether_addr(&hdr->d_addr, &bonded_mac);
831 free_pkts(pkts, expected_pkts_cnt);
832 TEST_ASSERT_EQUAL(eq_cnt, expected_pkts_cnt, "Packet address mismatch");
833 } else if (retval > 0)
834 free_pkts(pkts, retval);
836 TEST_ASSERT_EQUAL(retval, expected_pkts_cnt,
837 "Expected %u packets but received only %d", expected_pkts_cnt, retval);
839 /* Link down test: simulate link down for first slave. */
840 delay = bond_get_update_timeout_ms();
842 uint8_t slave_down_id = INVALID_PORT_ID;
844 /* Find first slave and make link down on it*/
845 FOR_EACH_SLAVE(i, slave) {
846 rte_eth_dev_set_link_down(slave->port_id);
847 slave_down_id = slave->port_id;
851 RTE_VERIFY(slave_down_id != INVALID_PORT_ID);
853 /* Give some time to rearrange bonding */
854 for (i = 0; i < 3; i++) {
859 TEST_ASSERT_SUCCESS(bond_handshake(), "Handshake after link down failed");
861 /* Put packet to each slave */
862 FOR_EACH_SLAVE(i, slave) {
865 dst_mac.addr_bytes[ETHER_ADDR_LEN - 1] = slave->port_id;
866 retval = generate_and_put_packets(slave, &src_mac, &dst_mac, 1);
867 TEST_ASSERT_SUCCESS(retval, "Failed to generate test packet burst.");
869 src_mac.addr_bytes[ETHER_ADDR_LEN - 1] = slave->port_id;
870 retval = generate_and_put_packets(slave, &src_mac, &bonded_mac, 1);
871 TEST_ASSERT_SUCCESS(retval, "Failed to generate test packet burst.");
873 retval = bond_rx(pkts, RTE_DIM(pkts));
877 free_pkts(pkts, retval);
879 while (rte_ring_dequeue(slave->rx_queue, (void **)&pkt) == 0)
880 rte_pktmbuf_free(pkt);
882 if (slave_down_id == slave->port_id)
883 TEST_ASSERT_EQUAL(retval, 0, "Packets received unexpectedly.");
885 TEST_ASSERT_NOT_EQUAL(retval, 0,
886 "Expected to receive some packets on slave %u.",
888 rte_eth_dev_start(slave->port_id);
890 for (j = 0; j < 5; j++) {
891 TEST_ASSERT(bond_handshake_reply(slave) >= 0,
892 "Handshake after link up");
894 if (bond_handshake_done(slave) == 1)
898 TEST_ASSERT(j < 5, "Failed to agregate slave after link up");
901 remove_slaves_and_stop_bonded_device();
906 test_mode4_tx_burst(void)
908 struct slave_conf *slave;
911 uint16_t exp_pkts_cnt, pkts_cnt = 0;
912 struct rte_mbuf *pkts[MAX_PKT_BURST];
916 struct ether_addr dst_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
917 struct ether_addr bonded_mac;
919 retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
920 TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
922 retval = bond_handshake();
923 TEST_ASSERT_SUCCESS(retval, "Initial handshake failed");
925 rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
928 for (pkts_cnt = 0; pkts_cnt < RTE_DIM(pkts); pkts_cnt++) {
929 dst_mac.addr_bytes[ETHER_ADDR_LEN - 1] = pkts_cnt;
930 retval = generate_packets(&bonded_mac, &dst_mac, 1, &pkts[pkts_cnt]);
933 free_pkts(pkts, pkts_cnt);
935 TEST_ASSERT_EQUAL(retval, 1, "Failed to generate packet %u", pkts_cnt);
937 exp_pkts_cnt = pkts_cnt;
939 /* Transmit packets on bonded device */
940 retval = bond_tx(pkts, pkts_cnt);
941 if (retval > 0 && retval < pkts_cnt)
942 free_pkts(&pkts[retval], pkts_cnt - retval);
944 TEST_ASSERT_EQUAL(retval, pkts_cnt, "TX on bonded device failed");
946 /* Check if packets were transmitted properly. Every slave should have
947 * at least one packet, and sum must match. Under normal operation
948 * there should be no LACP nor MARKER frames. */
950 FOR_EACH_SLAVE(i, slave) {
951 uint16_t normal_cnt, slow_cnt;
953 retval = slave_get_pkts(slave, pkts, RTE_DIM(pkts));
957 for (j = 0; j < retval; j++) {
958 if (make_lacp_reply(slave, pkts[j]) == 1)
964 free_pkts(pkts, normal_cnt + slow_cnt);
965 TEST_ASSERT_EQUAL(slow_cnt, 0,
966 "slave %u unexpectedly transmitted %d SLOW packets", slave->port_id,
969 TEST_ASSERT_NOT_EQUAL(normal_cnt, 0,
970 "slave %u did not transmitted any packets", slave->port_id);
972 pkts_cnt += normal_cnt;
975 TEST_ASSERT_EQUAL(exp_pkts_cnt, pkts_cnt,
976 "Expected %u packets but transmitted only %d", exp_pkts_cnt, pkts_cnt);
979 * simulate link down for first slave. */
980 delay = bond_get_update_timeout_ms();
982 uint8_t slave_down_id = INVALID_PORT_ID;
984 FOR_EACH_SLAVE(i, slave) {
985 rte_eth_dev_set_link_down(slave->port_id);
986 slave_down_id = slave->port_id;
990 RTE_VERIFY(slave_down_id != INVALID_PORT_ID);
992 /* Give some time to rearrange bonding. */
993 for (i = 0; i < 3; i++) {
998 TEST_ASSERT_SUCCESS(bond_handshake(), "Handshake after link down failed");
1000 /* Prepare burst. */
1001 for (pkts_cnt = 0; pkts_cnt < RTE_DIM(pkts); pkts_cnt++) {
1002 dst_mac.addr_bytes[ETHER_ADDR_LEN - 1] = pkts_cnt;
1003 retval = generate_packets(&bonded_mac, &dst_mac, 1, &pkts[pkts_cnt]);
1006 free_pkts(pkts, pkts_cnt);
1008 TEST_ASSERT_EQUAL(retval, 1, "Failed to generate test packet %u",
1011 exp_pkts_cnt = pkts_cnt;
1013 /* Transmit packets on bonded device. */
1014 retval = bond_tx(pkts, pkts_cnt);
1015 if (retval > 0 && retval < pkts_cnt)
1016 free_pkts(&pkts[retval], pkts_cnt - retval);
1018 TEST_ASSERT_EQUAL(retval, pkts_cnt, "TX on bonded device failed");
1020 /* Check if packets was transmitted properly. Every slave should have
1021 * at least one packet, and sum must match. Under normal operation
1022 * there should be no LACP nor MARKER frames. */
1024 FOR_EACH_SLAVE(i, slave) {
1025 uint16_t normal_cnt, slow_cnt;
1027 retval = slave_get_pkts(slave, pkts, RTE_DIM(pkts));
1031 for (j = 0; j < retval; j++) {
1032 if (make_lacp_reply(slave, pkts[j]) == 1)
1038 free_pkts(pkts, normal_cnt + slow_cnt);
1040 if (slave_down_id == slave->port_id) {
1041 TEST_ASSERT_EQUAL(normal_cnt + slow_cnt, 0,
1042 "slave %u enexpectedly transmitted %u packets",
1043 normal_cnt + slow_cnt, slave->port_id);
1045 TEST_ASSERT_EQUAL(slow_cnt, 0,
1046 "slave %u unexpectedly transmitted %d SLOW packets",
1047 slave->port_id, slow_cnt);
1049 TEST_ASSERT_NOT_EQUAL(normal_cnt, 0,
1050 "slave %u did not transmitted any packets", slave->port_id);
1053 pkts_cnt += normal_cnt;
1056 TEST_ASSERT_EQUAL(exp_pkts_cnt, pkts_cnt,
1057 "Expected %u packets but transmitted only %d", exp_pkts_cnt, pkts_cnt);
1059 return remove_slaves_and_stop_bonded_device();
1063 init_marker(struct rte_mbuf *pkt, struct slave_conf *slave)
1065 struct marker_header *marker_hdr = rte_pktmbuf_mtod(pkt,
1066 struct marker_header *);
1068 /* Copy multicast destination address */
1069 ether_addr_copy(&slow_protocol_mac_addr, &marker_hdr->eth_hdr.d_addr);
1071 /* Init source address */
1072 ether_addr_copy(&parnter_mac_default, &marker_hdr->eth_hdr.s_addr);
1073 marker_hdr->eth_hdr.s_addr.addr_bytes[ETHER_ADDR_LEN-1] = slave->port_id;
1075 marker_hdr->eth_hdr.ether_type = rte_cpu_to_be_16(ETHER_TYPE_SLOW);
1077 marker_hdr->marker.subtype = SLOW_SUBTYPE_MARKER;
1078 marker_hdr->marker.version_number = 1;
1079 marker_hdr->marker.tlv_type_marker = MARKER_TLV_TYPE_INFO;
1080 marker_hdr->marker.info_length =
1081 offsetof(struct marker, reserved_90) -
1082 offsetof(struct marker, requester_port);
1083 RTE_VERIFY(marker_hdr->marker.info_length == 16);
1084 marker_hdr->marker.requester_port = slave->port_id + 1;
1085 marker_hdr->marker.tlv_type_terminator = TLV_TYPE_TERMINATOR_INFORMATION;
1086 marker_hdr->marker.terminator_length = 0;
1090 test_mode4_marker(void)
1092 struct slave_conf *slave;
1093 struct rte_mbuf *pkts[MAX_PKT_BURST];
1094 struct rte_mbuf *marker_pkt;
1095 struct marker_header *marker_hdr;
1101 const uint16_t ethtype_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);
1103 retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 1);
1104 TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");
1106 /* Test LACP handshake function */
1107 retval = bond_handshake();
1108 TEST_ASSERT_SUCCESS(retval, "Initial handshake failed");
1110 delay = bond_get_update_timeout_ms();
1111 FOR_EACH_SLAVE(i, slave) {
1112 marker_pkt = rte_pktmbuf_alloc(test_params.mbuf_pool);
1113 TEST_ASSERT_NOT_NULL(marker_pkt, "Failed to allocate marker packet");
1114 init_marker(marker_pkt, slave);
1116 retval = slave_put_pkts(slave, &marker_pkt, 1);
1118 rte_pktmbuf_free(marker_pkt);
1120 TEST_ASSERT_EQUAL(retval, 1,
1121 "Failed to send marker packet to slave %u", slave->port_id);
1123 for (j = 0; j < 20; ++j) {
1124 rte_delay_ms(delay);
1125 retval = rte_eth_rx_burst(test_params.bonded_port_id, 0, pkts,
1129 free_pkts(pkts, retval);
1131 TEST_ASSERT_EQUAL(retval, 0, "Received packets unexpectedly");
1133 retval = rte_eth_tx_burst(test_params.bonded_port_id, 0, NULL, 0);
1134 TEST_ASSERT_EQUAL(retval, 0,
1135 "Requested TX of 0 packets but %d transmitted", retval);
1137 /* Check if LACP packet was send by state machines
1138 First and only packet must be a maker response */
1139 retval = slave_get_pkts(slave, pkts, MAX_PKT_BURST);
1143 free_pkts(pkts, retval);
1145 TEST_ASSERT_EQUAL(retval, 1, "failed to get slave packets");
1148 marker_hdr = rte_pktmbuf_mtod(pkts[0], struct marker_header *);
1149 /* Check if it's slow packet*/
1150 if (marker_hdr->eth_hdr.ether_type != ethtype_slow_be)
1152 /* Check if it's marker packet */
1153 else if (marker_hdr->marker.subtype != SLOW_SUBTYPE_MARKER)
1155 else if (marker_hdr->marker.tlv_type_marker != MARKER_TLV_TYPE_RESP)
1158 free_pkts(pkts, nb_pkts);
1160 TEST_ASSERT_NOT_EQUAL(retval, -1, "Unexpected protocol type");
1161 TEST_ASSERT_NOT_EQUAL(retval, -2, "Unexpected sub protocol type");
1162 TEST_ASSERT_NOT_EQUAL(retval, -3, "Unexpected marker type");
1166 TEST_ASSERT(j < 20, "Marker response not found");
1169 retval = remove_slaves_and_stop_bonded_device();
1170 TEST_ASSERT_SUCCESS(retval, "Test cleanup failed.");
1172 return TEST_SUCCESS;
1176 test_mode4_expired(void)
1178 struct slave_conf *slave, *exp_slave = NULL;
1179 struct rte_mbuf *pkts[MAX_PKT_BURST];
1186 struct rte_eth_bond_8023ad_conf conf;
1188 retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 1);
1189 /* Set custom timeouts to make test last shorter. */
1190 rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
1191 conf.fast_periodic_ms = 100;
1192 conf.slow_periodic_ms = 600;
1193 conf.short_timeout_ms = 300;
1194 conf.long_timeout_ms = 900;
1195 conf.aggregate_wait_timeout_ms = 200;
1196 conf.tx_period_ms = 100;
1197 old_delay = conf.update_timeout_ms;
1198 conf.update_timeout_ms = 10;
1199 rte_eth_bond_8023ad_setup(test_params.bonded_port_id, &conf);
1201 /* Wait for new settings to be applied. */
1202 for (i = 0; i < old_delay/conf.update_timeout_ms * 2; i++) {
1203 FOR_EACH_SLAVE(j, slave)
1204 bond_handshake_reply(slave);
1206 rte_delay_ms(conf.update_timeout_ms);
1209 retval = bond_handshake();
1210 TEST_ASSERT_SUCCESS(retval, "Initial handshake failed");
1212 /* Find first slave */
1213 FOR_EACH_SLAVE(i, slave) {
1218 RTE_VERIFY(exp_slave != NULL);
1220 /* When one of partners do not send or respond to LACP frame in
1221 * conf.long_timeout_ms time, internal state machines should detect this
1222 * and transit to expired state. */
1223 for (j = 0; j < conf.long_timeout_ms/conf.update_timeout_ms + 2; j++) {
1224 rte_delay_ms(conf.update_timeout_ms);
1226 retval = bond_tx(NULL, 0);
1227 TEST_ASSERT_EQUAL(retval, 0, "Unexpectedly received %d packets",
1230 FOR_EACH_SLAVE(i, slave) {
1231 retval = bond_handshake_reply(slave);
1232 TEST_ASSERT(retval >= 0, "Handshake failed");
1234 /* Remove replay for slave that supose to be expired. */
1235 if (slave == exp_slave) {
1236 while (rte_ring_count(slave->rx_queue) > 0) {
1239 rte_ring_dequeue(slave->rx_queue, &pkt);
1240 rte_pktmbuf_free(pkt);
1245 retval = bond_rx(pkts, RTE_DIM(pkts));
1247 free_pkts(pkts, retval);
1249 TEST_ASSERT_EQUAL(retval, 0, "Unexpectedly received %d packets",
1253 /* After test only expected slave should be in EXPIRED state */
1254 FOR_EACH_SLAVE(i, slave) {
1255 if (slave == exp_slave)
1256 TEST_ASSERT(slave->lacp_parnter_state & STATE_EXPIRED,
1257 "Slave %u should be in expired.", slave->port_id);
1259 TEST_ASSERT_EQUAL(bond_handshake_done(slave), 1,
1260 "Slave %u should be operational.", slave->port_id);
1263 retval = remove_slaves_and_stop_bonded_device();
1264 TEST_ASSERT_SUCCESS(retval, "Test cleanup failed.");
1266 return TEST_SUCCESS;
1270 check_environment(void)
1272 struct slave_conf *port;
1273 uint8_t i, env_state;
1274 uint8_t slaves[RTE_DIM(test_params.slave_ports)];
1278 FOR_EACH_PORT(i, port) {
1279 if (rte_ring_count(port->rx_queue) != 0)
1282 if (rte_ring_count(port->tx_queue) != 0)
1285 if (port->bonded != 0)
1288 if (port->lacp_parnter_state != 0)
1295 slaves_count = rte_eth_bond_slaves_get(test_params.bonded_port_id,
1296 slaves, RTE_DIM(slaves));
1298 if (slaves_count != 0)
1301 TEST_ASSERT_EQUAL(env_state, 0,
1302 "Environment not clean (port %u):%s%s%s%s%s",
1304 env_state & 0x01 ? " slave rx queue not clean" : "",
1305 env_state & 0x02 ? " slave tx queue not clean" : "",
1306 env_state & 0x04 ? " port marked as enslaved" : "",
1307 env_state & 0x80 ? " slave state is not reset" : "",
1308 env_state & 0x10 ? " slave count not equal 0" : ".");
1311 return TEST_SUCCESS;
1315 test_mode4_executor(int (*test_func)(void))
1317 struct slave_conf *port;
1322 /* Check if environment is clean. Fail to launch a test if there was
1323 * a critical error before that prevented to reset environment. */
1324 TEST_ASSERT_SUCCESS(check_environment(),
1325 "Refusing to launch test in dirty environment.");
1327 RTE_VERIFY(test_func != NULL);
1328 test_result = (*test_func)();
1330 /* If test succeed check if environment wast left in good condition. */
1331 if (test_result == TEST_SUCCESS)
1332 test_result = check_environment();
1334 /* Reset environment in case test failed to do that. */
1335 if (test_result != TEST_SUCCESS) {
1336 TEST_ASSERT_SUCCESS(remove_slaves_and_stop_bonded_device(),
1337 "Failed to stop bonded device");
1339 FOR_EACH_PORT(i, port) {
1340 while (rte_ring_count(port->rx_queue) != 0) {
1341 if (rte_ring_dequeue(port->rx_queue, &pkt) == 0)
1342 rte_pktmbuf_free(pkt);
1345 while (rte_ring_count(port->tx_queue) != 0) {
1346 if (rte_ring_dequeue(port->tx_queue, &pkt) == 0)
1347 rte_pktmbuf_free(pkt);
1356 test_mode4_lacp_wrapper(void)
1358 return test_mode4_executor(&test_mode4_lacp);
1362 test_mode4_marker_wrapper(void)
1364 return test_mode4_executor(&test_mode4_marker);
1368 test_mode4_rx_wrapper(void)
1370 return test_mode4_executor(&test_mode4_rx);
1374 test_mode4_tx_burst_wrapper(void)
1376 return test_mode4_executor(&test_mode4_tx_burst);
1380 test_mode4_expired_wrapper(void)
1382 return test_mode4_executor(&test_mode4_expired);
1385 static struct unit_test_suite link_bonding_mode4_test_suite = {
1386 .suite_name = "Link Bonding mode 4 Unit Test Suite",
1387 .setup = test_setup,
1388 .teardown = testsuite_teardown,
1389 .unit_test_cases = {
1390 TEST_CASE_NAMED("test_mode4_lacp", test_mode4_lacp_wrapper),
1391 TEST_CASE_NAMED("test_mode4_rx", test_mode4_rx_wrapper),
1392 TEST_CASE_NAMED("test_mode4_tx_burst", test_mode4_tx_burst_wrapper),
1393 TEST_CASE_NAMED("test_mode4_marker", test_mode4_marker_wrapper),
1394 TEST_CASE_NAMED("test_mode4_expired", test_mode4_expired_wrapper),
1395 { NULL, NULL, NULL, NULL, NULL } /**< NULL terminate unit test array */
1400 test_link_bonding_mode4(void)
1402 return unit_test_suite_runner(&link_bonding_mode4_test_suite);
1405 static struct test_command link_bonding_cmd = {
1406 .command = "link_bonding_mode4_autotest",
1407 .callback = test_link_bonding_mode4,
1410 REGISTER_TEST_COMMAND(link_bonding_cmd);