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