Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2014 Intel Corporation
3 : : */
4 : :
5 : : #include <unistd.h>
6 : : #include <string.h>
7 : : #include <stdarg.h>
8 : : #include <stdio.h>
9 : : #include <stdlib.h>
10 : : #include <stdint.h>
11 : : #include <inttypes.h>
12 : : #include <errno.h>
13 : : #include <pthread.h>
14 : : #include <sys/queue.h>
15 : : #include <sys/time.h>
16 : :
17 : : #include <rte_cycles.h>
18 : : #include <rte_byteorder.h>
19 : : #include <rte_common.h>
20 : : #include <rte_debug.h>
21 : : #include <rte_ethdev.h>
22 : : #include <ethdev_driver.h>
23 : : #include <rte_log.h>
24 : : #include <rte_lcore.h>
25 : : #include <rte_memory.h>
26 : : #include <rte_string_fns.h>
27 : : #include <rte_eth_bond.h>
28 : :
29 : : #include "virtual_pmd.h"
30 : : #include "packet_burst_generator.h"
31 : :
32 : : #include "test.h"
33 : :
34 : : #define TEST_MAX_NUMBER_OF_PORTS (6)
35 : :
36 : : #define RX_RING_SIZE 1024
37 : : #define RX_FREE_THRESH 32
38 : : #define RX_PTHRESH 8
39 : : #define RX_HTHRESH 8
40 : : #define RX_WTHRESH 0
41 : :
42 : : #define TX_RING_SIZE 1024
43 : : #define TX_FREE_THRESH 32
44 : : #define TX_PTHRESH 32
45 : : #define TX_HTHRESH 0
46 : : #define TX_WTHRESH 0
47 : : #define TX_RSBIT_THRESH 32
48 : :
49 : : #define MBUF_CACHE_SIZE (250)
50 : : #define BURST_SIZE (32)
51 : :
52 : : #define RX_DESC_MAX (2048)
53 : : #define TX_DESC_MAX (2048)
54 : : #define MAX_PKT_BURST (512)
55 : : #define DEF_PKT_BURST (16)
56 : :
57 : : #define BONDING_DEV_NAME ("net_bonding_ut")
58 : :
59 : : #define INVALID_SOCKET_ID (-1)
60 : : #define INVALID_PORT_ID (-1)
61 : : #define INVALID_BONDING_MODE (-1)
62 : :
63 : :
64 : : uint8_t member_mac[] = {0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 };
65 : : uint8_t bonding_mac[] = {0xAA, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF };
66 : :
67 : : struct link_bonding_unittest_params {
68 : : int16_t bonding_port_id;
69 : : int16_t member_port_ids[TEST_MAX_NUMBER_OF_PORTS];
70 : : uint16_t bonding_member_count;
71 : : uint8_t bonding_mode;
72 : :
73 : : uint16_t nb_rx_q;
74 : : uint16_t nb_tx_q;
75 : :
76 : : struct rte_mempool *mbuf_pool;
77 : :
78 : : struct rte_ether_addr *default_member_mac;
79 : : struct rte_ether_addr *default_bonding_mac;
80 : :
81 : : /* Packet Headers */
82 : : struct rte_ether_hdr *pkt_eth_hdr;
83 : : struct rte_ipv4_hdr *pkt_ipv4_hdr;
84 : : struct rte_ipv6_hdr *pkt_ipv6_hdr;
85 : : struct rte_udp_hdr *pkt_udp_hdr;
86 : :
87 : : };
88 : :
89 : : static struct rte_ipv4_hdr pkt_ipv4_hdr;
90 : : static struct rte_ipv6_hdr pkt_ipv6_hdr;
91 : : static struct rte_udp_hdr pkt_udp_hdr;
92 : :
93 : : static struct link_bonding_unittest_params default_params = {
94 : : .bonding_port_id = -1,
95 : : .member_port_ids = { -1 },
96 : : .bonding_member_count = 0,
97 : : .bonding_mode = BONDING_MODE_ROUND_ROBIN,
98 : :
99 : : .nb_rx_q = 1,
100 : : .nb_tx_q = 1,
101 : :
102 : : .mbuf_pool = NULL,
103 : :
104 : : .default_member_mac = (struct rte_ether_addr *)member_mac,
105 : : .default_bonding_mac = (struct rte_ether_addr *)bonding_mac,
106 : :
107 : : .pkt_eth_hdr = NULL,
108 : : .pkt_ipv4_hdr = &pkt_ipv4_hdr,
109 : : .pkt_ipv6_hdr = &pkt_ipv6_hdr,
110 : : .pkt_udp_hdr = &pkt_udp_hdr
111 : :
112 : : };
113 : :
114 : : static struct link_bonding_unittest_params *test_params = &default_params;
115 : :
116 : : static uint8_t src_mac[] = { 0xFF, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA };
117 : : static uint8_t dst_mac_0[] = { 0xFF, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA };
118 : : static uint8_t dst_mac_1[] = { 0xFF, 0xAA, 0xFF, 0xAA, 0xFF, 0xAB };
119 : :
120 : : static uint32_t src_addr = IPV4_ADDR(192, 168, 1, 98);
121 : : static uint32_t dst_addr_0 = IPV4_ADDR(192, 168, 1, 98);
122 : : static uint32_t dst_addr_1 = IPV4_ADDR(193, 166, 10, 97);
123 : :
124 : : static uint8_t src_ipv6_addr[] = { 0xFF, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF,
125 : : 0xAA, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA , 0xFF, 0xAA };
126 : : static uint8_t dst_ipv6_addr_0[] = { 0xFF, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF,
127 : : 0xAA, 0xFF, 0xAA, 0xFF, 0xAA , 0xFF, 0xAA, 0xFF, 0xAA };
128 : : static uint8_t dst_ipv6_addr_1[] = { 0xFF, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF,
129 : : 0xAA, 0xFF, 0xAA, 0xFF, 0xAA , 0xFF, 0xAA , 0xFF, 0xAB };
130 : :
131 : : static uint16_t src_port = 1024;
132 : : static uint16_t dst_port_0 = 1024;
133 : : static uint16_t dst_port_1 = 2024;
134 : :
135 : : static uint16_t vlan_id = 0x100;
136 : :
137 : : static struct rte_eth_conf default_pmd_conf = {
138 : : .rxmode = {
139 : : .mq_mode = RTE_ETH_MQ_RX_NONE,
140 : : },
141 : : .txmode = {
142 : : .mq_mode = RTE_ETH_MQ_TX_NONE,
143 : : },
144 : : .lpbk_mode = 0,
145 : : };
146 : :
147 : : static const struct rte_eth_rxconf rx_conf_default = {
148 : : .rx_thresh = {
149 : : .pthresh = RX_PTHRESH,
150 : : .hthresh = RX_HTHRESH,
151 : : .wthresh = RX_WTHRESH,
152 : : },
153 : : .rx_free_thresh = RX_FREE_THRESH,
154 : : .rx_drop_en = 0,
155 : : };
156 : :
157 : : static struct rte_eth_txconf tx_conf_default = {
158 : : .tx_thresh = {
159 : : .pthresh = TX_PTHRESH,
160 : : .hthresh = TX_HTHRESH,
161 : : .wthresh = TX_WTHRESH,
162 : : },
163 : : .tx_free_thresh = TX_FREE_THRESH,
164 : : .tx_rs_thresh = TX_RSBIT_THRESH,
165 : : };
166 : :
167 : : static void free_virtualpmd_tx_queue(void);
168 : :
169 : :
170 : :
171 : : static int
172 : 0 : configure_ethdev(uint16_t port_id, uint8_t start, uint8_t en_isr)
173 : : {
174 : : int q_id;
175 : :
176 [ # # ]: 0 : if (en_isr)
177 : 0 : default_pmd_conf.intr_conf.lsc = 1;
178 : : else
179 : 0 : default_pmd_conf.intr_conf.lsc = 0;
180 : :
181 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_configure(port_id, test_params->nb_rx_q,
182 : : test_params->nb_tx_q, &default_pmd_conf),
183 : : "rte_eth_dev_configure for port %d failed", port_id);
184 : :
185 : 0 : int ret = rte_eth_dev_set_mtu(port_id, 1550);
186 [ # # ]: 0 : RTE_TEST_ASSERT(ret == 0 || ret == -ENOTSUP,
187 : : "rte_eth_dev_set_mtu for port %d failed", port_id);
188 : :
189 [ # # ]: 0 : for (q_id = 0; q_id < test_params->nb_rx_q; q_id++)
190 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
191 : : rte_eth_dev_socket_id(port_id), &rx_conf_default,
192 : : test_params->mbuf_pool) ,
193 : : "rte_eth_rx_queue_setup for port %d failed", port_id);
194 : :
195 [ # # ]: 0 : for (q_id = 0; q_id < test_params->nb_tx_q; q_id++)
196 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
197 : : rte_eth_dev_socket_id(port_id), &tx_conf_default),
198 : : "rte_eth_tx_queue_setup for port %d failed", port_id);
199 : :
200 [ # # ]: 0 : if (start)
201 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(port_id),
202 : : "rte_eth_dev_start for port %d failed", port_id);
203 : :
204 : : return 0;
205 : : }
206 : :
207 : : static int members_initialized;
208 : : static int mac_members_initialized;
209 : :
210 : : static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
211 : : static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
212 : :
213 : :
214 : : static int
215 : 0 : test_setup(void)
216 : : {
217 : : int i, nb_mbuf_per_pool;
218 : : struct rte_ether_addr *mac_addr = (struct rte_ether_addr *)member_mac;
219 : :
220 : : /* Allocate ethernet packet header with space for VLAN header */
221 [ # # ]: 0 : if (test_params->pkt_eth_hdr == NULL) {
222 : 0 : test_params->pkt_eth_hdr = malloc(sizeof(struct rte_ether_hdr) +
223 : : sizeof(struct rte_vlan_hdr));
224 : :
225 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(test_params->pkt_eth_hdr,
226 : : "Ethernet header struct allocation failed!");
227 : : }
228 : :
229 : : nb_mbuf_per_pool = RX_DESC_MAX + DEF_PKT_BURST +
230 : : TX_DESC_MAX + MAX_PKT_BURST;
231 [ # # ]: 0 : if (test_params->mbuf_pool == NULL) {
232 : 0 : test_params->mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL",
233 : : nb_mbuf_per_pool, MBUF_CACHE_SIZE, 0,
234 : 0 : RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
235 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(test_params->mbuf_pool,
236 : : "rte_mempool_create failed");
237 : : }
238 : :
239 : : /* Create / Initialize virtual eth devs */
240 [ # # ]: 0 : if (!members_initialized) {
241 [ # # ]: 0 : for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++) {
242 : : char pmd_name[RTE_ETH_NAME_MAX_LEN];
243 : :
244 : 0 : mac_addr->addr_bytes[RTE_ETHER_ADDR_LEN-1] = i;
245 : :
246 : : snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_%d", i);
247 : :
248 : 0 : test_params->member_port_ids[i] = virtual_ethdev_create(pmd_name,
249 : 0 : mac_addr, rte_socket_id(), 1);
250 [ # # ]: 0 : TEST_ASSERT(test_params->member_port_ids[i] >= 0,
251 : : "Failed to create virtual virtual ethdev %s", pmd_name);
252 : :
253 [ # # ]: 0 : TEST_ASSERT_SUCCESS(configure_ethdev(
254 : : test_params->member_port_ids[i], 1, 0),
255 : : "Failed to configure virtual ethdev %s", pmd_name);
256 : : }
257 : 0 : members_initialized = 1;
258 : : }
259 : :
260 : : return 0;
261 : : }
262 : :
263 : : static int
264 : 0 : test_create_bonding_device(void)
265 : : {
266 : : int current_member_count;
267 : :
268 : : uint16_t members[RTE_MAX_ETHPORTS];
269 : :
270 : : /* Don't try to recreate bonding device if re-running test suite*/
271 [ # # ]: 0 : if (test_params->bonding_port_id == -1) {
272 : 0 : test_params->bonding_port_id = rte_eth_bond_create(BONDING_DEV_NAME,
273 : 0 : test_params->bonding_mode, rte_socket_id());
274 : :
275 [ # # ]: 0 : TEST_ASSERT(test_params->bonding_port_id >= 0,
276 : : "Failed to create bonding ethdev %s", BONDING_DEV_NAME);
277 : :
278 [ # # ]: 0 : TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonding_port_id, 0, 0),
279 : : "Failed to configure bonding ethdev %s", BONDING_DEV_NAME);
280 : : }
281 : :
282 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonding_port_id,
283 : : test_params->bonding_mode), "Failed to set ethdev %d to mode %d",
284 : : test_params->bonding_port_id, test_params->bonding_mode);
285 : :
286 : 0 : current_member_count = rte_eth_bond_members_get(test_params->bonding_port_id,
287 : : members, RTE_MAX_ETHPORTS);
288 : :
289 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_member_count, 0,
290 : : "Number of members %d is great than expected %d.",
291 : : current_member_count, 0);
292 : :
293 : 0 : current_member_count = rte_eth_bond_active_members_get(
294 : 0 : test_params->bonding_port_id, members, RTE_MAX_ETHPORTS);
295 : :
296 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_member_count, 0,
297 : : "Number of active members %d is great than expected %d.",
298 : : current_member_count, 0);
299 : :
300 : : return 0;
301 : : }
302 : :
303 : :
304 : : static int
305 : 0 : test_create_bonding_device_with_invalid_params(void)
306 : : {
307 : : int port_id;
308 : :
309 : 0 : test_params->bonding_mode = BONDING_MODE_ROUND_ROBIN;
310 : :
311 : : /* Invalid name */
312 : 0 : port_id = rte_eth_bond_create(NULL, test_params->bonding_mode,
313 : 0 : rte_socket_id());
314 [ # # ]: 0 : TEST_ASSERT(port_id < 0, "Created bonding device unexpectedly");
315 : :
316 : 0 : test_params->bonding_mode = INVALID_BONDING_MODE;
317 : :
318 : : /* Invalid bonding mode */
319 : 0 : port_id = rte_eth_bond_create(BONDING_DEV_NAME, test_params->bonding_mode,
320 : 0 : rte_socket_id());
321 [ # # ]: 0 : TEST_ASSERT(port_id < 0, "Created bonding device unexpectedly.");
322 : :
323 : 0 : test_params->bonding_mode = BONDING_MODE_ROUND_ROBIN;
324 : :
325 : : /* Invalid socket id */
326 : 0 : port_id = rte_eth_bond_create(BONDING_DEV_NAME, test_params->bonding_mode,
327 : : INVALID_SOCKET_ID);
328 [ # # ]: 0 : TEST_ASSERT(port_id < 0, "Created bonding device unexpectedly.");
329 : :
330 : : return 0;
331 : : }
332 : :
333 : : static int
334 : 0 : test_add_member_to_bonding_device(void)
335 : : {
336 : : int current_member_count;
337 : :
338 : : uint16_t members[RTE_MAX_ETHPORTS];
339 : :
340 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_member_add(test_params->bonding_port_id,
341 : : test_params->member_port_ids[test_params->bonding_member_count]),
342 : : "Failed to add member (%d) to bonding port (%d).",
343 : : test_params->member_port_ids[test_params->bonding_member_count],
344 : : test_params->bonding_port_id);
345 : :
346 : 0 : current_member_count = rte_eth_bond_members_get(test_params->bonding_port_id,
347 : : members, RTE_MAX_ETHPORTS);
348 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_member_count, test_params->bonding_member_count + 1,
349 : : "Number of members (%d) is greater than expected (%d).",
350 : : current_member_count, test_params->bonding_member_count + 1);
351 : :
352 : 0 : current_member_count = rte_eth_bond_active_members_get(
353 : 0 : test_params->bonding_port_id, members, RTE_MAX_ETHPORTS);
354 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_member_count, 0,
355 : : "Number of active members (%d) is not as expected (%d).\n",
356 : : current_member_count, 0);
357 : :
358 : 0 : test_params->bonding_member_count++;
359 : :
360 : 0 : return 0;
361 : : }
362 : :
363 : : static int
364 : 0 : test_add_member_to_invalid_bonding_device(void)
365 : : {
366 : : /* Invalid port ID */
367 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_member_add(test_params->bonding_port_id + 5,
368 : : test_params->member_port_ids[test_params->bonding_member_count]),
369 : : "Expected call to failed as invalid port specified.");
370 : :
371 : : /* Non bonding device */
372 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_member_add(test_params->member_port_ids[0],
373 : : test_params->member_port_ids[test_params->bonding_member_count]),
374 : : "Expected call to failed as invalid port specified.");
375 : :
376 : : return 0;
377 : : }
378 : :
379 : :
380 : : static int
381 : 0 : test_remove_member_from_bonding_device(void)
382 : : {
383 : : int current_member_count;
384 : : struct rte_ether_addr read_mac_addr, *mac_addr;
385 : : uint16_t members[RTE_MAX_ETHPORTS];
386 : :
387 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_member_remove(test_params->bonding_port_id,
388 : : test_params->member_port_ids[test_params->bonding_member_count-1]),
389 : : "Failed to remove member %d from bonding port (%d).",
390 : : test_params->member_port_ids[test_params->bonding_member_count-1],
391 : : test_params->bonding_port_id);
392 : :
393 : :
394 : 0 : current_member_count = rte_eth_bond_members_get(test_params->bonding_port_id,
395 : : members, RTE_MAX_ETHPORTS);
396 : :
397 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_member_count, test_params->bonding_member_count - 1,
398 : : "Number of members (%d) is great than expected (%d).\n",
399 : : current_member_count, test_params->bonding_member_count - 1);
400 : :
401 : :
402 : : mac_addr = (struct rte_ether_addr *)member_mac;
403 : 0 : mac_addr->addr_bytes[RTE_ETHER_ADDR_LEN-1] =
404 : 0 : test_params->bonding_member_count-1;
405 : :
406 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(
407 : : test_params->member_port_ids[test_params->bonding_member_count-1],
408 : : &read_mac_addr),
409 : : "Failed to get mac address (port %d)",
410 : : test_params->member_port_ids[test_params->bonding_member_count-1]);
411 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(mac_addr, &read_mac_addr, sizeof(read_mac_addr)),
412 : : "bonding port mac address not set to that of primary port\n");
413 : :
414 : 0 : rte_eth_stats_reset(
415 : 0 : test_params->member_port_ids[test_params->bonding_member_count-1]);
416 : :
417 : 0 : virtual_ethdev_simulate_link_status_interrupt(test_params->bonding_port_id,
418 : : 0);
419 : :
420 : 0 : test_params->bonding_member_count--;
421 : :
422 : 0 : return 0;
423 : : }
424 : :
425 : : static int
426 : 0 : test_remove_member_from_invalid_bonding_device(void)
427 : : {
428 : : /* Invalid port ID */
429 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_member_remove(
430 : : test_params->bonding_port_id + 5,
431 : : test_params->member_port_ids[test_params->bonding_member_count - 1]),
432 : : "Expected call to failed as invalid port specified.");
433 : :
434 : : /* Non bonding device */
435 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_member_remove(
436 : : test_params->member_port_ids[0],
437 : : test_params->member_port_ids[test_params->bonding_member_count - 1]),
438 : : "Expected call to failed as invalid port specified.");
439 : :
440 : : return 0;
441 : : }
442 : :
443 : : static int bonding_id = 2;
444 : :
445 : : static int
446 : 0 : test_add_already_bonding_member_to_bonding_device(void)
447 : : {
448 : : int port_id, current_member_count;
449 : : uint16_t members[RTE_MAX_ETHPORTS];
450 : : char pmd_name[RTE_ETH_NAME_MAX_LEN];
451 : :
452 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_add_member_to_bonding_device(),
453 : : "Failed to add member to bonding device");
454 : :
455 : 0 : current_member_count = rte_eth_bond_members_get(test_params->bonding_port_id,
456 : : members, RTE_MAX_ETHPORTS);
457 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_member_count, 1,
458 : : "Number of members (%d) is not that expected (%d).",
459 : : current_member_count, 1);
460 : :
461 : 0 : snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "%s_%d", BONDING_DEV_NAME, ++bonding_id);
462 : :
463 : 0 : port_id = rte_eth_bond_create(pmd_name, test_params->bonding_mode,
464 : 0 : rte_socket_id());
465 [ # # ]: 0 : TEST_ASSERT(port_id >= 0, "Failed to create bonding device.");
466 : :
467 [ # # ]: 0 : TEST_ASSERT(rte_eth_bond_member_add(port_id,
468 : : test_params->member_port_ids[test_params->bonding_member_count - 1])
469 : : < 0,
470 : : "Added member (%d) to bonding port (%d) unexpectedly.",
471 : : test_params->member_port_ids[test_params->bonding_member_count-1],
472 : : port_id);
473 : :
474 : 0 : return test_remove_member_from_bonding_device();
475 : : }
476 : :
477 : :
478 : : static int
479 : 0 : test_get_members_from_bonding_device(void)
480 : : {
481 : : int current_member_count;
482 : : uint16_t members[RTE_MAX_ETHPORTS];
483 : :
484 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_add_member_to_bonding_device(),
485 : : "Failed to add member to bonding device");
486 : :
487 : : /* Invalid port id */
488 : 0 : current_member_count = rte_eth_bond_members_get(INVALID_PORT_ID, members,
489 : : RTE_MAX_ETHPORTS);
490 [ # # ]: 0 : TEST_ASSERT(current_member_count < 0,
491 : : "Invalid port id unexpectedly succeeded");
492 : :
493 : 0 : current_member_count = rte_eth_bond_active_members_get(INVALID_PORT_ID,
494 : : members, RTE_MAX_ETHPORTS);
495 [ # # ]: 0 : TEST_ASSERT(current_member_count < 0,
496 : : "Invalid port id unexpectedly succeeded");
497 : :
498 : : /* Invalid members pointer */
499 : 0 : current_member_count = rte_eth_bond_members_get(test_params->bonding_port_id,
500 : : NULL, RTE_MAX_ETHPORTS);
501 [ # # ]: 0 : TEST_ASSERT(current_member_count < 0,
502 : : "Invalid member array unexpectedly succeeded");
503 : :
504 : 0 : current_member_count = rte_eth_bond_active_members_get(
505 : 0 : test_params->bonding_port_id, NULL, RTE_MAX_ETHPORTS);
506 [ # # ]: 0 : TEST_ASSERT(current_member_count < 0,
507 : : "Invalid member array unexpectedly succeeded");
508 : :
509 : : /* non bonding device*/
510 : 0 : current_member_count = rte_eth_bond_members_get(
511 : 0 : test_params->member_port_ids[0], NULL, RTE_MAX_ETHPORTS);
512 [ # # ]: 0 : TEST_ASSERT(current_member_count < 0,
513 : : "Invalid port id unexpectedly succeeded");
514 : :
515 : 0 : current_member_count = rte_eth_bond_active_members_get(
516 : 0 : test_params->member_port_ids[0], NULL, RTE_MAX_ETHPORTS);
517 [ # # ]: 0 : TEST_ASSERT(current_member_count < 0,
518 : : "Invalid port id unexpectedly succeeded");
519 : :
520 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_remove_member_from_bonding_device(),
521 : : "Failed to remove members from bonding device");
522 : :
523 : : return 0;
524 : : }
525 : :
526 : :
527 : : static int
528 : 0 : test_add_remove_multiple_members_to_from_bonding_device(void)
529 : : {
530 : : int i;
531 : :
532 [ # # ]: 0 : for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++)
533 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_add_member_to_bonding_device(),
534 : : "Failed to add member to bonding device");
535 : :
536 [ # # ]: 0 : for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++)
537 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_remove_member_from_bonding_device(),
538 : : "Failed to remove members from bonding device");
539 : :
540 : : return 0;
541 : : }
542 : :
543 : : static void
544 : 0 : enable_bonding_members(void)
545 : : {
546 : : int i;
547 : :
548 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
549 : 0 : virtual_ethdev_tx_burst_fn_set_success(test_params->member_port_ids[i],
550 : : 1);
551 : :
552 : 0 : virtual_ethdev_simulate_link_status_interrupt(
553 : 0 : test_params->member_port_ids[i], 1);
554 : : }
555 : 0 : }
556 : :
557 : : static int
558 : 0 : test_start_bonding_device(void)
559 : : {
560 : : struct rte_eth_link link_status;
561 : :
562 : : int current_member_count, current_bonding_mode, primary_port;
563 : : uint16_t members[RTE_MAX_ETHPORTS];
564 : : int retval;
565 : :
566 : : /* Add member to bonding device*/
567 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_add_member_to_bonding_device(),
568 : : "Failed to add member to bonding device");
569 : :
570 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonding_port_id),
571 : : "Failed to start bonding pmd eth device %d.",
572 : : test_params->bonding_port_id);
573 : :
574 : : /*
575 : : * Change link status of virtual pmd so it will be added to the active
576 : : * member list of the bonding device.
577 : : */
578 : 0 : virtual_ethdev_simulate_link_status_interrupt(
579 : 0 : test_params->member_port_ids[test_params->bonding_member_count-1], 1);
580 : :
581 : 0 : current_member_count = rte_eth_bond_members_get(test_params->bonding_port_id,
582 : : members, RTE_MAX_ETHPORTS);
583 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_member_count, test_params->bonding_member_count,
584 : : "Number of members (%d) is not expected value (%d).",
585 : : current_member_count, test_params->bonding_member_count);
586 : :
587 : 0 : current_member_count = rte_eth_bond_active_members_get(
588 : 0 : test_params->bonding_port_id, members, RTE_MAX_ETHPORTS);
589 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_member_count, test_params->bonding_member_count,
590 : : "Number of active members (%d) is not expected value (%d).",
591 : : current_member_count, test_params->bonding_member_count);
592 : :
593 : 0 : current_bonding_mode = rte_eth_bond_mode_get(test_params->bonding_port_id);
594 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_bonding_mode, test_params->bonding_mode,
595 : : "Bonding device mode (%d) is not expected value (%d).\n",
596 : : current_bonding_mode, test_params->bonding_mode);
597 : :
598 : 0 : primary_port = rte_eth_bond_primary_get(test_params->bonding_port_id);
599 [ # # ]: 0 : TEST_ASSERT_EQUAL(primary_port, test_params->member_port_ids[0],
600 : : "Primary port (%d) is not expected value (%d).",
601 : : primary_port, test_params->member_port_ids[0]);
602 : :
603 : 0 : retval = rte_eth_link_get(test_params->bonding_port_id, &link_status);
604 [ # # ]: 0 : TEST_ASSERT(retval >= 0,
605 : : "Bonding port (%d) link get failed: %s\n",
606 : : test_params->bonding_port_id, rte_strerror(-retval));
607 [ # # ]: 0 : TEST_ASSERT_EQUAL(link_status.link_status, 1,
608 : : "Bonding port (%d) status (%d) is not expected value (%d).\n",
609 : : test_params->bonding_port_id, link_status.link_status, 1);
610 : :
611 : : return 0;
612 : : }
613 : :
614 : : static int
615 : 0 : test_stop_bonding_device(void)
616 : : {
617 : : int current_member_count;
618 : : uint16_t members[RTE_MAX_ETHPORTS];
619 : :
620 : : struct rte_eth_link link_status;
621 : : int retval;
622 : :
623 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_stop(test_params->bonding_port_id),
624 : : "Failed to stop bonding port %u",
625 : : test_params->bonding_port_id);
626 : :
627 : 0 : retval = rte_eth_link_get(test_params->bonding_port_id, &link_status);
628 [ # # ]: 0 : TEST_ASSERT(retval >= 0,
629 : : "Bonding port (%d) link get failed: %s\n",
630 : : test_params->bonding_port_id, rte_strerror(-retval));
631 [ # # ]: 0 : TEST_ASSERT_EQUAL(link_status.link_status, 0,
632 : : "Bonding port (%d) status (%d) is not expected value (%d).",
633 : : test_params->bonding_port_id, link_status.link_status, 0);
634 : :
635 : 0 : current_member_count = rte_eth_bond_members_get(test_params->bonding_port_id,
636 : : members, RTE_MAX_ETHPORTS);
637 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_member_count, test_params->bonding_member_count,
638 : : "Number of members (%d) is not expected value (%d).",
639 : : current_member_count, test_params->bonding_member_count);
640 : :
641 : 0 : current_member_count = rte_eth_bond_active_members_get(
642 : 0 : test_params->bonding_port_id, members, RTE_MAX_ETHPORTS);
643 [ # # ]: 0 : TEST_ASSERT_EQUAL(current_member_count, 0,
644 : : "Number of active members (%d) is not expected value (%d).",
645 : : current_member_count, 0);
646 : :
647 : : return 0;
648 : : }
649 : :
650 : : static int
651 : 0 : remove_members_and_stop_bonding_device(void)
652 : : {
653 : : /* Clean up and remove members from bonding device */
654 : 0 : free_virtualpmd_tx_queue();
655 [ # # ]: 0 : while (test_params->bonding_member_count > 0)
656 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_remove_member_from_bonding_device(),
657 : : "test_remove_member_from_bonding_device failed");
658 : :
659 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_stop(test_params->bonding_port_id),
660 : : "Failed to stop bonding port %u",
661 : : test_params->bonding_port_id);
662 : :
663 : 0 : rte_eth_stats_reset(test_params->bonding_port_id);
664 : 0 : rte_eth_bond_mac_address_reset(test_params->bonding_port_id);
665 : :
666 : 0 : return 0;
667 : : }
668 : :
669 : : static int
670 : 0 : test_set_bonding_mode(void)
671 : : {
672 : : int i, bonding_mode;
673 : :
674 : 0 : int bonding_modes[] = { BONDING_MODE_ROUND_ROBIN,
675 : : BONDING_MODE_ACTIVE_BACKUP,
676 : : BONDING_MODE_BALANCE,
677 : : BONDING_MODE_BROADCAST
678 : : };
679 : :
680 : : /* Test supported link bonding modes */
681 [ # # ]: 0 : for (i = 0; i < (int)RTE_DIM(bonding_modes); i++) {
682 : : /* Invalid port ID */
683 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_mode_set(INVALID_PORT_ID,
684 : : bonding_modes[i]),
685 : : "Expected call to failed as invalid port (%d) specified.",
686 : : INVALID_PORT_ID);
687 : :
688 : : /* Non bonding device */
689 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_mode_set(test_params->member_port_ids[0],
690 : : bonding_modes[i]),
691 : : "Expected call to failed as invalid port (%d) specified.",
692 : : test_params->member_port_ids[0]);
693 : :
694 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonding_port_id,
695 : : bonding_modes[i]),
696 : : "Failed to set link bonding mode on port (%d) to (%d).",
697 : : test_params->bonding_port_id, bonding_modes[i]);
698 : :
699 : 0 : bonding_mode = rte_eth_bond_mode_get(test_params->bonding_port_id);
700 [ # # ]: 0 : TEST_ASSERT_EQUAL(bonding_mode, bonding_modes[i],
701 : : "Link bonding mode (%d) of port (%d) is not expected value (%d).",
702 : : bonding_mode, test_params->bonding_port_id,
703 : : bonding_modes[i]);
704 : :
705 : : /* Invalid port ID */
706 : 0 : bonding_mode = rte_eth_bond_mode_get(INVALID_PORT_ID);
707 [ # # ]: 0 : TEST_ASSERT(bonding_mode < 0,
708 : : "Expected call to failed as invalid port (%d) specified.",
709 : : INVALID_PORT_ID);
710 : :
711 : : /* Non bonding device */
712 : 0 : bonding_mode = rte_eth_bond_mode_get(test_params->member_port_ids[0]);
713 [ # # ]: 0 : TEST_ASSERT(bonding_mode < 0,
714 : : "Expected call to failed as invalid port (%d) specified.",
715 : : test_params->member_port_ids[0]);
716 : : }
717 : :
718 : 0 : return remove_members_and_stop_bonding_device();
719 : : }
720 : :
721 : : static int
722 : 0 : test_set_primary_member(void)
723 : : {
724 : : int i, j, retval;
725 : : struct rte_ether_addr read_mac_addr;
726 : : struct rte_ether_addr *expected_mac_addr;
727 : :
728 : : /* Add 4 members to bonding device */
729 [ # # ]: 0 : for (i = test_params->bonding_member_count; i < 4; i++)
730 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_add_member_to_bonding_device(),
731 : : "Failed to add member to bonding device.");
732 : :
733 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonding_port_id,
734 : : BONDING_MODE_ROUND_ROBIN),
735 : : "Failed to set link bonding mode on port (%d) to (%d).",
736 : : test_params->bonding_port_id, BONDING_MODE_ROUND_ROBIN);
737 : :
738 : : /* Invalid port ID */
739 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_primary_set(INVALID_PORT_ID,
740 : : test_params->member_port_ids[i]),
741 : : "Expected call to failed as invalid port specified.");
742 : :
743 : : /* Non bonding device */
744 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_primary_set(test_params->member_port_ids[i],
745 : : test_params->member_port_ids[i]),
746 : : "Expected call to failed as invalid port specified.");
747 : :
748 : : /* Set member as primary
749 : : * Verify member it is now primary member
750 : : * Verify that MAC address of bonding device is that of primary member
751 : : * Verify that MAC address of all bonding members are that of primary member
752 : : */
753 [ # # ]: 0 : for (i = 0; i < 4; i++) {
754 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(test_params->bonding_port_id,
755 : : test_params->member_port_ids[i]),
756 : : "Failed to set bonding port (%d) primary port to (%d)",
757 : : test_params->bonding_port_id, test_params->member_port_ids[i]);
758 : :
759 : 0 : retval = rte_eth_bond_primary_get(test_params->bonding_port_id);
760 [ # # ]: 0 : TEST_ASSERT(retval >= 0,
761 : : "Failed to read primary port from bonding port (%d)\n",
762 : : test_params->bonding_port_id);
763 : :
764 [ # # ]: 0 : TEST_ASSERT_EQUAL(retval, test_params->member_port_ids[i],
765 : : "Bonding port (%d) primary port (%d) not expected value (%d)\n",
766 : : test_params->bonding_port_id, retval,
767 : : test_params->member_port_ids[i]);
768 : :
769 : : /* stop/start bonding eth dev to apply new MAC */
770 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_stop(test_params->bonding_port_id),
771 : : "Failed to stop bonding port %u",
772 : : test_params->bonding_port_id);
773 : :
774 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonding_port_id),
775 : : "Failed to start bonding port %d",
776 : : test_params->bonding_port_id);
777 : :
778 : : expected_mac_addr = (struct rte_ether_addr *)&member_mac;
779 : 0 : expected_mac_addr->addr_bytes[RTE_ETHER_ADDR_LEN-1] = i;
780 : :
781 : : /* Check primary member MAC */
782 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[i],
783 : : &read_mac_addr),
784 : : "Failed to get mac address (port %d)",
785 : : test_params->member_port_ids[i]);
786 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(expected_mac_addr, &read_mac_addr,
787 : : sizeof(read_mac_addr)),
788 : : "bonding port mac address not set to that of primary port\n");
789 : :
790 : : /* Check bonding MAC */
791 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id,
792 : : &read_mac_addr),
793 : : "Failed to get mac address (port %d)",
794 : : test_params->bonding_port_id);
795 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(expected_mac_addr, &read_mac_addr,
796 : : sizeof(read_mac_addr)),
797 : : "bonding port mac address not set to that of primary port\n");
798 : :
799 : : /* Check other members MACs */
800 [ # # ]: 0 : for (j = 0; j < 4; j++) {
801 [ # # ]: 0 : if (j != i) {
802 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(
803 : : test_params->member_port_ids[j],
804 : : &read_mac_addr),
805 : : "Failed to get mac address (port %d)",
806 : : test_params->member_port_ids[j]);
807 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(expected_mac_addr, &read_mac_addr,
808 : : sizeof(read_mac_addr)),
809 : : "member port mac address not set to that of primary "
810 : : "port");
811 : : }
812 : : }
813 : : }
814 : :
815 : :
816 : : /* Test with none existent port */
817 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_primary_get(test_params->bonding_port_id + 10),
818 : : "read primary port from expectedly");
819 : :
820 : : /* Test with member port */
821 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_primary_get(test_params->member_port_ids[0]),
822 : : "read primary port from expectedly\n");
823 : :
824 [ # # ]: 0 : TEST_ASSERT_SUCCESS(remove_members_and_stop_bonding_device(),
825 : : "Failed to stop and remove members from bonding device");
826 : :
827 : : /* No members */
828 [ # # ]: 0 : TEST_ASSERT(rte_eth_bond_primary_get(test_params->bonding_port_id) < 0,
829 : : "read primary port from expectedly\n");
830 : :
831 : : return 0;
832 : : }
833 : :
834 : : static int
835 : 0 : test_set_explicit_bonding_mac(void)
836 : : {
837 : : int i;
838 : : struct rte_ether_addr read_mac_addr;
839 : : struct rte_ether_addr *mac_addr;
840 : :
841 : 0 : uint8_t explicit_bonding_mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x01 };
842 : :
843 : : mac_addr = (struct rte_ether_addr *)explicit_bonding_mac;
844 : :
845 : : /* Invalid port ID */
846 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_mac_address_set(INVALID_PORT_ID, mac_addr),
847 : : "Expected call to failed as invalid port specified.");
848 : :
849 : : /* Non bonding device */
850 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_mac_address_set(
851 : : test_params->member_port_ids[0], mac_addr),
852 : : "Expected call to failed as invalid port specified.");
853 : :
854 : : /* NULL MAC address */
855 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_mac_address_set(
856 : : test_params->bonding_port_id, NULL),
857 : : "Expected call to failed as NULL MAC specified");
858 : :
859 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
860 : : test_params->bonding_port_id, mac_addr),
861 : : "Failed to set MAC address on bonding port (%d)",
862 : : test_params->bonding_port_id);
863 : :
864 : : /* Add 4 members to bonding device */
865 [ # # ]: 0 : for (i = test_params->bonding_member_count; i < 4; i++) {
866 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_add_member_to_bonding_device(),
867 : : "Failed to add member to bonding device.\n");
868 : : }
869 : :
870 : : /* Check bonding MAC */
871 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
872 : : "Failed to get mac address (port %d)",
873 : : test_params->bonding_port_id);
874 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(mac_addr, &read_mac_addr, sizeof(read_mac_addr)),
875 : : "bonding port mac address not set to that of primary port");
876 : :
877 : : /* Check other members MACs */
878 [ # # ]: 0 : for (i = 0; i < 4; i++) {
879 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[i],
880 : : &read_mac_addr),
881 : : "Failed to get mac address (port %d)",
882 : : test_params->member_port_ids[i]);
883 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(mac_addr, &read_mac_addr,
884 : : sizeof(read_mac_addr)),
885 : : "member port mac address not set to that of primary port");
886 : : }
887 : :
888 : : /* test resetting mac address on bonding device */
889 [ # # ]: 0 : TEST_ASSERT_SUCCESS(
890 : : rte_eth_bond_mac_address_reset(test_params->bonding_port_id),
891 : : "Failed to reset MAC address on bonding port (%d)",
892 : : test_params->bonding_port_id);
893 : :
894 [ # # ]: 0 : TEST_ASSERT_FAIL(
895 : : rte_eth_bond_mac_address_reset(test_params->member_port_ids[0]),
896 : : "Reset MAC address on bonding port (%d) unexpectedly",
897 : : test_params->member_port_ids[1]);
898 : :
899 : : /* test resetting mac address on bonding device with no members */
900 [ # # ]: 0 : TEST_ASSERT_SUCCESS(remove_members_and_stop_bonding_device(),
901 : : "Failed to remove members and stop bonding device");
902 : :
903 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_reset(test_params->bonding_port_id),
904 : : "Failed to reset MAC address on bonding port (%d)",
905 : : test_params->bonding_port_id);
906 : :
907 : : return 0;
908 : : }
909 : :
910 : : #define BONDING_INIT_MAC_ASSIGNMENT_MEMBER_COUNT (3)
911 : :
912 : : static int
913 : 0 : test_set_bonding_port_initialization_mac_assignment(void)
914 : : {
915 : : int i, member_count;
916 : :
917 : : uint16_t members[RTE_MAX_ETHPORTS];
918 : : static int bonding_port_id = -1;
919 : : static int member_port_ids[BONDING_INIT_MAC_ASSIGNMENT_MEMBER_COUNT];
920 : :
921 : : struct rte_ether_addr member_mac_addr, bonding_mac_addr, read_mac_addr;
922 : :
923 : : /* Initialize default values for MAC addresses */
924 : : memcpy(&member_mac_addr, member_mac, sizeof(struct rte_ether_addr));
925 : : memcpy(&bonding_mac_addr, member_mac, sizeof(struct rte_ether_addr));
926 : :
927 : : /*
928 : : * 1. a - Create / configure bonding / member ethdevs
929 : : */
930 [ # # ]: 0 : if (bonding_port_id == -1) {
931 : 0 : bonding_port_id = rte_eth_bond_create("net_bonding_mac_ass_test",
932 : 0 : BONDING_MODE_ACTIVE_BACKUP, rte_socket_id());
933 [ # # ]: 0 : TEST_ASSERT(bonding_port_id > 0, "failed to create bonding device");
934 : :
935 [ # # ]: 0 : TEST_ASSERT_SUCCESS(configure_ethdev(bonding_port_id, 0, 0),
936 : : "Failed to configure bonding ethdev");
937 : : }
938 : :
939 [ # # ]: 0 : if (!mac_members_initialized) {
940 [ # # ]: 0 : for (i = 0; i < BONDING_INIT_MAC_ASSIGNMENT_MEMBER_COUNT; i++) {
941 : : char pmd_name[RTE_ETH_NAME_MAX_LEN];
942 : :
943 : 0 : member_mac_addr.addr_bytes[RTE_ETHER_ADDR_LEN - 1] =
944 : 0 : i + 100;
945 : :
946 : : snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN,
947 : : "eth_member_%d", i);
948 : :
949 : 0 : member_port_ids[i] = virtual_ethdev_create(pmd_name,
950 : 0 : &member_mac_addr, rte_socket_id(), 1);
951 : :
952 [ # # ]: 0 : TEST_ASSERT(member_port_ids[i] >= 0,
953 : : "Failed to create member ethdev %s",
954 : : pmd_name);
955 : :
956 [ # # ]: 0 : TEST_ASSERT_SUCCESS(configure_ethdev(member_port_ids[i], 1, 0),
957 : : "Failed to configure virtual ethdev %s",
958 : : pmd_name);
959 : : }
960 : 0 : mac_members_initialized = 1;
961 : : }
962 : :
963 : :
964 : : /*
965 : : * 2. Add member ethdevs to bonding device
966 : : */
967 [ # # ]: 0 : for (i = 0; i < BONDING_INIT_MAC_ASSIGNMENT_MEMBER_COUNT; i++) {
968 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_member_add(bonding_port_id,
969 : : member_port_ids[i]),
970 : : "Failed to add member (%d) to bonding port (%d).",
971 : : member_port_ids[i], bonding_port_id);
972 : : }
973 : :
974 : 0 : member_count = rte_eth_bond_members_get(bonding_port_id, members,
975 : : RTE_MAX_ETHPORTS);
976 [ # # ]: 0 : TEST_ASSERT_EQUAL(BONDING_INIT_MAC_ASSIGNMENT_MEMBER_COUNT, member_count,
977 : : "Number of members (%d) is not as expected (%d)",
978 : : member_count, BONDING_INIT_MAC_ASSIGNMENT_MEMBER_COUNT);
979 : :
980 : :
981 : : /*
982 : : * 3. Set explicit MAC address on bonding ethdev
983 : : */
984 : 0 : bonding_mac_addr.addr_bytes[RTE_ETHER_ADDR_LEN-2] = 0xFF;
985 : 0 : bonding_mac_addr.addr_bytes[RTE_ETHER_ADDR_LEN-1] = 0xAA;
986 : :
987 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
988 : : bonding_port_id, &bonding_mac_addr),
989 : : "Failed to set MAC address on bonding port (%d)",
990 : : bonding_port_id);
991 : :
992 : :
993 : : /* 4. a - Start bonding ethdev
994 : : * b - Enable member devices
995 : : * c - Verify bonding/members ethdev MAC addresses
996 : : */
997 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(bonding_port_id),
998 : : "Failed to start bonding pmd eth device %d.",
999 : : bonding_port_id);
1000 : :
1001 [ # # ]: 0 : for (i = 0; i < BONDING_INIT_MAC_ASSIGNMENT_MEMBER_COUNT; i++) {
1002 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1003 : 0 : member_port_ids[i], 1);
1004 : : }
1005 : :
1006 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(bonding_port_id, &read_mac_addr),
1007 : : "Failed to get mac address (port %d)",
1008 : : bonding_port_id);
1009 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac_addr, &read_mac_addr,
1010 : : sizeof(read_mac_addr)),
1011 : : "bonding port mac address not as expected");
1012 : :
1013 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(member_port_ids[0], &read_mac_addr),
1014 : : "Failed to get mac address (port %d)",
1015 : : member_port_ids[0]);
1016 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac_addr, &read_mac_addr,
1017 : : sizeof(read_mac_addr)),
1018 : : "member port 0 mac address not as expected");
1019 : :
1020 : 0 : member_mac_addr.addr_bytes[RTE_ETHER_ADDR_LEN-1] = 1 + 100;
1021 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(member_port_ids[1], &read_mac_addr),
1022 : : "Failed to get mac address (port %d)",
1023 : : member_port_ids[1]);
1024 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&member_mac_addr, &read_mac_addr,
1025 : : sizeof(read_mac_addr)),
1026 : : "member port 1 mac address not as expected");
1027 : :
1028 : 0 : member_mac_addr.addr_bytes[RTE_ETHER_ADDR_LEN-1] = 2 + 100;
1029 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(member_port_ids[2], &read_mac_addr),
1030 : : "Failed to get mac address (port %d)",
1031 : : member_port_ids[2]);
1032 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&member_mac_addr, &read_mac_addr,
1033 : : sizeof(read_mac_addr)),
1034 : : "member port 2 mac address not as expected");
1035 : :
1036 : :
1037 : : /* 7. a - Change primary port
1038 : : * b - Stop / Start bonding port
1039 : : * d - Verify member ethdev MAC addresses
1040 : : */
1041 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(bonding_port_id,
1042 : : member_port_ids[2]),
1043 : : "failed to set primary port on bonding device.");
1044 : :
1045 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_stop(bonding_port_id),
1046 : : "Failed to stop bonding port %u",
1047 : : bonding_port_id);
1048 : :
1049 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(bonding_port_id),
1050 : : "Failed to start bonding pmd eth device %d.",
1051 : : bonding_port_id);
1052 : :
1053 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(bonding_port_id, &read_mac_addr),
1054 : : "Failed to get mac address (port %d)",
1055 : : bonding_port_id);
1056 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac_addr, &read_mac_addr,
1057 : : sizeof(read_mac_addr)),
1058 : : "bonding port mac address not as expected");
1059 : :
1060 : 0 : member_mac_addr.addr_bytes[RTE_ETHER_ADDR_LEN-1] = 0 + 100;
1061 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(member_port_ids[0], &read_mac_addr),
1062 : : "Failed to get mac address (port %d)",
1063 : : member_port_ids[0]);
1064 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&member_mac_addr, &read_mac_addr,
1065 : : sizeof(read_mac_addr)),
1066 : : "member port 0 mac address not as expected");
1067 : :
1068 : 0 : member_mac_addr.addr_bytes[RTE_ETHER_ADDR_LEN-1] = 1 + 100;
1069 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(member_port_ids[1], &read_mac_addr),
1070 : : "Failed to get mac address (port %d)",
1071 : : member_port_ids[1]);
1072 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&member_mac_addr, &read_mac_addr,
1073 : : sizeof(read_mac_addr)),
1074 : : "member port 1 mac address not as expected");
1075 : :
1076 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(member_port_ids[2], &read_mac_addr),
1077 : : "Failed to get mac address (port %d)",
1078 : : member_port_ids[2]);
1079 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac_addr, &read_mac_addr,
1080 : : sizeof(read_mac_addr)),
1081 : : "member port 2 mac address not as expected");
1082 : :
1083 : : /* 6. a - Stop bonding ethdev
1084 : : * b - remove member ethdevs
1085 : : * c - Verify member ethdevs MACs are restored
1086 : : */
1087 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_stop(bonding_port_id),
1088 : : "Failed to stop bonding port %u",
1089 : : bonding_port_id);
1090 : :
1091 [ # # ]: 0 : for (i = 0; i < BONDING_INIT_MAC_ASSIGNMENT_MEMBER_COUNT; i++) {
1092 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_member_remove(bonding_port_id,
1093 : : member_port_ids[i]),
1094 : : "Failed to remove member %d from bonding port (%d).",
1095 : : member_port_ids[i], bonding_port_id);
1096 : : }
1097 : :
1098 : 0 : member_count = rte_eth_bond_members_get(bonding_port_id, members,
1099 : : RTE_MAX_ETHPORTS);
1100 : :
1101 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, 0,
1102 : : "Number of members (%d) is great than expected (%d).",
1103 : : member_count, 0);
1104 : :
1105 : 0 : member_mac_addr.addr_bytes[RTE_ETHER_ADDR_LEN-1] = 0 + 100;
1106 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(member_port_ids[0], &read_mac_addr),
1107 : : "Failed to get mac address (port %d)",
1108 : : member_port_ids[0]);
1109 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&member_mac_addr, &read_mac_addr,
1110 : : sizeof(read_mac_addr)),
1111 : : "member port 0 mac address not as expected");
1112 : :
1113 : 0 : member_mac_addr.addr_bytes[RTE_ETHER_ADDR_LEN-1] = 1 + 100;
1114 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(member_port_ids[1], &read_mac_addr),
1115 : : "Failed to get mac address (port %d)",
1116 : : member_port_ids[1]);
1117 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&member_mac_addr, &read_mac_addr,
1118 : : sizeof(read_mac_addr)),
1119 : : "member port 1 mac address not as expected");
1120 : :
1121 : 0 : member_mac_addr.addr_bytes[RTE_ETHER_ADDR_LEN-1] = 2 + 100;
1122 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(member_port_ids[2], &read_mac_addr),
1123 : : "Failed to get mac address (port %d)",
1124 : : member_port_ids[2]);
1125 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&member_mac_addr, &read_mac_addr,
1126 : : sizeof(read_mac_addr)),
1127 : : "member port 2 mac address not as expected");
1128 : :
1129 : : return 0;
1130 : : }
1131 : :
1132 : :
1133 : : static int
1134 : 0 : initialize_bonding_device_with_members(uint8_t bonding_mode, uint8_t bond_en_isr,
1135 : : uint16_t number_of_members, uint8_t enable_member)
1136 : : {
1137 : : /* Configure bonding device */
1138 [ # # ]: 0 : TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonding_port_id, 0,
1139 : : bond_en_isr), "Failed to configure bonding port (%d) in mode %d "
1140 : : "with (%d) members.", test_params->bonding_port_id, bonding_mode,
1141 : : number_of_members);
1142 : :
1143 : : /* Add members to bonding device */
1144 [ # # ]: 0 : while (number_of_members > test_params->bonding_member_count)
1145 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_add_member_to_bonding_device(),
1146 : : "Failed to add member (%d to bonding port (%d).",
1147 : : test_params->bonding_member_count - 1,
1148 : : test_params->bonding_port_id);
1149 : :
1150 : : /* Set link bonding mode */
1151 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonding_port_id,
1152 : : bonding_mode),
1153 : : "Failed to set link bonding mode on port (%d) to (%d).",
1154 : : test_params->bonding_port_id, bonding_mode);
1155 : :
1156 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonding_port_id),
1157 : : "Failed to start bonding pmd eth device %d.",
1158 : : test_params->bonding_port_id);
1159 : :
1160 [ # # ]: 0 : if (enable_member)
1161 : 0 : enable_bonding_members();
1162 : :
1163 : : return 0;
1164 : : }
1165 : :
1166 : : static int
1167 : 0 : test_adding_member_after_bonding_device_started(void)
1168 : : {
1169 : : int i;
1170 : :
1171 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
1172 : : BONDING_MODE_ROUND_ROBIN, 0, 4, 0),
1173 : : "Failed to add members to bonding device");
1174 : :
1175 : : /* Enabled member devices */
1176 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count + 1; i++) {
1177 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1178 : 0 : test_params->member_port_ids[i], 1);
1179 : : }
1180 : :
1181 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_member_add(test_params->bonding_port_id,
1182 : : test_params->member_port_ids[test_params->bonding_member_count]),
1183 : : "Failed to add member to bonding port.\n");
1184 : :
1185 : 0 : rte_eth_stats_reset(
1186 : 0 : test_params->member_port_ids[test_params->bonding_member_count]);
1187 : :
1188 : 0 : test_params->bonding_member_count++;
1189 : :
1190 : 0 : return remove_members_and_stop_bonding_device();
1191 : : }
1192 : :
1193 : : #define TEST_STATUS_INTERRUPT_MEMBER_COUNT 4
1194 : : #define TEST_LSC_WAIT_TIMEOUT_US 500000
1195 : :
1196 : : int test_lsc_interrupt_count;
1197 : :
1198 : :
1199 : : static int
1200 : 0 : test_bonding_lsc_event_callback(uint16_t port_id __rte_unused,
1201 : : enum rte_eth_event_type type __rte_unused,
1202 : : void *param __rte_unused,
1203 : : void *ret_param __rte_unused)
1204 : : {
1205 : 0 : pthread_mutex_lock(&mutex);
1206 : 0 : test_lsc_interrupt_count++;
1207 : :
1208 : 0 : pthread_cond_signal(&cvar);
1209 : 0 : pthread_mutex_unlock(&mutex);
1210 : :
1211 : 0 : return 0;
1212 : : }
1213 : :
1214 : : static inline int
1215 : 0 : lsc_timeout(int wait_us)
1216 : : {
1217 : : int retval = 0;
1218 : :
1219 : : struct timespec ts;
1220 : : struct timeval tp;
1221 : :
1222 : 0 : gettimeofday(&tp, NULL);
1223 : :
1224 : : /* Convert from timeval to timespec */
1225 : 0 : ts.tv_sec = tp.tv_sec;
1226 : 0 : ts.tv_nsec = tp.tv_usec * 1000;
1227 : 0 : ts.tv_nsec += wait_us * 1000;
1228 : : /* Normalize tv_nsec to [0,999999999L] */
1229 [ # # ]: 0 : while (ts.tv_nsec > 1000000000L) {
1230 : 0 : ts.tv_nsec -= 1000000000L;
1231 : 0 : ts.tv_sec += 1;
1232 : : }
1233 : :
1234 : 0 : pthread_mutex_lock(&mutex);
1235 [ # # ]: 0 : if (test_lsc_interrupt_count < 1)
1236 : 0 : retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
1237 : :
1238 : 0 : pthread_mutex_unlock(&mutex);
1239 : :
1240 [ # # # # ]: 0 : if (retval == 0 && test_lsc_interrupt_count < 1)
1241 : 0 : return -1;
1242 : :
1243 : : return retval;
1244 : : }
1245 : :
1246 : : static int
1247 : 0 : test_status_interrupt(void)
1248 : : {
1249 : : int member_count;
1250 : : uint16_t members[RTE_MAX_ETHPORTS];
1251 : :
1252 : : /* initialized bonding device with T members */
1253 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
1254 : : BONDING_MODE_ROUND_ROBIN, 1,
1255 : : TEST_STATUS_INTERRUPT_MEMBER_COUNT, 1),
1256 : : "Failed to initialise bonding device");
1257 : :
1258 : 0 : test_lsc_interrupt_count = 0;
1259 : :
1260 : : /* register link status change interrupt callback */
1261 : 0 : rte_eth_dev_callback_register(test_params->bonding_port_id,
1262 : : RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
1263 : 0 : &test_params->bonding_port_id);
1264 : :
1265 : 0 : member_count = rte_eth_bond_active_members_get(test_params->bonding_port_id,
1266 : : members, RTE_MAX_ETHPORTS);
1267 : :
1268 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, TEST_STATUS_INTERRUPT_MEMBER_COUNT,
1269 : : "Number of active members (%d) is not as expected (%d)",
1270 : : member_count, TEST_STATUS_INTERRUPT_MEMBER_COUNT);
1271 : :
1272 : : /* Bring all 4 members link status to down and test that we have received a
1273 : : * lsc interrupts */
1274 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1275 : 0 : test_params->member_port_ids[0], 0);
1276 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1277 : 0 : test_params->member_port_ids[1], 0);
1278 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1279 : 0 : test_params->member_port_ids[2], 0);
1280 : :
1281 [ # # ]: 0 : TEST_ASSERT_EQUAL(test_lsc_interrupt_count, 0,
1282 : : "Received a link status change interrupt unexpectedly");
1283 : :
1284 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1285 : 0 : test_params->member_port_ids[3], 0);
1286 : :
1287 [ # # ]: 0 : TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_US) == 0,
1288 : : "timed out waiting for interrupt");
1289 : :
1290 [ # # ]: 0 : TEST_ASSERT(test_lsc_interrupt_count > 0,
1291 : : "Did not receive link status change interrupt");
1292 : :
1293 : 0 : member_count = rte_eth_bond_active_members_get(test_params->bonding_port_id,
1294 : : members, RTE_MAX_ETHPORTS);
1295 : :
1296 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, 0,
1297 : : "Number of active members (%d) is not as expected (%d)",
1298 : : member_count, 0);
1299 : :
1300 : : /* bring one member port up so link status will change */
1301 : 0 : test_lsc_interrupt_count = 0;
1302 : :
1303 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1304 : 0 : test_params->member_port_ids[0], 1);
1305 : :
1306 [ # # ]: 0 : TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_US) == 0,
1307 : : "timed out waiting for interrupt");
1308 : :
1309 : : /* test that we have received another lsc interrupt */
1310 [ # # ]: 0 : TEST_ASSERT(test_lsc_interrupt_count > 0,
1311 : : "Did not receive link status change interrupt");
1312 : :
1313 : : /*
1314 : : * Verify that calling the same member lsc interrupt doesn't cause another
1315 : : * lsc interrupt from bonding device.
1316 : : */
1317 : 0 : test_lsc_interrupt_count = 0;
1318 : :
1319 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1320 : 0 : test_params->member_port_ids[0], 1);
1321 : :
1322 [ # # ]: 0 : TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_US) != 0,
1323 : : "received unexpected interrupt");
1324 : :
1325 [ # # ]: 0 : TEST_ASSERT_EQUAL(test_lsc_interrupt_count, 0,
1326 : : "Did not receive link status change interrupt");
1327 : :
1328 : :
1329 : : /* unregister lsc callback before exiting */
1330 : 0 : rte_eth_dev_callback_unregister(test_params->bonding_port_id,
1331 : : RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
1332 : 0 : &test_params->bonding_port_id);
1333 : :
1334 : : /* Clean up and remove members from bonding device */
1335 : 0 : return remove_members_and_stop_bonding_device();
1336 : : }
1337 : :
1338 : : static int
1339 : 0 : generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
1340 : : uint8_t vlan, uint8_t ipv4, uint8_t toggle_dst_mac,
1341 : : uint8_t toggle_ip_addr, uint16_t toggle_udp_port)
1342 : : {
1343 : : uint16_t pktlen, generated_burst_size, ether_type;
1344 : : void *ip_hdr;
1345 : :
1346 [ # # ]: 0 : if (ipv4)
1347 : : ether_type = RTE_ETHER_TYPE_IPV4;
1348 : : else
1349 : : ether_type = RTE_ETHER_TYPE_IPV6;
1350 : :
1351 [ # # ]: 0 : if (toggle_dst_mac)
1352 : 0 : initialize_eth_header(test_params->pkt_eth_hdr,
1353 : : (struct rte_ether_addr *)src_mac,
1354 : : (struct rte_ether_addr *)dst_mac_1,
1355 : : ether_type, vlan, vlan_id);
1356 : : else
1357 : 0 : initialize_eth_header(test_params->pkt_eth_hdr,
1358 : : (struct rte_ether_addr *)src_mac,
1359 : : (struct rte_ether_addr *)dst_mac_0,
1360 : : ether_type, vlan, vlan_id);
1361 : :
1362 : :
1363 [ # # ]: 0 : if (toggle_udp_port)
1364 : 0 : pktlen = initialize_udp_header(test_params->pkt_udp_hdr, src_port,
1365 : : dst_port_1, 64);
1366 : : else
1367 : 0 : pktlen = initialize_udp_header(test_params->pkt_udp_hdr, src_port,
1368 : : dst_port_0, 64);
1369 : :
1370 [ # # ]: 0 : if (ipv4) {
1371 [ # # ]: 0 : if (toggle_ip_addr)
1372 : 0 : pktlen = initialize_ipv4_header(test_params->pkt_ipv4_hdr, src_addr,
1373 : : dst_addr_1, pktlen);
1374 : : else
1375 : 0 : pktlen = initialize_ipv4_header(test_params->pkt_ipv4_hdr, src_addr,
1376 : : dst_addr_0, pktlen);
1377 : :
1378 : 0 : ip_hdr = test_params->pkt_ipv4_hdr;
1379 : : } else {
1380 [ # # ]: 0 : if (toggle_ip_addr)
1381 : 0 : pktlen = initialize_ipv6_header(test_params->pkt_ipv6_hdr,
1382 : : (uint8_t *)src_ipv6_addr, (uint8_t *)dst_ipv6_addr_1,
1383 : : pktlen);
1384 : : else
1385 : 0 : pktlen = initialize_ipv6_header(test_params->pkt_ipv6_hdr,
1386 : : (uint8_t *)src_ipv6_addr, (uint8_t *)dst_ipv6_addr_0,
1387 : : pktlen);
1388 : :
1389 : 0 : ip_hdr = test_params->pkt_ipv6_hdr;
1390 : : }
1391 : :
1392 : : /* Generate burst of packets to transmit */
1393 : 0 : generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
1394 : : pkts_burst, test_params->pkt_eth_hdr, vlan, ip_hdr, ipv4,
1395 : 0 : test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN_128,
1396 : : 1);
1397 [ # # ]: 0 : TEST_ASSERT_EQUAL(generated_burst_size, burst_size,
1398 : : "Failed to generate packet burst");
1399 : :
1400 : 0 : return generated_burst_size;
1401 : : }
1402 : :
1403 : : /** Round Robin Mode Tests */
1404 : :
1405 : : static int
1406 : 0 : test_roundrobin_tx_burst(void)
1407 : : {
1408 : : int i, burst_size;
1409 : : struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
1410 : : struct rte_eth_stats port_stats;
1411 : :
1412 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
1413 : : BONDING_MODE_ROUND_ROBIN, 0, 2, 1),
1414 : : "Failed to initialise bonding device");
1415 : :
1416 : 0 : burst_size = 20 * test_params->bonding_member_count;
1417 : :
1418 [ # # ]: 0 : TEST_ASSERT(burst_size <= MAX_PKT_BURST,
1419 : : "Burst size specified is greater than supported.");
1420 : :
1421 : : /* Generate test bursts of packets to transmit */
1422 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst, burst_size, 0, 1, 0, 0, 0),
1423 : : burst_size, "failed to generate test burst");
1424 : :
1425 : : /* Send burst on bonding port */
1426 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(
1427 : : test_params->bonding_port_id, 0, pkt_burst, burst_size), burst_size,
1428 : : "tx burst failed");
1429 : :
1430 : : /* Verify bonding port tx stats */
1431 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
1432 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
1433 : : "Bonding Port (%d) opackets value (%u) not as expected (%d)\n",
1434 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
1435 : : burst_size);
1436 : :
1437 : : /* Verify member ports tx stats */
1438 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
1439 : 0 : rte_eth_stats_get(test_params->member_port_ids[i], &port_stats);
1440 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
1441 : : (uint64_t)burst_size / test_params->bonding_member_count,
1442 : : "Member Port (%d) opackets value (%u) not as expected (%d)\n",
1443 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
1444 : : burst_size / test_params->bonding_member_count);
1445 : : }
1446 : :
1447 : : /* Put all members down and try and transmit */
1448 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
1449 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1450 : 0 : test_params->member_port_ids[i], 0);
1451 : : }
1452 : :
1453 : : /* Send burst on bonding port */
1454 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonding_port_id, 0,
1455 : : pkt_burst, burst_size), 0,
1456 : : "tx burst return unexpected value");
1457 : :
1458 : : /* Clean up and remove members from bonding device */
1459 : 0 : return remove_members_and_stop_bonding_device();
1460 : : }
1461 : :
1462 : : static int
1463 : 0 : verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
1464 : : {
1465 : : int i, refcnt;
1466 : :
1467 [ # # ]: 0 : for (i = 0; i < nb_mbufs; i++) {
1468 [ # # ]: 0 : refcnt = rte_mbuf_refcnt_read(mbufs[i]);
1469 [ # # ]: 0 : TEST_ASSERT_EQUAL(refcnt, val,
1470 : : "mbuf ref count (%d)is not the expected value (%d)",
1471 : : refcnt, val);
1472 : : }
1473 : : return 0;
1474 : : }
1475 : :
1476 : : static void
1477 : : free_mbufs(struct rte_mbuf **mbufs, int nb_mbufs)
1478 : : {
1479 : : int i;
1480 : :
1481 [ # # # # : 0 : for (i = 0; i < nb_mbufs; i++)
# # ]
1482 : 0 : rte_pktmbuf_free(mbufs[i]);
1483 : : }
1484 : :
1485 : : #define TEST_RR_MEMBER_TX_FAIL_MEMBER_COUNT (2)
1486 : : #define TEST_RR_MEMBER_TX_FAIL_BURST_SIZE (64)
1487 : : #define TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT (22)
1488 : : #define TEST_RR_MEMBER_TX_FAIL_FAILING_MEMBER_IDX (1)
1489 : :
1490 : : static int
1491 : 0 : test_roundrobin_tx_burst_member_tx_fail(void)
1492 : : {
1493 : : struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
1494 : : struct rte_mbuf *expected_tx_fail_pkts[MAX_PKT_BURST];
1495 : :
1496 : : struct rte_eth_stats port_stats;
1497 : :
1498 : : int i, first_fail_idx, tx_count;
1499 : :
1500 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
1501 : : BONDING_MODE_ROUND_ROBIN, 0,
1502 : : TEST_RR_MEMBER_TX_FAIL_MEMBER_COUNT, 1),
1503 : : "Failed to initialise bonding device");
1504 : :
1505 : : /* Generate test bursts of packets to transmit */
1506 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst,
1507 : : TEST_RR_MEMBER_TX_FAIL_BURST_SIZE, 0, 1, 0, 0, 0),
1508 : : TEST_RR_MEMBER_TX_FAIL_BURST_SIZE,
1509 : : "Failed to generate test packet burst");
1510 : :
1511 : : /* Copy references to packets which we expect not to be transmitted */
1512 : : first_fail_idx = (TEST_RR_MEMBER_TX_FAIL_BURST_SIZE -
1513 : : (TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT *
1514 : : TEST_RR_MEMBER_TX_FAIL_MEMBER_COUNT)) +
1515 : : TEST_RR_MEMBER_TX_FAIL_FAILING_MEMBER_IDX;
1516 : :
1517 [ # # ]: 0 : for (i = 0; i < TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT; i++) {
1518 : 0 : expected_tx_fail_pkts[i] = pkt_burst[first_fail_idx +
1519 : 0 : (i * TEST_RR_MEMBER_TX_FAIL_MEMBER_COUNT)];
1520 : : }
1521 : :
1522 : : /*
1523 : : * Set virtual member to only fail transmission of
1524 : : * TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT packets in burst.
1525 : : */
1526 : 0 : virtual_ethdev_tx_burst_fn_set_success(
1527 : 0 : test_params->member_port_ids[TEST_RR_MEMBER_TX_FAIL_FAILING_MEMBER_IDX],
1528 : : 0);
1529 : :
1530 : 0 : virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
1531 : 0 : test_params->member_port_ids[TEST_RR_MEMBER_TX_FAIL_FAILING_MEMBER_IDX],
1532 : : TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT);
1533 : :
1534 : 0 : tx_count = rte_eth_tx_burst(test_params->bonding_port_id, 0, pkt_burst,
1535 : : TEST_RR_MEMBER_TX_FAIL_BURST_SIZE);
1536 : :
1537 [ # # ]: 0 : TEST_ASSERT_EQUAL(tx_count, TEST_RR_MEMBER_TX_FAIL_BURST_SIZE -
1538 : : TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT,
1539 : : "Transmitted (%d) an unexpected (%d) number of packets", tx_count,
1540 : : TEST_RR_MEMBER_TX_FAIL_BURST_SIZE -
1541 : : TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT);
1542 : :
1543 : : /* Verify that failed packet are expected failed packets */
1544 [ # # ]: 0 : for (i = 0; i < TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT; i++) {
1545 [ # # ]: 0 : TEST_ASSERT_EQUAL(expected_tx_fail_pkts[i], pkt_burst[i + tx_count],
1546 : : "expected mbuf (%d) pointer %p not expected pointer %p",
1547 : : i, expected_tx_fail_pkts[i], pkt_burst[i + tx_count]);
1548 : : }
1549 : :
1550 : : /* Verify bonding port tx stats */
1551 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
1552 : :
1553 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
1554 : : (uint64_t)TEST_RR_MEMBER_TX_FAIL_BURST_SIZE -
1555 : : TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT,
1556 : : "Bonding Port (%d) opackets value (%u) not as expected (%d)",
1557 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
1558 : : TEST_RR_MEMBER_TX_FAIL_BURST_SIZE -
1559 : : TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT);
1560 : :
1561 : : /* Verify member ports tx stats */
1562 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
1563 : : int member_expected_tx_count;
1564 : :
1565 : 0 : rte_eth_stats_get(test_params->member_port_ids[i], &port_stats);
1566 : :
1567 : 0 : member_expected_tx_count = TEST_RR_MEMBER_TX_FAIL_BURST_SIZE /
1568 : 0 : test_params->bonding_member_count;
1569 : :
1570 [ # # ]: 0 : if (i == TEST_RR_MEMBER_TX_FAIL_FAILING_MEMBER_IDX)
1571 : 0 : member_expected_tx_count = member_expected_tx_count -
1572 : : TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT;
1573 : :
1574 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
1575 : : (uint64_t)member_expected_tx_count,
1576 : : "Member Port (%d) opackets value (%u) not as expected (%d)",
1577 : : test_params->member_port_ids[i],
1578 : : (unsigned int)port_stats.opackets, member_expected_tx_count);
1579 : : }
1580 : :
1581 : : /* Verify that all mbufs have a ref value of zero */
1582 [ # # ]: 0 : TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkt_burst[tx_count],
1583 : : TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT, 1),
1584 : : "mbufs refcnts not as expected");
1585 : : free_mbufs(&pkt_burst[tx_count], TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT);
1586 : :
1587 : : /* Clean up and remove members from bonding device */
1588 : 0 : return remove_members_and_stop_bonding_device();
1589 : : }
1590 : :
1591 : : static int
1592 : 0 : test_roundrobin_rx_burst_on_single_member(void)
1593 : : {
1594 : 0 : struct rte_mbuf *gen_pkt_burst[MAX_PKT_BURST] = { NULL };
1595 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
1596 : :
1597 : : struct rte_eth_stats port_stats;
1598 : :
1599 : : int i, j, burst_size = 25;
1600 : :
1601 : : /* Initialize bonding device with 4 members in round robin mode */
1602 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
1603 : : BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
1604 : : "Failed to initialize bonding device with members");
1605 : :
1606 : : /* Generate test bursts of packets to transmit */
1607 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
1608 : : gen_pkt_burst, burst_size, 0, 1, 0, 0, 0), burst_size,
1609 : : "burst generation failed");
1610 : :
1611 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
1612 : : /* Add rx data to member */
1613 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[i],
1614 : : &gen_pkt_burst[0], burst_size);
1615 : :
1616 : : /* Call rx burst on bonding device */
1617 : : /* Send burst on bonding port */
1618 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_rx_burst(
1619 : : test_params->bonding_port_id, 0, rx_pkt_burst,
1620 : : MAX_PKT_BURST), burst_size,
1621 : : "round-robin rx burst failed");
1622 : :
1623 : : /* Verify bonding device rx count */
1624 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
1625 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
1626 : : "Bonding Port (%d) ipackets value (%u) not as expected (%d)",
1627 : : test_params->bonding_port_id,
1628 : : (unsigned int)port_stats.ipackets, burst_size);
1629 : :
1630 : :
1631 : :
1632 : : /* Verify bonding member devices rx count */
1633 : : /* Verify member ports tx stats */
1634 [ # # ]: 0 : for (j = 0; j < test_params->bonding_member_count; j++) {
1635 : 0 : rte_eth_stats_get(test_params->member_port_ids[j], &port_stats);
1636 : :
1637 [ # # ]: 0 : if (i == j) {
1638 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
1639 : : "Member Port (%d) ipackets value (%u) not as expected"
1640 : : " (%d)", test_params->member_port_ids[i],
1641 : : (unsigned int)port_stats.ipackets, burst_size);
1642 : : } else {
1643 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
1644 : : "Member Port (%d) ipackets value (%u) not as expected"
1645 : : " (%d)", test_params->member_port_ids[i],
1646 : : (unsigned int)port_stats.ipackets, 0);
1647 : : }
1648 : :
1649 : : /* Reset bonding members stats */
1650 : 0 : rte_eth_stats_reset(test_params->member_port_ids[j]);
1651 : : }
1652 : : /* reset bonding device stats */
1653 : 0 : rte_eth_stats_reset(test_params->bonding_port_id);
1654 : : }
1655 : :
1656 : : /* free mbufs */
1657 [ # # ]: 0 : for (i = 0; i < MAX_PKT_BURST; i++) {
1658 : 0 : rte_pktmbuf_free(rx_pkt_burst[i]);
1659 : : }
1660 : :
1661 : :
1662 : : /* Clean up and remove members from bonding device */
1663 : 0 : return remove_members_and_stop_bonding_device();
1664 : : }
1665 : :
1666 : : #define TEST_ROUNDROBIN_TX_BURST_MEMBER_COUNT (3)
1667 : :
1668 : : static int
1669 : 0 : test_roundrobin_rx_burst_on_multiple_members(void)
1670 : : {
1671 : : struct rte_mbuf *gen_pkt_burst[TEST_ROUNDROBIN_TX_BURST_MEMBER_COUNT][MAX_PKT_BURST];
1672 : :
1673 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
1674 : : struct rte_eth_stats port_stats;
1675 : :
1676 : 0 : int burst_size[TEST_ROUNDROBIN_TX_BURST_MEMBER_COUNT] = { 15, 13, 36 };
1677 : : int i, nb_rx;
1678 : :
1679 : : /* Initialize bonding device with 4 members in round robin mode */
1680 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
1681 : : BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
1682 : : "Failed to initialize bonding device with members");
1683 : :
1684 : : /* Generate test bursts of packets to transmit */
1685 [ # # ]: 0 : for (i = 0; i < TEST_ROUNDROBIN_TX_BURST_MEMBER_COUNT; i++) {
1686 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
1687 : : &gen_pkt_burst[i][0], burst_size[i], 0, 1, 0, 0, 0),
1688 : : burst_size[i], "burst generation failed");
1689 : : }
1690 : :
1691 : : /* Add rx data to members */
1692 [ # # ]: 0 : for (i = 0; i < TEST_ROUNDROBIN_TX_BURST_MEMBER_COUNT; i++) {
1693 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[i],
1694 : : &gen_pkt_burst[i][0], burst_size[i]);
1695 : : }
1696 : :
1697 : : /* Call rx burst on bonding device */
1698 : : /* Send burst on bonding port */
1699 : 0 : nb_rx = rte_eth_rx_burst(test_params->bonding_port_id, 0, rx_pkt_burst,
1700 : : MAX_PKT_BURST);
1701 [ # # ]: 0 : TEST_ASSERT_EQUAL(nb_rx , burst_size[0] + burst_size[1] + burst_size[2],
1702 : : "round-robin rx burst failed (%d != %d)\n", nb_rx,
1703 : : burst_size[0] + burst_size[1] + burst_size[2]);
1704 : :
1705 : : /* Verify bonding device rx count */
1706 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
1707 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets,
1708 : : (uint64_t)(burst_size[0] + burst_size[1] + burst_size[2]),
1709 : : "Bonding Port (%d) ipackets value (%u) not as expected (%d)",
1710 : : test_params->bonding_port_id, (unsigned int)port_stats.ipackets,
1711 : : burst_size[0] + burst_size[1] + burst_size[2]);
1712 : :
1713 : : /* Verify bonding member devices rx counts */
1714 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
1715 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[0],
1716 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
1717 : : test_params->member_port_ids[0],
1718 : : (unsigned int)port_stats.ipackets, burst_size[0]);
1719 : :
1720 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
1721 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[1],
1722 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
1723 : : test_params->member_port_ids[1], (unsigned int)port_stats.ipackets,
1724 : : burst_size[1]);
1725 : :
1726 : 0 : rte_eth_stats_get(test_params->member_port_ids[2], &port_stats);
1727 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[2],
1728 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
1729 : : test_params->member_port_ids[2],
1730 : : (unsigned int)port_stats.ipackets, burst_size[2]);
1731 : :
1732 : 0 : rte_eth_stats_get(test_params->member_port_ids[3], &port_stats);
1733 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
1734 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
1735 : : test_params->member_port_ids[3],
1736 : : (unsigned int)port_stats.ipackets, 0);
1737 : :
1738 : : /* free mbufs */
1739 [ # # ]: 0 : for (i = 0; i < MAX_PKT_BURST; i++) {
1740 : 0 : rte_pktmbuf_free(rx_pkt_burst[i]);
1741 : : }
1742 : :
1743 : : /* Clean up and remove members from bonding device */
1744 : 0 : return remove_members_and_stop_bonding_device();
1745 : : }
1746 : :
1747 : : static int
1748 : 0 : test_roundrobin_verify_mac_assignment(void)
1749 : : {
1750 : : struct rte_ether_addr read_mac_addr;
1751 : : struct rte_ether_addr expected_mac_addr_0, expected_mac_addr_2;
1752 : :
1753 : : int i;
1754 : :
1755 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0],
1756 : : &expected_mac_addr_0),
1757 : : "Failed to get mac address (port %d)",
1758 : : test_params->member_port_ids[0]);
1759 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[2],
1760 : : &expected_mac_addr_2),
1761 : : "Failed to get mac address (port %d)",
1762 : : test_params->member_port_ids[2]);
1763 : :
1764 : : /* Initialize bonding device with 4 members in round robin mode */
1765 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
1766 : : BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
1767 : : "Failed to initialize bonding device with members");
1768 : :
1769 : : /* Verify that all MACs are the same as first member added to bonding dev */
1770 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
1771 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[i],
1772 : : &read_mac_addr),
1773 : : "Failed to get mac address (port %d)",
1774 : : test_params->member_port_ids[i]);
1775 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
1776 : : sizeof(read_mac_addr)),
1777 : : "member port (%d) mac address not set to that of primary port",
1778 : : test_params->member_port_ids[i]);
1779 : : }
1780 : :
1781 : : /* change primary and verify that MAC addresses haven't changed */
1782 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(test_params->bonding_port_id,
1783 : : test_params->member_port_ids[2]),
1784 : : "Failed to set bonding port (%d) primary port to (%d)",
1785 : : test_params->bonding_port_id, test_params->member_port_ids[i]);
1786 : :
1787 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
1788 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[i],
1789 : : &read_mac_addr),
1790 : : "Failed to get mac address (port %d)",
1791 : : test_params->member_port_ids[i]);
1792 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
1793 : : sizeof(read_mac_addr)),
1794 : : "member port (%d) mac address has changed to that of primary"
1795 : : " port without stop/start toggle of bonding device",
1796 : : test_params->member_port_ids[i]);
1797 : : }
1798 : :
1799 : : /*
1800 : : * stop / start bonding device and verify that primary MAC address is
1801 : : * propagate to bonding device and members.
1802 : : */
1803 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_stop(test_params->bonding_port_id),
1804 : : "Failed to stop bonding port %u",
1805 : : test_params->bonding_port_id);
1806 : :
1807 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonding_port_id),
1808 : : "Failed to start bonding device");
1809 : :
1810 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
1811 : : "Failed to get mac address (port %d)",
1812 : : test_params->bonding_port_id);
1813 [ # # ]: 0 : TEST_ASSERT_SUCCESS(
1814 : : memcmp(&expected_mac_addr_2, &read_mac_addr, sizeof(read_mac_addr)),
1815 : : "bonding port (%d) mac address not set to that of new primary port",
1816 : : test_params->member_port_ids[i]);
1817 : :
1818 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
1819 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[i],
1820 : : &read_mac_addr),
1821 : : "Failed to get mac address (port %d)",
1822 : : test_params->member_port_ids[i]);
1823 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_2, &read_mac_addr,
1824 : : sizeof(read_mac_addr)),
1825 : : "member port (%d) mac address not set to that of new primary"
1826 : : " port", test_params->member_port_ids[i]);
1827 : : }
1828 : :
1829 : : /* Set explicit MAC address */
1830 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
1831 : : test_params->bonding_port_id,
1832 : : (struct rte_ether_addr *)bonding_mac),
1833 : : "Failed to set MAC");
1834 : :
1835 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
1836 : : "Failed to get mac address (port %d)",
1837 : : test_params->bonding_port_id);
1838 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(bonding_mac, &read_mac_addr,
1839 : : sizeof(read_mac_addr)),
1840 : : "bonding port (%d) mac address not set to that of new primary port",
1841 : : test_params->member_port_ids[i]);
1842 : :
1843 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
1844 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[i],
1845 : : &read_mac_addr),
1846 : : "Failed to get mac address (port %d)",
1847 : : test_params->member_port_ids[i]);
1848 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(bonding_mac, &read_mac_addr,
1849 : : sizeof(read_mac_addr)), "member port (%d) mac address not set to"
1850 : : " that of new primary port\n", test_params->member_port_ids[i]);
1851 : : }
1852 : :
1853 : : /* Clean up and remove members from bonding device */
1854 : 0 : return remove_members_and_stop_bonding_device();
1855 : : }
1856 : :
1857 : : static int
1858 : 0 : test_roundrobin_verify_promiscuous_enable_disable(void)
1859 : : {
1860 : : int i, promiscuous_en;
1861 : : int ret;
1862 : :
1863 : : /* Initialize bonding device with 4 members in round robin mode */
1864 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
1865 : : BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
1866 : : "Failed to initialize bonding device with members");
1867 : :
1868 : 0 : ret = rte_eth_promiscuous_enable(test_params->bonding_port_id);
1869 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret,
1870 : : "Failed to enable promiscuous mode for port %d: %s",
1871 : : test_params->bonding_port_id, rte_strerror(-ret));
1872 : :
1873 : 0 : promiscuous_en = rte_eth_promiscuous_get(test_params->bonding_port_id);
1874 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, 1,
1875 : : "Port (%d) promiscuous mode not enabled",
1876 : : test_params->bonding_port_id);
1877 : :
1878 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
1879 : 0 : promiscuous_en = rte_eth_promiscuous_get(
1880 : 0 : test_params->member_port_ids[i]);
1881 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, 1,
1882 : : "member port (%d) promiscuous mode not enabled",
1883 : : test_params->member_port_ids[i]);
1884 : : }
1885 : :
1886 : 0 : ret = rte_eth_promiscuous_disable(test_params->bonding_port_id);
1887 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret,
1888 : : "Failed to disable promiscuous mode for port %d: %s",
1889 : : test_params->bonding_port_id, rte_strerror(-ret));
1890 : :
1891 : 0 : promiscuous_en = rte_eth_promiscuous_get(test_params->bonding_port_id);
1892 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, 0,
1893 : : "Port (%d) promiscuous mode not disabled\n",
1894 : : test_params->bonding_port_id);
1895 : :
1896 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
1897 : 0 : promiscuous_en = rte_eth_promiscuous_get(
1898 : 0 : test_params->member_port_ids[i]);
1899 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, 0,
1900 : : "Port (%d) promiscuous mode not disabled\n",
1901 : : test_params->member_port_ids[i]);
1902 : : }
1903 : :
1904 : : /* Clean up and remove members from bonding device */
1905 : 0 : return remove_members_and_stop_bonding_device();
1906 : : }
1907 : :
1908 : : #define TEST_RR_LINK_STATUS_MEMBER_COUNT (4)
1909 : : #define TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_MEMBER_COUNT (2)
1910 : :
1911 : : static int
1912 : 0 : test_roundrobin_verify_member_link_status_change_behaviour(void)
1913 : : {
1914 : 0 : struct rte_mbuf *tx_pkt_burst[MAX_PKT_BURST] = { NULL };
1915 : : struct rte_mbuf *gen_pkt_burst[TEST_RR_LINK_STATUS_MEMBER_COUNT][MAX_PKT_BURST];
1916 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
1917 : :
1918 : : struct rte_eth_stats port_stats;
1919 : : uint16_t members[RTE_MAX_ETHPORTS];
1920 : :
1921 : : int i, burst_size, member_count;
1922 : :
1923 : : /* NULL all pointers in array to simplify cleanup */
1924 : : memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
1925 : :
1926 : : /* Initialize bonding device with TEST_RR_LINK_STATUS_MEMBER_COUNT members
1927 : : * in round robin mode */
1928 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
1929 : : BONDING_MODE_ROUND_ROBIN, 0, TEST_RR_LINK_STATUS_MEMBER_COUNT, 1),
1930 : : "Failed to initialize bonding device with members");
1931 : :
1932 : : /* Verify Current Members Count /Active Member Count is */
1933 : 0 : member_count = rte_eth_bond_members_get(test_params->bonding_port_id, members,
1934 : : RTE_MAX_ETHPORTS);
1935 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, TEST_RR_LINK_STATUS_MEMBER_COUNT,
1936 : : "Number of members (%d) is not as expected (%d).",
1937 : : member_count, TEST_RR_LINK_STATUS_MEMBER_COUNT);
1938 : :
1939 : 0 : member_count = rte_eth_bond_active_members_get(test_params->bonding_port_id,
1940 : : members, RTE_MAX_ETHPORTS);
1941 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, TEST_RR_LINK_STATUS_MEMBER_COUNT,
1942 : : "Number of active members (%d) is not as expected (%d).",
1943 : : member_count, TEST_RR_LINK_STATUS_MEMBER_COUNT);
1944 : :
1945 : : /* Set 2 members eth_devs link status to down */
1946 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1947 : 0 : test_params->member_port_ids[1], 0);
1948 : 0 : virtual_ethdev_simulate_link_status_interrupt(
1949 : 0 : test_params->member_port_ids[3], 0);
1950 : :
1951 : 0 : member_count = rte_eth_bond_active_members_get(test_params->bonding_port_id,
1952 : : members, RTE_MAX_ETHPORTS);
1953 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count,
1954 : : TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_MEMBER_COUNT,
1955 : : "Number of active members (%d) is not as expected (%d).\n",
1956 : : member_count, TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_MEMBER_COUNT);
1957 : :
1958 : : burst_size = 20;
1959 : :
1960 : : /* Verify that pkts are not sent on members with link status down:
1961 : : *
1962 : : * 1. Generate test burst of traffic
1963 : : * 2. Transmit burst on bonding eth_dev
1964 : : * 3. Verify stats for bonding eth_dev (opackets = burst_size)
1965 : : * 4. Verify stats for member eth_devs (s0 = 10, s1 = 0, s2 = 10, s3 = 0)
1966 : : */
1967 [ # # ]: 0 : TEST_ASSERT_EQUAL(
1968 : : generate_test_burst(tx_pkt_burst, burst_size, 0, 1, 0, 0, 0),
1969 : : burst_size, "generate_test_burst failed");
1970 : :
1971 : 0 : rte_eth_stats_reset(test_params->bonding_port_id);
1972 : :
1973 : :
1974 [ # # ]: 0 : TEST_ASSERT_EQUAL(
1975 : : rte_eth_tx_burst(test_params->bonding_port_id, 0, tx_pkt_burst,
1976 : : burst_size), burst_size, "rte_eth_tx_burst failed");
1977 : :
1978 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
1979 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
1980 : : "Port (%d) opackets stats (%d) not expected (%d) value",
1981 : : test_params->bonding_port_id, (int)port_stats.opackets,
1982 : : burst_size);
1983 : :
1984 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
1985 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)10,
1986 : : "Port (%d) opackets stats (%d) not expected (%d) value",
1987 : : test_params->member_port_ids[0], (int)port_stats.opackets, 10);
1988 : :
1989 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
1990 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)0,
1991 : : "Port (%d) opackets stats (%d) not expected (%d) value",
1992 : : test_params->member_port_ids[1], (int)port_stats.opackets, 0);
1993 : :
1994 : 0 : rte_eth_stats_get(test_params->member_port_ids[2], &port_stats);
1995 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)10,
1996 : : "Port (%d) opackets stats (%d) not expected (%d) value",
1997 : : test_params->member_port_ids[2], (int)port_stats.opackets, 10);
1998 : :
1999 : 0 : rte_eth_stats_get(test_params->member_port_ids[3], &port_stats);
2000 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)0,
2001 : : "Port (%d) opackets stats (%d) not expected (%d) value",
2002 : : test_params->member_port_ids[3], (int)port_stats.opackets, 0);
2003 : :
2004 : : /* Verify that pkts are not sent on members with link status down:
2005 : : *
2006 : : * 1. Generate test bursts of traffic
2007 : : * 2. Add bursts on to virtual eth_devs
2008 : : * 3. Rx burst on bonding eth_dev, expected (burst_ size *
2009 : : * TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_MEMBER_COUNT) received
2010 : : * 4. Verify stats for bonding eth_dev
2011 : : * 6. Verify stats for member eth_devs (s0 = 10, s1 = 0, s2 = 10, s3 = 0)
2012 : : */
2013 [ # # ]: 0 : for (i = 0; i < TEST_RR_LINK_STATUS_MEMBER_COUNT; i++) {
2014 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
2015 : : &gen_pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0),
2016 : : burst_size, "failed to generate packet burst");
2017 : :
2018 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[i],
2019 : : &gen_pkt_burst[i][0], burst_size);
2020 : : }
2021 : :
2022 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_rx_burst(
2023 : : test_params->bonding_port_id, 0, rx_pkt_burst, MAX_PKT_BURST),
2024 : : burst_size + burst_size,
2025 : : "rte_eth_rx_burst failed");
2026 : :
2027 : : /* Verify bonding device rx count */
2028 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
2029 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets , (uint64_t)(burst_size + burst_size),
2030 : : "(%d) port_stats.ipackets not as expected\n",
2031 : : test_params->bonding_port_id);
2032 : :
2033 : : /* free mbufs */
2034 [ # # ]: 0 : for (i = 0; i < MAX_PKT_BURST; i++) {
2035 : 0 : rte_pktmbuf_free(rx_pkt_burst[i]);
2036 : : }
2037 : :
2038 : : /* Clean up and remove members from bonding device */
2039 : 0 : return remove_members_and_stop_bonding_device();
2040 : : }
2041 : :
2042 : : #define TEST_RR_POLLING_LINK_STATUS_MEMBER_COUNT (2)
2043 : :
2044 : : uint8_t polling_member_mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00 };
2045 : :
2046 : :
2047 : : int polling_test_members[TEST_RR_POLLING_LINK_STATUS_MEMBER_COUNT] = { -1, -1 };
2048 : :
2049 : : static int
2050 : 0 : test_roundrobin_verify_polling_member_link_status_change(void)
2051 : : {
2052 : : struct rte_ether_addr *mac_addr =
2053 : : (struct rte_ether_addr *)polling_member_mac;
2054 : : char member_name[RTE_ETH_NAME_MAX_LEN];
2055 : :
2056 : : int i;
2057 : :
2058 [ # # ]: 0 : for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_MEMBER_COUNT; i++) {
2059 : : /* Generate member name / MAC address */
2060 : : snprintf(member_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_poll_%d", i);
2061 : 0 : mac_addr->addr_bytes[RTE_ETHER_ADDR_LEN-1] = i;
2062 : :
2063 : : /* Create member devices with no ISR Support */
2064 [ # # ]: 0 : if (polling_test_members[i] == -1) {
2065 : 0 : polling_test_members[i] = virtual_ethdev_create(member_name, mac_addr,
2066 : 0 : rte_socket_id(), 0);
2067 [ # # ]: 0 : TEST_ASSERT(polling_test_members[i] >= 0,
2068 : : "Failed to create virtual ethdev %s\n", member_name);
2069 : :
2070 : : /* Configure member */
2071 [ # # ]: 0 : TEST_ASSERT_SUCCESS(configure_ethdev(polling_test_members[i], 0, 0),
2072 : : "Failed to configure virtual ethdev %s(%d)", member_name,
2073 : : polling_test_members[i]);
2074 : : }
2075 : :
2076 : : /* Add member to bonding device */
2077 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_member_add(test_params->bonding_port_id,
2078 : : polling_test_members[i]),
2079 : : "Failed to add member %s(%d) to bonding device %d",
2080 : : member_name, polling_test_members[i],
2081 : : test_params->bonding_port_id);
2082 : : }
2083 : :
2084 : : /* Initialize bonding device */
2085 [ # # ]: 0 : TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonding_port_id, 1, 1),
2086 : : "Failed to configure bonding device %d",
2087 : : test_params->bonding_port_id);
2088 : :
2089 : :
2090 : : /* Register link status change interrupt callback */
2091 : 0 : rte_eth_dev_callback_register(test_params->bonding_port_id,
2092 : : RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
2093 : 0 : &test_params->bonding_port_id);
2094 : :
2095 : : /* link status change callback for first member link up */
2096 : 0 : test_lsc_interrupt_count = 0;
2097 : :
2098 : 0 : virtual_ethdev_set_link_status(polling_test_members[0], 1);
2099 : :
2100 [ # # ]: 0 : TEST_ASSERT_SUCCESS(lsc_timeout(15000), "timed out waiting for interrupt");
2101 : :
2102 : :
2103 : : /* no link status change callback for second member link up */
2104 : 0 : test_lsc_interrupt_count = 0;
2105 : :
2106 : 0 : virtual_ethdev_set_link_status(polling_test_members[1], 1);
2107 : :
2108 [ # # ]: 0 : TEST_ASSERT_FAIL(lsc_timeout(15000), "unexpectedly succeeded");
2109 : :
2110 : : /* link status change callback for both member links down */
2111 : 0 : test_lsc_interrupt_count = 0;
2112 : :
2113 : 0 : virtual_ethdev_set_link_status(polling_test_members[0], 0);
2114 : 0 : virtual_ethdev_set_link_status(polling_test_members[1], 0);
2115 : :
2116 [ # # ]: 0 : TEST_ASSERT_SUCCESS(lsc_timeout(20000), "timed out waiting for interrupt");
2117 : :
2118 : : /* Un-Register link status change interrupt callback */
2119 : 0 : rte_eth_dev_callback_unregister(test_params->bonding_port_id,
2120 : : RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
2121 : 0 : &test_params->bonding_port_id);
2122 : :
2123 : :
2124 : : /* Clean up and remove members from bonding device */
2125 [ # # ]: 0 : for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_MEMBER_COUNT; i++) {
2126 : :
2127 [ # # ]: 0 : TEST_ASSERT_SUCCESS(
2128 : : rte_eth_bond_member_remove(test_params->bonding_port_id,
2129 : : polling_test_members[i]),
2130 : : "Failed to remove member %d from bonding port (%d)",
2131 : : polling_test_members[i], test_params->bonding_port_id);
2132 : : }
2133 : :
2134 : 0 : return remove_members_and_stop_bonding_device();
2135 : : }
2136 : :
2137 : :
2138 : : /** Active Backup Mode Tests */
2139 : :
2140 : : static int
2141 : 0 : test_activebackup_tx_burst(void)
2142 : : {
2143 : : int i, pktlen, primary_port, burst_size;
2144 : : struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
2145 : : struct rte_eth_stats port_stats;
2146 : :
2147 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
2148 : : BONDING_MODE_ACTIVE_BACKUP, 0, 1, 1),
2149 : : "Failed to initialize bonding device with members");
2150 : :
2151 : 0 : initialize_eth_header(test_params->pkt_eth_hdr,
2152 : : (struct rte_ether_addr *)src_mac,
2153 : : (struct rte_ether_addr *)dst_mac_0,
2154 : : RTE_ETHER_TYPE_IPV4, 0, 0);
2155 : 0 : pktlen = initialize_udp_header(test_params->pkt_udp_hdr, src_port,
2156 : : dst_port_0, 16);
2157 : 0 : pktlen = initialize_ipv4_header(test_params->pkt_ipv4_hdr, src_addr,
2158 : : dst_addr_0, pktlen);
2159 : :
2160 : 0 : burst_size = 20 * test_params->bonding_member_count;
2161 : :
2162 [ # # ]: 0 : TEST_ASSERT(burst_size < MAX_PKT_BURST,
2163 : : "Burst size specified is greater than supported.");
2164 : :
2165 : : /* Generate a burst of packets to transmit */
2166 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool, pkts_burst,
2167 : : test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
2168 : : test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN, 1),
2169 : : burst_size, "failed to generate burst correctly");
2170 : :
2171 : : /* Send burst on bonding port */
2172 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonding_port_id, 0, pkts_burst,
2173 : : burst_size), burst_size, "tx burst failed");
2174 : :
2175 : : /* Verify bonding port tx stats */
2176 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
2177 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
2178 : : "Bonding Port (%d) opackets value (%u) not as expected (%d)",
2179 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
2180 : : burst_size);
2181 : :
2182 : 0 : primary_port = rte_eth_bond_primary_get(test_params->bonding_port_id);
2183 : :
2184 : : /* Verify member ports tx stats */
2185 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
2186 : 0 : rte_eth_stats_get(test_params->member_port_ids[i], &port_stats);
2187 [ # # ]: 0 : if (test_params->member_port_ids[i] == primary_port) {
2188 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
2189 : : "Member Port (%d) opackets value (%u) not as expected (%d)",
2190 : : test_params->bonding_port_id,
2191 : : (unsigned int)port_stats.opackets,
2192 : : burst_size / test_params->bonding_member_count);
2193 : : } else {
2194 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, 0,
2195 : : "Member Port (%d) opackets value (%u) not as expected (%d)",
2196 : : test_params->bonding_port_id,
2197 : : (unsigned int)port_stats.opackets, 0);
2198 : : }
2199 : : }
2200 : :
2201 : : /* Put all members down and try and transmit */
2202 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
2203 : 0 : virtual_ethdev_simulate_link_status_interrupt(
2204 : 0 : test_params->member_port_ids[i], 0);
2205 : : }
2206 : :
2207 : : /* Send burst on bonding port */
2208 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonding_port_id, 0,
2209 : : pkts_burst, burst_size), 0, "Sending empty burst failed");
2210 : :
2211 : : /* Clean up and remove members from bonding device */
2212 : 0 : return remove_members_and_stop_bonding_device();
2213 : : }
2214 : :
2215 : : #define TEST_ACTIVE_BACKUP_RX_BURST_MEMBER_COUNT (4)
2216 : :
2217 : : static int
2218 : 0 : test_activebackup_rx_burst(void)
2219 : : {
2220 : 0 : struct rte_mbuf *gen_pkt_burst[MAX_PKT_BURST] = { NULL };
2221 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
2222 : :
2223 : : struct rte_eth_stats port_stats;
2224 : :
2225 : : int primary_port;
2226 : :
2227 : : int i, j, burst_size = 17;
2228 : :
2229 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
2230 : : BONDING_MODE_ACTIVE_BACKUP, 0,
2231 : : TEST_ACTIVE_BACKUP_RX_BURST_MEMBER_COUNT, 1),
2232 : : "Failed to initialize bonding device with members");
2233 : :
2234 : 0 : primary_port = rte_eth_bond_primary_get(test_params->bonding_port_id);
2235 [ # # ]: 0 : TEST_ASSERT(primary_port >= 0,
2236 : : "failed to get primary member for bonding port (%d)",
2237 : : test_params->bonding_port_id);
2238 : :
2239 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
2240 : : /* Generate test bursts of packets to transmit */
2241 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
2242 : : &gen_pkt_burst[0], burst_size, 0, 1, 0, 0, 0),
2243 : : burst_size, "burst generation failed");
2244 : :
2245 : : /* Add rx data to member */
2246 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[i],
2247 : : &gen_pkt_burst[0], burst_size);
2248 : :
2249 : : /* Call rx burst on bonding device */
2250 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_rx_burst(test_params->bonding_port_id, 0,
2251 : : &rx_pkt_burst[0], MAX_PKT_BURST), burst_size,
2252 : : "rte_eth_rx_burst failed");
2253 : :
2254 [ # # ]: 0 : if (test_params->member_port_ids[i] == primary_port) {
2255 : : /* Verify bonding device rx count */
2256 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
2257 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
2258 : : "Bonding Port (%d) ipackets value (%u) not as expected (%d)",
2259 : : test_params->bonding_port_id,
2260 : : (unsigned int)port_stats.ipackets, burst_size);
2261 : :
2262 : : /* Verify bonding member devices rx count */
2263 [ # # ]: 0 : for (j = 0; j < test_params->bonding_member_count; j++) {
2264 : 0 : rte_eth_stats_get(test_params->member_port_ids[j], &port_stats);
2265 [ # # ]: 0 : if (i == j) {
2266 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
2267 : : "Member Port (%d) ipackets value (%u) not as "
2268 : : "expected (%d)",
2269 : : test_params->member_port_ids[i],
2270 : : (unsigned int)port_stats.ipackets,
2271 : : burst_size);
2272 : : } else {
2273 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
2274 : : "Member Port (%d) ipackets value (%u) not as "
2275 : : "expected (%d)\n",
2276 : : test_params->member_port_ids[i],
2277 : : (unsigned int)port_stats.ipackets, 0);
2278 : : }
2279 : : }
2280 : : } else {
2281 [ # # ]: 0 : for (j = 0; j < test_params->bonding_member_count; j++) {
2282 : 0 : rte_eth_stats_get(test_params->member_port_ids[j], &port_stats);
2283 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
2284 : : "Member Port (%d) ipackets value (%u) not as expected "
2285 : : "(%d)", test_params->member_port_ids[i],
2286 : : (unsigned int)port_stats.ipackets, 0);
2287 : : }
2288 : : }
2289 : :
2290 : : /* free mbufs */
2291 : 0 : rte_pktmbuf_free_bulk(rx_pkt_burst, burst_size);
2292 : :
2293 : : /* reset bonding device stats */
2294 : 0 : rte_eth_stats_reset(test_params->bonding_port_id);
2295 : : }
2296 : :
2297 : : /* Clean up and remove members from bonding device */
2298 : 0 : return remove_members_and_stop_bonding_device();
2299 : : }
2300 : :
2301 : : static int
2302 : 0 : test_activebackup_verify_promiscuous_enable_disable(void)
2303 : : {
2304 : : int i, primary_port, promiscuous_en;
2305 : : int ret;
2306 : :
2307 : : /* Initialize bonding device with 4 members in round robin mode */
2308 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
2309 : : BONDING_MODE_ACTIVE_BACKUP, 0, 4, 1),
2310 : : "Failed to initialize bonding device with members");
2311 : :
2312 : 0 : primary_port = rte_eth_bond_primary_get(test_params->bonding_port_id);
2313 [ # # ]: 0 : TEST_ASSERT(primary_port >= 0,
2314 : : "failed to get primary member for bonding port (%d)",
2315 : : test_params->bonding_port_id);
2316 : :
2317 : 0 : ret = rte_eth_promiscuous_enable(test_params->bonding_port_id);
2318 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret,
2319 : : "Failed to enable promiscuous mode for port %d: %s",
2320 : : test_params->bonding_port_id, rte_strerror(-ret));
2321 : :
2322 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonding_port_id), 1,
2323 : : "Port (%d) promiscuous mode not enabled",
2324 : : test_params->bonding_port_id);
2325 : :
2326 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
2327 : 0 : promiscuous_en = rte_eth_promiscuous_get(
2328 : 0 : test_params->member_port_ids[i]);
2329 [ # # ]: 0 : if (primary_port == test_params->member_port_ids[i]) {
2330 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, 1,
2331 : : "member port (%d) promiscuous mode not enabled",
2332 : : test_params->member_port_ids[i]);
2333 : : } else {
2334 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, 0,
2335 : : "member port (%d) promiscuous mode enabled",
2336 : : test_params->member_port_ids[i]);
2337 : : }
2338 : :
2339 : : }
2340 : :
2341 : 0 : ret = rte_eth_promiscuous_disable(test_params->bonding_port_id);
2342 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret,
2343 : : "Failed to disable promiscuous mode for port %d: %s",
2344 : : test_params->bonding_port_id, rte_strerror(-ret));
2345 : :
2346 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonding_port_id), 0,
2347 : : "Port (%d) promiscuous mode not disabled\n",
2348 : : test_params->bonding_port_id);
2349 : :
2350 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
2351 : 0 : promiscuous_en = rte_eth_promiscuous_get(
2352 : 0 : test_params->member_port_ids[i]);
2353 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, 0,
2354 : : "member port (%d) promiscuous mode not disabled\n",
2355 : : test_params->member_port_ids[i]);
2356 : : }
2357 : :
2358 : : /* Clean up and remove members from bonding device */
2359 : 0 : return remove_members_and_stop_bonding_device();
2360 : : }
2361 : :
2362 : : static int
2363 : 0 : test_activebackup_verify_mac_assignment(void)
2364 : : {
2365 : : struct rte_ether_addr read_mac_addr;
2366 : : struct rte_ether_addr expected_mac_addr_0, expected_mac_addr_1;
2367 : :
2368 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0],
2369 : : &expected_mac_addr_0),
2370 : : "Failed to get mac address (port %d)",
2371 : : test_params->member_port_ids[0]);
2372 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1],
2373 : : &expected_mac_addr_1),
2374 : : "Failed to get mac address (port %d)",
2375 : : test_params->member_port_ids[1]);
2376 : :
2377 : : /* Initialize bonding device with 2 members in active backup mode */
2378 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
2379 : : BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1),
2380 : : "Failed to initialize bonding device with members");
2381 : :
2382 : : /* Verify that bonding MACs is that of first member and that the other member
2383 : : * MAC hasn't been changed */
2384 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
2385 : : "Failed to get mac address (port %d)",
2386 : : test_params->bonding_port_id);
2387 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
2388 : : sizeof(read_mac_addr)),
2389 : : "bonding port (%d) mac address not set to that of primary port",
2390 : : test_params->bonding_port_id);
2391 : :
2392 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
2393 : : "Failed to get mac address (port %d)",
2394 : : test_params->member_port_ids[0]);
2395 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
2396 : : sizeof(read_mac_addr)),
2397 : : "member port (%d) mac address not set to that of primary port",
2398 : : test_params->member_port_ids[0]);
2399 : :
2400 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
2401 : : "Failed to get mac address (port %d)",
2402 : : test_params->member_port_ids[1]);
2403 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
2404 : : sizeof(read_mac_addr)),
2405 : : "member port (%d) mac address not as expected",
2406 : : test_params->member_port_ids[1]);
2407 : :
2408 : : /* change primary and verify that MAC addresses haven't changed */
2409 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_primary_set(test_params->bonding_port_id,
2410 : : test_params->member_port_ids[1]), 0,
2411 : : "Failed to set bonding port (%d) primary port to (%d)",
2412 : : test_params->bonding_port_id, test_params->member_port_ids[1]);
2413 : :
2414 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
2415 : : "Failed to get mac address (port %d)",
2416 : : test_params->bonding_port_id);
2417 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
2418 : : sizeof(read_mac_addr)),
2419 : : "bonding port (%d) mac address not set to that of primary port",
2420 : : test_params->bonding_port_id);
2421 : :
2422 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
2423 : : "Failed to get mac address (port %d)",
2424 : : test_params->member_port_ids[0]);
2425 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
2426 : : sizeof(read_mac_addr)),
2427 : : "member port (%d) mac address not set to that of primary port",
2428 : : test_params->member_port_ids[0]);
2429 : :
2430 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
2431 : : "Failed to get mac address (port %d)",
2432 : : test_params->member_port_ids[1]);
2433 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
2434 : : sizeof(read_mac_addr)),
2435 : : "member port (%d) mac address not as expected",
2436 : : test_params->member_port_ids[1]);
2437 : :
2438 : : /*
2439 : : * stop / start bonding device and verify that primary MAC address is
2440 : : * propagated to bonding device and members.
2441 : : */
2442 : :
2443 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_stop(test_params->bonding_port_id),
2444 : : "Failed to stop bonding port %u",
2445 : : test_params->bonding_port_id);
2446 : :
2447 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonding_port_id),
2448 : : "Failed to start device");
2449 : :
2450 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
2451 : : "Failed to get mac address (port %d)",
2452 : : test_params->bonding_port_id);
2453 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
2454 : : sizeof(read_mac_addr)),
2455 : : "bonding port (%d) mac address not set to that of primary port",
2456 : : test_params->bonding_port_id);
2457 : :
2458 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
2459 : : "Failed to get mac address (port %d)",
2460 : : test_params->member_port_ids[0]);
2461 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
2462 : : sizeof(read_mac_addr)),
2463 : : "member port (%d) mac address not as expected",
2464 : : test_params->member_port_ids[0]);
2465 : :
2466 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
2467 : : "Failed to get mac address (port %d)",
2468 : : test_params->member_port_ids[1]);
2469 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
2470 : : sizeof(read_mac_addr)),
2471 : : "member port (%d) mac address not set to that of primary port",
2472 : : test_params->member_port_ids[1]);
2473 : :
2474 : : /* Set explicit MAC address */
2475 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
2476 : : test_params->bonding_port_id,
2477 : : (struct rte_ether_addr *)bonding_mac),
2478 : : "failed to set MAC address");
2479 : :
2480 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
2481 : : "Failed to get mac address (port %d)",
2482 : : test_params->bonding_port_id);
2483 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac, &read_mac_addr,
2484 : : sizeof(read_mac_addr)),
2485 : : "bonding port (%d) mac address not set to that of bonding port",
2486 : : test_params->bonding_port_id);
2487 : :
2488 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
2489 : : "Failed to get mac address (port %d)",
2490 : : test_params->member_port_ids[0]);
2491 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
2492 : : sizeof(read_mac_addr)),
2493 : : "member port (%d) mac address not as expected",
2494 : : test_params->member_port_ids[0]);
2495 : :
2496 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
2497 : : "Failed to get mac address (port %d)",
2498 : : test_params->member_port_ids[1]);
2499 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac, &read_mac_addr,
2500 : : sizeof(read_mac_addr)),
2501 : : "member port (%d) mac address not set to that of bonding port",
2502 : : test_params->member_port_ids[1]);
2503 : :
2504 : : /* Clean up and remove members from bonding device */
2505 : 0 : return remove_members_and_stop_bonding_device();
2506 : : }
2507 : :
2508 : : static int
2509 : 0 : test_activebackup_verify_member_link_status_change_failover(void)
2510 : : {
2511 : : struct rte_mbuf *pkt_burst[TEST_ACTIVE_BACKUP_RX_BURST_MEMBER_COUNT][MAX_PKT_BURST];
2512 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
2513 : : struct rte_eth_stats port_stats;
2514 : :
2515 : : uint16_t members[RTE_MAX_ETHPORTS];
2516 : :
2517 : : int i, burst_size, member_count, primary_port;
2518 : :
2519 : : burst_size = 21;
2520 : :
2521 : : memset(pkt_burst, 0, sizeof(pkt_burst));
2522 : :
2523 : : /* Generate packet burst for testing */
2524 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
2525 : : &pkt_burst[0][0], burst_size, 0, 1, 0, 0, 0), burst_size,
2526 : : "generate_test_burst failed");
2527 : :
2528 : : /* Initialize bonding device with 4 members in round robin mode */
2529 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
2530 : : BONDING_MODE_ACTIVE_BACKUP, 0,
2531 : : TEST_ACTIVE_BACKUP_RX_BURST_MEMBER_COUNT, 1),
2532 : : "Failed to initialize bonding device with members");
2533 : :
2534 : : /* Verify Current Members Count /Active Member Count is */
2535 : 0 : member_count = rte_eth_bond_members_get(test_params->bonding_port_id, members,
2536 : : RTE_MAX_ETHPORTS);
2537 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, 4,
2538 : : "Number of members (%d) is not as expected (%d).",
2539 : : member_count, 4);
2540 : :
2541 : 0 : member_count = rte_eth_bond_active_members_get(test_params->bonding_port_id,
2542 : : members, RTE_MAX_ETHPORTS);
2543 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, 4,
2544 : : "Number of active members (%d) is not as expected (%d).",
2545 : : member_count, 4);
2546 : :
2547 : 0 : primary_port = rte_eth_bond_primary_get(test_params->bonding_port_id);
2548 [ # # ]: 0 : TEST_ASSERT_EQUAL(primary_port, test_params->member_port_ids[0],
2549 : : "Primary port not as expected");
2550 : :
2551 : : /* Bring 2 members down and verify active member count */
2552 : 0 : virtual_ethdev_simulate_link_status_interrupt(
2553 : 0 : test_params->member_port_ids[1], 0);
2554 : 0 : virtual_ethdev_simulate_link_status_interrupt(
2555 : 0 : test_params->member_port_ids[3], 0);
2556 : :
2557 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_active_members_get(
2558 : : test_params->bonding_port_id, members, RTE_MAX_ETHPORTS), 2,
2559 : : "Number of active members (%d) is not as expected (%d).",
2560 : : member_count, 2);
2561 : :
2562 : 0 : virtual_ethdev_simulate_link_status_interrupt(
2563 : 0 : test_params->member_port_ids[1], 1);
2564 : 0 : virtual_ethdev_simulate_link_status_interrupt(
2565 : 0 : test_params->member_port_ids[3], 1);
2566 : :
2567 : :
2568 : : /* Bring primary port down, verify that active member count is 3 and primary
2569 : : * has changed */
2570 : 0 : virtual_ethdev_simulate_link_status_interrupt(
2571 : 0 : test_params->member_port_ids[0], 0);
2572 : :
2573 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_active_members_get(
2574 : : test_params->bonding_port_id, members, RTE_MAX_ETHPORTS),
2575 : : 3,
2576 : : "Number of active members (%d) is not as expected (%d).",
2577 : : member_count, 3);
2578 : :
2579 : 0 : primary_port = rte_eth_bond_primary_get(test_params->bonding_port_id);
2580 [ # # ]: 0 : TEST_ASSERT_EQUAL(primary_port, test_params->member_port_ids[2],
2581 : : "Primary port not as expected");
2582 : :
2583 : : /* Verify that pkts are sent on new primary member */
2584 : :
2585 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(
2586 : : test_params->bonding_port_id, 0, &pkt_burst[0][0],
2587 : : burst_size), burst_size, "rte_eth_tx_burst failed");
2588 : :
2589 : 0 : rte_eth_stats_get(test_params->member_port_ids[2], &port_stats);
2590 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
2591 : : "(%d) port_stats.opackets not as expected",
2592 : : test_params->member_port_ids[2]);
2593 : :
2594 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
2595 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, 0,
2596 : : "(%d) port_stats.opackets not as expected\n",
2597 : : test_params->member_port_ids[0]);
2598 : :
2599 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
2600 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, 0,
2601 : : "(%d) port_stats.opackets not as expected\n",
2602 : : test_params->member_port_ids[1]);
2603 : :
2604 : 0 : rte_eth_stats_get(test_params->member_port_ids[3], &port_stats);
2605 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, 0,
2606 : : "(%d) port_stats.opackets not as expected\n",
2607 : : test_params->member_port_ids[3]);
2608 : :
2609 : : /* Generate packet burst for testing */
2610 : :
2611 [ # # ]: 0 : for (i = 0; i < TEST_ACTIVE_BACKUP_RX_BURST_MEMBER_COUNT; i++) {
2612 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
2613 : : &pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0), burst_size,
2614 : : "generate_test_burst failed");
2615 : :
2616 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(
2617 : 0 : test_params->member_port_ids[i], &pkt_burst[i][0], burst_size);
2618 : : }
2619 : :
2620 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_rx_burst(
2621 : : test_params->bonding_port_id, 0, rx_pkt_burst, MAX_PKT_BURST),
2622 : : burst_size, "rte_eth_rx_burst\n");
2623 : :
2624 : : /* Verify bonding device rx count */
2625 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
2626 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
2627 : : "(%d) port_stats.ipackets not as expected",
2628 : : test_params->bonding_port_id);
2629 : :
2630 : 0 : rte_eth_stats_get(test_params->member_port_ids[2], &port_stats);
2631 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
2632 : : "(%d) port_stats.opackets not as expected",
2633 : : test_params->member_port_ids[2]);
2634 : :
2635 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
2636 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, 0,
2637 : : "(%d) port_stats.opackets not as expected",
2638 : : test_params->member_port_ids[0]);
2639 : :
2640 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
2641 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, 0,
2642 : : "(%d) port_stats.opackets not as expected",
2643 : : test_params->member_port_ids[1]);
2644 : :
2645 : 0 : rte_eth_stats_get(test_params->member_port_ids[3], &port_stats);
2646 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, 0,
2647 : : "(%d) port_stats.opackets not as expected",
2648 : : test_params->member_port_ids[3]);
2649 : :
2650 : : /* Clean up and remove members from bonding device */
2651 : 0 : return remove_members_and_stop_bonding_device();
2652 : : }
2653 : :
2654 : : /** Balance Mode Tests */
2655 : :
2656 : : static int
2657 : 0 : test_balance_xmit_policy_configuration(void)
2658 : : {
2659 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
2660 : : BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1),
2661 : : "Failed to initialize_bonding_device_with_members.");
2662 : :
2663 : : /* Invalid port id */
2664 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_xmit_policy_set(
2665 : : INVALID_PORT_ID, BALANCE_XMIT_POLICY_LAYER2),
2666 : : "Expected call to failed as invalid port specified.");
2667 : :
2668 : : /* Set xmit policy on non bonding device */
2669 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_xmit_policy_set(
2670 : : test_params->member_port_ids[0], BALANCE_XMIT_POLICY_LAYER2),
2671 : : "Expected call to failed as invalid port specified.");
2672 : :
2673 : :
2674 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
2675 : : test_params->bonding_port_id, BALANCE_XMIT_POLICY_LAYER2),
2676 : : "Failed to set balance xmit policy.");
2677 : :
2678 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_xmit_policy_get(test_params->bonding_port_id),
2679 : : BALANCE_XMIT_POLICY_LAYER2, "balance xmit policy not as expected.");
2680 : :
2681 : :
2682 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
2683 : : test_params->bonding_port_id, BALANCE_XMIT_POLICY_LAYER23),
2684 : : "Failed to set balance xmit policy.");
2685 : :
2686 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_xmit_policy_get(test_params->bonding_port_id),
2687 : : BALANCE_XMIT_POLICY_LAYER23,
2688 : : "balance xmit policy not as expected.");
2689 : :
2690 : :
2691 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
2692 : : test_params->bonding_port_id, BALANCE_XMIT_POLICY_LAYER34),
2693 : : "Failed to set balance xmit policy.");
2694 : :
2695 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_xmit_policy_get(test_params->bonding_port_id),
2696 : : BALANCE_XMIT_POLICY_LAYER34,
2697 : : "balance xmit policy not as expected.");
2698 : :
2699 : : /* Invalid port id */
2700 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_eth_bond_xmit_policy_get(INVALID_PORT_ID),
2701 : : "Expected call to failed as invalid port specified.");
2702 : :
2703 : : /* Clean up and remove members from bonding device */
2704 : 0 : return remove_members_and_stop_bonding_device();
2705 : : }
2706 : :
2707 : : #define TEST_BALANCE_L2_TX_BURST_MEMBER_COUNT (2)
2708 : :
2709 : : static int
2710 : 0 : test_balance_l2_tx_burst(void)
2711 : : {
2712 : : struct rte_mbuf *pkts_burst[TEST_BALANCE_L2_TX_BURST_MEMBER_COUNT][MAX_PKT_BURST];
2713 : 0 : int burst_size[TEST_BALANCE_L2_TX_BURST_MEMBER_COUNT] = { 10, 15 };
2714 : :
2715 : : uint16_t pktlen;
2716 : : int i;
2717 : : struct rte_eth_stats port_stats;
2718 : :
2719 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
2720 : : BONDING_MODE_BALANCE, 0, TEST_BALANCE_L2_TX_BURST_MEMBER_COUNT, 1),
2721 : : "Failed to initialize_bonding_device_with_members.");
2722 : :
2723 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
2724 : : test_params->bonding_port_id, BALANCE_XMIT_POLICY_LAYER2),
2725 : : "Failed to set balance xmit policy.");
2726 : :
2727 : 0 : initialize_eth_header(test_params->pkt_eth_hdr,
2728 : : (struct rte_ether_addr *)src_mac,
2729 : : (struct rte_ether_addr *)dst_mac_0,
2730 : : RTE_ETHER_TYPE_IPV4, 0, 0);
2731 : 0 : pktlen = initialize_udp_header(test_params->pkt_udp_hdr, src_port,
2732 : : dst_port_0, 16);
2733 : 0 : pktlen = initialize_ipv4_header(test_params->pkt_ipv4_hdr, src_addr,
2734 : : dst_addr_0, pktlen);
2735 : :
2736 : : /* Generate a burst 1 of packets to transmit */
2737 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
2738 : : test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
2739 : : test_params->pkt_udp_hdr, burst_size[0],
2740 : : PACKET_BURST_GEN_PKT_LEN, 1), burst_size[0],
2741 : : "failed to generate packet burst");
2742 : :
2743 : 0 : initialize_eth_header(test_params->pkt_eth_hdr,
2744 : : (struct rte_ether_addr *)src_mac,
2745 : : (struct rte_ether_addr *)dst_mac_1,
2746 : : RTE_ETHER_TYPE_IPV4, 0, 0);
2747 : :
2748 : : /* Generate a burst 2 of packets to transmit */
2749 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
2750 : : test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
2751 : : test_params->pkt_udp_hdr, burst_size[1],
2752 : : PACKET_BURST_GEN_PKT_LEN, 1), burst_size[1],
2753 : : "failed to generate packet burst");
2754 : :
2755 : : /* Send burst 1 on bonding port */
2756 [ # # ]: 0 : for (i = 0; i < TEST_BALANCE_L2_TX_BURST_MEMBER_COUNT; i++) {
2757 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonding_port_id, 0,
2758 : : &pkts_burst[i][0], burst_size[i]),
2759 : : burst_size[i], "Failed to transmit packet burst");
2760 : : }
2761 : :
2762 : : /* Verify bonding port tx stats */
2763 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
2764 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
2765 : : (uint64_t)(burst_size[0] + burst_size[1]),
2766 : : "Bonding Port (%d) opackets value (%u) not as expected (%d)",
2767 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
2768 : : burst_size[0] + burst_size[1]);
2769 : :
2770 : :
2771 : : /* Verify member ports tx stats */
2772 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
2773 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size[0],
2774 : : "Member Port (%d) opackets value (%u) not as expected (%d)",
2775 : : test_params->member_port_ids[0], (unsigned int)port_stats.opackets,
2776 : : burst_size[0]);
2777 : :
2778 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
2779 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size[1],
2780 : : "Member Port (%d) opackets value (%u) not as expected (%d)\n",
2781 : : test_params->member_port_ids[1], (unsigned int)port_stats.opackets,
2782 : : burst_size[1]);
2783 : :
2784 : : /* Put all members down and try and transmit */
2785 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
2786 : :
2787 : 0 : virtual_ethdev_simulate_link_status_interrupt(
2788 : 0 : test_params->member_port_ids[i], 0);
2789 : : }
2790 : :
2791 : : /* Send burst on bonding port */
2792 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(
2793 : : test_params->bonding_port_id, 0, &pkts_burst[0][0], burst_size[0]),
2794 : : 0, "Expected zero packet");
2795 : :
2796 : : /* Clean up and remove members from bonding device */
2797 : 0 : return remove_members_and_stop_bonding_device();
2798 : : }
2799 : :
2800 : : static int
2801 : 0 : balance_l23_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
2802 : : uint8_t toggle_mac_addr, uint8_t toggle_ip_addr)
2803 : : {
2804 : : int i, burst_size_1, burst_size_2, nb_tx_1, nb_tx_2;
2805 : :
2806 : : struct rte_mbuf *pkts_burst_1[MAX_PKT_BURST];
2807 : : struct rte_mbuf *pkts_burst_2[MAX_PKT_BURST];
2808 : :
2809 : : struct rte_eth_stats port_stats;
2810 : :
2811 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
2812 : : BONDING_MODE_BALANCE, 0, 2, 1),
2813 : : "Failed to initialize_bonding_device_with_members.");
2814 : :
2815 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
2816 : : test_params->bonding_port_id, BALANCE_XMIT_POLICY_LAYER23),
2817 : : "Failed to set balance xmit policy.");
2818 : :
2819 : : burst_size_1 = 20;
2820 : : burst_size_2 = 10;
2821 : :
2822 : : TEST_ASSERT(burst_size_1 < MAX_PKT_BURST || burst_size_2 < MAX_PKT_BURST,
2823 : : "Burst size specified is greater than supported.");
2824 : :
2825 : : /* Generate test bursts of packets to transmit */
2826 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
2827 : : pkts_burst_1, burst_size_1, vlan_enabled, ipv4, 0, 0, 0),
2828 : : burst_size_1, "failed to generate packet burst");
2829 : :
2830 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2, burst_size_2, vlan_enabled, ipv4,
2831 : : toggle_mac_addr, toggle_ip_addr, 0), burst_size_2,
2832 : : "failed to generate packet burst");
2833 : :
2834 : : /* Send burst 1 on bonding port */
2835 : 0 : nb_tx_1 = rte_eth_tx_burst(test_params->bonding_port_id, 0, pkts_burst_1,
2836 : : burst_size_1);
2837 [ # # ]: 0 : TEST_ASSERT_EQUAL(nb_tx_1, burst_size_1, "tx burst failed");
2838 : :
2839 : : /* Send burst 2 on bonding port */
2840 : 0 : nb_tx_2 = rte_eth_tx_burst(test_params->bonding_port_id, 0, pkts_burst_2,
2841 : : burst_size_2);
2842 [ # # ]: 0 : TEST_ASSERT_EQUAL(nb_tx_2, burst_size_2, "tx burst failed");
2843 : :
2844 : : /* Verify bonding port tx stats */
2845 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
2846 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(nb_tx_1 + nb_tx_2),
2847 : : "Bonding Port (%d) opackets value (%u) not as expected (%d)",
2848 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
2849 : : nb_tx_1 + nb_tx_2);
2850 : :
2851 : : /* Verify member ports tx stats */
2852 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
2853 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)nb_tx_1,
2854 : : "Member Port (%d) opackets value (%u) not as expected (%d)",
2855 : : test_params->member_port_ids[0], (unsigned int)port_stats.opackets,
2856 : : nb_tx_1);
2857 : :
2858 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
2859 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)nb_tx_2,
2860 : : "Member Port (%d) opackets value (%u) not as expected (%d)",
2861 : : test_params->member_port_ids[1], (unsigned int)port_stats.opackets,
2862 : : nb_tx_2);
2863 : :
2864 : : /* Put all members down and try and transmit */
2865 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
2866 : :
2867 : 0 : virtual_ethdev_simulate_link_status_interrupt(
2868 : 0 : test_params->member_port_ids[i], 0);
2869 : : }
2870 : :
2871 : : /* Send burst on bonding port */
2872 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(
2873 : : test_params->bonding_port_id, 0, pkts_burst_1,
2874 : : burst_size_1), 0, "Expected zero packet");
2875 : :
2876 : :
2877 : : /* Clean up and remove members from bonding device */
2878 : 0 : return remove_members_and_stop_bonding_device();
2879 : : }
2880 : :
2881 : : static int
2882 : 0 : test_balance_l23_tx_burst_ipv4_toggle_ip_addr(void)
2883 : : {
2884 : 0 : return balance_l23_tx_burst(0, 1, 0, 1);
2885 : : }
2886 : :
2887 : : static int
2888 : 0 : test_balance_l23_tx_burst_vlan_ipv4_toggle_ip_addr(void)
2889 : : {
2890 : 0 : return balance_l23_tx_burst(1, 1, 0, 1);
2891 : : }
2892 : :
2893 : : static int
2894 : 0 : test_balance_l23_tx_burst_ipv6_toggle_ip_addr(void)
2895 : : {
2896 : 0 : return balance_l23_tx_burst(0, 0, 0, 1);
2897 : : }
2898 : :
2899 : : static int
2900 : 0 : test_balance_l23_tx_burst_vlan_ipv6_toggle_ip_addr(void)
2901 : : {
2902 : 0 : return balance_l23_tx_burst(1, 0, 0, 1);
2903 : : }
2904 : :
2905 : : static int
2906 : 0 : test_balance_l23_tx_burst_toggle_mac_addr(void)
2907 : : {
2908 : 0 : return balance_l23_tx_burst(0, 0, 1, 0);
2909 : : }
2910 : :
2911 : : static int
2912 : 0 : balance_l34_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
2913 : : uint8_t toggle_mac_addr, uint8_t toggle_ip_addr,
2914 : : uint8_t toggle_udp_port)
2915 : : {
2916 : : int i, burst_size_1, burst_size_2, nb_tx_1, nb_tx_2;
2917 : :
2918 : : struct rte_mbuf *pkts_burst_1[MAX_PKT_BURST];
2919 : : struct rte_mbuf *pkts_burst_2[MAX_PKT_BURST];
2920 : :
2921 : : struct rte_eth_stats port_stats;
2922 : :
2923 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
2924 : : BONDING_MODE_BALANCE, 0, 2, 1),
2925 : : "Failed to initialize_bonding_device_with_members.");
2926 : :
2927 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
2928 : : test_params->bonding_port_id, BALANCE_XMIT_POLICY_LAYER34),
2929 : : "Failed to set balance xmit policy.");
2930 : :
2931 : : burst_size_1 = 20;
2932 : : burst_size_2 = 10;
2933 : :
2934 : : TEST_ASSERT(burst_size_1 < MAX_PKT_BURST || burst_size_2 < MAX_PKT_BURST,
2935 : : "Burst size specified is greater than supported.");
2936 : :
2937 : : /* Generate test bursts of packets to transmit */
2938 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
2939 : : pkts_burst_1, burst_size_1, vlan_enabled, ipv4, 0, 0, 0),
2940 : : burst_size_1, "failed to generate burst");
2941 : :
2942 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2, burst_size_2,
2943 : : vlan_enabled, ipv4, toggle_mac_addr, toggle_ip_addr,
2944 : : toggle_udp_port), burst_size_2, "failed to generate burst");
2945 : :
2946 : : /* Send burst 1 on bonding port */
2947 : 0 : nb_tx_1 = rte_eth_tx_burst(test_params->bonding_port_id, 0, pkts_burst_1,
2948 : : burst_size_1);
2949 [ # # ]: 0 : TEST_ASSERT_EQUAL(nb_tx_1, burst_size_1, "tx burst failed");
2950 : :
2951 : : /* Send burst 2 on bonding port */
2952 : 0 : nb_tx_2 = rte_eth_tx_burst(test_params->bonding_port_id, 0, pkts_burst_2,
2953 : : burst_size_2);
2954 [ # # ]: 0 : TEST_ASSERT_EQUAL(nb_tx_2, burst_size_2, "tx burst failed");
2955 : :
2956 : :
2957 : : /* Verify bonding port tx stats */
2958 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
2959 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(nb_tx_1 + nb_tx_2),
2960 : : "Bonding Port (%d) opackets value (%u) not as expected (%d)",
2961 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
2962 : : nb_tx_1 + nb_tx_2);
2963 : :
2964 : : /* Verify member ports tx stats */
2965 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
2966 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)nb_tx_1,
2967 : : "Member Port (%d) opackets value (%u) not as expected (%d)",
2968 : : test_params->member_port_ids[0], (unsigned int)port_stats.opackets,
2969 : : nb_tx_1);
2970 : :
2971 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
2972 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)nb_tx_2,
2973 : : "Member Port (%d) opackets value (%u) not as expected (%d)",
2974 : : test_params->member_port_ids[1], (unsigned int)port_stats.opackets,
2975 : : nb_tx_2);
2976 : :
2977 : : /* Put all members down and try and transmit */
2978 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
2979 : :
2980 : 0 : virtual_ethdev_simulate_link_status_interrupt(
2981 : 0 : test_params->member_port_ids[i], 0);
2982 : : }
2983 : :
2984 : : /* Send burst on bonding port */
2985 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(
2986 : : test_params->bonding_port_id, 0, pkts_burst_1,
2987 : : burst_size_1), 0, "Expected zero packet");
2988 : :
2989 : : /* Clean up and remove members from bonding device */
2990 : 0 : return remove_members_and_stop_bonding_device();
2991 : : }
2992 : :
2993 : : static int
2994 : 0 : test_balance_l34_tx_burst_ipv4_toggle_ip_addr(void)
2995 : : {
2996 : 0 : return balance_l34_tx_burst(0, 1, 0, 1, 0);
2997 : : }
2998 : :
2999 : : static int
3000 : 0 : test_balance_l34_tx_burst_ipv4_toggle_udp_port(void)
3001 : : {
3002 : 0 : return balance_l34_tx_burst(0, 1, 0, 0, 1);
3003 : : }
3004 : :
3005 : : static int
3006 : 0 : test_balance_l34_tx_burst_vlan_ipv4_toggle_ip_addr(void)
3007 : : {
3008 : 0 : return balance_l34_tx_burst(1, 1, 0, 1, 0);
3009 : : }
3010 : :
3011 : : static int
3012 : 0 : test_balance_l34_tx_burst_ipv6_toggle_ip_addr(void)
3013 : : {
3014 : 0 : return balance_l34_tx_burst(0, 0, 0, 1, 0);
3015 : : }
3016 : :
3017 : : static int
3018 : 0 : test_balance_l34_tx_burst_vlan_ipv6_toggle_ip_addr(void)
3019 : : {
3020 : 0 : return balance_l34_tx_burst(1, 0, 0, 1, 0);
3021 : : }
3022 : :
3023 : : static int
3024 : 0 : test_balance_l34_tx_burst_ipv6_toggle_udp_port(void)
3025 : : {
3026 : 0 : return balance_l34_tx_burst(0, 0, 0, 0, 1);
3027 : : }
3028 : :
3029 : : #define TEST_BAL_MEMBER_TX_FAIL_MEMBER_COUNT (2)
3030 : : #define TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1 (40)
3031 : : #define TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2 (20)
3032 : : #define TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT (25)
3033 : : #define TEST_BAL_MEMBER_TX_FAIL_FAILING_MEMBER_IDX (0)
3034 : :
3035 : : static int
3036 : 0 : test_balance_tx_burst_member_tx_fail(void)
3037 : : {
3038 : : struct rte_mbuf *pkts_burst_1[TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1];
3039 : : struct rte_mbuf *pkts_burst_2[TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2];
3040 : :
3041 : : struct rte_mbuf *expected_fail_pkts[TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT];
3042 : :
3043 : : struct rte_eth_stats port_stats;
3044 : :
3045 : : int i, first_tx_fail_idx, tx_count_1, tx_count_2;
3046 : :
3047 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
3048 : : BONDING_MODE_BALANCE, 0,
3049 : : TEST_BAL_MEMBER_TX_FAIL_MEMBER_COUNT, 1),
3050 : : "Failed to initialise bonding device");
3051 : :
3052 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
3053 : : test_params->bonding_port_id, BALANCE_XMIT_POLICY_LAYER2),
3054 : : "Failed to set balance xmit policy.");
3055 : :
3056 : :
3057 : : /* Generate test bursts for transmission */
3058 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_1,
3059 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1, 0, 0, 0, 0, 0),
3060 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1,
3061 : : "Failed to generate test packet burst 1");
3062 : :
3063 : : first_tx_fail_idx = TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1 -
3064 : : TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT;
3065 : :
3066 : : /* copy mbuf references for expected transmission failures */
3067 [ # # ]: 0 : for (i = 0; i < TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT; i++)
3068 : 0 : expected_fail_pkts[i] = pkts_burst_1[i + first_tx_fail_idx];
3069 : :
3070 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2,
3071 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2, 0, 0, 1, 0, 0),
3072 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2,
3073 : : "Failed to generate test packet burst 2");
3074 : :
3075 : :
3076 : : /*
3077 : : * Set virtual member TEST_BAL_MEMBER_TX_FAIL_FAILING_MEMBER_IDX to only fail
3078 : : * transmission of TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT packets of burst.
3079 : : */
3080 : 0 : virtual_ethdev_tx_burst_fn_set_success(
3081 : 0 : test_params->member_port_ids[TEST_BAL_MEMBER_TX_FAIL_FAILING_MEMBER_IDX],
3082 : : 0);
3083 : :
3084 : 0 : virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
3085 : 0 : test_params->member_port_ids[TEST_BAL_MEMBER_TX_FAIL_FAILING_MEMBER_IDX],
3086 : : TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT);
3087 : :
3088 : :
3089 : : /* Transmit burst 1 */
3090 : 0 : tx_count_1 = rte_eth_tx_burst(test_params->bonding_port_id, 0, pkts_burst_1,
3091 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1);
3092 : :
3093 [ # # ]: 0 : TEST_ASSERT_EQUAL(tx_count_1, TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1 -
3094 : : TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT,
3095 : : "Transmitted (%d) packets, expected to transmit (%d) packets",
3096 : : tx_count_1, TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1 -
3097 : : TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT);
3098 : :
3099 : : /* Verify that failed packet are expected failed packets */
3100 [ # # ]: 0 : for (i = 0; i < TEST_RR_MEMBER_TX_FAIL_PACKETS_COUNT; i++) {
3101 [ # # ]: 0 : TEST_ASSERT_EQUAL(expected_fail_pkts[i], pkts_burst_1[i + tx_count_1],
3102 : : "expected mbuf (%d) pointer %p not expected pointer %p",
3103 : : i, expected_fail_pkts[i], pkts_burst_1[i + tx_count_1]);
3104 : : }
3105 : :
3106 : : /* Transmit burst 2 */
3107 : 0 : tx_count_2 = rte_eth_tx_burst(test_params->bonding_port_id, 0, pkts_burst_2,
3108 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2);
3109 : :
3110 [ # # ]: 0 : TEST_ASSERT_EQUAL(tx_count_2, TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2,
3111 : : "Transmitted (%d) packets, expected to transmit (%d) packets",
3112 : : tx_count_2, TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2);
3113 : :
3114 : :
3115 : : /* Verify bonding port tx stats */
3116 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
3117 : :
3118 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
3119 : : (uint64_t)((TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1 -
3120 : : TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT) +
3121 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2),
3122 : : "Bonding Port (%d) opackets value (%u) not as expected (%d)",
3123 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
3124 : : (TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1 -
3125 : : TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT) +
3126 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2);
3127 : :
3128 : : /* Verify member ports tx stats */
3129 : :
3130 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
3131 : :
3132 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)
3133 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1 -
3134 : : TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT,
3135 : : "Member Port (%d) opackets value (%u) not as expected (%d)",
3136 : : test_params->member_port_ids[0],
3137 : : (unsigned int)port_stats.opackets,
3138 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_1 -
3139 : : TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT);
3140 : :
3141 : :
3142 : :
3143 : :
3144 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
3145 : :
3146 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
3147 : : (uint64_t)TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2,
3148 : : "Member Port (%d) opackets value (%u) not as expected (%d)",
3149 : : test_params->member_port_ids[1],
3150 : : (unsigned int)port_stats.opackets,
3151 : : TEST_BAL_MEMBER_TX_FAIL_BURST_SIZE_2);
3152 : :
3153 : : /* Verify that all mbufs have a ref value of zero */
3154 [ # # ]: 0 : TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkts_burst_1[tx_count_1],
3155 : : TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT, 1),
3156 : : "mbufs refcnts not as expected");
3157 : :
3158 : : free_mbufs(&pkts_burst_1[tx_count_1],
3159 : : TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT);
3160 : :
3161 : : /* Clean up and remove members from bonding device */
3162 : 0 : return remove_members_and_stop_bonding_device();
3163 : : }
3164 : :
3165 : : #define TEST_BALANCE_RX_BURST_MEMBER_COUNT (3)
3166 : :
3167 : : static int
3168 : 0 : test_balance_rx_burst(void)
3169 : : {
3170 : : struct rte_mbuf *gen_pkt_burst[TEST_BALANCE_RX_BURST_MEMBER_COUNT][MAX_PKT_BURST];
3171 : :
3172 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
3173 : : struct rte_eth_stats port_stats;
3174 : :
3175 : 0 : int burst_size[TEST_BALANCE_RX_BURST_MEMBER_COUNT] = { 10, 5, 30 };
3176 : : int i, j;
3177 : :
3178 : : memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
3179 : :
3180 : : /* Initialize bonding device with 4 members in round robin mode */
3181 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
3182 : : BONDING_MODE_BALANCE, 0, 3, 1),
3183 : : "Failed to initialise bonding device");
3184 : :
3185 : : /* Generate test bursts of packets to transmit */
3186 [ # # ]: 0 : for (i = 0; i < TEST_BALANCE_RX_BURST_MEMBER_COUNT; i++) {
3187 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
3188 : : &gen_pkt_burst[i][0], burst_size[i], 0, 0, 1,
3189 : : 0, 0), burst_size[i],
3190 : : "failed to generate packet burst");
3191 : : }
3192 : :
3193 : : /* Add rx data to members */
3194 [ # # ]: 0 : for (i = 0; i < TEST_BALANCE_RX_BURST_MEMBER_COUNT; i++) {
3195 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[i],
3196 : : &gen_pkt_burst[i][0], burst_size[i]);
3197 : : }
3198 : :
3199 : : /* Call rx burst on bonding device */
3200 : : /* Send burst on bonding port */
3201 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_rx_burst(test_params->bonding_port_id, 0,
3202 : : rx_pkt_burst, MAX_PKT_BURST),
3203 : : burst_size[0] + burst_size[1] + burst_size[2],
3204 : : "balance rx burst failed\n");
3205 : :
3206 : : /* Verify bonding device rx count */
3207 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
3208 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets,
3209 : : (uint64_t)(burst_size[0] + burst_size[1] + burst_size[2]),
3210 : : "Bonding Port (%d) ipackets value (%u) not as expected (%d)",
3211 : : test_params->bonding_port_id, (unsigned int)port_stats.ipackets,
3212 : : burst_size[0] + burst_size[1] + burst_size[2]);
3213 : :
3214 : :
3215 : : /* Verify bonding member devices rx counts */
3216 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
3217 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[0],
3218 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
3219 : : test_params->member_port_ids[0],
3220 : : (unsigned int)port_stats.ipackets, burst_size[0]);
3221 : :
3222 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
3223 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[1],
3224 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
3225 : : test_params->member_port_ids[1], (unsigned int)port_stats.ipackets,
3226 : : burst_size[1]);
3227 : :
3228 : 0 : rte_eth_stats_get(test_params->member_port_ids[2], &port_stats);
3229 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[2],
3230 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
3231 : : test_params->member_port_ids[2], (unsigned int)port_stats.ipackets,
3232 : : burst_size[2]);
3233 : :
3234 : 0 : rte_eth_stats_get(test_params->member_port_ids[3], &port_stats);
3235 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
3236 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
3237 : : test_params->member_port_ids[3], (unsigned int)port_stats.ipackets,
3238 : : 0);
3239 : :
3240 : : /* free mbufs */
3241 [ # # ]: 0 : for (i = 0; i < TEST_BALANCE_RX_BURST_MEMBER_COUNT; i++) {
3242 [ # # ]: 0 : for (j = 0; j < MAX_PKT_BURST; j++) {
3243 [ # # ]: 0 : if (gen_pkt_burst[i][j] != NULL) {
3244 : 0 : rte_pktmbuf_free(gen_pkt_burst[i][j]);
3245 : 0 : gen_pkt_burst[i][j] = NULL;
3246 : : }
3247 : : }
3248 : : }
3249 : :
3250 : : /* Clean up and remove members from bonding device */
3251 : 0 : return remove_members_and_stop_bonding_device();
3252 : : }
3253 : :
3254 : : static int
3255 : 0 : test_balance_verify_promiscuous_enable_disable(void)
3256 : : {
3257 : : int i;
3258 : : int ret;
3259 : :
3260 : : /* Initialize bonding device with 4 members in round robin mode */
3261 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
3262 : : BONDING_MODE_BALANCE, 0, 4, 1),
3263 : : "Failed to initialise bonding device");
3264 : :
3265 : 0 : ret = rte_eth_promiscuous_enable(test_params->bonding_port_id);
3266 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret,
3267 : : "Failed to enable promiscuous mode for port %d: %s",
3268 : : test_params->bonding_port_id, rte_strerror(-ret));
3269 : :
3270 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonding_port_id), 1,
3271 : : "Port (%d) promiscuous mode not enabled",
3272 : : test_params->bonding_port_id);
3273 : :
3274 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
3275 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(
3276 : : test_params->member_port_ids[i]), 1,
3277 : : "Port (%d) promiscuous mode not enabled",
3278 : : test_params->member_port_ids[i]);
3279 : : }
3280 : :
3281 : 0 : ret = rte_eth_promiscuous_disable(test_params->bonding_port_id);
3282 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret,
3283 : : "Failed to disable promiscuous mode for port %d: %s",
3284 : : test_params->bonding_port_id, rte_strerror(-ret));
3285 : :
3286 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonding_port_id), 0,
3287 : : "Port (%d) promiscuous mode not disabled",
3288 : : test_params->bonding_port_id);
3289 : :
3290 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
3291 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(
3292 : : test_params->member_port_ids[i]), 0,
3293 : : "Port (%d) promiscuous mode not disabled",
3294 : : test_params->member_port_ids[i]);
3295 : : }
3296 : :
3297 : : /* Clean up and remove members from bonding device */
3298 : 0 : return remove_members_and_stop_bonding_device();
3299 : : }
3300 : :
3301 : : static int
3302 : 0 : test_balance_verify_mac_assignment(void)
3303 : : {
3304 : : struct rte_ether_addr read_mac_addr;
3305 : : struct rte_ether_addr expected_mac_addr_0, expected_mac_addr_1;
3306 : :
3307 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0],
3308 : : &expected_mac_addr_0),
3309 : : "Failed to get mac address (port %d)",
3310 : : test_params->member_port_ids[0]);
3311 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1],
3312 : : &expected_mac_addr_1),
3313 : : "Failed to get mac address (port %d)",
3314 : : test_params->member_port_ids[1]);
3315 : :
3316 : : /* Initialize bonding device with 2 members in active backup mode */
3317 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
3318 : : BONDING_MODE_BALANCE, 0, 2, 1),
3319 : : "Failed to initialise bonding device");
3320 : :
3321 : : /* Verify that bonding MACs is that of first member and that the other member
3322 : : * MAC hasn't been changed */
3323 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
3324 : : "Failed to get mac address (port %d)",
3325 : : test_params->bonding_port_id);
3326 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
3327 : : sizeof(read_mac_addr)),
3328 : : "bonding port (%d) mac address not set to that of primary port",
3329 : : test_params->bonding_port_id);
3330 : :
3331 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
3332 : : "Failed to get mac address (port %d)",
3333 : : test_params->member_port_ids[0]);
3334 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
3335 : : sizeof(read_mac_addr)),
3336 : : "member port (%d) mac address not set to that of primary port",
3337 : : test_params->member_port_ids[0]);
3338 : :
3339 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
3340 : : "Failed to get mac address (port %d)",
3341 : : test_params->member_port_ids[1]);
3342 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
3343 : : sizeof(read_mac_addr)),
3344 : : "member port (%d) mac address not set to that of primary port",
3345 : : test_params->member_port_ids[1]);
3346 : :
3347 : : /* change primary and verify that MAC addresses haven't changed */
3348 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(test_params->bonding_port_id,
3349 : : test_params->member_port_ids[1]),
3350 : : "Failed to set bonding port (%d) primary port to (%d)\n",
3351 : : test_params->bonding_port_id, test_params->member_port_ids[1]);
3352 : :
3353 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
3354 : : "Failed to get mac address (port %d)",
3355 : : test_params->bonding_port_id);
3356 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
3357 : : sizeof(read_mac_addr)),
3358 : : "bonding port (%d) mac address not set to that of primary port",
3359 : : test_params->bonding_port_id);
3360 : :
3361 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
3362 : : "Failed to get mac address (port %d)",
3363 : : test_params->member_port_ids[0]);
3364 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
3365 : : sizeof(read_mac_addr)),
3366 : : "member port (%d) mac address not set to that of primary port",
3367 : : test_params->member_port_ids[0]);
3368 : :
3369 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
3370 : : "Failed to get mac address (port %d)",
3371 : : test_params->member_port_ids[1]);
3372 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
3373 : : sizeof(read_mac_addr)),
3374 : : "member port (%d) mac address not set to that of primary port",
3375 : : test_params->member_port_ids[1]);
3376 : :
3377 : : /*
3378 : : * stop / start bonding device and verify that primary MAC address is
3379 : : * propagated to bonding device and members.
3380 : : */
3381 : :
3382 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_stop(test_params->bonding_port_id),
3383 : : "Failed to stop bonding port %u",
3384 : : test_params->bonding_port_id);
3385 : :
3386 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonding_port_id),
3387 : : "Failed to start bonding device");
3388 : :
3389 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
3390 : : "Failed to get mac address (port %d)",
3391 : : test_params->bonding_port_id);
3392 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
3393 : : sizeof(read_mac_addr)),
3394 : : "bonding port (%d) mac address not set to that of primary port",
3395 : : test_params->bonding_port_id);
3396 : :
3397 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
3398 : : "Failed to get mac address (port %d)",
3399 : : test_params->member_port_ids[0]);
3400 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
3401 : : sizeof(read_mac_addr)),
3402 : : "member port (%d) mac address not set to that of primary port",
3403 : : test_params->member_port_ids[0]);
3404 : :
3405 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
3406 : : "Failed to get mac address (port %d)",
3407 : : test_params->member_port_ids[1]);
3408 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
3409 : : sizeof(read_mac_addr)),
3410 : : "member port (%d) mac address not set to that of primary port",
3411 : : test_params->member_port_ids[1]);
3412 : :
3413 : : /* Set explicit MAC address */
3414 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
3415 : : test_params->bonding_port_id,
3416 : : (struct rte_ether_addr *)bonding_mac),
3417 : : "failed to set MAC");
3418 : :
3419 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
3420 : : "Failed to get mac address (port %d)",
3421 : : test_params->bonding_port_id);
3422 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac, &read_mac_addr,
3423 : : sizeof(read_mac_addr)),
3424 : : "bonding port (%d) mac address not set to that of bonding port",
3425 : : test_params->bonding_port_id);
3426 : :
3427 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
3428 : : "Failed to get mac address (port %d)",
3429 : : test_params->member_port_ids[0]);
3430 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac, &read_mac_addr,
3431 : : sizeof(read_mac_addr)),
3432 : : "member port (%d) mac address not as expected\n",
3433 : : test_params->member_port_ids[0]);
3434 : :
3435 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
3436 : : "Failed to get mac address (port %d)",
3437 : : test_params->member_port_ids[1]);
3438 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac, &read_mac_addr,
3439 : : sizeof(read_mac_addr)),
3440 : : "member port (%d) mac address not set to that of bonding port",
3441 : : test_params->member_port_ids[1]);
3442 : :
3443 : : /* Clean up and remove members from bonding device */
3444 : 0 : return remove_members_and_stop_bonding_device();
3445 : : }
3446 : :
3447 : : #define TEST_BALANCE_LINK_STATUS_MEMBER_COUNT (4)
3448 : :
3449 : : static int
3450 : 0 : test_balance_verify_member_link_status_change_behaviour(void)
3451 : : {
3452 : : struct rte_mbuf *pkt_burst[TEST_BALANCE_LINK_STATUS_MEMBER_COUNT][MAX_PKT_BURST];
3453 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
3454 : : struct rte_eth_stats port_stats;
3455 : :
3456 : : uint16_t members[RTE_MAX_ETHPORTS];
3457 : :
3458 : : int i, burst_size, member_count;
3459 : :
3460 : : memset(pkt_burst, 0, sizeof(pkt_burst));
3461 : :
3462 : : /* Initialize bonding device with 4 members in round robin mode */
3463 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
3464 : : BONDING_MODE_BALANCE, 0, TEST_BALANCE_LINK_STATUS_MEMBER_COUNT, 1),
3465 : : "Failed to initialise bonding device");
3466 : :
3467 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
3468 : : test_params->bonding_port_id, BALANCE_XMIT_POLICY_LAYER2),
3469 : : "Failed to set balance xmit policy.");
3470 : :
3471 : :
3472 : : /* Verify Current Members Count /Active Member Count is */
3473 : 0 : member_count = rte_eth_bond_members_get(test_params->bonding_port_id, members,
3474 : : RTE_MAX_ETHPORTS);
3475 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, TEST_BALANCE_LINK_STATUS_MEMBER_COUNT,
3476 : : "Number of members (%d) is not as expected (%d).",
3477 : : member_count, TEST_BALANCE_LINK_STATUS_MEMBER_COUNT);
3478 : :
3479 : 0 : member_count = rte_eth_bond_active_members_get(test_params->bonding_port_id,
3480 : : members, RTE_MAX_ETHPORTS);
3481 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, TEST_BALANCE_LINK_STATUS_MEMBER_COUNT,
3482 : : "Number of active members (%d) is not as expected (%d).",
3483 : : member_count, TEST_BALANCE_LINK_STATUS_MEMBER_COUNT);
3484 : :
3485 : : /* Set 2 members link status to down */
3486 : 0 : virtual_ethdev_simulate_link_status_interrupt(
3487 : 0 : test_params->member_port_ids[1], 0);
3488 : 0 : virtual_ethdev_simulate_link_status_interrupt(
3489 : 0 : test_params->member_port_ids[3], 0);
3490 : :
3491 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_active_members_get(
3492 : : test_params->bonding_port_id, members, RTE_MAX_ETHPORTS), 2,
3493 : : "Number of active members (%d) is not as expected (%d).",
3494 : : member_count, 2);
3495 : :
3496 : : /*
3497 : : * Send to sets of packet burst and verify that they are balanced across
3498 : : * members.
3499 : : */
3500 : : burst_size = 21;
3501 : :
3502 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
3503 : : &pkt_burst[0][0], burst_size, 0, 1, 0, 0, 0), burst_size,
3504 : : "generate_test_burst failed");
3505 : :
3506 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
3507 : : &pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
3508 : : "generate_test_burst failed");
3509 : :
3510 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(
3511 : : test_params->bonding_port_id, 0, &pkt_burst[0][0], burst_size),
3512 : : burst_size, "rte_eth_tx_burst failed");
3513 : :
3514 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(
3515 : : test_params->bonding_port_id, 0, &pkt_burst[1][0], burst_size),
3516 : : burst_size, "rte_eth_tx_burst failed");
3517 : :
3518 : :
3519 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
3520 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
3521 : : "(%d) port_stats.opackets (%d) not as expected (%d).",
3522 : : test_params->bonding_port_id, (int)port_stats.opackets,
3523 : : burst_size + burst_size);
3524 : :
3525 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
3526 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
3527 : : "(%d) port_stats.opackets (%d) not as expected (%d).",
3528 : : test_params->member_port_ids[0], (int)port_stats.opackets,
3529 : : burst_size);
3530 : :
3531 : 0 : rte_eth_stats_get(test_params->member_port_ids[2], &port_stats);
3532 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
3533 : : "(%d) port_stats.opackets (%d) not as expected (%d).",
3534 : : test_params->member_port_ids[2], (int)port_stats.opackets,
3535 : : burst_size);
3536 : :
3537 : : /* verify that all packets get send on primary member when no other members
3538 : : * are available */
3539 : 0 : virtual_ethdev_simulate_link_status_interrupt(
3540 : 0 : test_params->member_port_ids[2], 0);
3541 : :
3542 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_active_members_get(
3543 : : test_params->bonding_port_id, members, RTE_MAX_ETHPORTS), 1,
3544 : : "Number of active members (%d) is not as expected (%d).",
3545 : : member_count, 1);
3546 : :
3547 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
3548 : : &pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
3549 : : "generate_test_burst failed");
3550 : :
3551 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(
3552 : : test_params->bonding_port_id, 0, &pkt_burst[1][0], burst_size),
3553 : : burst_size, "rte_eth_tx_burst failed");
3554 : :
3555 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
3556 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
3557 : : (uint64_t)(burst_size + burst_size + burst_size),
3558 : : "(%d) port_stats.opackets (%d) not as expected (%d).\n",
3559 : : test_params->bonding_port_id, (int)port_stats.opackets,
3560 : : burst_size + burst_size + burst_size);
3561 : :
3562 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
3563 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
3564 : : "(%d) port_stats.opackets (%d) not as expected (%d).",
3565 : : test_params->member_port_ids[0], (int)port_stats.opackets,
3566 : : burst_size + burst_size);
3567 : :
3568 : 0 : virtual_ethdev_simulate_link_status_interrupt(
3569 : 0 : test_params->member_port_ids[0], 0);
3570 : 0 : virtual_ethdev_simulate_link_status_interrupt(
3571 : 0 : test_params->member_port_ids[1], 1);
3572 : 0 : virtual_ethdev_simulate_link_status_interrupt(
3573 : 0 : test_params->member_port_ids[2], 1);
3574 : 0 : virtual_ethdev_simulate_link_status_interrupt(
3575 : 0 : test_params->member_port_ids[3], 1);
3576 : :
3577 [ # # ]: 0 : for (i = 0; i < TEST_BALANCE_LINK_STATUS_MEMBER_COUNT; i++) {
3578 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
3579 : : &pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0), burst_size,
3580 : : "Failed to generate packet burst");
3581 : :
3582 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[i],
3583 : : &pkt_burst[i][0], burst_size);
3584 : : }
3585 : :
3586 : : /* Verify that pkts are not received on members with link status down */
3587 : :
3588 : 0 : rte_eth_rx_burst(test_params->bonding_port_id, 0, rx_pkt_burst,
3589 : : MAX_PKT_BURST);
3590 : :
3591 : : /* Verify bonding device rx count */
3592 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
3593 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)(burst_size * 3),
3594 : : "(%d) port_stats.ipackets (%d) not as expected (%d)\n",
3595 : : test_params->bonding_port_id, (int)port_stats.ipackets,
3596 : : burst_size * 3);
3597 : :
3598 : : /* Clean up and remove members from bonding device */
3599 : 0 : return remove_members_and_stop_bonding_device();
3600 : : }
3601 : :
3602 : : static int
3603 : 0 : test_broadcast_tx_burst(void)
3604 : : {
3605 : : int i, pktlen, burst_size;
3606 : : struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
3607 : :
3608 : : struct rte_eth_stats port_stats;
3609 : :
3610 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
3611 : : BONDING_MODE_BROADCAST, 0, 2, 1),
3612 : : "Failed to initialise bonding device");
3613 : :
3614 : 0 : initialize_eth_header(test_params->pkt_eth_hdr,
3615 : : (struct rte_ether_addr *)src_mac,
3616 : : (struct rte_ether_addr *)dst_mac_0,
3617 : : RTE_ETHER_TYPE_IPV4, 0, 0);
3618 : :
3619 : 0 : pktlen = initialize_udp_header(test_params->pkt_udp_hdr, src_port,
3620 : : dst_port_0, 16);
3621 : 0 : pktlen = initialize_ipv4_header(test_params->pkt_ipv4_hdr, src_addr,
3622 : : dst_addr_0, pktlen);
3623 : :
3624 : 0 : burst_size = 20 * test_params->bonding_member_count;
3625 : :
3626 [ # # ]: 0 : TEST_ASSERT(burst_size < MAX_PKT_BURST,
3627 : : "Burst size specified is greater than supported.");
3628 : :
3629 : : /* Generate a burst of packets to transmit */
3630 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool,
3631 : : pkts_burst, test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
3632 : : 1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN,
3633 : : 1), burst_size, "Failed to generate packet burst");
3634 : :
3635 : : /* Send burst on bonding port */
3636 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonding_port_id, 0,
3637 : : pkts_burst, burst_size), burst_size,
3638 : : "Bonding Port (%d) rx burst failed, packets transmitted value "
3639 : : "not as expected (%d)",
3640 : : test_params->bonding_port_id, burst_size);
3641 : :
3642 : : /* Verify bonding port tx stats */
3643 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
3644 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
3645 : : (uint64_t)burst_size * test_params->bonding_member_count,
3646 : : "Bonding Port (%d) opackets value (%u) not as expected (%d)",
3647 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
3648 : : burst_size);
3649 : :
3650 : : /* Verify member ports tx stats */
3651 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
3652 : 0 : rte_eth_stats_get(test_params->member_port_ids[i], &port_stats);
3653 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
3654 : : "Member Port (%d) opackets value (%u) not as expected (%d)\n",
3655 : : test_params->bonding_port_id,
3656 : : (unsigned int)port_stats.opackets, burst_size);
3657 : : }
3658 : :
3659 : : /* Put all members down and try and transmit */
3660 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
3661 : :
3662 : 0 : virtual_ethdev_simulate_link_status_interrupt(
3663 : 0 : test_params->member_port_ids[i], 0);
3664 : : }
3665 : :
3666 : : /* Send burst on bonding port */
3667 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(
3668 : : test_params->bonding_port_id, 0, pkts_burst, burst_size), 0,
3669 : : "transmitted an unexpected number of packets");
3670 : :
3671 : : /* Clean up and remove members from bonding device */
3672 : 0 : return remove_members_and_stop_bonding_device();
3673 : : }
3674 : :
3675 : :
3676 : : #define TEST_BCAST_MEMBER_TX_FAIL_MEMBER_COUNT (3)
3677 : : #define TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE (40)
3678 : : #define TEST_BCAST_MEMBER_TX_FAIL_MAX_PACKETS_COUNT (15)
3679 : : #define TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT (10)
3680 : :
3681 : : static int
3682 : 0 : test_broadcast_tx_burst_member_tx_fail(void)
3683 : : {
3684 : : struct rte_mbuf *pkts_burst[TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE];
3685 : : struct rte_mbuf *expected_fail_pkts[TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT];
3686 : :
3687 : : struct rte_eth_stats port_stats;
3688 : :
3689 : : int i, tx_count;
3690 : :
3691 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
3692 : : BONDING_MODE_BROADCAST, 0,
3693 : : TEST_BCAST_MEMBER_TX_FAIL_MEMBER_COUNT, 1),
3694 : : "Failed to initialise bonding device");
3695 : :
3696 : : /* Generate test bursts for transmission */
3697 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst,
3698 : : TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE, 0, 0, 0, 0, 0),
3699 : : TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE,
3700 : : "Failed to generate test packet burst");
3701 : :
3702 [ # # ]: 0 : for (i = 0; i < TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT; i++) {
3703 : 0 : expected_fail_pkts[i] = pkts_burst[TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE -
3704 : 0 : TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT + i];
3705 : : }
3706 : :
3707 : : /*
3708 : : * Set virtual member TEST_BAL_MEMBER_TX_FAIL_FAILING_MEMBER_IDX to only fail
3709 : : * transmission of TEST_BAL_MEMBER_TX_FAIL_PACKETS_COUNT packets of burst.
3710 : : */
3711 : 0 : virtual_ethdev_tx_burst_fn_set_success(
3712 : 0 : test_params->member_port_ids[0],
3713 : : 0);
3714 : 0 : virtual_ethdev_tx_burst_fn_set_success(
3715 : 0 : test_params->member_port_ids[1],
3716 : : 0);
3717 : 0 : virtual_ethdev_tx_burst_fn_set_success(
3718 : 0 : test_params->member_port_ids[2],
3719 : : 0);
3720 : :
3721 : 0 : virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
3722 : 0 : test_params->member_port_ids[0],
3723 : : TEST_BCAST_MEMBER_TX_FAIL_MAX_PACKETS_COUNT);
3724 : :
3725 : 0 : virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
3726 : 0 : test_params->member_port_ids[1],
3727 : : TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT);
3728 : :
3729 : 0 : virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
3730 : 0 : test_params->member_port_ids[2],
3731 : : TEST_BCAST_MEMBER_TX_FAIL_MAX_PACKETS_COUNT);
3732 : :
3733 : : /* Transmit burst */
3734 : 0 : tx_count = rte_eth_tx_burst(test_params->bonding_port_id, 0, pkts_burst,
3735 : : TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE);
3736 : :
3737 [ # # ]: 0 : TEST_ASSERT_EQUAL(tx_count, TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE -
3738 : : TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT,
3739 : : "Transmitted (%d) packets, expected to transmit (%d) packets",
3740 : : tx_count, TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE -
3741 : : TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT);
3742 : :
3743 : : /* Verify that failed packet are expected failed packets */
3744 [ # # ]: 0 : for (i = 0; i < TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT; i++) {
3745 [ # # ]: 0 : TEST_ASSERT_EQUAL(expected_fail_pkts[i], pkts_burst[i + tx_count],
3746 : : "expected mbuf (%d) pointer %p not expected pointer %p",
3747 : : i, expected_fail_pkts[i], pkts_burst[i + tx_count]);
3748 : : }
3749 : :
3750 : : /* Verify member ports tx stats */
3751 : :
3752 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
3753 : :
3754 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
3755 : : (uint64_t)TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE -
3756 : : TEST_BCAST_MEMBER_TX_FAIL_MAX_PACKETS_COUNT,
3757 : : "Port (%d) opackets value (%u) not as expected (%d)",
3758 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
3759 : : TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE -
3760 : : TEST_BCAST_MEMBER_TX_FAIL_MAX_PACKETS_COUNT);
3761 : :
3762 : :
3763 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
3764 : :
3765 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
3766 : : (uint64_t)TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE -
3767 : : TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT,
3768 : : "Port (%d) opackets value (%u) not as expected (%d)",
3769 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
3770 : : TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE -
3771 : : TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT);
3772 : :
3773 : 0 : rte_eth_stats_get(test_params->member_port_ids[2], &port_stats);
3774 : :
3775 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets,
3776 : : (uint64_t)TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE -
3777 : : TEST_BCAST_MEMBER_TX_FAIL_MAX_PACKETS_COUNT,
3778 : : "Port (%d) opackets value (%u) not as expected (%d)",
3779 : : test_params->bonding_port_id, (unsigned int)port_stats.opackets,
3780 : : TEST_BCAST_MEMBER_TX_FAIL_BURST_SIZE -
3781 : : TEST_BCAST_MEMBER_TX_FAIL_MAX_PACKETS_COUNT);
3782 : :
3783 : :
3784 : : /* Verify that all mbufs who transmission failed have a ref value of one */
3785 [ # # ]: 0 : TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkts_burst[tx_count],
3786 : : TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT, 1),
3787 : : "mbufs refcnts not as expected");
3788 : :
3789 : : free_mbufs(&pkts_burst[tx_count],
3790 : : TEST_BCAST_MEMBER_TX_FAIL_MIN_PACKETS_COUNT);
3791 : :
3792 : : /* Clean up and remove members from bonding device */
3793 : 0 : return remove_members_and_stop_bonding_device();
3794 : : }
3795 : :
3796 : : #define BROADCAST_RX_BURST_NUM_OF_MEMBERS (3)
3797 : :
3798 : : static int
3799 : 0 : test_broadcast_rx_burst(void)
3800 : : {
3801 : : struct rte_mbuf *gen_pkt_burst[BROADCAST_RX_BURST_NUM_OF_MEMBERS][MAX_PKT_BURST];
3802 : :
3803 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
3804 : : struct rte_eth_stats port_stats;
3805 : :
3806 : 0 : int burst_size[BROADCAST_RX_BURST_NUM_OF_MEMBERS] = { 10, 5, 30 };
3807 : : int i, j;
3808 : :
3809 : : memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
3810 : :
3811 : : /* Initialize bonding device with 4 members in round robin mode */
3812 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
3813 : : BONDING_MODE_BROADCAST, 0, 3, 1),
3814 : : "Failed to initialise bonding device");
3815 : :
3816 : : /* Generate test bursts of packets to transmit */
3817 [ # # ]: 0 : for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_MEMBERS; i++) {
3818 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
3819 : : &gen_pkt_burst[i][0], burst_size[i], 0, 0, 1, 0, 0),
3820 : : burst_size[i], "failed to generate packet burst");
3821 : : }
3822 : :
3823 : : /* Add rx data to member 0 */
3824 [ # # ]: 0 : for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_MEMBERS; i++) {
3825 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[i],
3826 : : &gen_pkt_burst[i][0], burst_size[i]);
3827 : : }
3828 : :
3829 : :
3830 : : /* Call rx burst on bonding device */
3831 : : /* Send burst on bonding port */
3832 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_rx_burst(
3833 : : test_params->bonding_port_id, 0, rx_pkt_burst, MAX_PKT_BURST),
3834 : : burst_size[0] + burst_size[1] + burst_size[2],
3835 : : "rx burst failed");
3836 : :
3837 : : /* Verify bonding device rx count */
3838 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
3839 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets,
3840 : : (uint64_t)(burst_size[0] + burst_size[1] + burst_size[2]),
3841 : : "Bonding Port (%d) ipackets value (%u) not as expected (%d)",
3842 : : test_params->bonding_port_id, (unsigned int)port_stats.ipackets,
3843 : : burst_size[0] + burst_size[1] + burst_size[2]);
3844 : :
3845 : :
3846 : : /* Verify bonding member devices rx counts */
3847 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
3848 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[0],
3849 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
3850 : : test_params->member_port_ids[0], (unsigned int)port_stats.ipackets,
3851 : : burst_size[0]);
3852 : :
3853 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
3854 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[1],
3855 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
3856 : : test_params->member_port_ids[0], (unsigned int)port_stats.ipackets,
3857 : : burst_size[1]);
3858 : :
3859 : 0 : rte_eth_stats_get(test_params->member_port_ids[2], &port_stats);
3860 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[2],
3861 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
3862 : : test_params->member_port_ids[2], (unsigned int)port_stats.ipackets,
3863 : : burst_size[2]);
3864 : :
3865 : 0 : rte_eth_stats_get(test_params->member_port_ids[3], &port_stats);
3866 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
3867 : : "Member Port (%d) ipackets value (%u) not as expected (%d)",
3868 : : test_params->member_port_ids[3], (unsigned int)port_stats.ipackets,
3869 : : 0);
3870 : :
3871 : : /* free mbufs allocate for rx testing */
3872 [ # # ]: 0 : for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_MEMBERS; i++) {
3873 [ # # ]: 0 : for (j = 0; j < MAX_PKT_BURST; j++) {
3874 [ # # ]: 0 : if (gen_pkt_burst[i][j] != NULL) {
3875 : 0 : rte_pktmbuf_free(gen_pkt_burst[i][j]);
3876 : 0 : gen_pkt_burst[i][j] = NULL;
3877 : : }
3878 : : }
3879 : : }
3880 : :
3881 : : /* Clean up and remove members from bonding device */
3882 : 0 : return remove_members_and_stop_bonding_device();
3883 : : }
3884 : :
3885 : : static int
3886 : 0 : test_broadcast_verify_promiscuous_enable_disable(void)
3887 : : {
3888 : : int i;
3889 : : int ret;
3890 : :
3891 : : /* Initialize bonding device with 4 members in round robin mode */
3892 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
3893 : : BONDING_MODE_BROADCAST, 0, 4, 1),
3894 : : "Failed to initialise bonding device");
3895 : :
3896 : 0 : ret = rte_eth_promiscuous_enable(test_params->bonding_port_id);
3897 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret,
3898 : : "Failed to enable promiscuous mode for port %d: %s",
3899 : : test_params->bonding_port_id, rte_strerror(-ret));
3900 : :
3901 : :
3902 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonding_port_id), 1,
3903 : : "Port (%d) promiscuous mode not enabled",
3904 : : test_params->bonding_port_id);
3905 : :
3906 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
3907 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(
3908 : : test_params->member_port_ids[i]), 1,
3909 : : "Port (%d) promiscuous mode not enabled",
3910 : : test_params->member_port_ids[i]);
3911 : : }
3912 : :
3913 : 0 : ret = rte_eth_promiscuous_disable(test_params->bonding_port_id);
3914 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret,
3915 : : "Failed to disable promiscuous mode for port %d: %s",
3916 : : test_params->bonding_port_id, rte_strerror(-ret));
3917 : :
3918 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonding_port_id), 0,
3919 : : "Port (%d) promiscuous mode not disabled",
3920 : : test_params->bonding_port_id);
3921 : :
3922 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
3923 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(
3924 : : test_params->member_port_ids[i]), 0,
3925 : : "Port (%d) promiscuous mode not disabled",
3926 : : test_params->member_port_ids[i]);
3927 : : }
3928 : :
3929 : : /* Clean up and remove members from bonding device */
3930 : 0 : return remove_members_and_stop_bonding_device();
3931 : : }
3932 : :
3933 : : static int
3934 : 0 : test_broadcast_verify_mac_assignment(void)
3935 : : {
3936 : : struct rte_ether_addr read_mac_addr;
3937 : : struct rte_ether_addr expected_mac_addr_0, expected_mac_addr_1;
3938 : :
3939 : : int i;
3940 : :
3941 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0],
3942 : : &expected_mac_addr_0),
3943 : : "Failed to get mac address (port %d)",
3944 : : test_params->member_port_ids[0]);
3945 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[2],
3946 : : &expected_mac_addr_1),
3947 : : "Failed to get mac address (port %d)",
3948 : : test_params->member_port_ids[2]);
3949 : :
3950 : : /* Initialize bonding device with 4 members in round robin mode */
3951 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
3952 : : BONDING_MODE_BROADCAST, 0, 4, 1),
3953 : : "Failed to initialise bonding device");
3954 : :
3955 : : /* Verify that all MACs are the same as first member added to bonding
3956 : : * device */
3957 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
3958 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[i],
3959 : : &read_mac_addr),
3960 : : "Failed to get mac address (port %d)",
3961 : : test_params->member_port_ids[i]);
3962 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
3963 : : sizeof(read_mac_addr)),
3964 : : "member port (%d) mac address not set to that of primary port",
3965 : : test_params->member_port_ids[i]);
3966 : : }
3967 : :
3968 : : /* change primary and verify that MAC addresses haven't changed */
3969 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(test_params->bonding_port_id,
3970 : : test_params->member_port_ids[2]),
3971 : : "Failed to set bonding port (%d) primary port to (%d)",
3972 : : test_params->bonding_port_id, test_params->member_port_ids[i]);
3973 : :
3974 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
3975 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[i],
3976 : : &read_mac_addr),
3977 : : "Failed to get mac address (port %d)",
3978 : : test_params->member_port_ids[i]);
3979 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
3980 : : sizeof(read_mac_addr)),
3981 : : "member port (%d) mac address has changed to that of primary "
3982 : : "port without stop/start toggle of bonding device",
3983 : : test_params->member_port_ids[i]);
3984 : : }
3985 : :
3986 : : /*
3987 : : * stop / start bonding device and verify that primary MAC address is
3988 : : * propagated to bonding device and members.
3989 : : */
3990 : :
3991 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_stop(test_params->bonding_port_id),
3992 : : "Failed to stop bonding port %u",
3993 : : test_params->bonding_port_id);
3994 : :
3995 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonding_port_id),
3996 : : "Failed to start bonding device");
3997 : :
3998 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
3999 : : "Failed to get mac address (port %d)",
4000 : : test_params->bonding_port_id);
4001 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
4002 : : sizeof(read_mac_addr)),
4003 : : "bonding port (%d) mac address not set to that of new primary port",
4004 : : test_params->member_port_ids[i]);
4005 : :
4006 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
4007 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[i],
4008 : : &read_mac_addr),
4009 : : "Failed to get mac address (port %d)",
4010 : : test_params->member_port_ids[i]);
4011 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
4012 : : sizeof(read_mac_addr)),
4013 : : "member port (%d) mac address not set to that of new primary "
4014 : : "port", test_params->member_port_ids[i]);
4015 : : }
4016 : :
4017 : : /* Set explicit MAC address */
4018 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
4019 : : test_params->bonding_port_id,
4020 : : (struct rte_ether_addr *)bonding_mac),
4021 : : "Failed to set MAC address");
4022 : :
4023 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
4024 : : "Failed to get mac address (port %d)",
4025 : : test_params->bonding_port_id);
4026 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(bonding_mac, &read_mac_addr,
4027 : : sizeof(read_mac_addr)),
4028 : : "bonding port (%d) mac address not set to that of new primary port",
4029 : : test_params->member_port_ids[i]);
4030 : :
4031 : :
4032 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
4033 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[i],
4034 : : &read_mac_addr),
4035 : : "Failed to get mac address (port %d)",
4036 : : test_params->member_port_ids[i]);
4037 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(bonding_mac, &read_mac_addr,
4038 : : sizeof(read_mac_addr)),
4039 : : "member port (%d) mac address not set to that of new primary "
4040 : : "port", test_params->member_port_ids[i]);
4041 : : }
4042 : :
4043 : : /* Clean up and remove members from bonding device */
4044 : 0 : return remove_members_and_stop_bonding_device();
4045 : : }
4046 : :
4047 : : #define BROADCAST_LINK_STATUS_NUM_OF_MEMBERS (4)
4048 : : static int
4049 : 0 : test_broadcast_verify_member_link_status_change_behaviour(void)
4050 : : {
4051 : : struct rte_mbuf *pkt_burst[BROADCAST_LINK_STATUS_NUM_OF_MEMBERS][MAX_PKT_BURST];
4052 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
4053 : : struct rte_eth_stats port_stats;
4054 : :
4055 : : uint16_t members[RTE_MAX_ETHPORTS];
4056 : :
4057 : : int i, burst_size, member_count;
4058 : :
4059 : : memset(pkt_burst, 0, sizeof(pkt_burst));
4060 : :
4061 : : /* Initialize bonding device with 4 members in round robin mode */
4062 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
4063 : : BONDING_MODE_BROADCAST, 0, BROADCAST_LINK_STATUS_NUM_OF_MEMBERS,
4064 : : 1), "Failed to initialise bonding device");
4065 : :
4066 : : /* Verify Current Members Count /Active Member Count is */
4067 : 0 : member_count = rte_eth_bond_members_get(test_params->bonding_port_id, members,
4068 : : RTE_MAX_ETHPORTS);
4069 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, 4,
4070 : : "Number of members (%d) is not as expected (%d).",
4071 : : member_count, 4);
4072 : :
4073 : 0 : member_count = rte_eth_bond_active_members_get(test_params->bonding_port_id,
4074 : : members, RTE_MAX_ETHPORTS);
4075 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, 4,
4076 : : "Number of active members (%d) is not as expected (%d).",
4077 : : member_count, 4);
4078 : :
4079 : : /* Set 2 members link status to down */
4080 : 0 : virtual_ethdev_simulate_link_status_interrupt(
4081 : 0 : test_params->member_port_ids[1], 0);
4082 : 0 : virtual_ethdev_simulate_link_status_interrupt(
4083 : 0 : test_params->member_port_ids[3], 0);
4084 : :
4085 : 0 : member_count = rte_eth_bond_active_members_get(test_params->bonding_port_id,
4086 : : members, RTE_MAX_ETHPORTS);
4087 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, 2,
4088 : : "Number of active members (%d) is not as expected (%d).",
4089 : : member_count, 2);
4090 : :
4091 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++)
4092 : 0 : rte_eth_stats_reset(test_params->member_port_ids[i]);
4093 : :
4094 : : /* Verify that pkts are not sent on members with link status down */
4095 : : burst_size = 21;
4096 : :
4097 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
4098 : : &pkt_burst[0][0], burst_size, 0, 0, 1, 0, 0), burst_size,
4099 : : "generate_test_burst failed");
4100 : :
4101 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonding_port_id, 0,
4102 : : &pkt_burst[0][0], burst_size), burst_size,
4103 : : "rte_eth_tx_burst failed\n");
4104 : :
4105 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
4106 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size * member_count),
4107 : : "(%d) port_stats.opackets (%d) not as expected (%d)\n",
4108 : : test_params->bonding_port_id, (int)port_stats.opackets,
4109 : : burst_size * member_count);
4110 : :
4111 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
4112 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
4113 : : "(%d) port_stats.opackets not as expected",
4114 : : test_params->member_port_ids[0]);
4115 : :
4116 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
4117 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, 0,
4118 : : "(%d) port_stats.opackets not as expected",
4119 : : test_params->member_port_ids[1]);
4120 : :
4121 : 0 : rte_eth_stats_get(test_params->member_port_ids[2], &port_stats);
4122 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
4123 : : "(%d) port_stats.opackets not as expected",
4124 : : test_params->member_port_ids[2]);
4125 : :
4126 : :
4127 : 0 : rte_eth_stats_get(test_params->member_port_ids[3], &port_stats);
4128 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, 0,
4129 : : "(%d) port_stats.opackets not as expected",
4130 : : test_params->member_port_ids[3]);
4131 : :
4132 : :
4133 [ # # ]: 0 : for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_MEMBERS; i++) {
4134 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
4135 : : &pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0),
4136 : : burst_size, "failed to generate packet burst");
4137 : :
4138 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[i],
4139 : : &pkt_burst[i][0], burst_size);
4140 : : }
4141 : :
4142 : : /* Verify that pkts are not received on members with link status down */
4143 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_rx_burst(
4144 : : test_params->bonding_port_id, 0, rx_pkt_burst, MAX_PKT_BURST),
4145 : : burst_size + burst_size, "rte_eth_rx_burst failed");
4146 : :
4147 : :
4148 : : /* Verify bonding device rx count */
4149 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
4150 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)(burst_size + burst_size),
4151 : : "(%d) port_stats.ipackets not as expected\n",
4152 : : test_params->bonding_port_id);
4153 : :
4154 : : /* Clean up and remove members from bonding device */
4155 : 0 : return remove_members_and_stop_bonding_device();
4156 : : }
4157 : :
4158 : : static int
4159 : 0 : test_reconfigure_bonding_device(void)
4160 : : {
4161 : 0 : test_params->nb_rx_q = 4;
4162 : 0 : test_params->nb_tx_q = 4;
4163 : :
4164 [ # # ]: 0 : TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonding_port_id, 0, 0),
4165 : : "failed to reconfigure bonding device");
4166 : :
4167 : 0 : test_params->nb_rx_q = 2;
4168 : 0 : test_params->nb_tx_q = 2;
4169 : :
4170 [ # # ]: 0 : TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonding_port_id, 0, 0),
4171 : : "failed to reconfigure bonding device with less rx/tx queues");
4172 : :
4173 : : return 0;
4174 : : }
4175 : :
4176 : :
4177 : : static int
4178 : 0 : test_close_bonding_device(void)
4179 : : {
4180 : 0 : rte_eth_dev_close(test_params->bonding_port_id);
4181 : 0 : return 0;
4182 : : }
4183 : :
4184 : : static void
4185 : 0 : testsuite_teardown(void)
4186 : : {
4187 : 0 : free(test_params->pkt_eth_hdr);
4188 : 0 : test_params->pkt_eth_hdr = NULL;
4189 : :
4190 : : /* Clean up and remove members from bonding device */
4191 : 0 : remove_members_and_stop_bonding_device();
4192 : 0 : }
4193 : :
4194 : : static void
4195 : 0 : free_virtualpmd_tx_queue(void)
4196 : : {
4197 : : int i, member_port, to_free_cnt;
4198 : : struct rte_mbuf *pkts_to_free[MAX_PKT_BURST];
4199 : :
4200 : : /* Free tx queue of virtual pmd */
4201 [ # # ]: 0 : for (member_port = 0; member_port < test_params->bonding_member_count;
4202 : 0 : member_port++) {
4203 : 0 : to_free_cnt = virtual_ethdev_get_mbufs_from_tx_queue(
4204 : 0 : test_params->member_port_ids[member_port],
4205 : : pkts_to_free, MAX_PKT_BURST);
4206 [ # # ]: 0 : for (i = 0; i < to_free_cnt; i++)
4207 : 0 : rte_pktmbuf_free(pkts_to_free[i]);
4208 : : }
4209 : 0 : }
4210 : :
4211 : : static int
4212 : 0 : test_tlb_tx_burst(void)
4213 : : {
4214 : : int i, burst_size, nb_tx;
4215 : : uint64_t nb_tx2 = 0;
4216 : : struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
4217 : : struct rte_eth_stats port_stats[32];
4218 : : uint64_t sum_ports_opackets = 0, all_bond_opackets = 0, all_bond_obytes = 0;
4219 : : uint16_t pktlen;
4220 : :
4221 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members
4222 : : (BONDING_MODE_TLB, 1, 3, 1),
4223 : : "Failed to initialise bonding device");
4224 : :
4225 : 0 : burst_size = 20 * test_params->bonding_member_count;
4226 : :
4227 [ # # ]: 0 : TEST_ASSERT(burst_size < MAX_PKT_BURST,
4228 : : "Burst size specified is greater than supported.\n");
4229 : :
4230 : :
4231 : : /* Generate bursts of packets */
4232 [ # # ]: 0 : for (i = 0; i < 400000; i++) {
4233 : : /*test two types of mac src own(bonding) and others */
4234 [ # # ]: 0 : if (i % 2 == 0) {
4235 : 0 : initialize_eth_header(test_params->pkt_eth_hdr,
4236 : : (struct rte_ether_addr *)src_mac,
4237 : : (struct rte_ether_addr *)dst_mac_0,
4238 : : RTE_ETHER_TYPE_IPV4, 0, 0);
4239 : : } else {
4240 : 0 : initialize_eth_header(test_params->pkt_eth_hdr,
4241 : 0 : (struct rte_ether_addr *)test_params->default_member_mac,
4242 : : (struct rte_ether_addr *)dst_mac_0,
4243 : : RTE_ETHER_TYPE_IPV4, 0, 0);
4244 : : }
4245 : 0 : pktlen = initialize_udp_header(test_params->pkt_udp_hdr, src_port,
4246 : : dst_port_0, 16);
4247 : 0 : pktlen = initialize_ipv4_header(test_params->pkt_ipv4_hdr, src_addr,
4248 : : dst_addr_0, pktlen);
4249 : 0 : generate_packet_burst(test_params->mbuf_pool, pkt_burst,
4250 : 0 : test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
4251 : 0 : 1, test_params->pkt_udp_hdr, burst_size, 60, 1);
4252 : : /* Send burst on bonding port */
4253 : 0 : nb_tx = rte_eth_tx_burst(test_params->bonding_port_id, 0, pkt_burst,
4254 : : burst_size);
4255 : 0 : nb_tx2 += nb_tx;
4256 : :
4257 : 0 : free_virtualpmd_tx_queue();
4258 : :
4259 [ # # ]: 0 : TEST_ASSERT_EQUAL(nb_tx, burst_size,
4260 : : "number of packet not equal burst size");
4261 : :
4262 : 0 : rte_delay_us(5);
4263 : : }
4264 : :
4265 : :
4266 : : /* Verify bonding port tx stats */
4267 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats[0]);
4268 : :
4269 : 0 : all_bond_opackets = port_stats[0].opackets;
4270 : 0 : all_bond_obytes = port_stats[0].obytes;
4271 : :
4272 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats[0].opackets, (uint64_t)nb_tx2,
4273 : : "Bonding Port (%d) opackets value (%u) not as expected (%d)\n",
4274 : : test_params->bonding_port_id, (unsigned int)port_stats[0].opackets,
4275 : : burst_size);
4276 : :
4277 : :
4278 : : /* Verify member ports tx stats */
4279 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
4280 : 0 : rte_eth_stats_get(test_params->member_port_ids[i], &port_stats[i]);
4281 : 0 : sum_ports_opackets += port_stats[i].opackets;
4282 : : }
4283 : :
4284 [ # # ]: 0 : TEST_ASSERT_EQUAL(sum_ports_opackets, (uint64_t)all_bond_opackets,
4285 : : "Total packets sent by members is not equal to packets sent by bond interface");
4286 : :
4287 : : /* checking if distribution of packets is balanced over members */
4288 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
4289 [ # # # # ]: 0 : TEST_ASSERT(port_stats[i].obytes > 0 &&
4290 : : port_stats[i].obytes < all_bond_obytes,
4291 : : "Packets are not balanced over members");
4292 : : }
4293 : :
4294 : : /* Put all members down and try and transmit */
4295 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
4296 : 0 : virtual_ethdev_simulate_link_status_interrupt(
4297 : 0 : test_params->member_port_ids[i], 0);
4298 : : }
4299 : :
4300 : : /* Send burst on bonding port */
4301 : 0 : nb_tx = rte_eth_tx_burst(test_params->bonding_port_id, 0, pkt_burst,
4302 : : burst_size);
4303 [ # # ]: 0 : TEST_ASSERT_EQUAL(nb_tx, 0, " bad number of packet in burst");
4304 : :
4305 : : /* Clean up and remove members from bonding device */
4306 : 0 : return remove_members_and_stop_bonding_device();
4307 : : }
4308 : :
4309 : : #define TEST_ADAPTIVE_TLB_RX_BURST_MEMBER_COUNT (4)
4310 : :
4311 : : static int
4312 : 0 : test_tlb_rx_burst(void)
4313 : : {
4314 : 0 : struct rte_mbuf *gen_pkt_burst[MAX_PKT_BURST] = { NULL };
4315 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
4316 : :
4317 : : struct rte_eth_stats port_stats;
4318 : :
4319 : : int primary_port;
4320 : :
4321 : : uint16_t i, j, nb_rx, burst_size = 17;
4322 : :
4323 : : /* Initialize bonding device with 4 members in transmit load balancing mode */
4324 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
4325 : : BONDING_MODE_TLB,
4326 : : TEST_ADAPTIVE_TLB_RX_BURST_MEMBER_COUNT, 1, 1),
4327 : : "Failed to initialize bonding device");
4328 : :
4329 : :
4330 : 0 : primary_port = rte_eth_bond_primary_get(test_params->bonding_port_id);
4331 [ # # ]: 0 : TEST_ASSERT(primary_port >= 0,
4332 : : "failed to get primary member for bonding port (%d)",
4333 : : test_params->bonding_port_id);
4334 : :
4335 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
4336 : : /* Generate test bursts of packets to transmit */
4337 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
4338 : : &gen_pkt_burst[0], burst_size, 0, 1, 0, 0, 0), burst_size,
4339 : : "burst generation failed");
4340 : :
4341 : : /* Add rx data to member */
4342 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[i],
4343 : : &gen_pkt_burst[0], burst_size);
4344 : :
4345 : : /* Call rx burst on bonding device */
4346 : 0 : nb_rx = rte_eth_rx_burst(test_params->bonding_port_id, 0,
4347 : : &rx_pkt_burst[0], MAX_PKT_BURST);
4348 : :
4349 [ # # ]: 0 : TEST_ASSERT_EQUAL(nb_rx, burst_size, "rte_eth_rx_burst failed\n");
4350 : :
4351 [ # # ]: 0 : if (test_params->member_port_ids[i] == primary_port) {
4352 : : /* Verify bonding device rx count */
4353 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
4354 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
4355 : : "Bonding Port (%d) ipackets value (%u) not as expected (%d)\n",
4356 : : test_params->bonding_port_id,
4357 : : (unsigned int)port_stats.ipackets, burst_size);
4358 : :
4359 : : /* Verify bonding member devices rx count */
4360 [ # # ]: 0 : for (j = 0; j < test_params->bonding_member_count; j++) {
4361 : 0 : rte_eth_stats_get(test_params->member_port_ids[j], &port_stats);
4362 [ # # ]: 0 : if (i == j) {
4363 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
4364 : : "Member Port (%d) ipackets value (%u) not as expected (%d)\n",
4365 : : test_params->member_port_ids[i],
4366 : : (unsigned int)port_stats.ipackets, burst_size);
4367 : : } else {
4368 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)0,
4369 : : "Member Port (%d) ipackets value (%u) not as expected (%d)\n",
4370 : : test_params->member_port_ids[i],
4371 : : (unsigned int)port_stats.ipackets, 0);
4372 : : }
4373 : : }
4374 : : } else {
4375 [ # # ]: 0 : for (j = 0; j < test_params->bonding_member_count; j++) {
4376 : 0 : rte_eth_stats_get(test_params->member_port_ids[j], &port_stats);
4377 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)0,
4378 : : "Member Port (%d) ipackets value (%u) not as expected (%d)\n",
4379 : : test_params->member_port_ids[i],
4380 : : (unsigned int)port_stats.ipackets, 0);
4381 : : }
4382 : : }
4383 : :
4384 : : /* free mbufs */
4385 [ # # ]: 0 : for (i = 0; i < burst_size; i++)
4386 : 0 : rte_pktmbuf_free(rx_pkt_burst[i]);
4387 : :
4388 : : /* reset bonding device stats */
4389 : 0 : rte_eth_stats_reset(test_params->bonding_port_id);
4390 : : }
4391 : :
4392 : : /* Clean up and remove members from bonding device */
4393 : 0 : return remove_members_and_stop_bonding_device();
4394 : : }
4395 : :
4396 : : static int
4397 : 0 : test_tlb_verify_promiscuous_enable_disable(void)
4398 : : {
4399 : : int i, primary_port, promiscuous_en;
4400 : : int ret;
4401 : :
4402 : : /* Initialize bonding device with 4 members in transmit load balancing mode */
4403 [ # # ]: 0 : TEST_ASSERT_SUCCESS( initialize_bonding_device_with_members(
4404 : : BONDING_MODE_TLB, 0, 4, 1),
4405 : : "Failed to initialize bonding device");
4406 : :
4407 : 0 : primary_port = rte_eth_bond_primary_get(test_params->bonding_port_id);
4408 [ # # ]: 0 : TEST_ASSERT(primary_port >= 0,
4409 : : "failed to get primary member for bonding port (%d)",
4410 : : test_params->bonding_port_id);
4411 : :
4412 : 0 : ret = rte_eth_promiscuous_enable(test_params->bonding_port_id);
4413 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret,
4414 : : "Failed to enable promiscuous mode for port %d: %s",
4415 : : test_params->bonding_port_id, rte_strerror(-ret));
4416 : :
4417 : 0 : promiscuous_en = rte_eth_promiscuous_get(test_params->bonding_port_id);
4418 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, (int)1,
4419 : : "Port (%d) promiscuous mode not enabled\n",
4420 : : test_params->bonding_port_id);
4421 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
4422 : 0 : promiscuous_en = rte_eth_promiscuous_get(
4423 : 0 : test_params->member_port_ids[i]);
4424 [ # # ]: 0 : if (primary_port == test_params->member_port_ids[i]) {
4425 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, (int)1,
4426 : : "Port (%d) promiscuous mode not enabled\n",
4427 : : test_params->bonding_port_id);
4428 : : } else {
4429 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, (int)0,
4430 : : "Port (%d) promiscuous mode enabled\n",
4431 : : test_params->bonding_port_id);
4432 : : }
4433 : :
4434 : : }
4435 : :
4436 : 0 : ret = rte_eth_promiscuous_disable(test_params->bonding_port_id);
4437 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret,
4438 : : "Failed to disable promiscuous mode for port %d: %s\n",
4439 : : test_params->bonding_port_id, rte_strerror(-ret));
4440 : :
4441 : 0 : promiscuous_en = rte_eth_promiscuous_get(test_params->bonding_port_id);
4442 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, (int)0,
4443 : : "Port (%d) promiscuous mode not disabled\n",
4444 : : test_params->bonding_port_id);
4445 : :
4446 [ # # ]: 0 : for (i = 0; i < test_params->bonding_member_count; i++) {
4447 : 0 : promiscuous_en = rte_eth_promiscuous_get(
4448 : 0 : test_params->member_port_ids[i]);
4449 [ # # ]: 0 : TEST_ASSERT_EQUAL(promiscuous_en, (int)0,
4450 : : "member port (%d) promiscuous mode not disabled\n",
4451 : : test_params->member_port_ids[i]);
4452 : : }
4453 : :
4454 : : /* Clean up and remove members from bonding device */
4455 : 0 : return remove_members_and_stop_bonding_device();
4456 : : }
4457 : :
4458 : : static int
4459 : 0 : test_tlb_verify_mac_assignment(void)
4460 : : {
4461 : : struct rte_ether_addr read_mac_addr;
4462 : : struct rte_ether_addr expected_mac_addr_0, expected_mac_addr_1;
4463 : :
4464 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0],
4465 : : &expected_mac_addr_0),
4466 : : "Failed to get mac address (port %d)",
4467 : : test_params->member_port_ids[0]);
4468 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1],
4469 : : &expected_mac_addr_1),
4470 : : "Failed to get mac address (port %d)",
4471 : : test_params->member_port_ids[1]);
4472 : :
4473 : : /* Initialize bonding device with 2 members in active backup mode */
4474 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
4475 : : BONDING_MODE_TLB, 0, 2, 1),
4476 : : "Failed to initialize bonding device");
4477 : :
4478 : : /*
4479 : : * Verify that bonding MACs is that of first member and that the other member
4480 : : * MAC hasn't been changed.
4481 : : */
4482 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
4483 : : "Failed to get mac address (port %d)",
4484 : : test_params->bonding_port_id);
4485 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
4486 : : sizeof(read_mac_addr)),
4487 : : "bonding port (%d) mac address not set to that of primary port",
4488 : : test_params->bonding_port_id);
4489 : :
4490 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
4491 : : "Failed to get mac address (port %d)",
4492 : : test_params->member_port_ids[0]);
4493 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
4494 : : sizeof(read_mac_addr)),
4495 : : "member port (%d) mac address not set to that of primary port",
4496 : : test_params->member_port_ids[0]);
4497 : :
4498 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
4499 : : "Failed to get mac address (port %d)",
4500 : : test_params->member_port_ids[1]);
4501 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
4502 : : sizeof(read_mac_addr)),
4503 : : "member port (%d) mac address not as expected",
4504 : : test_params->member_port_ids[1]);
4505 : :
4506 : : /* change primary and verify that MAC addresses haven't changed */
4507 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_primary_set(test_params->bonding_port_id,
4508 : : test_params->member_port_ids[1]), 0,
4509 : : "Failed to set bonding port (%d) primary port to (%d)",
4510 : : test_params->bonding_port_id, test_params->member_port_ids[1]);
4511 : :
4512 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
4513 : : "Failed to get mac address (port %d)",
4514 : : test_params->bonding_port_id);
4515 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
4516 : : sizeof(read_mac_addr)),
4517 : : "bonding port (%d) mac address not set to that of primary port",
4518 : : test_params->bonding_port_id);
4519 : :
4520 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
4521 : : "Failed to get mac address (port %d)",
4522 : : test_params->member_port_ids[0]);
4523 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
4524 : : sizeof(read_mac_addr)),
4525 : : "member port (%d) mac address not set to that of primary port",
4526 : : test_params->member_port_ids[0]);
4527 : :
4528 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
4529 : : "Failed to get mac address (port %d)",
4530 : : test_params->member_port_ids[1]);
4531 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
4532 : : sizeof(read_mac_addr)),
4533 : : "member port (%d) mac address not as expected",
4534 : : test_params->member_port_ids[1]);
4535 : :
4536 : : /*
4537 : : * stop / start bonding device and verify that primary MAC address is
4538 : : * propagated to bonding device and members.
4539 : : */
4540 : :
4541 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_stop(test_params->bonding_port_id),
4542 : : "Failed to stop bonding port %u",
4543 : : test_params->bonding_port_id);
4544 : :
4545 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonding_port_id),
4546 : : "Failed to start device");
4547 : :
4548 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
4549 : : "Failed to get mac address (port %d)",
4550 : : test_params->bonding_port_id);
4551 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
4552 : : sizeof(read_mac_addr)),
4553 : : "bonding port (%d) mac address not set to that of primary port",
4554 : : test_params->bonding_port_id);
4555 : :
4556 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
4557 : : "Failed to get mac address (port %d)",
4558 : : test_params->member_port_ids[0]);
4559 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
4560 : : sizeof(read_mac_addr)),
4561 : : "member port (%d) mac address not as expected",
4562 : : test_params->member_port_ids[0]);
4563 : :
4564 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
4565 : : "Failed to get mac address (port %d)",
4566 : : test_params->member_port_ids[1]);
4567 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
4568 : : sizeof(read_mac_addr)),
4569 : : "member port (%d) mac address not set to that of primary port",
4570 : : test_params->member_port_ids[1]);
4571 : :
4572 : :
4573 : : /* Set explicit MAC address */
4574 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
4575 : : test_params->bonding_port_id,
4576 : : (struct rte_ether_addr *)bonding_mac),
4577 : : "failed to set MAC address");
4578 : :
4579 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->bonding_port_id, &read_mac_addr),
4580 : : "Failed to get mac address (port %d)",
4581 : : test_params->bonding_port_id);
4582 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac, &read_mac_addr,
4583 : : sizeof(read_mac_addr)),
4584 : : "bonding port (%d) mac address not set to that of bonding port",
4585 : : test_params->bonding_port_id);
4586 : :
4587 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[0], &read_mac_addr),
4588 : : "Failed to get mac address (port %d)",
4589 : : test_params->member_port_ids[0]);
4590 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
4591 : : sizeof(read_mac_addr)),
4592 : : "member port (%d) mac address not as expected",
4593 : : test_params->member_port_ids[0]);
4594 : :
4595 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_eth_macaddr_get(test_params->member_port_ids[1], &read_mac_addr),
4596 : : "Failed to get mac address (port %d)",
4597 : : test_params->member_port_ids[1]);
4598 [ # # ]: 0 : TEST_ASSERT_SUCCESS(memcmp(&bonding_mac, &read_mac_addr,
4599 : : sizeof(read_mac_addr)),
4600 : : "member port (%d) mac address not set to that of bonding port",
4601 : : test_params->member_port_ids[1]);
4602 : :
4603 : : /* Clean up and remove members from bonding device */
4604 : 0 : return remove_members_and_stop_bonding_device();
4605 : : }
4606 : :
4607 : : static int
4608 : 0 : test_tlb_verify_member_link_status_change_failover(void)
4609 : : {
4610 : : struct rte_mbuf *pkt_burst[TEST_ADAPTIVE_TLB_RX_BURST_MEMBER_COUNT][MAX_PKT_BURST];
4611 : 0 : struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST] = { NULL };
4612 : : struct rte_eth_stats port_stats;
4613 : :
4614 : : uint16_t members[RTE_MAX_ETHPORTS];
4615 : :
4616 : : int i, burst_size, member_count, primary_port;
4617 : :
4618 : : burst_size = 21;
4619 : :
4620 : : memset(pkt_burst, 0, sizeof(pkt_burst));
4621 : :
4622 : :
4623 : :
4624 : : /* Initialize bonding device with 4 members in round robin mode */
4625 [ # # ]: 0 : TEST_ASSERT_SUCCESS(initialize_bonding_device_with_members(
4626 : : BONDING_MODE_TLB, 0,
4627 : : TEST_ADAPTIVE_TLB_RX_BURST_MEMBER_COUNT, 1),
4628 : : "Failed to initialize bonding device with members");
4629 : :
4630 : : /* Verify Current Members Count /Active Member Count is */
4631 : 0 : member_count = rte_eth_bond_members_get(test_params->bonding_port_id, members,
4632 : : RTE_MAX_ETHPORTS);
4633 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, 4,
4634 : : "Number of members (%d) is not as expected (%d).\n",
4635 : : member_count, 4);
4636 : :
4637 : 0 : member_count = rte_eth_bond_active_members_get(test_params->bonding_port_id,
4638 : : members, RTE_MAX_ETHPORTS);
4639 [ # # ]: 0 : TEST_ASSERT_EQUAL(member_count, 4,
4640 : : "Number of members (%d) is not as expected (%d).\n",
4641 : : member_count, 4);
4642 : :
4643 : 0 : primary_port = rte_eth_bond_primary_get(test_params->bonding_port_id);
4644 [ # # ]: 0 : TEST_ASSERT_EQUAL(primary_port, test_params->member_port_ids[0],
4645 : : "Primary port not as expected");
4646 : :
4647 : : /* Bring 2 members down and verify active member count */
4648 : 0 : virtual_ethdev_simulate_link_status_interrupt(
4649 : 0 : test_params->member_port_ids[1], 0);
4650 : 0 : virtual_ethdev_simulate_link_status_interrupt(
4651 : 0 : test_params->member_port_ids[3], 0);
4652 : :
4653 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_active_members_get(
4654 : : test_params->bonding_port_id, members, RTE_MAX_ETHPORTS), 2,
4655 : : "Number of active members (%d) is not as expected (%d).",
4656 : : member_count, 2);
4657 : :
4658 : 0 : virtual_ethdev_simulate_link_status_interrupt(
4659 : 0 : test_params->member_port_ids[1], 1);
4660 : 0 : virtual_ethdev_simulate_link_status_interrupt(
4661 : 0 : test_params->member_port_ids[3], 1);
4662 : :
4663 : :
4664 : : /*
4665 : : * Bring primary port down, verify that active member count is 3 and primary
4666 : : * has changed.
4667 : : */
4668 : 0 : virtual_ethdev_simulate_link_status_interrupt(
4669 : 0 : test_params->member_port_ids[0], 0);
4670 : :
4671 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_bond_active_members_get(
4672 : : test_params->bonding_port_id, members, RTE_MAX_ETHPORTS), 3,
4673 : : "Number of active members (%d) is not as expected (%d).",
4674 : : member_count, 3);
4675 : :
4676 : 0 : primary_port = rte_eth_bond_primary_get(test_params->bonding_port_id);
4677 [ # # ]: 0 : TEST_ASSERT_EQUAL(primary_port, test_params->member_port_ids[2],
4678 : : "Primary port not as expected");
4679 : 0 : rte_delay_us(500000);
4680 : : /* Verify that pkts are sent on new primary member */
4681 [ # # ]: 0 : for (i = 0; i < 4; i++) {
4682 [ # # ]: 0 : TEST_ASSERT_EQUAL(generate_test_burst(
4683 : : &pkt_burst[0][0], burst_size, 0, 1, 0, 0, 0), burst_size,
4684 : : "generate_test_burst failed\n");
4685 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_eth_tx_burst(
4686 : : test_params->bonding_port_id, 0, &pkt_burst[0][0], burst_size),
4687 : : burst_size,
4688 : : "rte_eth_tx_burst failed\n");
4689 : 0 : rte_delay_us(11000);
4690 : : }
4691 : :
4692 : 0 : rte_eth_stats_get(test_params->member_port_ids[0], &port_stats);
4693 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.opackets, (int8_t)0,
4694 : : "(%d) port_stats.opackets not as expected\n",
4695 : : test_params->member_port_ids[0]);
4696 : :
4697 : 0 : rte_eth_stats_get(test_params->member_port_ids[1], &port_stats);
4698 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(port_stats.opackets, (int8_t)0,
4699 : : "(%d) port_stats.opackets not as expected\n",
4700 : : test_params->member_port_ids[1]);
4701 : :
4702 : 0 : rte_eth_stats_get(test_params->member_port_ids[2], &port_stats);
4703 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(port_stats.opackets, (int8_t)0,
4704 : : "(%d) port_stats.opackets not as expected\n",
4705 : : test_params->member_port_ids[2]);
4706 : :
4707 : 0 : rte_eth_stats_get(test_params->member_port_ids[3], &port_stats);
4708 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(port_stats.opackets, (int8_t)0,
4709 : : "(%d) port_stats.opackets not as expected\n",
4710 : : test_params->member_port_ids[3]);
4711 : :
4712 : :
4713 : : /* Generate packet burst for testing */
4714 : :
4715 [ # # ]: 0 : for (i = 0; i < TEST_ADAPTIVE_TLB_RX_BURST_MEMBER_COUNT; i++) {
4716 [ # # ]: 0 : if (generate_test_burst(&pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0) !=
4717 : : burst_size)
4718 : : return -1;
4719 : :
4720 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(
4721 : 0 : test_params->member_port_ids[i], &pkt_burst[i][0], burst_size);
4722 : : }
4723 : :
4724 [ # # ]: 0 : if (rte_eth_rx_burst(test_params->bonding_port_id, 0, rx_pkt_burst,
4725 : : MAX_PKT_BURST) != burst_size) {
4726 : : printf("rte_eth_rx_burst\n");
4727 : 0 : return -1;
4728 : :
4729 : : }
4730 : :
4731 : : /* Verify bonding device rx count */
4732 : 0 : rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
4733 [ # # ]: 0 : TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
4734 : : "(%d) port_stats.ipackets not as expected\n",
4735 : : test_params->bonding_port_id);
4736 : :
4737 : : /* Clean up and remove members from bonding device */
4738 : 0 : return remove_members_and_stop_bonding_device();
4739 : : }
4740 : :
4741 : : #define TEST_ALB_MEMBER_COUNT 2
4742 : :
4743 : : static uint8_t mac_client1[] = {0x00, 0xAA, 0x55, 0xFF, 0xCC, 1};
4744 : : static uint8_t mac_client2[] = {0x00, 0xAA, 0x55, 0xFF, 0xCC, 2};
4745 : : static uint8_t mac_client3[] = {0x00, 0xAA, 0x55, 0xFF, 0xCC, 3};
4746 : : static uint8_t mac_client4[] = {0x00, 0xAA, 0x55, 0xFF, 0xCC, 4};
4747 : :
4748 : : static uint32_t ip_host = IPV4_ADDR(192, 168, 0, 0);
4749 : : static uint32_t ip_client1 = IPV4_ADDR(192, 168, 0, 1);
4750 : : static uint32_t ip_client2 = IPV4_ADDR(192, 168, 0, 2);
4751 : : static uint32_t ip_client3 = IPV4_ADDR(192, 168, 0, 3);
4752 : : static uint32_t ip_client4 = IPV4_ADDR(192, 168, 0, 4);
4753 : :
4754 : : static int
4755 : 0 : test_alb_change_mac_in_reply_sent(void)
4756 : : {
4757 : : struct rte_mbuf *pkt;
4758 : : struct rte_mbuf *pkts_sent[MAX_PKT_BURST];
4759 : :
4760 : : struct rte_ether_hdr *eth_pkt;
4761 : : struct rte_arp_hdr *arp_pkt;
4762 : :
4763 : : int member_idx, nb_pkts, pkt_idx;
4764 : : int retval = 0;
4765 : :
4766 : : struct rte_ether_addr bond_mac, client_mac;
4767 : : struct rte_ether_addr *member_mac1, *member_mac2;
4768 : :
4769 [ # # ]: 0 : TEST_ASSERT_SUCCESS(
4770 : : initialize_bonding_device_with_members(BONDING_MODE_ALB,
4771 : : 0, TEST_ALB_MEMBER_COUNT, 1),
4772 : : "Failed to initialize_bonding_device_with_members.");
4773 : :
4774 : : /* Flush tx queue */
4775 : 0 : rte_eth_tx_burst(test_params->bonding_port_id, 0, NULL, 0);
4776 [ # # ]: 0 : for (member_idx = 0; member_idx < test_params->bonding_member_count;
4777 : 0 : member_idx++) {
4778 : 0 : nb_pkts = virtual_ethdev_get_mbufs_from_tx_queue(
4779 : 0 : test_params->member_port_ids[member_idx], pkts_sent,
4780 : : MAX_PKT_BURST);
4781 : : }
4782 : :
4783 : : rte_ether_addr_copy(
4784 : 0 : rte_eth_devices[test_params->bonding_port_id].data->mac_addrs,
4785 : : &bond_mac);
4786 : :
4787 : : /*
4788 : : * Generating four packets with different mac and ip addresses and sending
4789 : : * them through the bonding port.
4790 : : */
4791 : 0 : pkt = rte_pktmbuf_alloc(test_params->mbuf_pool);
4792 : : memcpy(client_mac.addr_bytes, mac_client1, RTE_ETHER_ADDR_LEN);
4793 : 0 : eth_pkt = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *);
4794 : 0 : initialize_eth_header(eth_pkt, &bond_mac, &client_mac,
4795 : : RTE_ETHER_TYPE_ARP, 0, 0);
4796 : 0 : arp_pkt = (struct rte_arp_hdr *)((char *)eth_pkt +
4797 : : sizeof(struct rte_ether_hdr));
4798 : 0 : initialize_arp_header(arp_pkt, &bond_mac, &client_mac, ip_host, ip_client1,
4799 : : RTE_ARP_OP_REPLY);
4800 : 0 : rte_eth_tx_burst(test_params->bonding_port_id, 0, &pkt, 1);
4801 : :
4802 : 0 : pkt = rte_pktmbuf_alloc(test_params->mbuf_pool);
4803 : : memcpy(client_mac.addr_bytes, mac_client2, RTE_ETHER_ADDR_LEN);
4804 : 0 : eth_pkt = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *);
4805 : 0 : initialize_eth_header(eth_pkt, &bond_mac, &client_mac,
4806 : : RTE_ETHER_TYPE_ARP, 0, 0);
4807 : 0 : arp_pkt = (struct rte_arp_hdr *)((char *)eth_pkt +
4808 : : sizeof(struct rte_ether_hdr));
4809 : 0 : initialize_arp_header(arp_pkt, &bond_mac, &client_mac, ip_host, ip_client2,
4810 : : RTE_ARP_OP_REPLY);
4811 : 0 : rte_eth_tx_burst(test_params->bonding_port_id, 0, &pkt, 1);
4812 : :
4813 : 0 : pkt = rte_pktmbuf_alloc(test_params->mbuf_pool);
4814 : : memcpy(client_mac.addr_bytes, mac_client3, RTE_ETHER_ADDR_LEN);
4815 : 0 : eth_pkt = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *);
4816 : 0 : initialize_eth_header(eth_pkt, &bond_mac, &client_mac,
4817 : : RTE_ETHER_TYPE_ARP, 0, 0);
4818 : 0 : arp_pkt = (struct rte_arp_hdr *)((char *)eth_pkt +
4819 : : sizeof(struct rte_ether_hdr));
4820 : 0 : initialize_arp_header(arp_pkt, &bond_mac, &client_mac, ip_host, ip_client3,
4821 : : RTE_ARP_OP_REPLY);
4822 : 0 : rte_eth_tx_burst(test_params->bonding_port_id, 0, &pkt, 1);
4823 : :
4824 : 0 : pkt = rte_pktmbuf_alloc(test_params->mbuf_pool);
4825 : : memcpy(client_mac.addr_bytes, mac_client4, RTE_ETHER_ADDR_LEN);
4826 : 0 : eth_pkt = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *);
4827 : 0 : initialize_eth_header(eth_pkt, &bond_mac, &client_mac,
4828 : : RTE_ETHER_TYPE_ARP, 0, 0);
4829 : 0 : arp_pkt = (struct rte_arp_hdr *)((char *)eth_pkt +
4830 : : sizeof(struct rte_ether_hdr));
4831 : 0 : initialize_arp_header(arp_pkt, &bond_mac, &client_mac, ip_host, ip_client4,
4832 : : RTE_ARP_OP_REPLY);
4833 : 0 : rte_eth_tx_burst(test_params->bonding_port_id, 0, &pkt, 1);
4834 : :
4835 : 0 : member_mac1 =
4836 : 0 : rte_eth_devices[test_params->member_port_ids[0]].data->mac_addrs;
4837 : 0 : member_mac2 =
4838 : 0 : rte_eth_devices[test_params->member_port_ids[1]].data->mac_addrs;
4839 : :
4840 : : /*
4841 : : * Checking if packets are properly distributed on bonding ports. Packets
4842 : : * 0 and 2 should be sent on port 0 and packets 1 and 3 on port 1.
4843 : : */
4844 [ # # ]: 0 : for (member_idx = 0; member_idx < test_params->bonding_member_count; member_idx++) {
4845 : 0 : nb_pkts = virtual_ethdev_get_mbufs_from_tx_queue(
4846 : 0 : test_params->member_port_ids[member_idx], pkts_sent,
4847 : : MAX_PKT_BURST);
4848 : :
4849 [ # # ]: 0 : for (pkt_idx = 0; pkt_idx < nb_pkts; pkt_idx++) {
4850 : 0 : eth_pkt = rte_pktmbuf_mtod(
4851 : : pkts_sent[pkt_idx], struct rte_ether_hdr *);
4852 : : arp_pkt = (struct rte_arp_hdr *)((char *)eth_pkt +
4853 : : sizeof(struct rte_ether_hdr));
4854 : :
4855 [ # # ]: 0 : if (member_idx%2 == 0) {
4856 [ # # ]: 0 : if (!rte_is_same_ether_addr(member_mac1,
4857 : : &arp_pkt->arp_data.arp_sha)) {
4858 : : retval = -1;
4859 : 0 : goto test_end;
4860 : : }
4861 : : } else {
4862 [ # # ]: 0 : if (!rte_is_same_ether_addr(member_mac2,
4863 : : &arp_pkt->arp_data.arp_sha)) {
4864 : : retval = -1;
4865 : 0 : goto test_end;
4866 : : }
4867 : : }
4868 : : }
4869 : : }
4870 : :
4871 : 0 : test_end:
4872 : 0 : retval += remove_members_and_stop_bonding_device();
4873 : 0 : return retval;
4874 : : }
4875 : :
4876 : : static int
4877 : 0 : test_alb_reply_from_client(void)
4878 : : {
4879 : : struct rte_ether_hdr *eth_pkt;
4880 : : struct rte_arp_hdr *arp_pkt;
4881 : :
4882 : : struct rte_mbuf *pkt;
4883 : : struct rte_mbuf *pkts_sent[MAX_PKT_BURST];
4884 : :
4885 : : int member_idx, nb_pkts, pkt_idx, nb_pkts_sum = 0;
4886 : : int retval = 0;
4887 : :
4888 : : struct rte_ether_addr bond_mac, client_mac;
4889 : : struct rte_ether_addr *member_mac1, *member_mac2;
4890 : :
4891 [ # # ]: 0 : TEST_ASSERT_SUCCESS(
4892 : : initialize_bonding_device_with_members(BONDING_MODE_ALB,
4893 : : 0, TEST_ALB_MEMBER_COUNT, 1),
4894 : : "Failed to initialize_bonding_device_with_members.");
4895 : :
4896 : : /* Flush tx queue */
4897 : 0 : rte_eth_tx_burst(test_params->bonding_port_id, 0, NULL, 0);
4898 [ # # ]: 0 : for (member_idx = 0; member_idx < test_params->bonding_member_count; member_idx++) {
4899 : 0 : nb_pkts = virtual_ethdev_get_mbufs_from_tx_queue(
4900 : 0 : test_params->member_port_ids[member_idx], pkts_sent,
4901 : : MAX_PKT_BURST);
4902 : : }
4903 : :
4904 : : rte_ether_addr_copy(
4905 : 0 : rte_eth_devices[test_params->bonding_port_id].data->mac_addrs,
4906 : : &bond_mac);
4907 : :
4908 : : /*
4909 : : * Generating four packets with different mac and ip addresses and placing
4910 : : * them in the rx queue to be received by the bonding driver on rx_burst.
4911 : : */
4912 : 0 : pkt = rte_pktmbuf_alloc(test_params->mbuf_pool);
4913 : : memcpy(client_mac.addr_bytes, mac_client1, RTE_ETHER_ADDR_LEN);
4914 : 0 : eth_pkt = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *);
4915 : 0 : initialize_eth_header(eth_pkt, &bond_mac, &client_mac,
4916 : : RTE_ETHER_TYPE_ARP, 0, 0);
4917 : 0 : arp_pkt = (struct rte_arp_hdr *)((char *)eth_pkt +
4918 : : sizeof(struct rte_ether_hdr));
4919 : 0 : initialize_arp_header(arp_pkt, &client_mac, &bond_mac, ip_client1, ip_host,
4920 : : RTE_ARP_OP_REPLY);
4921 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[0], &pkt,
4922 : : 1);
4923 : :
4924 : 0 : pkt = rte_pktmbuf_alloc(test_params->mbuf_pool);
4925 : : memcpy(client_mac.addr_bytes, mac_client2, RTE_ETHER_ADDR_LEN);
4926 : 0 : eth_pkt = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *);
4927 : 0 : initialize_eth_header(eth_pkt, &bond_mac, &client_mac,
4928 : : RTE_ETHER_TYPE_ARP, 0, 0);
4929 : 0 : arp_pkt = (struct rte_arp_hdr *)((char *)eth_pkt +
4930 : : sizeof(struct rte_ether_hdr));
4931 : 0 : initialize_arp_header(arp_pkt, &client_mac, &bond_mac, ip_client2, ip_host,
4932 : : RTE_ARP_OP_REPLY);
4933 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[0], &pkt,
4934 : : 1);
4935 : :
4936 : 0 : pkt = rte_pktmbuf_alloc(test_params->mbuf_pool);
4937 : : memcpy(client_mac.addr_bytes, mac_client3, RTE_ETHER_ADDR_LEN);
4938 : 0 : eth_pkt = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *);
4939 : 0 : initialize_eth_header(eth_pkt, &bond_mac, &client_mac,
4940 : : RTE_ETHER_TYPE_ARP, 0, 0);
4941 : 0 : arp_pkt = (struct rte_arp_hdr *)((char *)eth_pkt +
4942 : : sizeof(struct rte_ether_hdr));
4943 : 0 : initialize_arp_header(arp_pkt, &client_mac, &bond_mac, ip_client3, ip_host,
4944 : : RTE_ARP_OP_REPLY);
4945 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[0], &pkt,
4946 : : 1);
4947 : :
4948 : 0 : pkt = rte_pktmbuf_alloc(test_params->mbuf_pool);
4949 : : memcpy(client_mac.addr_bytes, mac_client4, RTE_ETHER_ADDR_LEN);
4950 : 0 : eth_pkt = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *);
4951 : 0 : initialize_eth_header(eth_pkt, &bond_mac, &client_mac,
4952 : : RTE_ETHER_TYPE_ARP, 0, 0);
4953 : 0 : arp_pkt = (struct rte_arp_hdr *)((char *)eth_pkt +
4954 : : sizeof(struct rte_ether_hdr));
4955 : 0 : initialize_arp_header(arp_pkt, &client_mac, &bond_mac, ip_client4, ip_host,
4956 : : RTE_ARP_OP_REPLY);
4957 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[0], &pkt,
4958 : : 1);
4959 : :
4960 : : /*
4961 : : * Issue rx_burst and tx_burst to force bonding driver to send update ARP
4962 : : * packets to every client in alb table.
4963 : : */
4964 : 0 : rte_eth_rx_burst(test_params->bonding_port_id, 0, pkts_sent, MAX_PKT_BURST);
4965 : 0 : rte_eth_tx_burst(test_params->bonding_port_id, 0, NULL, 0);
4966 : :
4967 : 0 : member_mac1 = rte_eth_devices[test_params->member_port_ids[0]].data->mac_addrs;
4968 : 0 : member_mac2 = rte_eth_devices[test_params->member_port_ids[1]].data->mac_addrs;
4969 : :
4970 : : /*
4971 : : * Checking if update ARP packets were properly send on member ports.
4972 : : */
4973 [ # # ]: 0 : for (member_idx = 0; member_idx < test_params->bonding_member_count; member_idx++) {
4974 : 0 : nb_pkts = virtual_ethdev_get_mbufs_from_tx_queue(
4975 : 0 : test_params->member_port_ids[member_idx], pkts_sent, MAX_PKT_BURST);
4976 : 0 : nb_pkts_sum += nb_pkts;
4977 : :
4978 [ # # ]: 0 : for (pkt_idx = 0; pkt_idx < nb_pkts; pkt_idx++) {
4979 : 0 : eth_pkt = rte_pktmbuf_mtod(
4980 : : pkts_sent[pkt_idx], struct rte_ether_hdr *);
4981 : : arp_pkt = (struct rte_arp_hdr *)((char *)eth_pkt +
4982 : : sizeof(struct rte_ether_hdr));
4983 : :
4984 [ # # ]: 0 : if (member_idx%2 == 0) {
4985 [ # # ]: 0 : if (!rte_is_same_ether_addr(member_mac1,
4986 : : &arp_pkt->arp_data.arp_sha)) {
4987 : : retval = -1;
4988 : 0 : goto test_end;
4989 : : }
4990 : : } else {
4991 [ # # ]: 0 : if (!rte_is_same_ether_addr(member_mac2,
4992 : : &arp_pkt->arp_data.arp_sha)) {
4993 : : retval = -1;
4994 : 0 : goto test_end;
4995 : : }
4996 : : }
4997 : : }
4998 : : }
4999 : :
5000 : : /* Check if proper number of packets was send */
5001 [ # # ]: 0 : if (nb_pkts_sum < 4) {
5002 : : retval = -1;
5003 : 0 : goto test_end;
5004 : : }
5005 : :
5006 : 0 : test_end:
5007 : 0 : retval += remove_members_and_stop_bonding_device();
5008 : 0 : return retval;
5009 : : }
5010 : :
5011 : : static int
5012 : 0 : test_alb_receive_vlan_reply(void)
5013 : : {
5014 : : struct rte_ether_hdr *eth_pkt;
5015 : : struct rte_vlan_hdr *vlan_pkt;
5016 : : struct rte_arp_hdr *arp_pkt;
5017 : :
5018 : : struct rte_mbuf *pkt;
5019 : : struct rte_mbuf *pkts_sent[MAX_PKT_BURST];
5020 : :
5021 : : int member_idx, nb_pkts, pkt_idx;
5022 : : int retval = 0;
5023 : :
5024 : : struct rte_ether_addr bond_mac, client_mac;
5025 : :
5026 [ # # ]: 0 : TEST_ASSERT_SUCCESS(
5027 : : initialize_bonding_device_with_members(BONDING_MODE_ALB,
5028 : : 0, TEST_ALB_MEMBER_COUNT, 1),
5029 : : "Failed to initialize_bonding_device_with_members.");
5030 : :
5031 : : /* Flush tx queue */
5032 : 0 : rte_eth_tx_burst(test_params->bonding_port_id, 0, NULL, 0);
5033 [ # # ]: 0 : for (member_idx = 0; member_idx < test_params->bonding_member_count; member_idx++) {
5034 : 0 : nb_pkts = virtual_ethdev_get_mbufs_from_tx_queue(
5035 : 0 : test_params->member_port_ids[member_idx], pkts_sent,
5036 : : MAX_PKT_BURST);
5037 : : }
5038 : :
5039 : : rte_ether_addr_copy(
5040 : 0 : rte_eth_devices[test_params->bonding_port_id].data->mac_addrs,
5041 : : &bond_mac);
5042 : :
5043 : : /*
5044 : : * Generating packet with double VLAN header and placing it in the rx queue.
5045 : : */
5046 : 0 : pkt = rte_pktmbuf_alloc(test_params->mbuf_pool);
5047 : : memcpy(client_mac.addr_bytes, mac_client1, RTE_ETHER_ADDR_LEN);
5048 : 0 : eth_pkt = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *);
5049 : 0 : initialize_eth_header(eth_pkt, &bond_mac, &client_mac,
5050 : : RTE_ETHER_TYPE_VLAN, 0, 0);
5051 : : vlan_pkt = (struct rte_vlan_hdr *)((char *)(eth_pkt + 1));
5052 : 0 : vlan_pkt->vlan_tci = rte_cpu_to_be_16(1);
5053 : 0 : vlan_pkt->eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5054 : : vlan_pkt = vlan_pkt+1;
5055 : 0 : vlan_pkt->vlan_tci = rte_cpu_to_be_16(2);
5056 : 0 : vlan_pkt->eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP);
5057 : 0 : arp_pkt = (struct rte_arp_hdr *)((char *)(vlan_pkt + 1));
5058 : 0 : initialize_arp_header(arp_pkt, &client_mac, &bond_mac, ip_client1, ip_host,
5059 : : RTE_ARP_OP_REPLY);
5060 : 0 : virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[0], &pkt,
5061 : : 1);
5062 : :
5063 : 0 : rte_eth_rx_burst(test_params->bonding_port_id, 0, pkts_sent, MAX_PKT_BURST);
5064 : 0 : rte_eth_tx_burst(test_params->bonding_port_id, 0, NULL, 0);
5065 : :
5066 : : /*
5067 : : * Checking if VLAN headers in generated ARP Update packet are correct.
5068 : : */
5069 [ # # ]: 0 : for (member_idx = 0; member_idx < test_params->bonding_member_count; member_idx++) {
5070 : 0 : nb_pkts = virtual_ethdev_get_mbufs_from_tx_queue(
5071 : 0 : test_params->member_port_ids[member_idx], pkts_sent,
5072 : : MAX_PKT_BURST);
5073 : :
5074 [ # # ]: 0 : for (pkt_idx = 0; pkt_idx < nb_pkts; pkt_idx++) {
5075 : 0 : eth_pkt = rte_pktmbuf_mtod(
5076 : : pkts_sent[pkt_idx], struct rte_ether_hdr *);
5077 : : vlan_pkt = (struct rte_vlan_hdr *)(
5078 : : (char *)(eth_pkt + 1));
5079 [ # # ]: 0 : if (vlan_pkt->vlan_tci != rte_cpu_to_be_16(1)) {
5080 : : retval = -1;
5081 : 0 : goto test_end;
5082 : : }
5083 [ # # ]: 0 : if (vlan_pkt->eth_proto != rte_cpu_to_be_16(
5084 : : RTE_ETHER_TYPE_VLAN)) {
5085 : : retval = -1;
5086 : 0 : goto test_end;
5087 : : }
5088 : : vlan_pkt = vlan_pkt+1;
5089 [ # # ]: 0 : if (vlan_pkt->vlan_tci != rte_cpu_to_be_16(2)) {
5090 : : retval = -1;
5091 : 0 : goto test_end;
5092 : : }
5093 [ # # ]: 0 : if (vlan_pkt->eth_proto != rte_cpu_to_be_16(
5094 : : RTE_ETHER_TYPE_ARP)) {
5095 : : retval = -1;
5096 : 0 : goto test_end;
5097 : : }
5098 : : }
5099 : : }
5100 : :
5101 : 0 : test_end:
5102 : 0 : retval += remove_members_and_stop_bonding_device();
5103 : 0 : return retval;
5104 : : }
5105 : :
5106 : : static int
5107 : 0 : test_alb_ipv4_tx(void)
5108 : : {
5109 : : int burst_size, retval, pkts_send;
5110 : : struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
5111 : :
5112 : : retval = 0;
5113 : :
5114 [ # # ]: 0 : TEST_ASSERT_SUCCESS(
5115 : : initialize_bonding_device_with_members(BONDING_MODE_ALB,
5116 : : 0, TEST_ALB_MEMBER_COUNT, 1),
5117 : : "Failed to initialize_bonding_device_with_members.");
5118 : :
5119 : : burst_size = 32;
5120 : :
5121 : : /* Generate test bursts of packets to transmit */
5122 [ # # ]: 0 : if (generate_test_burst(pkt_burst, burst_size, 0, 1, 0, 0, 0) != burst_size) {
5123 : : retval = -1;
5124 : 0 : goto test_end;
5125 : : }
5126 : :
5127 : : /*
5128 : : * Checking if ipv4 traffic is transmitted via TLB policy.
5129 : : */
5130 : 0 : pkts_send = rte_eth_tx_burst(
5131 : 0 : test_params->bonding_port_id, 0, pkt_burst, burst_size);
5132 [ # # ]: 0 : if (pkts_send != burst_size) {
5133 : : retval = -1;
5134 : 0 : goto test_end;
5135 : : }
5136 : :
5137 : 0 : test_end:
5138 : 0 : retval += remove_members_and_stop_bonding_device();
5139 : 0 : return retval;
5140 : : }
5141 : :
5142 : : static struct unit_test_suite link_bonding_test_suite = {
5143 : : .suite_name = "Link Bonding Unit Test Suite",
5144 : : .setup = test_setup,
5145 : : .teardown = testsuite_teardown,
5146 : : .unit_test_cases = {
5147 : : TEST_CASE(test_create_bonding_device),
5148 : : TEST_CASE(test_create_bonding_device_with_invalid_params),
5149 : : TEST_CASE(test_add_member_to_bonding_device),
5150 : : TEST_CASE(test_add_member_to_invalid_bonding_device),
5151 : : TEST_CASE(test_remove_member_from_bonding_device),
5152 : : TEST_CASE(test_remove_member_from_invalid_bonding_device),
5153 : : TEST_CASE(test_get_members_from_bonding_device),
5154 : : TEST_CASE(test_add_already_bonding_member_to_bonding_device),
5155 : : TEST_CASE(test_add_remove_multiple_members_to_from_bonding_device),
5156 : : TEST_CASE(test_start_bonding_device),
5157 : : TEST_CASE(test_stop_bonding_device),
5158 : : TEST_CASE(test_set_bonding_mode),
5159 : : TEST_CASE(test_set_primary_member),
5160 : : TEST_CASE(test_set_explicit_bonding_mac),
5161 : : TEST_CASE(test_set_bonding_port_initialization_mac_assignment),
5162 : : TEST_CASE(test_status_interrupt),
5163 : : TEST_CASE(test_adding_member_after_bonding_device_started),
5164 : : TEST_CASE(test_roundrobin_tx_burst),
5165 : : TEST_CASE(test_roundrobin_tx_burst_member_tx_fail),
5166 : : TEST_CASE(test_roundrobin_rx_burst_on_single_member),
5167 : : TEST_CASE(test_roundrobin_rx_burst_on_multiple_members),
5168 : : TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),
5169 : : TEST_CASE(test_roundrobin_verify_mac_assignment),
5170 : : TEST_CASE(test_roundrobin_verify_member_link_status_change_behaviour),
5171 : : TEST_CASE(test_roundrobin_verify_polling_member_link_status_change),
5172 : : TEST_CASE(test_activebackup_tx_burst),
5173 : : TEST_CASE(test_activebackup_rx_burst),
5174 : : TEST_CASE(test_activebackup_verify_promiscuous_enable_disable),
5175 : : TEST_CASE(test_activebackup_verify_mac_assignment),
5176 : : TEST_CASE(test_activebackup_verify_member_link_status_change_failover),
5177 : : TEST_CASE(test_balance_xmit_policy_configuration),
5178 : : TEST_CASE(test_balance_l2_tx_burst),
5179 : : TEST_CASE(test_balance_l23_tx_burst_ipv4_toggle_ip_addr),
5180 : : TEST_CASE(test_balance_l23_tx_burst_vlan_ipv4_toggle_ip_addr),
5181 : : TEST_CASE(test_balance_l23_tx_burst_ipv6_toggle_ip_addr),
5182 : : TEST_CASE(test_balance_l23_tx_burst_vlan_ipv6_toggle_ip_addr),
5183 : : TEST_CASE(test_balance_l23_tx_burst_toggle_mac_addr),
5184 : : TEST_CASE(test_balance_l34_tx_burst_ipv4_toggle_ip_addr),
5185 : : TEST_CASE(test_balance_l34_tx_burst_ipv4_toggle_udp_port),
5186 : : TEST_CASE(test_balance_l34_tx_burst_vlan_ipv4_toggle_ip_addr),
5187 : : TEST_CASE(test_balance_l34_tx_burst_ipv6_toggle_ip_addr),
5188 : : TEST_CASE(test_balance_l34_tx_burst_vlan_ipv6_toggle_ip_addr),
5189 : : TEST_CASE(test_balance_l34_tx_burst_ipv6_toggle_udp_port),
5190 : : TEST_CASE(test_balance_tx_burst_member_tx_fail),
5191 : : TEST_CASE(test_balance_rx_burst),
5192 : : TEST_CASE(test_balance_verify_promiscuous_enable_disable),
5193 : : TEST_CASE(test_balance_verify_mac_assignment),
5194 : : TEST_CASE(test_balance_verify_member_link_status_change_behaviour),
5195 : : TEST_CASE(test_tlb_tx_burst),
5196 : : TEST_CASE(test_tlb_rx_burst),
5197 : : TEST_CASE(test_tlb_verify_mac_assignment),
5198 : : TEST_CASE(test_tlb_verify_promiscuous_enable_disable),
5199 : : TEST_CASE(test_tlb_verify_member_link_status_change_failover),
5200 : : TEST_CASE(test_alb_change_mac_in_reply_sent),
5201 : : TEST_CASE(test_alb_reply_from_client),
5202 : : TEST_CASE(test_alb_receive_vlan_reply),
5203 : : TEST_CASE(test_alb_ipv4_tx),
5204 : : TEST_CASE(test_broadcast_tx_burst),
5205 : : TEST_CASE(test_broadcast_tx_burst_member_tx_fail),
5206 : : TEST_CASE(test_broadcast_rx_burst),
5207 : : TEST_CASE(test_broadcast_verify_promiscuous_enable_disable),
5208 : : TEST_CASE(test_broadcast_verify_mac_assignment),
5209 : : TEST_CASE(test_broadcast_verify_member_link_status_change_behaviour),
5210 : : TEST_CASE(test_reconfigure_bonding_device),
5211 : : TEST_CASE(test_close_bonding_device),
5212 : :
5213 : : TEST_CASES_END() /**< NULL terminate unit test array */
5214 : : }
5215 : : };
5216 : :
5217 : :
5218 : : static int
5219 : 0 : test_link_bonding(void)
5220 : : {
5221 : 0 : return unit_test_suite_runner(&link_bonding_test_suite);
5222 : : }
5223 : :
5224 : 251 : REGISTER_DRIVER_TEST(link_bonding_autotest, test_link_bonding);
|