Skip to contentSkip to conversation

link bonding

PATCH Superseded Declan Doherty 9 participants 91 messages Aug 19, 2014 – Nov 25, 2014 20 messages not in the archive Page 1 of 3

lore
Share & tools
lore
#0 lore raw

cover link bonding

This patch set adds support for link status interrupt in the link bonding pmd. It also contains some patches to tidy up the code structure and to of the link bonding code and to fix bugs relating to transmission failures in the under lying slave pmd which could lead to leaked mbufs.

Declan Doherty (6):
bond: link status interrupt support
bond: removing switch statement from rx burst method
bond: fix naming inconsistency in tx_burst_round_robin
bond: free mbufs if transmission fails in bonding tx_burst functions test app: adding support for generating variable sized packets
testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist

 app/test-pmd/cmdline.c                 |    2 +-
 app/test-pmd/testpmd.c                 |    3 +-
 app/test-pmd/testpmd.h                 |    2 +-
 app/test/packet_burst_generator.c      |   22 +--
 app/test/packet_burst_generator.h      |    6 +-
 app/test/test_link_bonding.c           |  234 ++++++++++++++++++++++++++------
 lib/librte_pmd_bond/rte_eth_bond_api.c |    4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  124 +++++++++++------
 8 files changed, 295 insertions(+), 102 deletions(-)

A message that is not in the archive (sent off-list or not yet received): 1408456313-28812-1-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/6 bond: link status interrupt support

Adding support for lsc interrupt from bonded device to link bonding library with supporting unit tests in the test application.

---
 app/test/test_link_bonding.c           |  216 +++++++++++++++++++++++++++-----
 lib/librte_pmd_bond/rte_eth_bond_api.c |    4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |    6 +
 3 files changed, 192 insertions(+), 34 deletions(-)
app/test/test_link_bonding.c +182 -34
index 5c1303e..02823b6 100644
@@ -39,6 +39,7 @@
 #include <inttypes.h>
 #include <errno.h>
 #include <sys/queue.h>
+#include <sys/time.h>
 
 #include <rte_byteorder.h>
 #include <rte_common.h>
@@ -224,10 +225,15 @@ static struct rte_eth_txconf tx_conf_default = {
 };
 
 static int
-configure_ethdev(uint8_t port_id, uint8_t start)
+configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 {
 	int q_id;
 
+	if (en_isr)
+		default_pmd_conf.intr_conf.lsc = 1;
+	else
+		default_pmd_conf.intr_conf.lsc = 0;
+
 	if (rte_eth_dev_configure(port_id, test_params->nb_rx_q,
 			test_params->nb_tx_q, &default_pmd_conf) != 0) {
 		goto error;
@@ -312,7 +318,7 @@ test_setup(void)
 
 			printf("Created virtual ethdev %s\n", pmd_name);
 
-			retval = configure_ethdev(test_params->slave_port_ids[i], 1);
+			retval = configure_ethdev(test_params->slave_port_ids[i], 1, 0);
 			if (retval != 0) {
 				printf("Failed to configure virtual ethdev %s\n", pmd_name);
 				return -1;
@@ -341,7 +347,7 @@ test_create_bonded_device(void)
 		TEST_ASSERT(test_params->bonded_port_id >= 0,
 				"Failed to create bonded ethdev %s", BONDED_DEV_NAME);
 
-		TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
+		TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
 				"Failed to configure bonded ethdev %s", BONDED_DEV_NAME);
 	}
 
@@ -1078,12 +1084,12 @@ test_set_explicit_bonded_mac(void)
 
 
 static int
-initialize_bonded_device_with_slaves(uint8_t bonding_mode,
+initialize_bonded_device_with_slaves(uint8_t bonding_mode, uint8_t bond_en_isr,
 		uint8_t number_of_slaves, uint8_t enable_slave)
 {
 	/* configure bonded device */
-	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
-			"Failed to configure bonding port (%d) in mode %d "
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0,
+			bond_en_isr), "Failed to configure bonding port (%d) in mode %d "
 			"with (%d) slaves.", test_params->bonded_port_id, bonding_mode,
 			number_of_slaves);
 
@@ -1116,8 +1122,8 @@ test_adding_slave_after_bonded_device_started(void)
 {
 	int i;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 0) !=
-			0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 0)
+			!= 0)
 		return -1;
 
 	/* Enabled slave devices */
@@ -1141,6 +1147,147 @@ test_adding_slave_after_bonded_device_started(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_STATUS_INTERRUPT_SLAVE_COUNT	4
+#define TEST_LSC_WAIT_TIMEOUT_MS	500
+
+int test_lsc_interupt_count;
+
+static pthread_mutex_t mutex;
+static pthread_cond_t cvar;
+
+static void
+test_bonding_lsc_event_callback(uint8_t port_id __rte_unused,
+		enum rte_eth_event_type type  __rte_unused, void *param __rte_unused)
+{
+	pthread_mutex_lock(&mutex);
+	test_lsc_interupt_count++;
+
+	pthread_cond_signal(&cvar);
+	pthread_mutex_unlock(&mutex);
+}
+
+static inline int
+lsc_timeout(int wait_us)
+{
+	int retval = 0;
+
+	struct timespec ts;
+	struct timeval tp;
+
+	gettimeofday(&tp, NULL);
+
+	/* Convert from timeval to timespec */
+	ts.tv_sec  = tp.tv_sec;
+	ts.tv_nsec = tp.tv_usec * 1000;
+	ts.tv_nsec += wait_us * 1000;
+
+	pthread_mutex_lock(&mutex);
+	if (test_lsc_interupt_count < 1)
+		retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+
+	pthread_mutex_unlock(&mutex);
+
+	if (test_lsc_interupt_count  < 1)
+               return retval;
+
+	return 0;
+}
+
+static int
+test_status_interrupt(void)
+{
+	int slave_count;
+	uint8_t slaves[RTE_MAX_ETHPORTS];
+
+	pthread_mutex_init(&mutex, NULL);
+	pthread_cond_init(&cvar, NULL);
+
+	/* initialized bonding device with T slaves */
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 1,
+			TEST_STATUS_INTERRUPT_SLAVE_COUNT, 1) != 0)
+		return -1;
+
+	test_lsc_interupt_count = 0;
+
+	/* register link status change interrupt callback */
+	rte_eth_dev_callback_register(test_params->bonded_port_id,
+			RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
+			&test_params->bonded_port_id);
+
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+
+	TEST_ASSERT_EQUAL(slave_count, TEST_STATUS_INTERRUPT_SLAVE_COUNT,
+			"Number of active slaves (%d) is not as expected (%d)",
+			slave_count, TEST_STATUS_INTERRUPT_SLAVE_COUNT);
+
+	/* Bring all 4 slaves link status to down and test that we have received a
+	 * lsc interrupts */
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 0);
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[1], 0);
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[2], 0);
+
+	TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+			"Received a link status change interrupt unexpectedly");
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[3], 0);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
+			"timed out waiting for interrupt");
+
+	TEST_ASSERT(test_lsc_interupt_count > 0,
+			"Did not receive link status change interrupt");
+
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+
+	TEST_ASSERT_EQUAL(slave_count, 0,
+			"Number of active slaves (%d) is not as expected (%d)",
+			slave_count, 0);
+
+	/* bring one slave port up so link status will change */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 1);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
+			"timed out waiting for interrupt");
+
+	/* test that we have received another lsc interrupt */
+	TEST_ASSERT(test_lsc_interupt_count > 0,
+			"Did not receive link status change interrupt");
+
+	/* Verify that calling the same slave lsc interrupt doesn't cause another
+	 * lsc interrupt from bonded device */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 1);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) != 0,
+			"received unexpected interrupt");
+
+	TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+			"Did not receive link status change interrupt");
+
+
+	/* unregister lsc callback before exiting */
+	rte_eth_dev_callback_unregister(test_params->bonded_port_id,
+				RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
+				&test_params->bonded_port_id);
+
+	pthread_mutex_destroy(&mutex);
+	pthread_cond_destroy(&cvar);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 static int
 generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 		uint8_t vlan, uint8_t ipv4, uint8_t toggle_dst_mac,
@@ -1209,7 +1356,7 @@ test_roundrobin_tx_burst(void)
 	struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 2, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 2, 1)
 			!= 0)
 		return -1;
 
@@ -1279,7 +1426,7 @@ test_roundrobin_rx_burst_on_single_slave(void)
 	int i, j, nb_rx, burst_size = 25;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1369,7 +1516,7 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1461,7 +1608,7 @@ test_roundrobin_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[2], &expected_mac_addr_2);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1)
 			!= 0)
 		return -1;
 
@@ -1552,7 +1699,7 @@ test_roundrobin_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1616,7 +1763,7 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 	/* Initialize bonded device with TEST_RR_LINK_STATUS_SLAVE_COUNT slaves
 	 * in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
 			TEST_RR_LINK_STATUS_SLAVE_COUNT, 1) != 0)
 		return -1;
 
@@ -1757,7 +1904,7 @@ test_activebackup_tx_burst(void)
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -1854,7 +2001,7 @@ test_activebackup_rx_burst(void)
 	int i, j, nb_rx, burst_size = 17;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
 			!= 0)
 		return -1;
@@ -1948,7 +2095,7 @@ test_activebackup_verify_promiscuous_enable_disable(void)
 	int i, primary_port, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 4, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 4, 1)
 			!= 0)
 		return -1;
 
@@ -2018,7 +2165,7 @@ test_activebackup_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 2, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1)
 			!= 0)
 		return -1;
 
@@ -2157,7 +2304,7 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 	}
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
 			!= 0)
 		return -1;
@@ -2328,7 +2475,7 @@ test_balance_xmit_policy_configuration(void)
 {
 	int retval;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
@@ -2408,7 +2555,7 @@ test_balance_l2_tx_burst(void)
 	int retval, i;
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE,
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
 			TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
@@ -2506,7 +2653,7 @@ balance_l23_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -2634,7 +2781,7 @@ balance_l34_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -2772,7 +2919,7 @@ test_balance_rx_burst(void)
 	memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 3, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 3, 1)
 			!= 0)
 		return -1;
 
@@ -2861,7 +3008,7 @@ test_balance_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1) != 0)
 		return -1;
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
@@ -2915,7 +3062,7 @@ test_balance_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1) != 0)
 		return -1;
 
 	/* Verify that bonded MACs is that of first slave and that the other slave
@@ -3045,7 +3192,7 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
 			TEST_BALANCE_LINK_STATUS_SLAVE_COUNT, 1) != 0)
 		return -1;
 
@@ -3237,7 +3384,7 @@ test_broadcast_tx_burst(void)
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -3327,7 +3474,7 @@ test_broadcast_rx_burst(void)
 	memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 3, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 3, 1) != 0)
 		return -1;
 
 
@@ -3419,7 +3566,7 @@ test_broadcast_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1) != 0)
 		return -1;
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
@@ -3475,7 +3622,7 @@ test_broadcast_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[2], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4, 1) != 0)
 		return -1;
 
 	/* Verify that all MACs are the same as first slave added to bonded
@@ -3575,7 +3722,7 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0,
 			BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
 		return -1;
 
@@ -3711,7 +3858,7 @@ test_reconfigure_bonded_device(void)
 	test_params->nb_rx_q = 4;
 	test_params->nb_tx_q = 4;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0)  != 0) {
+	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
 		printf("failed to reconfigure bonded device");
 		return -1;
 	}
@@ -3720,7 +3867,7 @@ test_reconfigure_bonded_device(void)
 	test_params->nb_rx_q = 2;
 	test_params->nb_tx_q = 2;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0)  != 0) {
+	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
 		printf("failed to reconfigure bonded device with less rx/tx queues");
 		return -1;
 	}
@@ -3768,6 +3915,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_set_bonding_mode),
 		TEST_CASE(test_set_primary_slave),
 		TEST_CASE(test_set_explicit_bonded_mac),
+		TEST_CASE(test_status_interrupt),
 		TEST_CASE(test_adding_slave_after_bonded_device_started),
 		TEST_CASE(test_roundrobin_tx_burst),
 		TEST_CASE(test_roundrobin_rx_burst_on_single_slave),
lib/librte_pmd_bond/rte_eth_bond_api.c +4 -0
index 75f5694..dd33119 100644
@@ -177,6 +177,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	pci_drv->id_table->vendor_id = PCI_ANY_ID;
 	pci_drv->id_table->subsystem_vendor_id = PCI_ANY_ID;
 
+	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
 		RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
@@ -200,6 +202,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
 
+	TAILQ_INIT(&(eth_dev->callbacks));
+
 	eth_dev->data->dev_link.link_status = 0;
 
 	eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
lib/librte_pmd_bond/rte_eth_bond_pmd.c +6 -0
index d72d6ed..cd3eecf 100644
@@ -921,6 +921,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 	struct rte_eth_link link;
 
 	int i, valid_slave = 0, active_pos = -1;
+	uint8_t lsc_flag = 0;
 
 	if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
 		return;
@@ -966,6 +967,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 			/* If first active slave, then change link status */
 			bonded_eth_dev->data->dev_link.link_status = 1;
 			internals->current_primary_port = port_id;
+			lsc_flag = 1;
 
 			/* Inherit eth dev link properties from first active slave */
 			link_properties_set(bonded_eth_dev,
@@ -990,6 +992,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		/* No active slaves, change link status to down and reset other
 		 * link properties */
 		if (internals->active_slave_count < 1) {
+			lsc_flag = 1;
 			bonded_eth_dev->data->dev_link.link_status = 0;
 
 			link_properties_reset(bonded_eth_dev);
@@ -1005,6 +1008,9 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 				internals->current_primary_port = internals->primary_port;
 		}
 	}
+
+	if (lsc_flag)
+		_rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
 }
 
 struct eth_dev_ops default_dev_ops = {
Signature · 1 line
1.7.0.7

A message that is not in the archive (sent off-list or not yet received): 1408456313-28812-2-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

Reviewed-by
#4 lore raw

Re: [PATCH 1/6] bond: link status interrupt support

Quoted 602 lines

Adding support for lsc interrupt from bonded device to link bonding library with supporting unit tests in the test application.

---
app/test/test_link_bonding.c | 216
+++++++++++++++++++++++++++-----

lib/librte_pmd_bond/rte_eth_bond_api.c |    4 +
lib/librte_pmd_bond/rte_eth_bond_pmd.c |    6 +
3 files changed, 192 insertions(+), 34 deletions(-)
app/test/test_link_bonding.c +1 -0
index 5c1303e..02823b6 100644
@@ -39,6 +39,7 @@
 #include <inttypes.h>
 #include <errno.h>
 #include <sys/queue.h>
+#include <sys/time.h>
 
 #include <rte_byteorder.h>
 #include <rte_common.h>
@@ -224,10 +225,15 @@ static struct rte_eth_txconf tx_conf_default = {
 };
 

static int

app/test/test_link_bonding.c +1 -1
-configure_ethdev(uint8_t port_id, uint8_t start)
+configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
{
      int q_id;
app/test/test_link_bonding.c +7 -2
+      if (en_isr)
+              default_pmd_conf.intr_conf.lsc = 1;
+      else
+              default_pmd_conf.intr_conf.lsc = 0;
+
      if (rte_eth_dev_configure(port_id, test_params->nb_rx_q,
                      test_params->nb_tx_q, &default_pmd_conf) != 0) {
              goto error;
@@ -312,7 +318,7 @@ test_setup(void)
 
                      printf("Created virtual ethdev %s\n", pmd_name);
 
-                      retval = configure_ethdev(test_params->slave_port_ids[i], 1);
+                      retval = configure_ethdev(test_params->slave_port_ids[i], 1, 0);
                      if (retval != 0) {
                              printf("Failed to configure virtual ethdev %s\n", pmd_name);
                              return -1;
@@ -341,7 +347,7 @@ test_create_bonded_device(void)
              TEST_ASSERT(test_params->bonded_port_id >= 0,
                              "Failed to create bonded ethdev %s", BONDED_DEV_NAME);
 
-              TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
+              TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0,
 0),
                              "Failed to configure bonded ethdev %s", BONDED_DEV_NAME);
      }
@@ -1078,12 +1084,12 @@ test_set_explicit_bonded_mac(void)
 
 

static int

app/test/test_link_bonding.c +1 -1
-initialize_bonded_device_with_slaves(uint8_t bonding_mode,
+initialize_bonded_device_with_slaves(uint8_t bonding_mode, uint8_t

bond_en_isr,
uint8_t number_of_slaves, uint8_t enable_slave)

{
      /* configure bonded device */
app/test/test_link_bonding.c +2 -3
-      TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
-                      "Failed to configure bonding port (%d) in mode %d "
+      TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0,
+                      bond_en_isr), "Failed to configure bonding port (%d) in mode %d "
                      "with (%d) slaves.", test_params->bonded_port_id, bonding_mode,
                      number_of_slaves);
@@ -1116,8 +1122,8 @@ test_adding_slave_after_bonded_device_started(void)
 {
      int i;
 
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4,

0) !=

app/test/test_link_bonding.c +1 -1
-                      0)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,

4, 0)

app/test/test_link_bonding.c +76 -0
+                      != 0)
              return -1;
 
      /* Enabled slave devices */
@@ -1141,6 +1147,147 @@
 test_adding_slave_after_bonded_device_started(void)
      return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_STATUS_INTERRUPT_SLAVE_COUNT     4
+#define TEST_LSC_WAIT_TIMEOUT_MS      500
+
+int test_lsc_interupt_count;
+
+static pthread_mutex_t mutex;
+static pthread_cond_t cvar;
+
+static void
+test_bonding_lsc_event_callback(uint8_t port_id __rte_unused,
+              enum rte_eth_event_type type  __rte_unused, void *param __rte_unused)
+{
+      pthread_mutex_lock(&mutex);
+      test_lsc_interupt_count++;
+
+      pthread_cond_signal(&cvar);
+      pthread_mutex_unlock(&mutex);
+}
+
+static inline int
+lsc_timeout(int wait_us)
+{
+      int retval = 0;
+
+      struct timespec ts;
+      struct timeval tp;
+
+      gettimeofday(&tp, NULL);
+
+      /* Convert from timeval to timespec */
+      ts.tv_sec  = tp.tv_sec;
+      ts.tv_nsec = tp.tv_usec * 1000;
+      ts.tv_nsec += wait_us * 1000;
+
+      pthread_mutex_lock(&mutex);
+      if (test_lsc_interupt_count < 1)
+              retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+
+      pthread_mutex_unlock(&mutex);
+
+      if (test_lsc_interupt_count  < 1)
+               return retval;
+
+      return 0;
+}
+
+static int
+test_status_interrupt(void)
+{
+      int slave_count;
+      uint8_t slaves[RTE_MAX_ETHPORTS];
+
+      pthread_mutex_init(&mutex, NULL);
+      pthread_cond_init(&cvar, NULL);
+
+      /* initialized bonding device with T slaves */
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 1,
+                      TEST_STATUS_INTERRUPT_SLAVE_COUNT, 1) != 0)
+              return -1;
+
+      test_lsc_interupt_count = 0;
+
+      /* register link status change interrupt callback */
+      rte_eth_dev_callback_register(test_params->bonded_port_id,
+                      RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
+                      &test_params->bonded_port_id);
+
+      slave_count =
 rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+                      slaves, RTE_MAX_ETHPORTS);
+
+      TEST_ASSERT_EQUAL(slave_count, TEST_STATUS_INTERRUPT_SLAVE_COUNT,
+                      "Number of active slaves (%d) is not as expected (%d)",
+                      slave_count, TEST_STATUS_INTERRUPT_SLAVE_COUNT);
+
+      /* Bring all 4 slaves link status to down and test that we have

received a

app/test/test_link_bonding.c +21 -0
+       * lsc interrupts */
+      virtual_ethdev_simulate_link_status_interrupt(
+                      test_params->slave_port_ids[0], 0);
+      virtual_ethdev_simulate_link_status_interrupt(
+                      test_params->slave_port_ids[1], 0);
+      virtual_ethdev_simulate_link_status_interrupt(
+                      test_params->slave_port_ids[2], 0);
+
+      TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+                      "Received a link status change interrupt unexpectedly");
+
+      virtual_ethdev_simulate_link_status_interrupt(
+                      test_params->slave_port_ids[3], 0);
+
+      TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
+                      "timed out waiting for interrupt");
+
+      TEST_ASSERT(test_lsc_interupt_count > 0,
+                      "Did not receive link status change interrupt");
+
+      slave_count =

rte_eth_bond_active_slaves_get(test_params->bonded_port_id,

app/test/test_link_bonding.c +20 -0
+                      slaves, RTE_MAX_ETHPORTS);
+
+      TEST_ASSERT_EQUAL(slave_count, 0,
+                      "Number of active slaves (%d) is not as expected (%d)",
+                      slave_count, 0);
+
+      /* bring one slave port up so link status will change */
+      test_lsc_interupt_count = 0;
+
+      virtual_ethdev_simulate_link_status_interrupt(
+                      test_params->slave_port_ids[0], 1);
+
+      TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
+                      "timed out waiting for interrupt");
+
+      /* test that we have received another lsc interrupt */
+      TEST_ASSERT(test_lsc_interupt_count > 0,
+                      "Did not receive link status change interrupt");
+
+      /* Verify that calling the same slave lsc interrupt doesn't cause

another

app/test/test_link_bonding.c +25 -0
+       * lsc interrupt from bonded device */
+      test_lsc_interupt_count = 0;
+
+      virtual_ethdev_simulate_link_status_interrupt(
+                      test_params->slave_port_ids[0], 1);
+
+      TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) != 0,
+                      "received unexpected interrupt");
+
+      TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+                      "Did not receive link status change interrupt");
+
+
+      /* unregister lsc callback before exiting */
+      rte_eth_dev_callback_unregister(test_params->bonded_port_id,
+                              RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
+                              &test_params->bonded_port_id);
+
+      pthread_mutex_destroy(&mutex);
+      pthread_cond_destroy(&cvar);
+
+      /* Clean up and remove slaves from bonded device */
+      return remove_slaves_and_stop_bonded_device();
+}
+

static int
generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
uint8_t vlan, uint8_t ipv4, uint8_t toggle_dst_mac,

app/test/test_link_bonding.c +1 -2
@@ -1209,7 +1356,7 @@ test_roundrobin_tx_burst(void)
      struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
      struct rte_eth_stats port_stats;
 
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 2, 1)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
 2, 1)
                      != 0)
              return -1;
@@ -1279,7 +1426,7 @@ test_roundrobin_rx_burst_on_single_slave(void)
      int i, j, nb_rx, burst_size = 25;
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4,

1) !=
+ if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
4, 1) !=

                      0)
              return -1;
app/test/test_link_bonding.c +0 -1
@@ -1369,7 +1516,7 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4,

1) !=
+ if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
4, 1) !=

                      0)
              return -1;
app/test/test_link_bonding.c +1 -1
@@ -1461,7 +1608,7 @@ test_roundrobin_verify_mac_assignment(void)
      rte_eth_macaddr_get(test_params->slave_port_ids[2],
 &expected_mac_addr_2);
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
 4, 1)
                      != 0)
              return -1;
app/test/test_link_bonding.c +0 -1
@@ -1552,7 +1699,7 @@
 test_roundrobin_verify_promiscuous_enable_disable(void)
      int i, promiscuous_en;
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4,

1) !=
+ if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
4, 1) !=

                      0)
              return -1;
app/test/test_link_bonding.c +2 -2
@@ -1616,7 +1763,7 @@
 test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
      /* Initialize bonded device with TEST_RR_LINK_STATUS_SLAVE_COUNT slaves
       * in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN,
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
                      TEST_RR_LINK_STATUS_SLAVE_COUNT, 1) != 0)
              return -1;
@@ -1757,7 +1904,7 @@ test_activebackup_tx_burst(void)
      struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
      struct rte_eth_stats port_stats;
 
-      retval =
 initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 2, 1);
+      retval =
 initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1);
      if (retval != 0) {
              printf("Failed to initialize_bonded_device_with_slaves.\n");
              return -1;
app/test/test_link_bonding.c +2 -2
@@ -1854,7 +2001,7 @@ test_activebackup_rx_burst(void)
      int i, j, nb_rx, burst_size = 17;
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
                      TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
                      != 0)
              return -1;
@@ -1948,7 +2095,7 @@
 test_activebackup_verify_promiscuous_enable_disable(void)
      int i, primary_port, promiscuous_en;
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 4,
 1)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 4, 1)
                      != 0)
              return -1;
app/test/test_link_bonding.c +1 -1
@@ -2018,7 +2165,7 @@ test_activebackup_verify_mac_assignment(void)
      rte_eth_macaddr_get(test_params->slave_port_ids[1],
 &expected_mac_addr_1);
 
      /* Initialize bonded device with 2 slaves in active backup mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 2,
 1)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 2, 1)
                      != 0)
              return -1;
app/test/test_link_bonding.c +1 -1
@@ -2157,7 +2304,7 @@
 test_activebackup_verify_slave_link_status_change_failover(void)
      }
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
                      TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
                      != 0)
              return -1;
app/test/test_link_bonding.c +1 -1
@@ -2328,7 +2475,7 @@ test_balance_xmit_policy_configuration(void)
 {
      int retval;
 
-      retval =
 initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+      retval =
 initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
                      2, 1);
      if (retval != 0) {
              printf("Failed to initialize_bonded_device_with_slaves.\n");
app/test/test_link_bonding.c +2 -2
@@ -2408,7 +2555,7 @@ test_balance_l2_tx_burst(void)
      int retval, i;
      struct rte_eth_stats port_stats;
 
-      retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE,
+      retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
                      TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT, 1);
      if (retval != 0) {
              printf("Failed to initialize_bonded_device_with_slaves.\n");
@@ -2506,7 +2653,7 @@ balance_l23_tx_burst(uint8_t vlan_enabled, uint8_t
 ipv4,
 
      struct rte_eth_stats port_stats;
 
-      retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2,
 1);
+      retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
 2, 1);
      if (retval != 0) {
              printf("Failed to initialize_bonded_device_with_slaves.\n");
              return -1;
app/test/test_link_bonding.c +1 -1
@@ -2634,7 +2781,7 @@ balance_l34_tx_burst(uint8_t vlan_enabled, uint8_t
 ipv4,
 
      struct rte_eth_stats port_stats;
 
-      retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2,
 1);
+      retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
 2, 1);
      if (retval != 0) {
              printf("Failed to initialize_bonded_device_with_slaves.\n");
              return -1;
app/test/test_link_bonding.c +2 -2
@@ -2772,7 +2919,7 @@ test_balance_rx_burst(void)
      memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 3, 1)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 3, 1)
                      != 0)
              return -1;
 
@@ -2861,7 +3008,7 @@ test_balance_verify_promiscuous_enable_disable(void)
      int i, promiscuous_en;
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 4, 1) !=
 0)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1)
 != 0)
              return -1;
      rte_eth_promiscuous_enable(test_params->bonded_port_id);
app/test/test_link_bonding.c +1 -1
@@ -2915,7 +3062,7 @@ test_balance_verify_mac_assignment(void)
      rte_eth_macaddr_get(test_params->slave_port_ids[1],
 &expected_mac_addr_1);
 
      /* Initialize bonded device with 2 slaves in active backup mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1) !=
 0)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1)
 != 0)
              return -1;

      /* Verify that bonded MACs is that of first slave and that the other

slave

app/test/test_link_bonding.c +2 -2
@@ -3045,7 +3192,7 @@
 test_balance_verify_slave_link_status_change_behaviour(void)
      memset(pkt_burst, 0, sizeof(pkt_burst));
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE,
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
                      TEST_BALANCE_LINK_STATUS_SLAVE_COUNT, 1) != 0)
              return -1;
@@ -3237,7 +3384,7 @@ test_broadcast_tx_burst(void)
 
      struct rte_eth_stats port_stats;
 
-      retval = initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST,
 2, 1);
+      retval = initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST,
 0, 2, 1);
      if (retval != 0) {
              printf("Failed to initialize_bonded_device_with_slaves.\n");
              return -1;
app/test/test_link_bonding.c +2 -2
@@ -3327,7 +3474,7 @@ test_broadcast_rx_burst(void)
      memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 3, 1)
 != 0)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 3,
 1) != 0)
              return -1;
@@ -3419,7 +3566,7 @@
 test_broadcast_verify_promiscuous_enable_disable(void)
      int i, promiscuous_en;
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 4, 1) !=
 0)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1)
 != 0)
              return -1;

      rte_eth_promiscuous_enable(test_params->bonded_port_id);
app/test/test_link_bonding.c +1 -1
@@ -3475,7 +3622,7 @@ test_broadcast_verify_mac_assignment(void)
      rte_eth_macaddr_get(test_params->slave_port_ids[2],
 &expected_mac_addr_1);
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 4, 1)
 != 0)
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4,
 1) != 0)
              return -1;

      /* Verify that all MACs are the same as first slave added to bonded
app/test/test_link_bonding.c +4 -3
@@ -3575,7 +3722,7 @@
 test_broadcast_verify_slave_link_status_change_behaviour(void)
      memset(pkt_burst, 0, sizeof(pkt_burst));
 
      /* Initialize bonded device with 4 slaves in round robin mode */
-      if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST,
+      if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0,
                      BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
              return -1;
@@ -3711,7 +3858,7 @@ test_reconfigure_bonded_device(void)
      test_params->nb_rx_q = 4;
      test_params->nb_tx_q = 4;
 
-      if (configure_ethdev(test_params->bonded_port_id, 0)  != 0) {
+      if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
              printf("failed to reconfigure bonded device");
              return -1;
      }
@@ -3720,7 +3867,7 @@ test_reconfigure_bonded_device(void)
      test_params->nb_rx_q = 2;
      test_params->nb_tx_q = 2;
 
-      if (configure_ethdev(test_params->bonded_port_id, 0)  != 0) {
+      if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
              printf("failed to reconfigure bonded device with less rx/tx queues");
              return -1;
      }
@@ -3768,6 +3915,7 @@ static struct unit_test_suite
 link_bonding_test_suite  = {
              TEST_CASE(test_set_bonding_mode),
              TEST_CASE(test_set_primary_slave),
              TEST_CASE(test_set_explicit_bonded_mac),
+              TEST_CASE(test_status_interrupt),
              TEST_CASE(test_adding_slave_after_bonded_device_started),
              TEST_CASE(test_roundrobin_tx_burst),

TEST_CASE(test_roundrobin_rx_burst_on_single_slave),

lib/librte_pmd_bond/rte_eth_bond_api.c +2 -0
index 75f5694..dd33119 100644
@@ -177,6 +177,8 @@ rte_eth_bond_create(const char *name, uint8_t mode,
 uint8_t socket_id)
      pci_drv->id_table->vendor_id = PCI_ANY_ID;
      pci_drv->id_table->subsystem_vendor_id = PCI_ANY_ID;
 
+      pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+
      internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
      if (internals == NULL) {
              RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
lib/librte_pmd_bond/rte_eth_bond_api.c +2 -0
@@ -200,6 +202,8 @@ rte_eth_bond_create(const char *name, uint8_t mode,
 uint8_t socket_id)
      eth_dev->data->nb_rx_queues = (uint16_t)1;
      eth_dev->data->nb_tx_queues = (uint16_t)1;
 
+      TAILQ_INIT(&(eth_dev->callbacks));
+
      eth_dev->data->dev_link.link_status = 0;
 
      eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
lib/librte_pmd_bond/rte_eth_bond_pmd.c +1 -0
index d72d6ed..cd3eecf 100644
@@ -921,6 +921,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum
 rte_eth_event_type type,
      struct rte_eth_link link;
 
      int i, valid_slave = 0, active_pos = -1;
+      uint8_t lsc_flag = 0;
 
      if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
              return;
lib/librte_pmd_bond/rte_eth_bond_pmd.c +1 -0
@@ -966,6 +967,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum
 rte_eth_event_type type,
                      /* If first active slave, then change link status */
                      bonded_eth_dev->data->dev_link.link_status = 1;
                      internals->current_primary_port = port_id;
+                      lsc_flag = 1;
 
                      /* Inherit eth dev link properties from first active slave */

link_properties_set(bonded_eth_dev,

lib/librte_pmd_bond/rte_eth_bond_pmd.c +1 -0
@@ -990,6 +992,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum
 rte_eth_event_type type,
              /* No active slaves, change link status to down and reset other
               * link properties */
              if (internals->active_slave_count < 1) {
+                      lsc_flag = 1;
                      bonded_eth_dev->data->dev_link.link_status = 0;
 
                      link_properties_reset(bonded_eth_dev);
lib/librte_pmd_bond/rte_eth_bond_pmd.c +3 -0
@@ -1005,6 +1008,9 @@ bond_ethdev_lsc_event_callback(uint8_t port_id,
 enum rte_eth_event_type type,
                              internals->current_primary_port = internals->primary_port;
              }
      }
+
+      if (lsc_flag)
+              _rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
 }
 

struct eth_dev_ops default_dev_ops = {
--
1.7.0.7

#5 lore raw

PATCH 2/6 bond: removing switch statement from rx burst method

In reply to a message not in the archive

Splitting rx burst function into seperate functions to avoid the need for a switch statement and also to match the structure of the tx burst functions.

---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   62 ++++++++++++++++++--------------
 1 files changed, 35 insertions(+), 27 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +35 -27
index cd3eecf..683b146 100644
@@ -59,33 +59,37 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	internals = bd_rx_q->dev_private;
 
-	switch (internals->mode) {
-	case BONDING_MODE_ROUND_ROBIN:
-	case BONDING_MODE_BROADCAST:
-	case BONDING_MODE_BALANCE:
-		for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
-			/* Offset of pointer to *bufs increases as packets are received
-			 * from other slaves */
-			num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
-					bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
-			if (num_rx_slave) {
-				num_rx_total += num_rx_slave;
-				nb_pkts -= num_rx_slave;
-			}
+	for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
+		/* Offset of pointer to *bufs increases as packets are received
+		 * from other slaves */
+		num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
+				bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
+		if (num_rx_slave) {
+			num_rx_total += num_rx_slave;
+			nb_pkts -= num_rx_slave;
 		}
-		break;
-	case BONDING_MODE_ACTIVE_BACKUP:
-		num_rx_slave = rte_eth_rx_burst(internals->current_primary_port,
-				bd_rx_q->queue_id, bufs, nb_pkts);
-		if (num_rx_slave)
-			num_rx_total = num_rx_slave;
-		break;
 	}
+
 	return num_rx_total;
 }
 
 static uint16_t
-bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
+bond_ethdev_rx_burst_active_backup(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
+{
+	struct bond_dev_private *internals;
+
+	/* Cast to structure, containing bonded device's port id and queue id */
+	struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
+
+	internals = bd_rx_q->dev_private;
+
+	return rte_eth_rx_burst(internals->current_primary_port,
+			bd_rx_q->queue_id, bufs, nb_pkts);
+}
+
+static uint16_t
+bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
 {
 	struct bond_dev_private *dev_private;
@@ -134,7 +138,7 @@ bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
 }
 
 static uint16_t
-bond_ethdev_tx_active_backup(void *queue,
+bond_ethdev_tx_burst_active_backup(void *queue,
 		struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
 	struct bond_dev_private *internals;
@@ -270,7 +274,8 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t slave_count, uint8_t policy)
 }
 
 static uint16_t
-bond_ethdev_tx_balance(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
 {
 	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
@@ -480,22 +485,25 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int mode)
 
 	switch (mode) {
 	case BONDING_MODE_ROUND_ROBIN:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_round_robin;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_round_robin;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	case BONDING_MODE_ACTIVE_BACKUP:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_active_backup;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_active_backup;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup;
 		break;
 	case BONDING_MODE_BALANCE:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_balance;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_balance;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	case BONDING_MODE_BROADCAST:
 		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	default:
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 	internals->mode = mode;
 
 	return 0;
Signature · 1 line
1.7.0.7

A message that is not in the archive (sent off-list or not yet received): 1408456313-28812-3-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

Reviewed-by
#7 lore raw

Re: [PATCH 2/6] bond: removing switch statement from rx burst method

Quoted 131 lines

Splitting rx burst function into seperate functions to avoid the need for a switch statement and also to match the structure of the tx burst functions.

---
lib/librte_pmd_bond/rte_eth_bond_pmd.c | 62
++++++++++++++++++--------------

1 files changed, 35 insertions(+), 27 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +9 -20
index cd3eecf..683b146 100644
@@ -59,33 +59,37 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf
 **bufs, uint16_t nb_pkts)
 
 	internals = bd_rx_q->dev_private;
 
-	switch (internals->mode) {
-	case BONDING_MODE_ROUND_ROBIN:
-	case BONDING_MODE_BROADCAST:
-	case BONDING_MODE_BALANCE:
-		for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
-			/* Offset of pointer to *bufs increases as packets are received
-			 * from other slaves */
-			num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
-					bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
-			if (num_rx_slave) {
-				num_rx_total += num_rx_slave;
-				nb_pkts -= num_rx_slave;
-			}
+	for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
+		/* Offset of pointer to *bufs increases as packets are received
+		 * from other slaves */
+		num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
+				bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
+		if (num_rx_slave) {
+			num_rx_total += num_rx_slave;
+			nb_pkts -= num_rx_slave;
 		}
-		break;
-	case BONDING_MODE_ACTIVE_BACKUP:
-		num_rx_slave = rte_eth_rx_burst(internals->current_primary_port,
-				bd_rx_q->queue_id, bufs, nb_pkts);
-		if (num_rx_slave)
-			num_rx_total = num_rx_slave;
-		break;
 	}
+
 	return num_rx_total;
 }
 

static uint16_t

lib/librte_pmd_bond/rte_eth_bond_pmd.c +16 -1
-bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
+bond_ethdev_rx_burst_active_backup(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
+{
+	struct bond_dev_private *internals;
+
+	/* Cast to structure, containing bonded device's port id and queue id */
+	struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
+
+	internals = bd_rx_q->dev_private;
+
+	return rte_eth_rx_burst(internals->current_primary_port,
+			bd_rx_q->queue_id, bufs, nb_pkts);
+}
+
+static uint16_t
+bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
		uint16_t nb_pkts)
{
	struct bond_dev_private *dev_private;
lib/librte_pmd_bond/rte_eth_bond_pmd.c +0 -0
@@ -134,7 +138,7 @@ bond_ethdev_tx_round_robin(void *queue, struct
 rte_mbuf **bufs,
 }
 

static uint16_t

lib/librte_pmd_bond/rte_eth_bond_pmd.c +1 -1
-bond_ethdev_tx_active_backup(void *queue,
+bond_ethdev_tx_burst_active_backup(void *queue,

struct rte_mbuf **bufs, uint16_t nb_pkts)

{
	struct bond_dev_private *internals;
lib/librte_pmd_bond/rte_eth_bond_pmd.c +0 -0
@@ -270,7 +274,8 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t
 slave_count, uint8_t policy)
 }
 

static uint16_t
-bond_ethdev_tx_balance(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)

lib/librte_pmd_bond/rte_eth_bond_pmd.c +2 -0
+bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
{
	struct bond_dev_private *internals;
	struct bond_tx_queue *bd_tx_q;
lib/librte_pmd_bond/rte_eth_bond_pmd.c +7 -4
@@ -480,22 +485,25 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev,
 int mode)
 
 	switch (mode) {
 	case BONDING_MODE_ROUND_ROBIN:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_round_robin;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_round_robin;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	case BONDING_MODE_ACTIVE_BACKUP:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_active_backup;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_active_backup;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup;
 		break;
 	case BONDING_MODE_BALANCE:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_balance;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_balance;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	case BONDING_MODE_BROADCAST:
 		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	default:
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 	internals->mode = mode;
 
	return 0;
Signature · 1 line
1.7.0.7
#8 lore raw

PATCH 3/6 bond: fix naming inconsistency in tx_burst_round_robin

In reply to a message not in the archive

Renaming struct bond_dev_pritvate *dev_private to internals to match convention used in other pmds

---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +5 -5
index 683b146..70123fc 100644
@@ -92,7 +92,7 @@ static uint16_t
 bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
 {
-	struct bond_dev_private *dev_private;
+	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
 
 	struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_pkts];
@@ -107,13 +107,13 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 	int i, cs_idx = 0;
 
 	bd_tx_q = (struct bond_tx_queue *)queue;
-	dev_private = bd_tx_q->dev_private;
+	internals = bd_tx_q->dev_private;
 
 	/* Copy slave list to protect against slave up/down changes during tx
 	 * bursting */
-	num_of_slaves = dev_private->active_slave_count;
-	memcpy(slaves, dev_private->active_slaves,
-			sizeof(dev_private->active_slaves[0]) * num_of_slaves);
+	num_of_slaves = internals->active_slave_count;
+	memcpy(slaves, internals->active_slaves,
+			sizeof(internals->active_slaves[0]) * num_of_slaves);
 
 	if (num_of_slaves < 1)
 		return num_tx_total;
Signature · 1 line
1.7.0.7

A message that is not in the archive (sent off-list or not yet received): 1408456313-28812-4-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

Reviewed-by
#10 lore raw

Re: [PATCH 3/6] bond: fix naming inconsistency in tx_burst_round_robin

Quoted 44 lines

Renaming struct bond_dev_pritvate *dev_private to internals to match convention used in other pmds

---
lib/librte_pmd_bond/rte_eth_bond_pmd.c | 10 +++++-----

1 files changed, 5 insertions(+), 5 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +5 -5
index 683b146..70123fc 100644
@@ -92,7 +92,7 @@ static uint16_t
 bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
 {
-	struct bond_dev_private *dev_private;
+	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
 
 	struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_pkts];
@@ -107,13 +107,13 @@ bond_ethdev_tx_burst_round_robin(void *queue,
 struct rte_mbuf **bufs,
 	int i, cs_idx = 0;
 
 	bd_tx_q = (struct bond_tx_queue *)queue;
-	dev_private = bd_tx_q->dev_private;
+	internals = bd_tx_q->dev_private;
 
 	/* Copy slave list to protect against slave up/down changes during tx
 	 * bursting */
-	num_of_slaves = dev_private->active_slave_count;
-	memcpy(slaves, dev_private->active_slaves,
-			sizeof(dev_private->active_slaves[0]) * num_of_slaves);
+	num_of_slaves = internals->active_slave_count;
+	memcpy(slaves, internals->active_slaves,
+			sizeof(internals->active_slaves[0]) * num_of_slaves);
 
 	if (num_of_slaves < 1)
		return num_tx_total;
Signature · 1 line
1.7.0.7
#11 lore raw

PATCH 4/6 bond: free mbufs if transmission fails in bonding tx_burst functions

In reply to a message not in the archive

Fixing a number of corner cases that if transmission failed on slave devices then this could lead to leaked mbufs

---
 app/test/test_link_bonding.c           |    4 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   46 +++++++++++++++++++++++++-------
 2 files changed, 38 insertions(+), 12 deletions(-)
app/test/test_link_bonding.c +2 -2
index 02823b6..3c265ee 100644
@@ -3415,7 +3415,7 @@ test_broadcast_tx_burst(void)
 	/* Send burst on bonded port */
 	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
 			burst_size);
-	if (nb_tx != burst_size * test_params->bonded_slave_count) {
+	if (nb_tx != burst_size) {
 		printf("Bonded Port (%d) rx burst failed, packets transmitted value (%u) not as expected (%d)\n",
 				test_params->bonded_port_id,
 				nb_tx, burst_size);
@@ -3770,7 +3770,7 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	}
 
 	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[0][0],
-			burst_size) != (burst_size * slave_count)) {
+			burst_size) != burst_size) {
 		printf("rte_eth_tx_burst failed\n");
 		return -1;
 	}
lib/librte_pmd_bond/rte_eth_bond_pmd.c +36 -10

88 lines not on this page · raw message

Signature · 1 line
1.7.0.7
#12 lore raw

PATCH 5/6 test app: adding support for generating variable sized packets

In reply to a message not in the archive
---
 app/test/packet_burst_generator.c |   22 +++++++---------------
 app/test/packet_burst_generator.h |    6 +++++-
 app/test/test_link_bonding.c      |   14 +++++++++-----
 3 files changed, 21 insertions(+), 21 deletions(-)
app/test/packet_burst_generator.c +7 -15
index 5d539f1..9ce6472 100644
@@ -190,20 +190,12 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */
 
-#define TXONLY_DEF_PACKET_LEN 64
-#define TXONLY_DEF_PACKET_LEN_128 128
-
-uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN;
-uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = {
-		TXONLY_DEF_PACKET_LEN_128,
-};
-
-uint8_t  tx_pkt_nb_segs = 1;
 
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
 		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst)
+		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+		uint8_t pkt_len, uint8_t nb_pkt_segs)
 {
 	int i, nb_pkt = 0;
 	size_t eth_hdr_size;
@@ -220,9 +212,9 @@ nomore_mbuf:
 			break;
 		}
 
-		pkt->pkt.data_len = tx_pkt_seg_lengths[0];
+		pkt->pkt.data_len = pkt_len;
 		pkt_seg = pkt;
-		for (i = 1; i < tx_pkt_nb_segs; i++) {
+		for (i = 1; i < nb_pkt_segs; i++) {
 			pkt_seg->pkt.next = rte_pktmbuf_alloc(mp);
 			if (pkt_seg->pkt.next == NULL) {
 				pkt->pkt.nb_segs = i;
@@ -230,7 +222,7 @@ nomore_mbuf:
 				goto nomore_mbuf;
 			}
 			pkt_seg = pkt_seg->pkt.next;
-			pkt_seg->pkt.data_len = tx_pkt_seg_lengths[i];
+			pkt_seg->pkt.data_len = pkt_len;
 		}
 		pkt_seg->pkt.next = NULL; /* Last segment of packet. */
 
@@ -258,8 +250,8 @@ nomore_mbuf:
 		 * Complete first mbuf of packet and append it to the
 		 * burst of packets to be transmitted.
 		 */
-		pkt->pkt.nb_segs = tx_pkt_nb_segs;
-		pkt->pkt.pkt_len = tx_pkt_length;
+		pkt->pkt.nb_segs = nb_pkt_segs;
+		pkt->pkt.pkt_len = pkt_len;
 		pkt->pkt.vlan_macip.f.l2_len = eth_hdr_size;
 
 		if (ipv4) {
app/test/packet_burst_generator.h +5 -1
index 5b3cd6c..f86589e 100644
@@ -47,6 +47,9 @@ extern "C" {
 #define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \
 		((c & 0xff) << 8) | (d & 0xff))
 
+#define PACKET_BURST_GEN_PKT_LEN 60
+#define PACKET_BURST_GEN_PKT_LEN_128 128
+
 
 void
 initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
@@ -68,7 +71,8 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
 		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst);
+		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+		uint8_t pkt_len, uint8_t nb_pkt_segs);
 
 #ifdef __cplusplus
 }
app/test/test_link_bonding.c +9 -5
index 3c265ee..d31c553 100644
@@ -1338,7 +1338,8 @@ generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 	/* Generate burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, vlan, ip_hdr, ipv4,
-			test_params->pkt_udp_hdr, burst_size);
+			test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN_128,
+			1);
 	if (generated_burst_size != burst_size) {
 		printf("Failed to generate packet burst");
 		return -1;
@@ -1927,7 +1928,7 @@ test_activebackup_tx_burst(void)
 	/* Generate a burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size);
+			1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN, 1);
 	if (generated_burst_size != burst_size)
 		return -1;
 
@@ -2580,7 +2581,8 @@ test_balance_l2_tx_burst(void)
 	/* Generate a burst 1 of packets to transmit */
 	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
-			test_params->pkt_udp_hdr, burst_size[0]) != burst_size[0])
+			test_params->pkt_udp_hdr, burst_size[0],
+			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[0])
 		return -1;
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
@@ -2589,7 +2591,8 @@ test_balance_l2_tx_burst(void)
 	/* Generate a burst 2 of packets to transmit */
 	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
-			test_params->pkt_udp_hdr, burst_size[1]) != burst_size[1])
+			test_params->pkt_udp_hdr, burst_size[1],
+			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1])
 		return -1;
 
 	/* Send burst 1 on bonded port */
@@ -3408,7 +3411,8 @@ test_broadcast_tx_burst(void)
 	/* Generate a burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size);
+			1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN,
+			1);
 	if (generated_burst_size != burst_size)
 		return -1;
 
Signature · 1 line
1.7.0.7
#13 lore raw

PATCH 6/6 testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist

In reply to a message not in the archive

Fix for "show port info" command which displays the incorrect "connected to socket" when port is a link bonding port.

---
 app/test-pmd/cmdline.c |    2 +-
 app/test-pmd/testpmd.c |    3 ++-
 app/test-pmd/testpmd.h |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
app/test-pmd/cmdline.c +1 -1
index 345be11..8cc4937 100644
@@ -3515,7 +3515,7 @@ static void cmd_create_bonded_device_parsed(void *parsed_result,
 
 		/* Update number of ports */
 		nb_ports = rte_eth_dev_count();
-		reconfig(port_id);
+		reconfig(port_id, res->socket);
 		rte_eth_promiscuous_enable(port_id);
 	}
 
app/test-pmd/testpmd.c +2 -1
index e8a4b45..58ed03c 100644
@@ -627,7 +627,7 @@ init_config(void)
 
 
 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
 	struct rte_port *port;
 
@@ -646,6 +646,7 @@ reconfig(portid_t new_port_id)
 	/* set flag to initialize port/queue */
 	port->need_reconfig = 1;
 	port->need_reconfig_queues = 1;
+	port->socket_id = socket_id;
 
 	init_port_config();
 }
app/test-pmd/testpmd.h +1 -1
index ac86bfe..207eacb 100644
@@ -455,7 +455,7 @@ void fwd_config_display(void);
 void rxtx_config_display(void);
 void fwd_config_setup(void);
 void set_def_fwd_config(void);
-void reconfig(portid_t new_port_id);
+void reconfig(portid_t new_port_id, unsigned socket_id);
 int init_fwd_streams(void);
 
 void port_mtu_set(portid_t port_id, uint16_t mtu);
Signature · 1 line
1.7.0.7
Tested-by
#14 lore raw
In reply to a message not in the archive

These patches have be verified, and are ready to integrate into DPDK.org.

There are 18 test cases in this feature now. All cases are passed. Please see the test result as following:

	active_backup_all_slave_down	    	PASSED
	active_backup_change_primary	   	PASSED
	active_backup_one_slave_down	   	PASSED
	active_backup_rx_tx	          	PASSED
	bonded_mac_address	      	PASSED
	broadcast_rx_tx				PASSED
	broadcast_tx_all_slave_down		PASSED
	broadcast_tx_one_slave_down		PASSED
	create_bonded_devices_and_slaves	PASSED
	device_promiscuous_mode			PASSED
	round_robin_all_slave_down		PASSED
	round_robin_one_slave_down		PASSED
	round_robin_rx_tx				PASSED
	xor_l34_forward				PASSED
	xor_rx					PASSED
	xor_tx					PASSED
	xor_tx_all_slave_down			PASSED
	xor_tx_one_slave_down			PASSED

Test environment: Fedora 20, 3.11.10-301.fc20.x86_64, GCC 4.8.2, Intel Xeon processor E5-2680 v2, with Intel Niantic 82599.

Quoted 32 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Tuesday, August 19, 2014 9:52 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH 0/6] link bonding

This patch set adds support for link status interrupt in the link bonding
pmd. It also contains some patches to tidy up the code structure and to of the link bonding code and to fix bugs relating to transmission failures in the under lying slave pmd which could lead to leaked mbufs.

Declan Doherty (6):
bond: link status interrupt support
bond: removing switch statement from rx burst method
bond: fix naming inconsistency in tx_burst_round_robin
bond: free mbufs if transmission fails in bonding tx_burst functions test app: adding support for generating variable sized packets
testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist

 app/test-pmd/cmdline.c                 |    2 +-
 app/test-pmd/testpmd.c                 |    3 +-
 app/test-pmd/testpmd.h                 |    2 +-
 app/test/packet_burst_generator.c      |   22 +--
 app/test/packet_burst_generator.h      |    6 +-
 app/test/test_link_bonding.c           |  234
++++++++++++++++++++++++++------
 lib/librte_pmd_bond/rte_eth_bond_api.c |    4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  124 +++++++++++------
 8 files changed, 295 insertions(+), 102 deletions(-)
#15 lore raw

v2 cover link bonding

In reply to a message not in the archive

This patch set adds support for link status interrupt in the link bonding pmd. It also contains some patches to tidy up the code structure and to of the link bonding code and to fix bugs relating to transmission failures in the under lying slave pmd which could lead to leaked mbufs.

V2 addresses issues with the logic around the handling of fail transmissions. In this version all modei behave in a manner similar to a standard PMD, returning the number of successfully transmitted mbufs and with the failing mbufs at the end of bufs array for freeing / retansmission by the application software

Declan Doherty (6):
bond: link status interrupt support
bond: removing switch statement from rx burst method
bond: fix naming inconsistency in tx_burst_round_robin
bond: free mbufs if transmission fails in bonding tx_burst functions test app: adding support for generating variable sized packets
testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist

 app/test-pmd/cmdline.c                 |    2 +-
 app/test-pmd/testpmd.c                 |    3 +-
 app/test-pmd/testpmd.h                 |    2 +-
 app/test/packet_burst_generator.c      |   22 +-
 app/test/packet_burst_generator.h      |    6 +-
 app/test/test_link_bonding.c           |  620 +++++++++++++++++++++++++++++---
 app/test/virtual_pmd.c                 |   80 ++++-
 app/test/virtual_pmd.h                 |    7 +
 lib/librte_pmd_bond/rte_eth_bond_api.c |    4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  161 ++++++---
 10 files changed, 779 insertions(+), 128 deletions(-)

A message that is not in the archive (sent off-list or not yet received): 1409560289-29558-1-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#17 lore raw
Quoted 29 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Monday, September 01, 2014 9:31 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v2 0/6] link bonding

This patch set adds support for link status interrupt in the link bonding pmd. It also contains some patches to tidy up the code structure and to of the link bonding code and to fix bugs relating to transmission failures in the under lying slave pmd which could lead to leaked mbufs.

V2 addresses issues with the logic around the handling of fail transmissions. In this version all modei behave in a manner similar to a standard PMD, returning
the number of successfully transmitted mbufs and with the failing mbufs at the end of bufs array for freeing / retansmission by the application software

Declan Doherty (6):
bond: link status interrupt support
bond: removing switch statement from rx burst method
bond: fix naming inconsistency in tx_burst_round_robin
bond: free mbufs if transmission fails in bonding tx_burst functions test app: adding support for generating variable sized packets
testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist

Quoted 12 lines
 app/test-pmd/cmdline.c                 |    2 +-
 app/test-pmd/testpmd.c                 |    3 +-
 app/test-pmd/testpmd.h                 |    2 +-
 app/test/packet_burst_generator.c      |   22 +-
 app/test/packet_burst_generator.h      |    6 +-
 app/test/test_link_bonding.c           |  620
+++++++++++++++++++++++++++++---
 app/test/virtual_pmd.c                 |   80 ++++-
 app/test/virtual_pmd.h                 |    7 +
 lib/librte_pmd_bond/rte_eth_bond_api.c |    4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  161 ++++++---
 10 files changed, 779 insertions(+), 128 deletions(-)

Acked-by Pablo de Lara <[email protected]>

#18 lore raw
In reply to a message not in the archive
Quoted 4 lines · On Mon, 1 Sep 2014 09:31:23 +0100 Declan Doherty…

This patch set adds support for link status interrupt in the link bonding pmd. It also contains some patches to tidy up the code structure and to of the link bonding code and to fix bugs relating to transmission failures in the under lying slave pmd which could lead to leaked mbufs.

Does this work when interfaces being bonded do not support link state like VF's and some other virtual devices (like vmxnet3?).

I am concerned that the flag to say whether device support LSC or not is in drv_flags which is normally invariant. So either bond has to simulate link state if slave devices do not support (by polling) or provide another mechanism for application to determine availablity of link state.

#19 lore raw

PATCH v2 1/6 bond: link status interrupt support

In reply to a message not in the archive

Adding support for lsc interrupt from bonded device to link bonding library with supporting unit tests in the test application.

---
 app/test/test_link_bonding.c           |  213 +++++++++++++++++++++++++++-----
 lib/librte_pmd_bond/rte_eth_bond_api.c |    4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |    6 +
 3 files changed, 189 insertions(+), 34 deletions(-)
app/test/test_link_bonding.c +179 -34
index db5b180..cce32ed 100644
@@ -39,6 +39,7 @@
 #include <inttypes.h>
 #include <errno.h>
 #include <sys/queue.h>
+#include <sys/time.h>
 
 #include <rte_byteorder.h>
 #include <rte_common.h>
@@ -224,10 +225,15 @@ static struct rte_eth_txconf tx_conf_default = {
 };
 
 static int
-configure_ethdev(uint8_t port_id, uint8_t start)
+configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 {
 	int q_id;
 
+	if (en_isr)
+		default_pmd_conf.intr_conf.lsc = 1;
+	else
+		default_pmd_conf.intr_conf.lsc = 0;
+
 	if (rte_eth_dev_configure(port_id, test_params->nb_rx_q,
 			test_params->nb_tx_q, &default_pmd_conf) != 0) {
 		goto error;
@@ -312,7 +318,7 @@ test_setup(void)
 
 			printf("Created virtual ethdev %s\n", pmd_name);
 
-			retval = configure_ethdev(test_params->slave_port_ids[i], 1);
+			retval = configure_ethdev(test_params->slave_port_ids[i], 1, 0);
 			if (retval != 0) {
 				printf("Failed to configure virtual ethdev %s\n", pmd_name);
 				return -1;
@@ -341,7 +347,7 @@ test_create_bonded_device(void)
 		TEST_ASSERT(test_params->bonded_port_id >= 0,
 				"Failed to create bonded ethdev %s", BONDED_DEV_NAME);
 
-		TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
+		TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
 				"Failed to configure bonded ethdev %s", BONDED_DEV_NAME);
 	}
 
@@ -1078,12 +1084,12 @@ test_set_explicit_bonded_mac(void)
 
 
 static int
-initialize_bonded_device_with_slaves(uint8_t bonding_mode,
+initialize_bonded_device_with_slaves(uint8_t bonding_mode, uint8_t bond_en_isr,
 		uint8_t number_of_slaves, uint8_t enable_slave)
 {
 	/* configure bonded device */
-	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
-			"Failed to configure bonding port (%d) in mode %d "
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0,
+			bond_en_isr), "Failed to configure bonding port (%d) in mode %d "
 			"with (%d) slaves.", test_params->bonded_port_id, bonding_mode,
 			number_of_slaves);
 
@@ -1116,8 +1122,8 @@ test_adding_slave_after_bonded_device_started(void)
 {
 	int i;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 0) !=
-			0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 0)
+			!= 0)
 		return -1;
 
 	/* Enabled slave devices */
@@ -1141,6 +1147,144 @@ test_adding_slave_after_bonded_device_started(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_STATUS_INTERRUPT_SLAVE_COUNT	4
+#define TEST_LSC_WAIT_TIMEOUT_MS	500
+
+int test_lsc_interupt_count;
+
+static pthread_mutex_t mutex;
+static pthread_cond_t cvar;
+
+static void
+test_bonding_lsc_event_callback(uint8_t port_id __rte_unused,
+		enum rte_eth_event_type type  __rte_unused, void *param __rte_unused)
+{
+	pthread_mutex_lock(&mutex);
+	test_lsc_interupt_count++;
+
+	pthread_cond_signal(&cvar);
+	pthread_mutex_unlock(&mutex);
+}
+
+static inline int
+lsc_timeout(int wait_us)
+{
+	int retval = 0;
+
+	struct timespec ts;
+	struct timeval tp;
+
+	gettimeofday(&tp, NULL);
+
+	/* Convert from timeval to timespec */
+	ts.tv_sec  = tp.tv_sec;
+	ts.tv_nsec = tp.tv_usec * 1000;
+	ts.tv_nsec += wait_us * 1000;
+
+	pthread_mutex_lock(&mutex);
+	if (test_lsc_interupt_count < 1)
+		retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+
+	pthread_mutex_unlock(&mutex);
+
+	return retval;
+}
+
+static int
+test_status_interrupt(void)
+{
+	int slave_count;
+	uint8_t slaves[RTE_MAX_ETHPORTS];
+
+	pthread_mutex_init(&mutex, NULL);
+	pthread_cond_init(&cvar, NULL);
+
+	/* initialized bonding device with T slaves */
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 1,
+			TEST_STATUS_INTERRUPT_SLAVE_COUNT, 1) != 0)
+		return -1;
+
+	test_lsc_interupt_count = 0;
+
+	/* register link status change interrupt callback */
+	rte_eth_dev_callback_register(test_params->bonded_port_id,
+			RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
+			&test_params->bonded_port_id);
+
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+
+	TEST_ASSERT_EQUAL(slave_count, TEST_STATUS_INTERRUPT_SLAVE_COUNT,
+			"Number of active slaves (%d) is not as expected (%d)",
+			slave_count, TEST_STATUS_INTERRUPT_SLAVE_COUNT);
+
+	/* Bring all 4 slaves link status to down and test that we have received a
+	 * lsc interrupts */
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 0);
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[1], 0);
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[2], 0);
+
+	TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+			"Received a link status change interrupt unexpectedly");
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[3], 0);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
+			"timed out waiting for interrupt");
+
+	TEST_ASSERT(test_lsc_interupt_count > 0,
+			"Did not receive link status change interrupt");
+
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+
+	TEST_ASSERT_EQUAL(slave_count, 0,
+			"Number of active slaves (%d) is not as expected (%d)",
+			slave_count, 0);
+
+	/* bring one slave port up so link status will change */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 1);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
+			"timed out waiting for interrupt");
+
+	/* test that we have received another lsc interrupt */
+	TEST_ASSERT(test_lsc_interupt_count > 0,
+			"Did not receive link status change interrupt");
+
+	/* Verify that calling the same slave lsc interrupt doesn't cause another
+	 * lsc interrupt from bonded device */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 1);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) != 0,
+			"received unexpected interrupt");
+
+	TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+			"Did not receive link status change interrupt");
+
+
+	/* unregister lsc callback before exiting */
+	rte_eth_dev_callback_unregister(test_params->bonded_port_id,
+				RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
+				&test_params->bonded_port_id);
+
+	pthread_mutex_destroy(&mutex);
+	pthread_cond_destroy(&cvar);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 static int
 generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 		uint8_t vlan, uint8_t ipv4, uint8_t toggle_dst_mac,
@@ -1209,7 +1353,7 @@ test_roundrobin_tx_burst(void)
 	struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 2, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 2, 1)
 			!= 0)
 		return -1;
 
@@ -1279,7 +1423,7 @@ test_roundrobin_rx_burst_on_single_slave(void)
 	int i, j, nb_rx, burst_size = 25;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1369,7 +1513,7 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1461,7 +1605,7 @@ test_roundrobin_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[2], &expected_mac_addr_2);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1)
 			!= 0)
 		return -1;
 
@@ -1552,7 +1696,7 @@ test_roundrobin_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1616,7 +1760,7 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 	/* Initialize bonded device with TEST_RR_LINK_STATUS_SLAVE_COUNT slaves
 	 * in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
 			TEST_RR_LINK_STATUS_SLAVE_COUNT, 1) != 0)
 		return -1;
 
@@ -1757,7 +1901,7 @@ test_activebackup_tx_burst(void)
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -1854,7 +1998,7 @@ test_activebackup_rx_burst(void)
 	int i, j, nb_rx, burst_size = 17;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
 			!= 0)
 		return -1;
@@ -1948,7 +2092,7 @@ test_activebackup_verify_promiscuous_enable_disable(void)
 	int i, primary_port, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 4, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 4, 1)
 			!= 0)
 		return -1;
 
@@ -2018,7 +2162,7 @@ test_activebackup_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 2, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1)
 			!= 0)
 		return -1;
 
@@ -2157,7 +2301,7 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 	}
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
 			!= 0)
 		return -1;
@@ -2328,7 +2472,7 @@ test_balance_xmit_policy_configuration(void)
 {
 	int retval;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
@@ -2408,7 +2552,7 @@ test_balance_l2_tx_burst(void)
 	int retval, i;
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE,
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
 			TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
@@ -2506,7 +2650,7 @@ balance_l23_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -2634,7 +2778,7 @@ balance_l34_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -2772,7 +2916,7 @@ test_balance_rx_burst(void)
 	memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 3, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 3, 1)
 			!= 0)
 		return -1;
 
@@ -2861,7 +3005,7 @@ test_balance_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1) != 0)
 		return -1;
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
@@ -2915,7 +3059,7 @@ test_balance_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1) != 0)
 		return -1;
 
 	/* Verify that bonded MACs is that of first slave and that the other slave
@@ -3045,7 +3189,7 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
 			TEST_BALANCE_LINK_STATUS_SLAVE_COUNT, 1) != 0)
 		return -1;
 
@@ -3237,7 +3381,7 @@ test_broadcast_tx_burst(void)
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -3327,7 +3471,7 @@ test_broadcast_rx_burst(void)
 	memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 3, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 3, 1) != 0)
 		return -1;
 
 
@@ -3419,7 +3563,7 @@ test_broadcast_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1) != 0)
 		return -1;
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
@@ -3475,7 +3619,7 @@ test_broadcast_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[2], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4, 1) != 0)
 		return -1;
 
 	/* Verify that all MACs are the same as first slave added to bonded
@@ -3575,7 +3719,7 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0,
 			BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
 		return -1;
 
@@ -3711,7 +3855,7 @@ test_reconfigure_bonded_device(void)
 	test_params->nb_rx_q = 4;
 	test_params->nb_tx_q = 4;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0)  != 0) {
+	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
 		printf("failed to reconfigure bonded device");
 		return -1;
 	}
@@ -3720,7 +3864,7 @@ test_reconfigure_bonded_device(void)
 	test_params->nb_rx_q = 2;
 	test_params->nb_tx_q = 2;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0)  != 0) {
+	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
 		printf("failed to reconfigure bonded device with less rx/tx queues");
 		return -1;
 	}
@@ -3768,6 +3912,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_set_bonding_mode),
 		TEST_CASE(test_set_primary_slave),
 		TEST_CASE(test_set_explicit_bonded_mac),
+		TEST_CASE(test_status_interrupt),
 		TEST_CASE(test_adding_slave_after_bonded_device_started),
 		TEST_CASE(test_roundrobin_tx_burst),
 		TEST_CASE(test_roundrobin_rx_burst_on_single_slave),
lib/librte_pmd_bond/rte_eth_bond_api.c +4 -0
index 75f5694..dd33119 100644
@@ -177,6 +177,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	pci_drv->id_table->vendor_id = PCI_ANY_ID;
 	pci_drv->id_table->subsystem_vendor_id = PCI_ANY_ID;
 
+	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
 		RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
@@ -200,6 +202,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
 
+	TAILQ_INIT(&(eth_dev->callbacks));
+
 	eth_dev->data->dev_link.link_status = 0;
 
 	eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
lib/librte_pmd_bond/rte_eth_bond_pmd.c +6 -0
index d72d6ed..cd3eecf 100644
@@ -921,6 +921,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 	struct rte_eth_link link;
 
 	int i, valid_slave = 0, active_pos = -1;
+	uint8_t lsc_flag = 0;
 
 	if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
 		return;
@@ -966,6 +967,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 			/* If first active slave, then change link status */
 			bonded_eth_dev->data->dev_link.link_status = 1;
 			internals->current_primary_port = port_id;
+			lsc_flag = 1;
 
 			/* Inherit eth dev link properties from first active slave */
 			link_properties_set(bonded_eth_dev,
@@ -990,6 +992,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		/* No active slaves, change link status to down and reset other
 		 * link properties */
 		if (internals->active_slave_count < 1) {
+			lsc_flag = 1;
 			bonded_eth_dev->data->dev_link.link_status = 0;
 
 			link_properties_reset(bonded_eth_dev);
@@ -1005,6 +1008,9 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 				internals->current_primary_port = internals->primary_port;
 		}
 	}
+
+	if (lsc_flag)
+		_rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
 }
 
 struct eth_dev_ops default_dev_ops = {
Signature · 1 line
1.7.0.7
#20 lore raw

PATCH v2 2/6 bond: removing switch statement from rx burst method

In reply to a message not in the archive
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   62 ++++++++++++++++++--------------
 1 files changed, 35 insertions(+), 27 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +35 -27
index cd3eecf..683b146 100644
@@ -59,33 +59,37 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	internals = bd_rx_q->dev_private;
 
-	switch (internals->mode) {
-	case BONDING_MODE_ROUND_ROBIN:
-	case BONDING_MODE_BROADCAST:
-	case BONDING_MODE_BALANCE:
-		for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
-			/* Offset of pointer to *bufs increases as packets are received
-			 * from other slaves */
-			num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
-					bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
-			if (num_rx_slave) {
-				num_rx_total += num_rx_slave;
-				nb_pkts -= num_rx_slave;
-			}
+	for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
+		/* Offset of pointer to *bufs increases as packets are received
+		 * from other slaves */
+		num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
+				bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
+		if (num_rx_slave) {
+			num_rx_total += num_rx_slave;
+			nb_pkts -= num_rx_slave;
 		}
-		break;
-	case BONDING_MODE_ACTIVE_BACKUP:
-		num_rx_slave = rte_eth_rx_burst(internals->current_primary_port,
-				bd_rx_q->queue_id, bufs, nb_pkts);
-		if (num_rx_slave)
-			num_rx_total = num_rx_slave;
-		break;
 	}
+
 	return num_rx_total;
 }
 
 static uint16_t
-bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
+bond_ethdev_rx_burst_active_backup(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
+{
+	struct bond_dev_private *internals;
+
+	/* Cast to structure, containing bonded device's port id and queue id */
+	struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
+
+	internals = bd_rx_q->dev_private;
+
+	return rte_eth_rx_burst(internals->current_primary_port,
+			bd_rx_q->queue_id, bufs, nb_pkts);
+}
+
+static uint16_t
+bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
 {
 	struct bond_dev_private *dev_private;
@@ -134,7 +138,7 @@ bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
 }
 
 static uint16_t
-bond_ethdev_tx_active_backup(void *queue,
+bond_ethdev_tx_burst_active_backup(void *queue,
 		struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
 	struct bond_dev_private *internals;
@@ -270,7 +274,8 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t slave_count, uint8_t policy)
 }
 
 static uint16_t
-bond_ethdev_tx_balance(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
 {
 	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
@@ -480,22 +485,25 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int mode)
 
 	switch (mode) {
 	case BONDING_MODE_ROUND_ROBIN:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_round_robin;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_round_robin;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	case BONDING_MODE_ACTIVE_BACKUP:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_active_backup;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_active_backup;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup;
 		break;
 	case BONDING_MODE_BALANCE:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_balance;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_balance;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	case BONDING_MODE_BROADCAST:
 		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	default:
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 	internals->mode = mode;
 
 	return 0;
Signature · 1 line
1.7.0.7
#21 lore raw

PATCH v2 3/6 bond: fix naming inconsistency in tx_burst_round_robin

In reply to a message not in the archive
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +5 -5
index 683b146..70123fc 100644
@@ -92,7 +92,7 @@ static uint16_t
 bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
 {
-	struct bond_dev_private *dev_private;
+	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
 
 	struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_pkts];
@@ -107,13 +107,13 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 	int i, cs_idx = 0;
 
 	bd_tx_q = (struct bond_tx_queue *)queue;
-	dev_private = bd_tx_q->dev_private;
+	internals = bd_tx_q->dev_private;
 
 	/* Copy slave list to protect against slave up/down changes during tx
 	 * bursting */
-	num_of_slaves = dev_private->active_slave_count;
-	memcpy(slaves, dev_private->active_slaves,
-			sizeof(dev_private->active_slaves[0]) * num_of_slaves);
+	num_of_slaves = internals->active_slave_count;
+	memcpy(slaves, internals->active_slaves,
+			sizeof(internals->active_slaves[0]) * num_of_slaves);
 
 	if (num_of_slaves < 1)
 		return num_tx_total;
Signature · 1 line
1.7.0.7
#22 lore raw

PATCH v2 4/6 bond: free mbufs if transmission fails in bonding tx_burst functions

In reply to a message not in the archive

Fixing a number of corner cases that if transmission failed on slave devices then this could lead to leaked mbufs

V2 addresses behaviouraly issues in the first version and packets are no longer freed in the bonding layer, except in the case of broadcast mode where in failures happen on more than a single slave then mbufs will be freed in all slaves except the one where the least errors occured. Also contains new unit tests to test the transmission
failure case in slaves for
round-robin, balance, and broadcast modes.

---
 app/test/test_link_bonding.c           |  393 +++++++++++++++++++++++++++++++-
 app/test/virtual_pmd.c                 |   80 +++++--
 app/test/virtual_pmd.h                 |    7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   83 ++++++--
 4 files changed, 525 insertions(+), 38 deletions(-)
app/test/test_link_bonding.c +391 -2
index cce32ed..c5aaa80 100644
@@ -663,6 +663,9 @@ enable_bonded_slaves(void)
 	int i;
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
+		virtual_ethdev_tx_burst_fn_set_success(test_params->slave_port_ids[i],
+				1);
+
 		virtual_ethdev_simulate_link_status_interrupt(
 				test_params->slave_port_ids[i], 1);
 	}
@@ -1413,6 +1416,135 @@ test_roundrobin_tx_burst(void)
 }
 
 static int
+verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
+{
+	int i, refcnt;
+
+	for (i = 0; i < nb_mbufs; i++) {
+		refcnt = rte_mbuf_refcnt_read(mbufs[i]);
+		TEST_ASSERT_EQUAL(refcnt, val,
+			"mbuf ref count (%d)is not the expected value (%d)",
+			refcnt, val);
+	}
+	return 0;
+}
+
+
+static void
+free_mbufs(struct rte_mbuf **mbufs, int nb_mbufs)
+{
+	int i;
+
+	for (i = 0; i < nb_mbufs; i++)
+		rte_pktmbuf_free(mbufs[i]);
+}
+
+#define TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT		(2)
+#define TEST_RR_SLAVE_TX_FAIL_BURST_SIZE		(64)
+#define TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT		(22)
+#define TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX	(1)
+
+static int
+test_roundrobin_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
+	struct rte_mbuf *expected_tx_fail_pkts[MAX_PKT_BURST];
+
+	struct rte_eth_stats port_stats;
+
+	int i, first_fail_idx, tx_count;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0,
+			TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	/* Generate test bursts of packets to transmit */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE, 0, 1, 0, 0, 0),
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE,
+			"Failed to generate test packet burst");
+
+	/* Copy references to packets which we expect not to be transmitted */
+	first_fail_idx = (TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			(TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT *
+			TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)) +
+			TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX;
+
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		expected_tx_fail_pkts[i] = pkt_burst[first_fail_idx +
+				(i * TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)];
+	}
+
+	/* Set virtual slave to only fail transmission of
+	 * TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT packets in burst */
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkt_burst,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE);
+
+	TEST_ASSERT_EQUAL(tx_count, TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Transmitted (%d) an unexpected (%d) number of packets", tx_count,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_tx_fail_pkts[i], pkt_burst[i + tx_count],
+				"expected mbuf (%d) pointer %p not expected pointer %p",
+				i, expected_tx_fail_pkts[i], pkt_burst[i + tx_count]);
+	}
+
+	/* Verify bonded port tx stats */
+	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify slave ports tx stats */
+	for (i = 0; i < test_params->bonded_slave_count; i++) {
+		int slave_expected_tx_count;
+
+		rte_eth_stats_get(test_params->slave_port_ids[i], &port_stats);
+
+		slave_expected_tx_count = TEST_RR_SLAVE_TX_FAIL_BURST_SIZE /
+				test_params->bonded_slave_count;
+
+		if (i == TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX)
+			slave_expected_tx_count = slave_expected_tx_count -
+					TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT;
+
+		TEST_ASSERT_EQUAL(port_stats.opackets,
+				(uint64_t)slave_expected_tx_count,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)",
+				test_params->slave_port_ids[i],
+				(unsigned int)port_stats.opackets, slave_expected_tx_count);
+	}
+
+	/* Verify that all mbufs have a ref value of zero */
+	TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkt_burst[tx_count],
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkt_burst[tx_count], TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
+static int
 test_roundrobin_rx_burst_on_single_slave(void)
 {
 	struct rte_mbuf *gen_pkt_burst[MAX_PKT_BURST] = { NULL };
@@ -2900,6 +3032,141 @@ test_balance_l34_tx_burst_ipv6_toggle_udp_port(void)
 	return balance_l34_tx_burst(0, 0, 0, 0, 1);
 }
 
+#define TEST_BAL_SLAVE_TX_FAIL_SLAVE_COUNT			(2)
+#define TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1			(40)
+#define TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2			(20)
+#define TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT		(25)
+#define TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX	(0)
+
+static int
+test_balance_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf *pkts_burst_1[TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1];
+	struct rte_mbuf *pkts_burst_2[TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2];
+
+	struct rte_mbuf *expected_fail_pkts[TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT];
+
+	struct rte_eth_stats port_stats;
+
+	int i, first_tx_fail_idx, tx_count_1, tx_count_2;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0,
+			TEST_BAL_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER2),
+			"Failed to set balance xmit policy.");
+
+
+	/* Generate test bursts for transmission */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_1,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1, 0, 0, 0, 0, 0),
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1,
+			"Failed to generate test packet burst 1");
+
+	first_tx_fail_idx = TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT;
+
+	/* copy mbuf referneces for expected transmission failures */
+	for (i = 0; i < TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		expected_fail_pkts[i] = pkts_burst_1[i + first_tx_fail_idx];
+	}
+
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2, 0, 0, 1, 0, 0),
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
+			"Failed to generate test packet burst 2");
+
+
+	/* Set virtual slave TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX to only fail
+	 * transmission of TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT packets of burst */
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+
+	/* Transmit burst 1 */
+	tx_count_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1);
+
+	TEST_ASSERT_EQUAL(tx_count_1, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Transmitted (%d) packets, expected to transmit (%d) packets",
+			tx_count_1, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_fail_pkts[i], pkts_burst_1[i + tx_count_1],
+				"expected mbuf (%d) pointer %p not expected pointer %p",
+				i, expected_fail_pkts[i], pkts_burst_1[i + tx_count_1]);
+	}
+
+	/* Transmit burst 2 */
+	tx_count_2 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_2,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	TEST_ASSERT_EQUAL(tx_count_2, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
+			"Transmitted (%d) packets, expected to transmit (%d) packets",
+			tx_count_2, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+
+	/* Verify bonded port tx stats */
+	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)((TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT) +
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2),
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			(TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT) +
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	/* Verify slave ports tx stats */
+
+	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+				TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)",
+				test_params->slave_port_ids[0],
+				(unsigned int)port_stats.opackets,
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+				TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+
+
+
+	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+				(uint64_t)TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)",
+				test_params->slave_port_ids[1],
+				(unsigned int)port_stats.opackets,
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	/* Verify that all mbufs have a ref value of zero */
+	TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkts_burst_1[tx_count_1],
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkts_burst_1[tx_count_1],
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 #define TEST_BALANCE_RX_BURST_SLAVE_COUNT (3)
 
 static int
@@ -3412,7 +3679,7 @@ test_broadcast_tx_burst(void)
 	/* Send burst on bonded port */
 	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
 			burst_size);
-	if (nb_tx != burst_size * test_params->bonded_slave_count) {
+	if (nb_tx != burst_size) {
 		printf("Bonded Port (%d) rx burst failed, packets transmitted value (%u) not as expected (%d)\n",
 				test_params->bonded_port_id,
 				nb_tx, burst_size);
@@ -3455,6 +3722,125 @@ test_broadcast_tx_burst(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+
+#define TEST_BCAST_SLAVE_TX_FAIL_SLAVE_COUNT		(3)
+#define TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE			(40)
+#define TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT	(15)
+#define TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT	(10)
+
+static int
+test_broadcast_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf *pkts_burst[TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE];
+	struct rte_mbuf *expected_fail_pkts[TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT];
+
+	struct rte_eth_stats port_stats;
+
+	int i, tx_count;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0,
+			TEST_BCAST_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	/* Generate test bursts for transmission */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE, 0, 0, 0, 0, 0),
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE,
+			"Failed to generate test packet burst");
+
+	for (i = 0; i < TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT; i++) {
+		expected_fail_pkts[i] = pkts_burst[TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT + i];
+	}
+
+	/* Set virtual slave TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX to only fail
+	 * transmission of TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT packets of burst */
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[0],
+			0);
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[1],
+			0);
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[2],
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[0],
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[1],
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[2],
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+	/* Transmit burst */
+	tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE);
+
+	TEST_ASSERT_EQUAL(tx_count, TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT,
+			"Transmitted (%d) packets, expected to transmit (%d) packets",
+			tx_count, TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_fail_pkts[i], pkts_burst[i + tx_count],
+				"expected mbuf (%d) pointer %p not expected pointer %p",
+				i, expected_fail_pkts[i], pkts_burst[i + tx_count]);
+	}
+
+	/* Verify slave ports tx stats */
+
+	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT,
+			"Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+
+	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT,
+			"Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -s
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT,
+			"Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+
+	/* Verify that all mbufs who transmission failed have a ref value of one */
+	TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkts_burst[tx_count],
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkts_burst[tx_count],
+		TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 #define BROADCAST_RX_BURST_NUM_OF_SLAVES (3)
 
 static int
@@ -3767,7 +4153,7 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	}
 
 	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[0][0],
-			burst_size) != (burst_size * slave_count)) {
+			burst_size) != burst_size) {
 		printf("rte_eth_tx_burst failed\n");
 		return -1;
 	}
@@ -3915,6 +4301,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_status_interrupt),
 		TEST_CASE(test_adding_slave_after_bonded_device_started),
 		TEST_CASE(test_roundrobin_tx_burst),
+		TEST_CASE(test_roundrobin_tx_burst_slave_tx_fail),
 		TEST_CASE(test_roundrobin_rx_burst_on_single_slave),
 		TEST_CASE(test_roundrobin_rx_burst_on_multiple_slaves),
 		TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),
@@ -3938,11 +4325,13 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_balance_l34_tx_burst_ipv6_toggle_ip_addr),
 		TEST_CASE(test_balance_l34_tx_burst_vlan_ipv6_toggle_ip_addr),
 		TEST_CASE(test_balance_l34_tx_burst_ipv6_toggle_udp_port),
+		TEST_CASE(test_balance_tx_burst_slave_tx_fail),
 		TEST_CASE(test_balance_rx_burst),
 		TEST_CASE(test_balance_verify_promiscuous_enable_disable),
 		TEST_CASE(test_balance_verify_mac_assignment),
 		TEST_CASE(test_balance_verify_slave_link_status_change_behaviour),
 		TEST_CASE(test_broadcast_tx_burst),
+		TEST_CASE(test_broadcast_tx_burst_slave_tx_fail),
 		TEST_CASE(test_broadcast_rx_burst),
 		TEST_CASE(test_broadcast_verify_promiscuous_enable_disable),
 		TEST_CASE(test_broadcast_verify_mac_assignment),
app/test/virtual_pmd.c +62 -18

127 lines not on this page · raw message

app/test/virtual_pmd.h +7 -0
index 766b6ac..3b5c911 100644
@@ -67,6 +67,13 @@ void virtual_ethdev_rx_burst_fn_set_success(uint8_t port_id, uint8_t success);
 
 void virtual_ethdev_tx_burst_fn_set_success(uint8_t port_id, uint8_t success);
 
+/* if a value greater than zero is set for packet_fail_count then virtual
+ * device tx burst function will fail that many packet from burst or all
+ * packets if packet_fail_count is greater than the number of packets in the
+ * burst */
+void virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
+		uint8_t packet_fail_count);
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_pmd_bond/rte_eth_bond_pmd.c +65 -18

135 lines not on this page · raw message

Signature · 1 line
1.7.0.7

A message that is not in the archive (sent off-list or not yet received): 1409560289-29558-5-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#24 lore raw

Re: [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions

Quoted 25 lines

-----Original Message-----
From: Doherty, Declan
Sent: Monday, September 1, 2014 9:31 AM
To: [email protected]
Cc: [email protected]; [email protected]; Doherty, Declan
Subject: [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst
functions

Fixing a number of corner cases that if transmission failed on slave devices then this
could lead to leaked mbufs

V2 addresses behaviouraly issues in the first version and packets are no longer freed in
the bonding layer, except in the case of broadcast mode where in failures happen on
more than a single slave then mbufs will be freed in all slaves except the one where
the least errors occured. Also contains new unit tests to test the transmission
failure case in slaves for
round-robin, balance, and broadcast modes.

---

.....

Quoted 2 lines

--
1.7.0.7

I've just noticed that I inserted an extra character into the patch when I was annotating this patch which will cause this a fail compilation.

Review

Quoted 2 lines
(quoted diff) +2 -0
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -s
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);

should have been

Review

Quoted 2 lines
(quoted diff) +2 -0
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);

Thomas, do you want me to submit a V3 of this?

Regards
Declan

A message that is not in the archive (sent off-list or not yet received): 345C63BAECC1AD42A2EC8C63AFFC3ADC2737656B-kPTMFJFq+rF9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org

#26 lore raw

Re: [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions

Hi Declan,

2014-09-02 09:22, Doherty, Declan:

Quoted 11 lines

I've just noticed that I inserted an extra character into the patch when I was annotating this patch which will cause this a fail compilation.

Review

Quoted 2 lines
(quoted diff) +2 -0
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -s
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);

should have been

Review

Quoted 2 lines
(quoted diff) +2 -0
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);

Thomas, do you want me to submit a V3 of this?

I'd prefer to have some comments first.
Anyone to review this patchset?

Signature · 1 line
Thomas
#27 lore raw

v3 cover link bonding

In reply to a message not in the archive

This patch set contains a typo fix for the bond free mbufs patch aswell as updates to the test app patch to rebase for changes in the mbuf patches . It also contains a patch to add support for slave devices which don't support link status interrupts and also a patch to tidy up the link bonding unit test so that all tests use the new test macros.

Declan Doherty (5):
bond: free mbufs if transmission fails in bonding tx_burst functions test app: adding support for generating variable sized packet
testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist
bond: lsc polling support
bond: unit test test macro refactor

 app/test-pmd/cmdline.c                     |    2 +-
 app/test-pmd/testpmd.c                     |    3 +-
 app/test-pmd/testpmd.h                     |    2 +-
 app/test/packet_burst_generator.c          |   25 +-
 app/test/packet_burst_generator.h          |    6 +-
 app/test/test.h                            |    7 +-
 app/test/test_link_bonding.c               | 3245 ++++++++++++++--------------
 app/test/virtual_pmd.c                     |   97 +-
 app/test/virtual_pmd.h                     |   53 +-
 lib/librte_pmd_bond/rte_eth_bond.h         |   80 +
 lib/librte_pmd_bond/rte_eth_bond_api.c     |  309 ++-
 lib/librte_pmd_bond/rte_eth_bond_args.c    |   30 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c     |  470 +++-
 lib/librte_pmd_bond/rte_eth_bond_private.h |   71 +-
 14 files changed, 2450 insertions(+), 1950 deletions(-)
Signature · 1 line
1.7.4.1

A message that is not in the archive (sent off-list or not yet received): 1411478290-28807-1-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#29 lore raw

PATCH v3 1/5 bond: free mbufs if transmission fails in bonding tx_burst functions

Fixing a number of corner cases that if transmission failed on slave devices then this could lead to leaked mbufs

---
 app/test/test_link_bonding.c           |  393 +++++++++++++++++++++++++++++++-
 app/test/virtual_pmd.c                 |   80 +++++--
 app/test/virtual_pmd.h                 |    7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   83 ++++++--
 4 files changed, 525 insertions(+), 38 deletions(-)
app/test/test_link_bonding.c +391 -2
index cce32ed..1a847eb 100644
@@ -663,6 +663,9 @@ enable_bonded_slaves(void)
 	int i;
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
+		virtual_ethdev_tx_burst_fn_set_success(test_params->slave_port_ids[i],
+				1);
+
 		virtual_ethdev_simulate_link_status_interrupt(
 				test_params->slave_port_ids[i], 1);
 	}
@@ -1413,6 +1416,135 @@ test_roundrobin_tx_burst(void)
 }
 
 static int
+verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
+{
+	int i, refcnt;
+
+	for (i = 0; i < nb_mbufs; i++) {
+		refcnt = rte_mbuf_refcnt_read(mbufs[i]);
+		TEST_ASSERT_EQUAL(refcnt, val,
+			"mbuf ref count (%d)is not the expected value (%d)",
+			refcnt, val);
+	}
+	return 0;
+}
+
+
+static void
+free_mbufs(struct rte_mbuf **mbufs, int nb_mbufs)
+{
+	int i;
+
+	for (i = 0; i < nb_mbufs; i++)
+		rte_pktmbuf_free(mbufs[i]);
+}
+
+#define TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT		(2)
+#define TEST_RR_SLAVE_TX_FAIL_BURST_SIZE		(64)
+#define TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT		(22)
+#define TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX	(1)
+
+static int
+test_roundrobin_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
+	struct rte_mbuf *expected_tx_fail_pkts[MAX_PKT_BURST];
+
+	struct rte_eth_stats port_stats;
+
+	int i, first_fail_idx, tx_count;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0,
+			TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	/* Generate test bursts of packets to transmit */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE, 0, 1, 0, 0, 0),
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE,
+			"Failed to generate test packet burst");
+
+	/* Copy references to packets which we expect not to be transmitted */
+	first_fail_idx = (TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			(TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT *
+			TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)) +
+			TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX;
+
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		expected_tx_fail_pkts[i] = pkt_burst[first_fail_idx +
+				(i * TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)];
+	}
+
+	/* Set virtual slave to only fail transmission of
+	 * TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT packets in burst */
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkt_burst,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE);
+
+	TEST_ASSERT_EQUAL(tx_count, TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Transmitted (%d) an unexpected (%d) number of packets", tx_count,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_tx_fail_pkts[i], pkt_burst[i + tx_count],
+				"expected mbuf (%d) pointer %p not expected pointer %p",
+				i, expected_tx_fail_pkts[i], pkt_burst[i + tx_count]);
+	}
+
+	/* Verify bonded port tx stats */
+	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify slave ports tx stats */
+	for (i = 0; i < test_params->bonded_slave_count; i++) {
+		int slave_expected_tx_count;
+
+		rte_eth_stats_get(test_params->slave_port_ids[i], &port_stats);
+
+		slave_expected_tx_count = TEST_RR_SLAVE_TX_FAIL_BURST_SIZE /
+				test_params->bonded_slave_count;
+
+		if (i == TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX)
+			slave_expected_tx_count = slave_expected_tx_count -
+					TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT;
+
+		TEST_ASSERT_EQUAL(port_stats.opackets,
+				(uint64_t)slave_expected_tx_count,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)",
+				test_params->slave_port_ids[i],
+				(unsigned int)port_stats.opackets, slave_expected_tx_count);
+	}
+
+	/* Verify that all mbufs have a ref value of zero */
+	TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkt_burst[tx_count],
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkt_burst[tx_count], TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
+static int
 test_roundrobin_rx_burst_on_single_slave(void)
 {
 	struct rte_mbuf *gen_pkt_burst[MAX_PKT_BURST] = { NULL };
@@ -2900,6 +3032,141 @@ test_balance_l34_tx_burst_ipv6_toggle_udp_port(void)
 	return balance_l34_tx_burst(0, 0, 0, 0, 1);
 }
 
+#define TEST_BAL_SLAVE_TX_FAIL_SLAVE_COUNT			(2)
+#define TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1			(40)
+#define TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2			(20)
+#define TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT		(25)
+#define TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX	(0)
+
+static int
+test_balance_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf *pkts_burst_1[TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1];
+	struct rte_mbuf *pkts_burst_2[TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2];
+
+	struct rte_mbuf *expected_fail_pkts[TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT];
+
+	struct rte_eth_stats port_stats;
+
+	int i, first_tx_fail_idx, tx_count_1, tx_count_2;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0,
+			TEST_BAL_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER2),
+			"Failed to set balance xmit policy.");
+
+
+	/* Generate test bursts for transmission */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_1,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1, 0, 0, 0, 0, 0),
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1,
+			"Failed to generate test packet burst 1");
+
+	first_tx_fail_idx = TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT;
+
+	/* copy mbuf referneces for expected transmission failures */
+	for (i = 0; i < TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		expected_fail_pkts[i] = pkts_burst_1[i + first_tx_fail_idx];
+	}
+
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2, 0, 0, 1, 0, 0),
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
+			"Failed to generate test packet burst 2");
+
+
+	/* Set virtual slave TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX to only fail
+	 * transmission of TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT packets of burst */
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+
+	/* Transmit burst 1 */
+	tx_count_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1);
+
+	TEST_ASSERT_EQUAL(tx_count_1, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Transmitted (%d) packets, expected to transmit (%d) packets",
+			tx_count_1, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_fail_pkts[i], pkts_burst_1[i + tx_count_1],
+				"expected mbuf (%d) pointer %p not expected pointer %p",
+				i, expected_fail_pkts[i], pkts_burst_1[i + tx_count_1]);
+	}
+
+	/* Transmit burst 2 */
+	tx_count_2 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_2,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	TEST_ASSERT_EQUAL(tx_count_2, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
+			"Transmitted (%d) packets, expected to transmit (%d) packets",
+			tx_count_2, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+
+	/* Verify bonded port tx stats */
+	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)((TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT) +
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2),
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			(TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT) +
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	/* Verify slave ports tx stats */
+
+	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+				TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)",
+				test_params->slave_port_ids[0],
+				(unsigned int)port_stats.opackets,
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+				TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+
+
+
+	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+				(uint64_t)TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)",
+				test_params->slave_port_ids[1],
+				(unsigned int)port_stats.opackets,
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	/* Verify that all mbufs have a ref value of zero */
+	TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkts_burst_1[tx_count_1],
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkts_burst_1[tx_count_1],
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 #define TEST_BALANCE_RX_BURST_SLAVE_COUNT (3)
 
 static int
@@ -3412,7 +3679,7 @@ test_broadcast_tx_burst(void)
 	/* Send burst on bonded port */
 	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
 			burst_size);
-	if (nb_tx != burst_size * test_params->bonded_slave_count) {
+	if (nb_tx != burst_size) {
 		printf("Bonded Port (%d) rx burst failed, packets transmitted value (%u) not as expected (%d)\n",
 				test_params->bonded_port_id,
 				nb_tx, burst_size);
@@ -3455,6 +3722,125 @@ test_broadcast_tx_burst(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+
+#define TEST_BCAST_SLAVE_TX_FAIL_SLAVE_COUNT		(3)
+#define TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE			(40)
+#define TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT	(15)
+#define TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT	(10)
+
+static int
+test_broadcast_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf *pkts_burst[TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE];
+	struct rte_mbuf *expected_fail_pkts[TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT];
+
+	struct rte_eth_stats port_stats;
+
+	int i, tx_count;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0,
+			TEST_BCAST_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	/* Generate test bursts for transmission */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE, 0, 0, 0, 0, 0),
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE,
+			"Failed to generate test packet burst");
+
+	for (i = 0; i < TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT; i++) {
+		expected_fail_pkts[i] = pkts_burst[TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT + i];
+	}
+
+	/* Set virtual slave TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX to only fail
+	 * transmission of TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT packets of burst */
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[0],
+			0);
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[1],
+			0);
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[2],
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[0],
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[1],
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[2],
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+	/* Transmit burst */
+	tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE);
+
+	TEST_ASSERT_EQUAL(tx_count, TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT,
+			"Transmitted (%d) packets, expected to transmit (%d) packets",
+			tx_count, TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_fail_pkts[i], pkts_burst[i + tx_count],
+				"expected mbuf (%d) pointer %p not expected pointer %p",
+				i, expected_fail_pkts[i], pkts_burst[i + tx_count]);
+	}
+
+	/* Verify slave ports tx stats */
+
+	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT,
+			"Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+
+	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT,
+			"Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT,
+			"Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+
+	/* Verify that all mbufs who transmission failed have a ref value of one */
+	TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkts_burst[tx_count],
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkts_burst[tx_count],
+		TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 #define BROADCAST_RX_BURST_NUM_OF_SLAVES (3)
 
 static int
@@ -3767,7 +4153,7 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	}
 
 	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[0][0],
-			burst_size) != (burst_size * slave_count)) {
+			burst_size) != burst_size) {
 		printf("rte_eth_tx_burst failed\n");
 		return -1;
 	}
@@ -3915,6 +4301,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_status_interrupt),
 		TEST_CASE(test_adding_slave_after_bonded_device_started),
 		TEST_CASE(test_roundrobin_tx_burst),
+		TEST_CASE(test_roundrobin_tx_burst_slave_tx_fail),
 		TEST_CASE(test_roundrobin_rx_burst_on_single_slave),
 		TEST_CASE(test_roundrobin_rx_burst_on_multiple_slaves),
 		TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),
@@ -3938,11 +4325,13 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_balance_l34_tx_burst_ipv6_toggle_ip_addr),
 		TEST_CASE(test_balance_l34_tx_burst_vlan_ipv6_toggle_ip_addr),
 		TEST_CASE(test_balance_l34_tx_burst_ipv6_toggle_udp_port),
+		TEST_CASE(test_balance_tx_burst_slave_tx_fail),
 		TEST_CASE(test_balance_rx_burst),
 		TEST_CASE(test_balance_verify_promiscuous_enable_disable),
 		TEST_CASE(test_balance_verify_mac_assignment),
 		TEST_CASE(test_balance_verify_slave_link_status_change_behaviour),
 		TEST_CASE(test_broadcast_tx_burst),
+		TEST_CASE(test_broadcast_tx_burst_slave_tx_fail),
 		TEST_CASE(test_broadcast_rx_burst),
 		TEST_CASE(test_broadcast_verify_promiscuous_enable_disable),
 		TEST_CASE(test_broadcast_verify_mac_assignment),
app/test/virtual_pmd.c +62 -18

127 lines not on this page · raw message

app/test/virtual_pmd.h +7 -0
index 766b6ac..3b5c911 100644
@@ -67,6 +67,13 @@ void virtual_ethdev_rx_burst_fn_set_success(uint8_t port_id, uint8_t success);
 
 void virtual_ethdev_tx_burst_fn_set_success(uint8_t port_id, uint8_t success);
 
+/* if a value greater than zero is set for packet_fail_count then virtual
+ * device tx burst function will fail that many packet from burst or all
+ * packets if packet_fail_count is greater than the number of packets in the
+ * burst */
+void virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
+		uint8_t packet_fail_count);
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_pmd_bond/rte_eth_bond_pmd.c +65 -18

135 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#30 lore raw

PATCH v3 2/5 test app: adding support for generating variable sized packet

In reply to a message not in the archive
---
 app/test/packet_burst_generator.c |   25 ++++++++-----------------
 app/test/packet_burst_generator.h |    6 +++++-
 app/test/test_link_bonding.c      |   14 +++++++++-----
 3 files changed, 22 insertions(+), 23 deletions(-)
app/test/packet_burst_generator.c +8 -17
index 9e747a4..b2824dc 100644
@@ -74,8 +74,7 @@ static inline void
 copy_buf_to_pkt(void *buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)
 {
 	if (offset + len <= pkt->data_len) {
-		rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset,
-				buf, (size_t) len);
+		rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset, buf, (size_t) len);
 		return;
 	}
 	copy_buf_to_pkt_segs(buf, len, pkt, offset);
@@ -191,20 +190,12 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */
 
-#define TXONLY_DEF_PACKET_LEN 64
-#define TXONLY_DEF_PACKET_LEN_128 128
-
-uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN;
-uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = {
-		TXONLY_DEF_PACKET_LEN_128,
-};
-
-uint8_t  tx_pkt_nb_segs = 1;
 
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
 		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst)
+		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+		uint8_t pkt_len, uint8_t nb_pkt_segs)
 {
 	int i, nb_pkt = 0;
 	size_t eth_hdr_size;
@@ -221,9 +212,9 @@ nomore_mbuf:
 			break;
 		}
 
-		pkt->data_len = tx_pkt_seg_lengths[0];
+		pkt->data_len = pkt_len;
 		pkt_seg = pkt;
-		for (i = 1; i < tx_pkt_nb_segs; i++) {
+		for (i = 1; i < nb_pkt_segs; i++) {
 			pkt_seg->next = rte_pktmbuf_alloc(mp);
 			if (pkt_seg->next == NULL) {
 				pkt->nb_segs = i;
@@ -231,7 +222,7 @@ nomore_mbuf:
 				goto nomore_mbuf;
 			}
 			pkt_seg = pkt_seg->next;
-			pkt_seg->data_len = tx_pkt_seg_lengths[i];
+			pkt_seg->data_len = pkt_len;
 		}
 		pkt_seg->next = NULL; /* Last segment of packet. */
 
@@ -259,8 +250,8 @@ nomore_mbuf:
 		 * Complete first mbuf of packet and append it to the
 		 * burst of packets to be transmitted.
 		 */
-		pkt->nb_segs = tx_pkt_nb_segs;
-		pkt->pkt_len = tx_pkt_length;
+		pkt->nb_segs = nb_pkt_segs;
+		pkt->pkt_len = pkt_len;
 		pkt->l2_len = eth_hdr_size;
 
 		if (ipv4) {
app/test/packet_burst_generator.h +5 -1
index 5b3cd6c..f86589e 100644
@@ -47,6 +47,9 @@ extern "C" {
 #define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \
 		((c & 0xff) << 8) | (d & 0xff))
 
+#define PACKET_BURST_GEN_PKT_LEN 60
+#define PACKET_BURST_GEN_PKT_LEN_128 128
+
 
 void
 initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
@@ -68,7 +71,8 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
 		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst);
+		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+		uint8_t pkt_len, uint8_t nb_pkt_segs);
 
 #ifdef __cplusplus
 }
app/test/test_link_bonding.c +9 -5
index 1a847eb..50355a3 100644
@@ -1338,7 +1338,8 @@ generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 	/* Generate burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, vlan, ip_hdr, ipv4,
-			test_params->pkt_udp_hdr, burst_size);
+			test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN_128,
+			1);
 	if (generated_burst_size != burst_size) {
 		printf("Failed to generate packet burst");
 		return -1;
@@ -2056,7 +2057,7 @@ test_activebackup_tx_burst(void)
 	/* Generate a burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size);
+			1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN, 1);
 	if (generated_burst_size != burst_size)
 		return -1;
 
@@ -2709,7 +2710,8 @@ test_balance_l2_tx_burst(void)
 	/* Generate a burst 1 of packets to transmit */
 	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
-			test_params->pkt_udp_hdr, burst_size[0]) != burst_size[0])
+			test_params->pkt_udp_hdr, burst_size[0],
+			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[0])
 		return -1;
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
@@ -2718,7 +2720,8 @@ test_balance_l2_tx_burst(void)
 	/* Generate a burst 2 of packets to transmit */
 	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
-			test_params->pkt_udp_hdr, burst_size[1]) != burst_size[1])
+			test_params->pkt_udp_hdr, burst_size[1],
+			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1])
 		return -1;
 
 	/* Send burst 1 on bonded port */
@@ -3672,7 +3675,8 @@ test_broadcast_tx_burst(void)
 	/* Generate a burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size);
+			1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN,
+			1);
 	if (generated_burst_size != burst_size)
 		return -1;
 
Signature · 1 line
1.7.4.1
#31 lore raw

PATCH v3 3/5 testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist

In reply to a message not in the archive
---
 app/test-pmd/cmdline.c |    2 +-
 app/test-pmd/testpmd.c |    3 ++-
 app/test-pmd/testpmd.h |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
app/test-pmd/cmdline.c +1 -1
index 67321f7..ed76eea 100644
@@ -3614,7 +3614,7 @@ static void cmd_create_bonded_device_parsed(void *parsed_result,
 
 		/* Update number of ports */
 		nb_ports = rte_eth_dev_count();
-		reconfig(port_id);
+		reconfig(port_id, res->socket);
 		rte_eth_promiscuous_enable(port_id);
 	}
 
app/test-pmd/testpmd.c +2 -1
index 9f6cdc4..66e3c7c 100644
@@ -628,7 +628,7 @@ init_config(void)
 
 
 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
 	struct rte_port *port;
 
@@ -647,6 +647,7 @@ reconfig(portid_t new_port_id)
 	/* set flag to initialize port/queue */
 	port->need_reconfig = 1;
 	port->need_reconfig_queues = 1;
+	port->socket_id = socket_id;
 
 	init_port_config();
 }
app/test-pmd/testpmd.h +1 -1
index 142091d..7b78cc5 100644
@@ -455,7 +455,7 @@ void fwd_config_display(void);
 void rxtx_config_display(void);
 void fwd_config_setup(void);
 void set_def_fwd_config(void);
-void reconfig(portid_t new_port_id);
+void reconfig(portid_t new_port_id, unsigned socket_id);
 int init_fwd_streams(void);
 
 void port_mtu_set(portid_t port_id, uint16_t mtu);
Signature · 1 line
1.7.4.1
#32 lore raw

PATCH v3 4/5 bond: lsc polling support

In reply to a message not in the archive

Adds link status polling functionality to bonding device as well as API to set polling interval and link up / down propagation delay. Also contains unit tests for testing polling functionailty.

---
 app/test/test.h                            |    7 +-
 app/test/test_link_bonding.c               |  258 ++++++++++++-------
 app/test/virtual_pmd.c                     |   17 +-
 app/test/virtual_pmd.h                     |   48 +++-
 lib/librte_pmd_bond/rte_eth_bond.h         |   80 ++++++
 lib/librte_pmd_bond/rte_eth_bond_api.c     |  309 +++++++++++++++--------
 lib/librte_pmd_bond/rte_eth_bond_args.c    |   30 ++-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c     |  387 +++++++++++++++++++++-------
 lib/librte_pmd_bond/rte_eth_bond_private.h |   71 ++++--
 9 files changed, 861 insertions(+), 346 deletions(-)
app/test/test.h +4 -3
index 98ab804..24b1640 100644
@@ -62,14 +62,15 @@
 
 #define TEST_ASSERT_SUCCESS(val, msg, ...) do {					\
 		if (!(val == 0)) {										\
-			printf("TestCase %s() line %d failed: "			\
-				msg "\n", __func__, __LINE__, ##__VA_ARGS__);	\
+			printf("TestCase %s() line %d failed (err %d): "	\
+				msg "\n", __func__, __LINE__, val,				\
+				##__VA_ARGS__);									\
 			return -1;											\
 		}														\
 } while (0)
 
 #define TEST_ASSERT_FAIL(val, msg, ...) do {					\
-		if (!(val != -1)) {										\
+		if (!(val != 0)) {										\
 			printf("TestCase %s() line %d failed: "			\
 				msg "\n", __func__, __LINE__, ##__VA_ARGS__);	\
 			return -1;											\
app/test/test_link_bonding.c +162 -96

400 lines not on this page · raw message

app/test/virtual_pmd.c +15 -2
index f9bd841..fffaa35 100644
@@ -458,6 +458,14 @@ virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
 }
 
 void
+virtual_ethdev_set_link_status(uint8_t port_id, uint8_t link_status)
+{
+	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
+
+	vrtl_eth_dev->data->dev_link.link_status = link_status;
+}
+
+void
 virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id,
 		uint8_t link_status)
 {
@@ -505,7 +513,7 @@ get_number_of_sockets(void)
 
 int
 virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
-		uint8_t socket_id)
+		uint8_t socket_id, uint8_t isr_support)
 {
 	struct rte_pci_device *pci_dev = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
@@ -555,7 +563,12 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 	pci_dev->numa_node = socket_id;
 	pci_drv->name = virtual_ethdev_driver_name;
 	pci_drv->id_table = id_table;
-	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+
+	if (isr_support)
+		pci_drv->drv_flags |= RTE_PCI_DRV_INTR_LSC;
+	else
+		pci_drv->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;
+
 
 	eth_drv->pci_drv = (struct rte_pci_driver)(*pci_drv);
 	eth_dev->driver = eth_drv;
app/test/virtual_pmd.h +34 -14

72 lines not on this page · raw message

lib/librte_pmd_bond/rte_eth_bond.h +80 -0

86 lines not on this page · raw message

lib/librte_pmd_bond/rte_eth_bond_api.c +206 -103

501 lines not on this page · raw message

lib/librte_pmd_bond/rte_eth_bond_args.c +26 -4
index 11d9816..bbbc69b 100644
@@ -118,7 +118,7 @@ parse_port_id(const char *port_str)
 	}
 
 	if (port_id < 0 || port_id > RTE_MAX_ETHPORTS) {
-		RTE_LOG(ERR, PMD, "Invalid slave port value (%s) specified.\n",
+		RTE_BOND_LOG(ERR, "Slave port specified (%s) outside expected range",
 				port_str);
 		return -1;
 	}
@@ -138,9 +138,10 @@ bond_ethdev_parse_slave_port_kvarg(const char *key __rte_unused,
 
 	if (strcmp(key, PMD_BOND_SLAVE_PORT_KVARG) == 0) {
 		int port_id = parse_port_id(value);
-		if (port_id < 0)
+		if (port_id < 0) {
+			RTE_BOND_LOG(ERR, "Invalid slave port value (%s) specified", value);
 			return -1;
-		else
+		} else
 			slave_ports->slaves[slave_ports->slave_count++] =
 					(uint8_t)port_id;
 	}
@@ -172,6 +173,7 @@ bond_ethdev_parse_slave_mode_kvarg(const char *key __rte_unused,
 	case BONDING_MODE_BROADCAST:
 		return 0;
 	default:
+		RTE_BOND_LOG(ERR, "Invalid slave mode value (%s) specified", value);
 		return -1;
 	}
 }
@@ -191,7 +193,7 @@ bond_ethdev_parse_socket_id_kvarg(const char *key __rte_unused,
 	if (*endptr != 0 || errno != 0)
 		return -1;
 
-	/* validate mode value */
+	/* validate socket id value */
 	if (socket_id >= 0 && socket_id < number_of_sockets()) {
 		*(uint8_t *)extra_args = (uint8_t)socket_id;
 		return 0;
@@ -250,3 +252,23 @@ bond_ethdev_parse_bond_mac_addr_kvarg(const char *key __rte_unused,
 	/* Parse MAC */
 	return cmdline_parse_etheraddr(NULL, value, extra_args);
 }
+
+int
+bond_ethdev_parse_time_ms_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args)
+{
+	uint32_t time_ms;
+	char *endptr;
+
+	if (value == NULL || extra_args == NULL)
+		return -1;
+
+	errno = 0;
+	time_ms = (uint32_t)strtol(value, &endptr, 10);
+	if (*endptr != 0 || errno != 0)
+		return -1;
+
+	*(uint32_t *)extra_args = time_ms;
+
+	return 0;
+}
lib/librte_pmd_bond/rte_eth_bond_pmd.c +288 -99

589 lines not on this page · raw message

lib/librte_pmd_bond/rte_eth_bond_private.h +46 -25

134 lines not on this page · raw message

Signature · 1 line
1.7.4.1

A message that is not in the archive (sent off-list or not yet received): 1411478290-28807-5-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#34 lore raw

Re: [PATCH v3 4/5] bond: lsc polling support

Quoted 26 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Tuesday, September 23, 2014 2:18 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v3 4/5] bond: lsc polling support

Adds link status polling functionality to bonding device as well as API to set polling interval and link up / down propagation delay. Also contains unit tests for testing polling functionailty.

---
 app/test/test.h                            |    7 +-
 app/test/test_link_bonding.c               |  258 ++++++++++++-------
 app/test/virtual_pmd.c                     |   17 +-
 app/test/virtual_pmd.h                     |   48 +++-
 lib/librte_pmd_bond/rte_eth_bond.h         |   80 ++++++
 lib/librte_pmd_bond/rte_eth_bond_api.c     |  309 +++++++++++++++--------
 lib/librte_pmd_bond/rte_eth_bond_args.c    |   30 ++-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c     |  387 +++++++++++++++++++++-------
 lib/librte_pmd_bond/rte_eth_bond_private.h |   71 ++++--
 9 files changed, 861 insertions(+), 346 deletions(-)
Quoted 2 lines

--
1.7.4.1

#35 lore raw

PATCH v3 5/5 bond: unit test test macro refactor

In reply to a message not in the archive
---
 app/test/test_link_bonding.c | 2574 +++++++++++++++++-------------------------
 1 files changed, 1036 insertions(+), 1538 deletions(-)
app/test/test_link_bonding.c +1036 -1538
index c32b685..c4fcaf7 100644
@@ -31,6 +31,7 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "unistd.h"
 #include <string.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -265,7 +266,7 @@ static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
 static int
 test_setup(void)
 {
-	int i, retval, nb_mbuf_per_pool;
+	int i, nb_mbuf_per_pool;
 	struct ether_addr *mac_addr = (struct ether_addr *)slave_mac;
 
 	/* Allocate ethernet packet header with space for VLAN header */
@@ -273,10 +274,8 @@ test_setup(void)
 		test_params->pkt_eth_hdr = malloc(sizeof(struct ether_hdr) +
 				sizeof(struct vlan_hdr));
 
-		if (test_params->pkt_eth_hdr == NULL) {
-			printf("ethernet header struct allocation failed!\n");
-			return -1;
-		}
+		TEST_ASSERT_NOT_NULL(test_params->pkt_eth_hdr,
+				"Ethernet header struct allocation failed!");
 	}
 
 	nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX + DEF_PKT_BURST +
@@ -286,10 +285,8 @@ test_setup(void)
 				MBUF_SIZE, MBUF_CACHE_SIZE, sizeof(struct rte_pktmbuf_pool_private),
 				rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,
 				rte_socket_id(), 0);
-		if (test_params->mbuf_pool == NULL) {
-			printf("rte_mempool_create failed\n");
-			return -1;
-		}
+		TEST_ASSERT_NOT_NULL(test_params->mbuf_pool,
+				"rte_mempool_create failed");
 	}
 
 	/* Create / Initialize virtual eth devs */
@@ -303,20 +300,12 @@ test_setup(void)
 
 			test_params->slave_port_ids[i] = virtual_ethdev_create(pmd_name,
 					mac_addr, rte_socket_id(), 1);
-			if (test_params->slave_port_ids[i] < 0) {
-				printf("Failed to create virtual virtual ethdev %s\n", pmd_name);
-				return -1;
-			}
+			TEST_ASSERT(test_params->slave_port_ids[i] >= 0,
+					"Failed to create virtual virtual ethdev %s", pmd_name);
 
-			printf("Created virtual ethdev %s\n", pmd_name);
-
-			retval = configure_ethdev(test_params->slave_port_ids[i], 1, 0);
-			if (retval != 0) {
-				printf("Failed to configure virtual ethdev %s\n", pmd_name);
-				return -1;
-			}
-
-			printf("Configured virtual ethdev %s\n", pmd_name);
+			TEST_ASSERT_SUCCESS(configure_ethdev(
+					test_params->slave_port_ids[i], 1, 0),
+					"Failed to configure virtual ethdev %s", pmd_name);
 		}
 		slaves_initialized = 1;
 	}
@@ -350,14 +339,14 @@ test_create_bonded_device(void)
 	current_slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
 
-	TEST_ASSERT(current_slave_count == 0,
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
 			"Number of slaves %d is great than expected %d.",
 			current_slave_count, 0);
 
 	current_slave_count = rte_eth_bond_active_slaves_get(
 			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS);
 
-	TEST_ASSERT(current_slave_count == 0,
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
 			"Number of active slaves %d is great than expected %d.",
 			current_slave_count, 0);
 
@@ -375,30 +364,21 @@ test_create_bonded_device_with_invalid_params(void)
 	/* Invalid name */
 	port_id = rte_eth_bond_create(NULL, test_params->bonding_mode,
 			rte_socket_id());
-	if (port_id >= 0) {
-		printf("Created bonded device unexpectedly.\n");
-		return -1;
-	}
+	TEST_ASSERT(port_id < 0, "Created bonded device unexpectedly");
 
 	test_params->bonding_mode = INVALID_BONDING_MODE;
 
 	/* Invalid bonding mode */
 	port_id = rte_eth_bond_create(BONDED_DEV_NAME, test_params->bonding_mode,
 			rte_socket_id());
-	if (port_id >= 0) {
-		printf("Created bonded device unexpectedly.\n");
-		return -1;
-	}
+	TEST_ASSERT(port_id < 0, "Created bonded device unexpectedly.");
 
 	test_params->bonding_mode = BONDING_MODE_ROUND_ROBIN;
 
 	/* Invalid socket id */
 	port_id = rte_eth_bond_create(BONDED_DEV_NAME, test_params->bonding_mode,
 			INVALID_SOCKET_ID);
-	if (port_id >= 0) {
-		printf("Created bonded device unexpectedly.\n");
-		return -1;
-	}
+	TEST_ASSERT(port_id < 0, "Created bonded device unexpectedly.");
 
 	return 0;
 }
@@ -436,23 +416,15 @@ test_add_slave_to_bonded_device(void)
 static int
 test_add_slave_to_invalid_bonded_device(void)
 {
-	int retval;
-
 	/* Invalid port ID */
-	retval = rte_eth_bond_slave_add(test_params->bonded_port_id + 5,
-			test_params->slave_port_ids[test_params->bonded_slave_count]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_slave_add(test_params->bonded_port_id + 5,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Expected call to failed as invalid port specified.");
 
 	/* Non bonded device */
-	retval = rte_eth_bond_slave_add(test_params->slave_port_ids[0],
-			test_params->slave_port_ids[test_params->bonded_slave_count]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_slave_add(test_params->slave_port_ids[0],
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Expected call to failed as invalid port specified.");
 
 	return 0;
 }
@@ -504,23 +476,17 @@ test_remove_slave_from_bonded_device(void)
 static int
 test_remove_slave_from_invalid_bonded_device(void)
 {
-	int retval;
-
 	/* Invalid port ID */
-	retval = rte_eth_bond_slave_remove(test_params->bonded_port_id + 5,
-			test_params->slave_port_ids[test_params->bonded_slave_count - 1]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_slave_remove(
+			test_params->bonded_port_id + 5,
+			test_params->slave_port_ids[test_params->bonded_slave_count - 1]),
+			"Expected call to failed as invalid port specified.");
 
 	/* Non bonded device */
-	retval = rte_eth_bond_slave_remove(test_params->slave_port_ids[0],
-			test_params->slave_port_ids[test_params->bonded_slave_count - 1]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_slave_remove(
+			test_params->slave_port_ids[0],
+			test_params->slave_port_ids[test_params->bonded_slave_count - 1]),
+			"Expected call to failed as invalid port specified.");
 
 	return 0;
 }
@@ -530,7 +496,7 @@ static int bonded_id = 2;
 static int
 test_add_already_bonded_slave_to_bonded_device(void)
 {
-	int retval, port_id, current_slave_count;
+	int port_id, current_slave_count;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 	char pmd_name[RTE_ETH_NAME_MAX_LEN];
 
@@ -538,29 +504,22 @@ test_add_already_bonded_slave_to_bonded_device(void)
 
 	current_slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count != 1) {
-		printf("Number of slaves (%d) is not that expected (%d).\n",
-				current_slave_count, 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, 1,
+			"Number of slaves (%d) is not that expected (%d).",
+			current_slave_count, 1);
 
 	snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "%s_%d", BONDED_DEV_NAME, ++bonded_id);
 
 	port_id = rte_eth_bond_create(pmd_name, test_params->bonding_mode,
 			rte_socket_id());
-	if (port_id < 0) {
-		printf("Failed to create bonded device.\n");
-		return -1;
-	}
+	TEST_ASSERT(port_id >= 0, "Failed to create bonded device.");
 
-	retval = rte_eth_bond_slave_add(port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count - 1]);
-	if (retval == 0) {
-		printf("Added slave (%d) to bonded port (%d) unexpectedly.\n",
-				test_params->slave_port_ids[test_params->bonded_slave_count-1],
-				port_id);
-		return -1;
-	}
+	TEST_ASSERT(rte_eth_bond_slave_add(port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count - 1])
+			< 0,
+			"Added slave (%d) to bonded port (%d) unexpectedly.",
+			test_params->slave_port_ids[test_params->bonded_slave_count-1],
+			port_id);
 
 	return test_remove_slave_from_bonded_device();
 }
@@ -569,50 +528,47 @@ test_add_already_bonded_slave_to_bonded_device(void)
 static int
 test_get_slaves_from_bonded_device(void)
 {
-	int retval, current_slave_count;
-
+	int current_slave_count;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = test_add_slave_to_bonded_device();
-	if (retval != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
+			"Failed to add slave to bonded device");
 
 	/* Invalid port id */
 	current_slave_count = rte_eth_bond_slaves_get(INVALID_PORT_ID, slaves,
 			RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid port id unexpectedly succeeded");
 
 	current_slave_count = rte_eth_bond_active_slaves_get(INVALID_PORT_ID,
 			slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid port id unexpectedly succeeded");
 
 	/* Invalid slaves pointer */
 	current_slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id,
 			NULL, RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid slave array unexpectedly succeeded");
 
 	current_slave_count = rte_eth_bond_active_slaves_get(
 			test_params->bonded_port_id, NULL, RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid slave array unexpectedly succeeded");
 
 	/* non bonded device*/
 	current_slave_count = rte_eth_bond_slaves_get(
 			test_params->slave_port_ids[0], NULL, RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid port id unexpectedly succeeded");
 
 	current_slave_count = rte_eth_bond_active_slaves_get(
 			test_params->slave_port_ids[0],	NULL, RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid port id unexpectedly succeeded");
 
-	retval = test_remove_slave_from_bonded_device();
-	if (retval != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(test_remove_slave_from_bonded_device(),
+			"Failed to remove slaves from bonded device");
 
 	return 0;
 }
@@ -623,15 +579,13 @@ test_add_remove_multiple_slaves_to_from_bonded_device(void)
 {
 	int i;
 
-	for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++) {
-		if (test_add_slave_to_bonded_device() != 0)
-			return -1;
-	}
+	for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++)
+		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
+				"Failed to add slave to bonded device");
 
-	for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++) {
-		if (test_remove_slave_from_bonded_device() != 0)
-			return -1;
-	}
+	for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++)
+		TEST_ASSERT_SUCCESS(test_remove_slave_from_bonded_device(),
+				"Failed to remove slaves from bonded device");
 
 	return 0;
 }
@@ -659,8 +613,8 @@ test_start_bonded_device(void)
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
 	/* Add slave to bonded device*/
-	if (test_add_slave_to_bonded_device() != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
+			"Failed to add slave to bonded device");
 
 	TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonded_port_id),
 		"Failed to start bonded pmd eth device %d.",
@@ -673,43 +627,30 @@ test_start_bonded_device(void)
 
 	current_slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count != test_params->bonded_slave_count) {
-		printf("Number of slaves (%d) is not expected value (%d).\n",
-				current_slave_count, test_params->bonded_slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count,
+			"Number of slaves (%d) is not expected value (%d).",
+			current_slave_count, test_params->bonded_slave_count);
 
 	current_slave_count = rte_eth_bond_active_slaves_get(
 			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count != test_params->bonded_slave_count) {
-		printf("Number of active slaves (%d) is not expected value (%d).\n",
-				current_slave_count, test_params->bonded_slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count,
+			"Number of active slaves (%d) is not expected value (%d).",
+			current_slave_count, test_params->bonded_slave_count);
 
 	current_bonding_mode = rte_eth_bond_mode_get(test_params->bonded_port_id);
-	if (current_bonding_mode != test_params->bonding_mode) {
-		printf("Bonded device mode (%d) is not expected value (%d).\n",
-				current_bonding_mode, test_params->bonding_mode);
-		return -1;
-
-	}
+	TEST_ASSERT_EQUAL(current_bonding_mode, test_params->bonding_mode,
+			"Bonded device mode (%d) is not expected value (%d).\n",
+			current_bonding_mode, test_params->bonding_mode);
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (primary_port != test_params->slave_port_ids[0]) {
-		printf("Primary port (%d) is not expected value (%d).\n",
-				primary_port, test_params->slave_port_ids[0]);
-		return -1;
-
-	}
+	TEST_ASSERT_EQUAL(primary_port, test_params->slave_port_ids[0],
+			"Primary port (%d) is not expected value (%d).",
+			primary_port, test_params->slave_port_ids[0]);
 
 	rte_eth_link_get(test_params->bonded_port_id, &link_status);
-	if (!link_status.link_status) {
-		printf("Bonded port (%d) status (%d) is not expected value (%d).\n",
-				test_params->bonded_port_id, link_status.link_status, 1);
-		return -1;
-
-	}
+	TEST_ASSERT_EQUAL(link_status.link_status, 1,
+			"Bonded port (%d) status (%d) is not expected value (%d).\n",
+			test_params->bonded_port_id, link_status.link_status, 1);
 
 	return 0;
 }
@@ -725,40 +666,32 @@ test_stop_bonded_device(void)
 	rte_eth_dev_stop(test_params->bonded_port_id);
 
 	rte_eth_link_get(test_params->bonded_port_id, &link_status);
-	if (link_status.link_status) {
-		printf("Bonded port (%d) status (%d) is not expected value (%d).\n",
-				test_params->bonded_port_id, link_status.link_status, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(link_status.link_status, 0,
+			"Bonded port (%d) status (%d) is not expected value (%d).",
+			test_params->bonded_port_id, link_status.link_status, 0);
 
 	current_slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count != test_params->bonded_slave_count) {
-		printf("Number of slaves (%d) is not expected value (%d).\n",
-				current_slave_count, test_params->bonded_slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count,
+			"Number of slaves (%d) is not expected value (%d).",
+			current_slave_count, test_params->bonded_slave_count);
 
 	current_slave_count = rte_eth_bond_active_slaves_get(
 			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count != 0) {
-		printf("Number of active slaves (%d) is not expected value (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
+			"Number of active slaves (%d) is not expected value (%d).",
+			current_slave_count, 0);
 
 	return 0;
 }
 
-static int remove_slaves_and_stop_bonded_device(void)
+static int
+remove_slaves_and_stop_bonded_device(void)
 {
 	/* Clean up and remove slaves from bonded device */
-	while (test_params->bonded_slave_count > 0) {
-		if (test_remove_slave_from_bonded_device() != 0) {
-			printf("test_remove_slave_from_bonded_device failed\n");
-			return -1;
-		}
-	}
+	while (test_params->bonded_slave_count > 0)
+		TEST_ASSERT_SUCCESS(test_remove_slave_from_bonded_device(),
+				"test_remove_slave_from_bonded_device failed");
 
 	rte_eth_dev_stop(test_params->bonded_port_id);
 	rte_eth_stats_reset(test_params->bonded_port_id);
@@ -770,8 +703,7 @@ static int remove_slaves_and_stop_bonded_device(void)
 static int
 test_set_bonding_mode(void)
 {
-	int i;
-	int retval, bonding_mode;
+	int i, bonding_mode;
 
 	int bonding_modes[] = { BONDING_MODE_ROUND_ROBIN,
 							BONDING_MODE_ACTIVE_BACKUP,
@@ -781,56 +713,39 @@ test_set_bonding_mode(void)
 	/* Test supported link bonding modes */
 	for (i = 0; i < (int)RTE_DIM(bonding_modes);	i++) {
 		/* Invalid port ID */
-		retval = rte_eth_bond_mode_set(INVALID_PORT_ID, bonding_modes[i]);
-		if (retval == 0) {
-			printf("Expected call to failed as invalid port (%d) specified.\n",
-					INVALID_PORT_ID);
-			return -1;
-		}
+		TEST_ASSERT_FAIL(rte_eth_bond_mode_set(INVALID_PORT_ID,
+				bonding_modes[i]),
+				"Expected call to failed as invalid port (%d) specified.",
+				INVALID_PORT_ID);
 
 		/* Non bonded device */
-		retval = rte_eth_bond_mode_set(test_params->slave_port_ids[0],
-				bonding_modes[i]);
-		if (retval == 0) {
-			printf("Expected call to failed as invalid port (%d) specified.\n",
-					test_params->slave_port_ids[0]);
-			return -1;
-		}
+		TEST_ASSERT_FAIL(rte_eth_bond_mode_set(test_params->slave_port_ids[0],
+				bonding_modes[i]),
+				"Expected call to failed as invalid port (%d) specified.",
+				test_params->slave_port_ids[0]);
 
-		retval = rte_eth_bond_mode_set(test_params->bonded_port_id,
-				bonding_modes[i]);
-		if (retval != 0) {
-			printf("Failed to set link bonding mode on port (%d) to (%d).\n",
-					test_params->bonded_port_id, bonding_modes[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonded_port_id,
+				bonding_modes[i]),
+				"Failed to set link bonding mode on port (%d) to (%d).",
+				test_params->bonded_port_id, bonding_modes[i]);
 
 		bonding_mode = rte_eth_bond_mode_get(test_params->bonded_port_id);
-		if (bonding_mode != bonding_modes[i]) {
-			printf("Link bonding mode (%d) of port (%d) is not expected value (%d).\n",
-					bonding_mode, test_params->bonded_port_id,
-					bonding_modes[i]);
-			return -1;
-		}
-
+		TEST_ASSERT_EQUAL(bonding_mode, bonding_modes[i],
+				"Link bonding mode (%d) of port (%d) is not expected value (%d).",
+				bonding_mode, test_params->bonded_port_id,
+				bonding_modes[i]);
 
 		/* Invalid port ID */
 		bonding_mode = rte_eth_bond_mode_get(INVALID_PORT_ID);
-		if (bonding_mode >= 0) {
-			printf("Expected call to failed as invalid port (%d) specified.\n",
-					INVALID_PORT_ID);
-			return -1;
-		}
-
+		TEST_ASSERT(bonding_mode < 0,
+				"Expected call to failed as invalid port (%d) specified.",
+				INVALID_PORT_ID);
 
 		/* Non bonded device */
 		bonding_mode = rte_eth_bond_mode_get(test_params->slave_port_ids[0]);
-		if (bonding_mode >= 0) {
-			printf("Expected call to failed as invalid port (%d) specified.\n",
-					test_params->slave_port_ids[0]);
-			return -1;
-		}
-
+		TEST_ASSERT(bonding_mode < 0,
+				"Expected call to failed as invalid port (%d) specified.",
+				test_params->slave_port_ids[0]);
 	}
 
 	return remove_slaves_and_stop_bonded_device();
@@ -844,36 +759,24 @@ test_set_primary_slave(void)
 	struct ether_addr *expected_mac_addr;
 
 	/* Add 4 slaves to bonded device */
-	for (i = test_params->bonded_slave_count; i < 4; i++) {
-		retval = test_add_slave_to_bonded_device();
-		if (retval != 0) {
-			printf("Failed to add slave to bonded device.\n");
-			return -1;
-		}
-	}
-	retval = rte_eth_bond_mode_set(test_params->bonded_port_id,
-			BONDING_MODE_ROUND_ROBIN);
-	if (retval != 0) {
-		printf("Failed to set link bonding mode on port (%d) to (%d).\n",
-				test_params->bonded_port_id, BONDING_MODE_ROUND_ROBIN);
-		return -1;
-	}
+	for (i = test_params->bonded_slave_count; i < 4; i++)
+		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
+				"Failed to add slave to bonded device.");
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonded_port_id,
+			BONDING_MODE_ROUND_ROBIN),
+			"Failed to set link bonding mode on port (%d) to (%d).",
+			test_params->bonded_port_id, BONDING_MODE_ROUND_ROBIN);
 
 	/* Invalid port ID */
-	retval = rte_eth_bond_primary_set(INVALID_PORT_ID,
-			test_params->slave_port_ids[i]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_primary_set(INVALID_PORT_ID,
+			test_params->slave_port_ids[i]),
+			"Expected call to failed as invalid port specified.");
 
 	/* Non bonded device */
-	retval = rte_eth_bond_primary_set(test_params->slave_port_ids[i],
-			test_params->slave_port_ids[i]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_primary_set(test_params->slave_port_ids[i],
+			test_params->slave_port_ids[i]),
+			"Expected call to failed as invalid port specified.");
 
 	/* Set slave as primary
 	 * Verify slave it is now primary slave
@@ -881,32 +784,27 @@ test_set_primary_slave(void)
 	 * Verify that MAC address of all bonded slaves are that of primary slave
 	 */
 	for (i = 0; i < 4; i++) {
-		retval = rte_eth_bond_primary_set(test_params->bonded_port_id,
-				test_params->slave_port_ids[i]);
-		if (retval != 0) {
-			printf("Failed to set bonded port (%d) primary port to (%d)\n",
-					test_params->bonded_port_id,
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(test_params->bonded_port_id,
+				test_params->slave_port_ids[i]),
+				"Failed to set bonded port (%d) primary port to (%d)",
+				test_params->bonded_port_id, test_params->slave_port_ids[i]);
 
 		retval = rte_eth_bond_primary_get(test_params->bonded_port_id);
-		if (retval < 0) {
-			printf("Failed to read primary port from bonded port (%d)\n",
+		TEST_ASSERT(retval >= 0,
+				"Failed to read primary port from bonded port (%d)\n",
 					test_params->bonded_port_id);
-			return -1;
-		} else if (retval != test_params->slave_port_ids[i]) {
-			printf("Bonded port (%d) primary port (%d) not expected value (%d)\n",
-					test_params->bonded_port_id, retval,
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+
+		TEST_ASSERT_EQUAL(retval, test_params->slave_port_ids[i],
+				"Bonded port (%d) primary port (%d) not expected value (%d)\n",
+				test_params->bonded_port_id, retval,
+				test_params->slave_port_ids[i]);
 
 		/* stop/start bonded eth dev to apply new MAC */
 		rte_eth_dev_stop(test_params->bonded_port_id);
 
-		if (rte_eth_dev_start(test_params->bonded_port_id) != 0)
-			return -1;
+		TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonded_port_id),
+				"Failed to start bonded port %d",
+				test_params->bonded_port_id);
 
 		expected_mac_addr = (struct ether_addr *)&slave_mac;
 		expected_mac_addr->addr_bytes[ETHER_ADDR_LEN-1] =
@@ -914,56 +812,44 @@ test_set_primary_slave(void)
 
 		/* Check primary slave MAC */
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(expected_mac_addr, &read_mac_addr, sizeof(read_mac_addr))) {
-			printf("bonded port mac address not set to that of primary port\n");
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(expected_mac_addr, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"bonded port mac address not set to that of primary port\n");
 
 		/* Check bonded MAC */
 		rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-		if (memcmp(&read_mac_addr, &read_mac_addr, sizeof(read_mac_addr))) {
-			printf("bonded port mac address not set to that of primary port\n");
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(&read_mac_addr, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"bonded port mac address not set to that of primary port\n");
 
 		/* Check other slaves MACs */
 		for (j = 0; j < 4; j++) {
 			if (j != i) {
 				rte_eth_macaddr_get(test_params->slave_port_ids[j],
 						&read_mac_addr);
-				if (memcmp(expected_mac_addr, &read_mac_addr,
-						sizeof(read_mac_addr))) {
-					printf("slave port mac address not set to that of primary port\n");
-					return -1;
-				}
+				TEST_ASSERT_SUCCESS(memcmp(expected_mac_addr, &read_mac_addr,
+						sizeof(read_mac_addr)),
+						"slave port mac address not set to that of primary "
+						"port");
 			}
 		}
 	}
 
 
 	/* Test with none existent port */
-	retval = rte_eth_bond_primary_get(test_params->bonded_port_id + 10);
-	if (retval >= 0) {
-		printf("read primary port from expectedly\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_primary_get(test_params->bonded_port_id + 10),
+			"read primary port from expectedly");
 
 	/* Test with slave port */
-	retval = rte_eth_bond_primary_get(test_params->slave_port_ids[0]);
-	if (retval >= 0) {
-		printf("read primary port from expectedly\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_primary_get(test_params->slave_port_ids[0]),
+			"read primary port from expectedly\n");
 
-	if (remove_slaves_and_stop_bonded_device() != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(remove_slaves_and_stop_bonded_device(),
+			"Failed to stop and remove slaves from bonded device");
 
 	/* No slaves  */
-	retval = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (retval >= 0) {
-		printf("read primary port from expectedly\n");
-		return -1;
-	}
+	TEST_ASSERT(rte_eth_bond_primary_get(test_params->bonded_port_id)  < 0,
+			"read primary port from expectedly\n");
 
 	return 0;
 }
@@ -971,7 +857,7 @@ test_set_primary_slave(void)
 static int
 test_set_explicit_bonded_mac(void)
 {
-	int i, retval;
+	int i;
 	struct ether_addr read_mac_addr;
 	struct ether_addr *mac_addr;
 
@@ -980,87 +866,62 @@ test_set_explicit_bonded_mac(void)
 	mac_addr = (struct ether_addr *)explicit_bonded_mac;
 
 	/* Invalid port ID */
-	retval = rte_eth_bond_mac_address_set(INVALID_PORT_ID, mac_addr);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_mac_address_set(INVALID_PORT_ID, mac_addr),
+			"Expected call to failed as invalid port specified.");
 
 	/* Non bonded device */
-	retval = rte_eth_bond_mac_address_set(test_params->slave_port_ids[0],
-			mac_addr);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_mac_address_set(
+			test_params->slave_port_ids[0],	mac_addr),
+			"Expected call to failed as invalid port specified.");
 
 	/* NULL MAC address */
-	retval = rte_eth_bond_mac_address_set(test_params->bonded_port_id, NULL);
-	if (retval == 0) {
-		printf("Expected call to failed as NULL MAC specified\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_mac_address_set(
+			test_params->bonded_port_id, NULL),
+			"Expected call to failed as NULL MAC specified");
 
-	retval = rte_eth_bond_mac_address_set(test_params->bonded_port_id,
-			mac_addr);
-	if (retval != 0) {
-		printf("Failed to set MAC address on bonded port (%d)\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
+			test_params->bonded_port_id, mac_addr),
+			"Failed to set MAC address on bonded port (%d)",
+			test_params->bonded_port_id);
 
 	/* Add 4 slaves to bonded device */
 	for (i = test_params->bonded_slave_count; i < 4; i++) {
-		retval = test_add_slave_to_bonded_device();
-		if (retval != 0) {
-			printf("Failed to add slave to bonded device.\n");
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
+				"Failed to add slave to bonded device.\n");
 	}
 
 	/* Check bonded MAC */
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(mac_addr, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port mac address not set to that of primary port\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(mac_addr, &read_mac_addr, sizeof(read_mac_addr)),
+			"bonded port mac address not set to that of primary port");
 
 	/* Check other slaves MACs */
 	for (i = 0; i < 4; i++) {
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(mac_addr, &read_mac_addr, sizeof(read_mac_addr))) {
-			printf("slave port mac address not set to that of primary port\n");
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(mac_addr, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"slave port mac address not set to that of primary port");
 	}
 
 	/* test resetting mac address on bonded device */
-	if (rte_eth_bond_mac_address_reset(test_params->bonded_port_id) != 0) {
-		printf("Failed to reset MAC address on bonded port (%d)\n",
-				test_params->bonded_port_id);
-
-		return -1;
-	}
-
-	if (rte_eth_bond_mac_address_reset(test_params->slave_port_ids[0]) == 0) {
-		printf("Reset MAC address on bonded port (%d) unexpectedly\n",
-				test_params->slave_port_ids[1]);
+	TEST_ASSERT_SUCCESS(
+			rte_eth_bond_mac_address_reset(test_params->bonded_port_id),
+			"Failed to reset MAC address on bonded port (%d)",
+			test_params->bonded_port_id);
 
-		return -1;
-	}
+	TEST_ASSERT_FAIL(
+			rte_eth_bond_mac_address_reset(test_params->slave_port_ids[0]),
+			"Reset MAC address on bonded port (%d) unexpectedly",
+			test_params->slave_port_ids[1]);
 
 	/* test resetting mac address on bonded device with no slaves */
+	TEST_ASSERT_SUCCESS(remove_slaves_and_stop_bonded_device(),
+			"Failed to remove slaves and stop bonded device");
 
-	if (remove_slaves_and_stop_bonded_device() != 0)
-		return -1;
-
-	if (rte_eth_bond_mac_address_reset(test_params->bonded_port_id) != 0) {
-		printf("Failed to reset MAC address on bonded port (%d)\n",
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_reset(test_params->bonded_port_id),
+			"Failed to reset MAC address on bonded port (%d)",
 				test_params->bonded_port_id);
 
-		return -1;
-	}
-
 	return 0;
 }
 
@@ -1176,9 +1037,10 @@ test_status_interrupt(void)
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
 	/* initialized bonding device with T slaves */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 1,
-			TEST_STATUS_INTERRUPT_SLAVE_COUNT, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 1,
+			TEST_STATUS_INTERRUPT_SLAVE_COUNT, 1),
+			"Failed to initialise bonded device");
 
 	test_lsc_interupt_count = 0;
 
@@ -1310,10 +1172,8 @@ generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 			pkts_burst,	test_params->pkt_eth_hdr, vlan, ip_hdr, ipv4,
 			test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN_128,
 			1);
-	if (generated_burst_size != burst_size) {
-		printf("Failed to generate packet burst");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generated_burst_size, burst_size,
+			"Failed to generate packet burst");
 
 	return generated_burst_size;
 }
@@ -1323,51 +1183,43 @@ generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 static int
 test_roundrobin_tx_burst(void)
 {
-	int i, burst_size, nb_tx;
+	int i, burst_size;
 	struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 2, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 2, 1),
+			"Failed to intialise bonded device");
 
 	burst_size = 20 * test_params->bonded_slave_count;
 
-	if (burst_size > MAX_PKT_BURST) {
-		printf("Burst size specified is greater than supported.\n");
-		return -1;
-	}
+	TEST_ASSERT(burst_size <= MAX_PKT_BURST,
+			"Burst size specified is greater than supported.");
 
 	/* Generate test bursts of packets to transmit */
-	if (generate_test_burst(pkt_burst, burst_size, 0, 1, 0, 0, 0) != burst_size)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst, burst_size, 0, 1, 0, 0, 0),
+			burst_size, "failed to generate test burst");
 
 	/* Send burst on bonded port */
-	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkt_burst,
-			burst_size);
-	if (nb_tx != burst_size)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkt_burst, burst_size), burst_size,
+			"tx burst failed");
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			burst_size);
 
 	/* Verify slave ports tx stats */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_stats_get(test_params->slave_port_ids[i], &port_stats);
-		if (port_stats.opackets !=
-				(uint64_t)burst_size / test_params->bonded_slave_count) {
-			printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-					test_params->bonded_port_id,
-					(unsigned int)port_stats.opackets,
-					burst_size / test_params->bonded_slave_count);
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(port_stats.opackets,
+				(uint64_t)burst_size / test_params->bonded_slave_count,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)\n",
+				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+				burst_size / test_params->bonded_slave_count);
 	}
 
 	/* Put all slaves down and try and transmit */
@@ -1377,10 +1229,9 @@ test_roundrobin_tx_burst(void)
 	}
 
 	/* Send burst on bonded port */
-	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkt_burst,
-			burst_size);
-	if (nb_tx != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+			pkt_burst, burst_size), 0,
+			"tx burst return unexpected value");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -1523,17 +1374,17 @@ test_roundrobin_rx_burst_on_single_slave(void)
 
 	struct rte_eth_stats port_stats;
 
-	int i, j, nb_rx, burst_size = 25;
+	int i, j, burst_size = 25;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
-			0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
+			"Failed to initialize bonded device with slaves");
 
 	/* Generate test bursts of packets to transmit */
-	if (generate_test_burst(gen_pkt_burst, burst_size, 0, 1, 0, 0, 0) !=
-			burst_size)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			gen_pkt_burst, burst_size, 0, 1, 0, 0, 0), burst_size,
+			"burst generation failed");
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		/* Add rx data to slave */
@@ -1542,21 +1393,17 @@ test_roundrobin_rx_burst_on_single_slave(void)
 
 		/* Call rx burst on bonded device */
 		/* Send burst on bonded port */
-		nb_rx = rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
-				MAX_PKT_BURST);
-		if (nb_rx != burst_size) {
-			printf("round-robin rx burst failed");
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(rte_eth_rx_burst(
+				test_params->bonded_port_id, 0, rx_pkt_burst,MAX_PKT_BURST),
+				burst_size, "round-robin rx burst failed");
 
 		/* Verify bonded device rx count */
 		rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-		if (port_stats.ipackets != (uint64_t)burst_size) {
-			printf("Bonded Port (%d) ipackets value (%u) not as expected (%d)\n",
-					test_params->bonded_port_id,
-					(unsigned int)port_stats.ipackets, burst_size);
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
+				"Bonded Port (%d) ipackets value (%u) not as expected (%d)",
+				test_params->bonded_port_id,
+				(unsigned int)port_stats.ipackets, burst_size);
+
 
 
 		/* Verify bonded slave devices rx count */
@@ -1565,19 +1412,15 @@ test_roundrobin_rx_burst_on_single_slave(void)
 			rte_eth_stats_get(test_params->slave_port_ids[j], &port_stats);
 
 			if (i == j) {
-				if (port_stats.ipackets != (uint64_t)burst_size) {
-					printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-							test_params->slave_port_ids[i],
-							(unsigned int)port_stats.ipackets, burst_size);
-					return -1;
-				}
+				TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
+						"Slave Port (%d) ipackets value (%u) not as expected"
+						" (%d)", test_params->slave_port_ids[i],
+						(unsigned int)port_stats.ipackets, burst_size);
 			} else {
-				if (port_stats.ipackets != 0) {
-					printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-							test_params->slave_port_ids[i],
-							(unsigned int)port_stats.ipackets, 0);
-					return -1;
-				}
+				TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
+						"Slave Port (%d) ipackets value (%u) not as expected"
+						" (%d)", test_params->slave_port_ids[i],
+						(unsigned int)port_stats.ipackets, 0);
 			}
 
 			/* Reset bonded slaves stats */
@@ -1614,17 +1457,16 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 	int burst_size[TEST_ROUNDROBIN_TX_BURST_SLAVE_COUNT] = { 15, 13, 36 };
 	int i, nb_rx;
 
-
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
-			0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
+			"Failed to initialize bonded device with slaves");
 
 	/* Generate test bursts of packets to transmit */
 	for (i = 0; i < TEST_ROUNDROBIN_TX_BURST_SLAVE_COUNT; i++) {
-		if (generate_test_burst(&gen_pkt_burst[i][0], burst_size[i], 0, 1, 0, 0,
-				0) != burst_size[i])
-			return -1;
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&gen_pkt_burst[i][0], burst_size[i], 0, 1, 0, 0, 0),
+				burst_size[i], "burst generation failed");
 	}
 
 	/* Add rx data to slaves */
@@ -1635,57 +1477,44 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 
 	/* Call rx burst on bonded device */
 	/* Send burst on bonded port */
-	nb_rx = rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
+	nb_rx = rte_eth_rx_burst( test_params->bonded_port_id, 0, rx_pkt_burst,
 			MAX_PKT_BURST);
-	if (nb_rx != burst_size[0] + burst_size[1] + burst_size[2]) {
-		printf("round-robin rx burst failed (%d != %d)\n", nb_rx,
-				burst_size[0] + burst_size[1] + burst_size[2]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(nb_rx , burst_size[0] + burst_size[1] + burst_size[2],
+			"round-robin rx burst failed (%d != %d)\n", nb_rx,
+			burst_size[0] + burst_size[1] + burst_size[2]);
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size[0] + burst_size[1] +
-			burst_size[2])) {
-		printf("Bonded Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.ipackets,
-				burst_size[0] + burst_size[1] + burst_size[2]);
-		return -1;
-	}
-
+	TEST_ASSERT_EQUAL(port_stats.ipackets,
+			(uint64_t)(burst_size[0] + burst_size[1] + burst_size[2]),
+			"Bonded Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.ipackets,
+			burst_size[0] + burst_size[1] + burst_size[2]);
 
 	/* Verify bonded slave devices rx counts */
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[0]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[0],
-				(unsigned int)port_stats.ipackets, burst_size[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[0],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[0],
+			(unsigned int)port_stats.ipackets, burst_size[0]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[1]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[1],
-				(unsigned int)port_stats.ipackets, burst_size[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[1],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[1], (unsigned int)port_stats.ipackets,
+			burst_size[1]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[2]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[2],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
 				test_params->slave_port_ids[2],
 				(unsigned int)port_stats.ipackets, burst_size[2]);
-		return -1;
-	}
 
 	rte_eth_stats_get(test_params->slave_port_ids[3], &port_stats);
-	if (port_stats.ipackets != 0) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[3],
-				(unsigned int)port_stats.ipackets, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[3],
+			(unsigned int)port_stats.ipackets, 0);
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
@@ -1702,91 +1531,77 @@ test_roundrobin_verify_mac_assignment(void)
 {
 	struct ether_addr read_mac_addr, expected_mac_addr_0, expected_mac_addr_2;
 
-	int i, retval;
+	int i;
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &expected_mac_addr_0);
 	rte_eth_macaddr_get(test_params->slave_port_ids[2], &expected_mac_addr_2);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+				BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
+				"Failed to initialize bonded device with slaves");
 
 	/* Verify that all MACs are the same as first slave added to bonded dev */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(&expected_mac_addr_0, &read_mac_addr,
-				sizeof(read_mac_addr))) {
-			printf("slave port (%d) mac address not set to that of primary port\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"slave port (%d) mac address not set to that of primary port",
+				test_params->slave_port_ids[i]);
 	}
 
 	/* change primary and verify that MAC addresses haven't changed */
-	retval = rte_eth_bond_primary_set(test_params->bonded_port_id,
-			test_params->slave_port_ids[2]);
-	if (retval != 0) {
-		printf("Failed to set bonded port (%d) primary port to (%d)\n",
-				test_params->bonded_port_id, test_params->slave_port_ids[i]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(test_params->bonded_port_id,
+			test_params->slave_port_ids[2]),
+			"Failed to set bonded port (%d) primary port to (%d)",
+			test_params->bonded_port_id, test_params->slave_port_ids[i]);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(&expected_mac_addr_0, &read_mac_addr,
-				sizeof(read_mac_addr))) {
-			printf("slave port (%d) mac address has changed to that of primary port without stop/start toggle of bonded device\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"slave port (%d) mac address has changed to that of primary"
+				" port without stop/start toggle of bonded device",
+				test_params->slave_port_ids[i]);
 	}
 
 	/* stop / start bonded device and verify that primary MAC address is
 	 * propagate to bonded device and slaves */
-
 	rte_eth_dev_stop(test_params->bonded_port_id);
 
-	if (rte_eth_dev_start(test_params->bonded_port_id) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonded_port_id),
+			"Failed to start bonded device");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_2, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of new primary port\n",
-				test_params->slave_port_ids[i]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(
+			memcmp(&expected_mac_addr_2, &read_mac_addr, sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of new primary port",
+			test_params->slave_port_ids[i]);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(&expected_mac_addr_2, &read_mac_addr,
-				sizeof(read_mac_addr))) {
-			printf("slave port (%d) mac address not set to that of new primary port\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_2, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"slave port (%d) mac address not set to that of new primary"
+				" port", test_params->slave_port_ids[i]);
 	}
 
 	/* Set explicit MAC address */
-	if (rte_eth_bond_mac_address_set(test_params->bonded_port_id,
-			(struct ether_addr *)bonded_mac) != 0) {
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
+			test_params->bonded_port_id, (struct ether_addr *)bonded_mac),
+			"Failed to set MAC");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of new primary port\n",
+	TEST_ASSERT_SUCCESS(memcmp(bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of new primary port",
 				test_params->slave_port_ids[i]);
-		return -1;
-	}
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-			printf("slave port (%d) mac address not set to that of new primary port\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(bonded_mac, &read_mac_addr,
+				sizeof(read_mac_addr)), "slave port (%d) mac address not set to"
+				"that of new primary port\n", test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -1799,44 +1614,38 @@ test_roundrobin_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
-			0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
+			"Failed to initialize bonded device with slaves");
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
 
 	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 1) {
-		printf("Port (%d) promiscuous mode not enabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(promiscuous_en, 1,
+			"Port (%d) promiscuous mode not enabled",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
-		promiscuous_en = rte_eth_promiscuous_get(test_params->slave_port_ids[i]);
-		if (promiscuous_en != 1) {
-			printf("slave port (%d) promiscuous mode not enabled\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		promiscuous_en = rte_eth_promiscuous_get(
+				test_params->slave_port_ids[i]);
+		TEST_ASSERT_EQUAL(promiscuous_en, 1,
+				"slave port (%d) promiscuous mode not enabled",
+				test_params->slave_port_ids[i]);
 	}
 
 	rte_eth_promiscuous_disable(test_params->bonded_port_id);
 
 	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 0) {
-		printf("Port (%d) promiscuous mode not disabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(promiscuous_en, 0,
+			"Port (%d) promiscuous mode not disabled\n",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
-		promiscuous_en = rte_eth_promiscuous_get(test_params->slave_port_ids[i]);
-		if (promiscuous_en != 0) {
-			printf("slave port (%d) promiscuous mode not disabled\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		promiscuous_en = rte_eth_promiscuous_get(
+				test_params->slave_port_ids[i]);
+		TEST_ASSERT_EQUAL(promiscuous_en, 0,
+				"Port (%d) promiscuous mode not disabled\n",
+				test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -1863,26 +1672,22 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 	/* Initialize bonded device with TEST_RR_LINK_STATUS_SLAVE_COUNT slaves
 	 * in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
-			TEST_RR_LINK_STATUS_SLAVE_COUNT, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, TEST_RR_LINK_STATUS_SLAVE_COUNT, 1),
+			"Failed to initialize bonded device with slaves");
 
 	/* Verify Current Slaves Count /Active Slave Count is */
 	slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id, slaves,
 			RTE_MAX_ETHPORTS);
-	if (slave_count != TEST_RR_LINK_STATUS_SLAVE_COUNT) {
-		printf("Number of slaves (%d) is not as expected (%d).\n", slave_count,
-				TEST_RR_LINK_STATUS_SLAVE_COUNT);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, TEST_RR_LINK_STATUS_SLAVE_COUNT,
+			"Number of slaves (%d) is not as expected (%d).",
+			slave_count, TEST_RR_LINK_STATUS_SLAVE_COUNT);
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != TEST_RR_LINK_STATUS_SLAVE_COUNT) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, TEST_RR_LINK_STATUS_SLAVE_COUNT);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, TEST_RR_LINK_STATUS_SLAVE_COUNT,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, TEST_RR_LINK_STATUS_SLAVE_COUNT);
 
 	/* Set 2 slaves eth_devs link status to down */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -1890,13 +1695,12 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[3], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
-			slaves, RTE_MAX_ETHPORTS) !=
-					TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_SLAVE_COUNT) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_SLAVE_COUNT);
-		return -1;
-	}
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+	TEST_ASSERT_EQUAL(slave_count,
+			TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_SLAVE_COUNT,
+			"Number of active slaves (%d) is not as expected (%d).\n",
+			slave_count, TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_SLAVE_COUNT);
 
 	burst_size = 20;
 
@@ -1907,19 +1711,16 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	 * 3. Verify stats for bonded eth_dev (opackets = burst_size)
 	 * 4. Verify stats for slave eth_devs (s0 = 10, s1 = 0, s2 = 10, s3 = 0)
 	 */
-	if (generate_test_burst(tx_pkt_burst, burst_size, 0, 1, 0, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(
+			generate_test_burst(tx_pkt_burst, burst_size, 0, 1, 0, 0, 0),
+			burst_size, "generate_test_burst failed");
 
 	rte_eth_stats_reset(test_params->bonded_port_id);
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, tx_pkt_burst,
-			burst_size) != burst_size) {
-		printf("rte_eth_tx_burst failed\n");
-		return -1;
-	}
+
+	TEST_ASSERT_EQUAL(
+			rte_eth_tx_burst(test_params->bonded_port_id, 0, tx_pkt_burst,
+			burst_size), burst_size, "rte_eth_tx_burst failed");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
 	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
@@ -1957,27 +1758,24 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	 * 6. Verify stats for slave eth_devs (s0 = 10, s1 = 0, s2 = 10, s3 = 0)
 	 */
 	for (i = 0; i < TEST_RR_LINK_STATUS_SLAVE_COUNT; i++) {
-		if (generate_test_burst(&gen_pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0)
-				!= burst_size) {
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&gen_pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0),
+				burst_size, "failed to generate packet burst");
+
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&gen_pkt_burst[i][0], burst_size);
 	}
 
-	if (rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
-			MAX_PKT_BURST) != burst_size + burst_size) {
-		printf("rte_eth_rx_burst\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_rx_burst(
+			test_params->bonded_port_id, 0, rx_pkt_burst, MAX_PKT_BURST),
+			burst_size + burst_size,
+			"rte_eth_rx_burst failed");
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.ipackets not as expected\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets , (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.ipackets not as expected\n",
+			test_params->bonded_port_id);
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
@@ -1999,7 +1797,6 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 uint8_t polling_slave_mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00 };
 
-#include "unistd.h"
 
 int polling_test_slaves[TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT] = { -1, -1 } ;
 
@@ -2033,7 +1830,8 @@ test_roundrobin_verfiy_polling_slave_link_status_change(void)
 		TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
 				polling_test_slaves[i]),
 				"Failed to add slave %s(%d) to bonded device %d",
-				slave_name, polling_test_slaves[i], test_params->bonded_port_id);
+				slave_name, polling_test_slaves[i],
+				test_params->bonded_port_id);
 	}
 
 	/* Initialize bonded device */
@@ -2095,15 +1893,13 @@ test_roundrobin_verfiy_polling_slave_link_status_change(void)
 static int
 test_activebackup_tx_burst(void)
 {
-	int i, retval, pktlen, primary_port, burst_size, generated_burst_size, nb_tx;
+	int i, pktlen, primary_port, burst_size;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1);
-	if (retval != 0) {
-		printf("Failed to initialize_bonded_device_with_slaves.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0, 1, 1),
+			"Failed to initialize bonded device with slaves");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
@@ -2114,32 +1910,25 @@ test_activebackup_tx_burst(void)
 
 	burst_size = 20 * test_params->bonded_slave_count;
 
-	if (burst_size > MAX_PKT_BURST) {
-		printf("Burst size specified is greater than supported.\n");
-		return -1;
-	}
+	TEST_ASSERT(burst_size < MAX_PKT_BURST,
+			"Burst size specified is greater than supported.");
 
 	/* Generate a burst of packets to transmit */
-	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
-			pkts_burst,	test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN, 1);
-	if (generated_burst_size != burst_size)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool, pkts_burst,
+			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
+			test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN, 1),
+			burst_size,	"failed to generate burst correctly");
 
 	/* Send burst on bonded port */
-	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
-			burst_size);
-	if (nb_tx != burst_size)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
+			burst_size),  burst_size, "tx burst failed");
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			burst_size);
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
 
@@ -2147,35 +1936,28 @@ test_activebackup_tx_burst(void)
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_stats_get(test_params->slave_port_ids[i], &port_stats);
 		if (test_params->slave_port_ids[i] == primary_port) {
-			if (port_stats.opackets != (uint64_t)burst_size) {
-				printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-						test_params->bonded_port_id,
-						(unsigned int)port_stats.opackets,
-						burst_size / test_params->bonded_slave_count);
-				return -1;
-			}
+			TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+					"Slave Port (%d) opackets value (%u) not as expected (%d)",
+					test_params->bonded_port_id,
+					(unsigned int)port_stats.opackets,
+					burst_size / test_params->bonded_slave_count);
 		} else {
-			if (port_stats.opackets != 0) {
-				printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-						test_params->bonded_port_id,
-						(unsigned int)port_stats.opackets, 0);
-				return -1;
-			}
+			TEST_ASSERT_EQUAL(port_stats.opackets, 0,
+					"Slave Port (%d) opackets value (%u) not as expected (%d)",
+					test_params->bonded_port_id,
+					(unsigned int)port_stats.opackets, 0);
 		}
 	}
 
 	/* Put all slaves down and try and transmit */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
-
 		virtual_ethdev_simulate_link_status_interrupt(
 				test_params->slave_port_ids[i], 0);
 	}
 
 	/* Send burst on bonded port */
-	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
-			burst_size);
-	if (nb_tx != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+			pkts_burst, burst_size), 0, "Sending empty burst failed");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -2193,78 +1975,63 @@ test_activebackup_rx_burst(void)
 
 	int primary_port;
 
-	int i, j, nb_rx, burst_size = 17;
-
-	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
-			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
-			!= 0)
-		return -1;
+	int i, j, burst_size = 17;
 
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0,
+			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1),
+			"Failed to initialize bonded device with slaves");
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (primary_port < 0) {
-		printf("failed to get primary slave for bonded port (%d)",
-				test_params->bonded_port_id);
-	}
+	TEST_ASSERT(primary_port >= 0,
+			"failed to get primary slave for bonded port (%d)",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		/* Generate test bursts of packets to transmit */
-		if (generate_test_burst(&gen_pkt_burst[0], burst_size, 0, 1, 0, 0, 0)
-				!= burst_size) {
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&gen_pkt_burst[0], burst_size, 0, 1, 0, 0, 0),
+				burst_size, "burst generation failed");
 
 		/* Add rx data to slave */
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&gen_pkt_burst[0], burst_size);
 
 		/* Call rx burst on bonded device */
-		nb_rx = rte_eth_rx_burst(test_params->bonded_port_id, 0,
-				&rx_pkt_burst[0], MAX_PKT_BURST);
-		if (nb_rx < 0) {
-			printf("rte_eth_rx_burst failed\n");
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(rte_eth_rx_burst(test_params->bonded_port_id, 0,
+				&rx_pkt_burst[0], MAX_PKT_BURST), burst_size,
+				"rte_eth_rx_burst failed");
 
 		if (test_params->slave_port_ids[i] == primary_port) {
 			/* Verify bonded device rx count */
 			rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-			if (port_stats.ipackets != (uint64_t)burst_size) {
-				printf("Bonded Port (%d) ipackets value (%u) not as expected (%d)\n",
-						test_params->bonded_port_id,
-						(unsigned int)port_stats.ipackets, burst_size);
-				return -1;
-			}
+			TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
+					"Bonded Port (%d) ipackets value (%u) not as expected (%d)",
+					test_params->bonded_port_id,
+					(unsigned int)port_stats.ipackets, burst_size);
 
 			/* Verify bonded slave devices rx count */
 			for (j = 0; j < test_params->bonded_slave_count; j++) {
 				rte_eth_stats_get(test_params->slave_port_ids[j], &port_stats);
 				if (i == j) {
-					if (port_stats.ipackets != (uint64_t)burst_size) {
-						printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-								test_params->slave_port_ids[i],
-								(unsigned int)port_stats.ipackets, burst_size);
-						return -1;
-					}
+					TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
+							"Slave Port (%d) ipackets value (%u) not as "
+							"expected (%d)", test_params->slave_port_ids[i],
+							(unsigned int)port_stats.ipackets, burst_size);
 				} else {
-					if (port_stats.ipackets != 0) {
-						printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-								test_params->slave_port_ids[i],
-								(unsigned int)port_stats.ipackets, 0);
-						return -1;
-					}
+					TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
+							"Slave Port (%d) ipackets value (%u) not as "
+							"expected (%d)\n", test_params->slave_port_ids[i],
+							(unsigned int)port_stats.ipackets, 0);
 				}
 			}
 		} else {
 			for (j = 0; j < test_params->bonded_slave_count; j++) {
 				rte_eth_stats_get(test_params->slave_port_ids[j], &port_stats);
-				if (port_stats.ipackets != 0) {
-					printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-							test_params->slave_port_ids[i],
-							(unsigned int)port_stats.ipackets, 0);
-					return -1;
-				}
+				TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
+						"Slave Port (%d) ipackets value (%u) not as expected "
+						"(%d)", test_params->slave_port_ids[i],
+						(unsigned int)port_stats.ipackets, 0);
 			}
 		}
 
@@ -2290,61 +2057,48 @@ test_activebackup_verify_promiscuous_enable_disable(void)
 	int i, primary_port, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 4, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0, 4, 1),
+			"Failed to initialize bonded device with slaves");
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (primary_port < 0) {
-		printf("failed to get primary slave for bonded port (%d)",
-				test_params->bonded_port_id);
-	}
+	TEST_ASSERT(primary_port >= 0,
+			"failed to get primary slave for bonded port (%d)",
+			test_params->bonded_port_id);
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
 
-	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 1) {
-		printf("Port (%d) promiscuous mode not enabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 1,
+			"Port (%d) promiscuous mode not enabled",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		promiscuous_en = rte_eth_promiscuous_get(
 				test_params->slave_port_ids[i]);
 		if (primary_port == test_params->slave_port_ids[i]) {
-			if (promiscuous_en != 1) {
-				printf("slave port (%d) promiscuous mode not enabled\n",
-						test_params->slave_port_ids[i]);
-				return -1;
-			}
+			TEST_ASSERT_EQUAL(promiscuous_en, 1,
+					"slave port (%d) promiscuous mode not enabled",
+					test_params->slave_port_ids[i]);
 		} else {
-			if (promiscuous_en != 0) {
-				printf("slave port (%d) promiscuous mode enabled\n",
-						test_params->slave_port_ids[i]);
-				return -1;
-			}
+			TEST_ASSERT_EQUAL(promiscuous_en, 0,
+					"slave port (%d) promiscuous mode enabled",
+					test_params->slave_port_ids[i]);
 		}
 
 	}
 
 	rte_eth_promiscuous_disable(test_params->bonded_port_id);
 
-	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 0) {
-		printf("Port (%d) promiscuous mode not disabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 0,
+			"Port (%d) promiscuous mode not disabled\n",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		promiscuous_en = rte_eth_promiscuous_get(
 				test_params->slave_port_ids[i]);
-		if (promiscuous_en != 0) {
-			printf("slave port (%d) promiscuous mode not disabled\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(promiscuous_en, 0,
+				"slave port (%d) promiscuous mode not disabled\n",
+				test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -2360,117 +2114,102 @@ test_activebackup_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1),
+			"Failed to initialize bonded device with slaves");
 
 	/* Verify that bonded MACs is that of first slave and that the other slave
 	 * MAC hasn't been changed */
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not as expected\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not as expected",
+			test_params->slave_port_ids[1]);
 
 	/* change primary and verify that MAC addresses haven't changed */
-	if (rte_eth_bond_primary_set(test_params->bonded_port_id,
-			test_params->slave_port_ids[1]) != 0) {
-		printf("Failed to set bonded port (%d) primary port to (%d)\n",
-				test_params->bonded_port_id, test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_primary_set(test_params->bonded_port_id,
+			test_params->slave_port_ids[1]), 0,
+			"Failed to set bonded port (%d) primary port to (%d)",
+			test_params->bonded_port_id, test_params->slave_port_ids[1]);
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not as expected\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not as expected",
+			test_params->slave_port_ids[1]);
 
 	/* stop / start bonded device and verify that primary MAC address is
 	 * propagated to bonded device and slaves */
 
 	rte_eth_dev_stop(test_params->bonded_port_id);
 
-	if (rte_eth_dev_start(test_params->bonded_port_id) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonded_port_id),
+			"Failed to start device");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not as expected",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[1]);
 
 	/* Set explicit MAC address */
-	if (rte_eth_bond_mac_address_set(test_params->bonded_port_id,
-			(struct ether_addr *)bonded_mac) != 0) {
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
+			test_params->bonded_port_id, (struct ether_addr *)bonded_mac),
+			"failed to set MAC addres");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of bonded port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of bonded port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not as expected",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of bonded port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of bonded port",
+			test_params->slave_port_ids[1]);
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -2492,38 +2231,32 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Generate packet burst for testing */
-	if (generate_test_burst(&pkt_burst[0][0], burst_size, 0, 1, 0, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[0][0], burst_size, 0, 1, 0, 0, 0), burst_size,
+			"generate_test_burst failed");
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
-			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0,
+			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1),
+			"Failed to initialize bonded device with slaves");
 
 	/* Verify Current Slaves Count /Active Slave Count is */
 	slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id, slaves,
 			RTE_MAX_ETHPORTS);
-	if (slave_count != 4) {
-		printf("Number of slaves (%d) is not as expected (%d).\n",
-				slave_count, 4);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, 4,
+			"Number of slaves (%d) is not as expected (%d).",
+			slave_count, 4);
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != 4) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 4);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, 4,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 4);
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (primary_port != test_params->slave_port_ids[0])
-		printf("Primary port not as expected");
+	TEST_ASSERT_EQUAL(primary_port, test_params->slave_port_ids[0],
+			"Primary port not as expected");
 
 	/* Bring 2 slaves down and verify active slave count */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -2531,12 +2264,10 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[3], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id, slaves,
-			RTE_MAX_ETHPORTS) != 2) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_active_slaves_get(
+			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS), 2,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 2);
 
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[1], 1);
@@ -2549,103 +2280,81 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[0], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id, slaves,
-			RTE_MAX_ETHPORTS) != 3) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 3);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_active_slaves_get(
+			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS), 3,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 3);
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (primary_port != test_params->slave_port_ids[2])
-		printf("Primary port not as expected");
+	TEST_ASSERT_EQUAL(primary_port, test_params->slave_port_ids[2],
+			"Primary port not as expected");
 
 	/* Verify that pkts are sent on new primary slave */
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[0][0], burst_size)
-			!= burst_size) {
-		printf("rte_eth_tx_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, &pkt_burst[0][0], burst_size),
+			burst_size,"rte_eth_tx_burst failed");
 
 	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[2]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets not as expected",
+			test_params->slave_port_ids[2]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected\n",
+			test_params->slave_port_ids[0]);
+
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected\n",
+			test_params->slave_port_ids[1]);
+
 	rte_eth_stats_get(test_params->slave_port_ids[3], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[3]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected\n",
+			test_params->slave_port_ids[3]);
 
 	/* Generate packet burst for testing */
 
 	for (i = 0; i < TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT; i++) {
-		if (generate_test_burst(&pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0) !=
-				burst_size)
-			return -1;
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0), burst_size,
+				"generate_test_burst failed");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(
 			test_params->slave_port_ids[i], &pkt_burst[i][0], burst_size);
 	}
 
-	if (rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
-			MAX_PKT_BURST) != burst_size) {
-		printf("rte_eth_rx_burst\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_rx_burst(
+			test_params->bonded_port_id, 0, rx_pkt_burst, MAX_PKT_BURST),
+			burst_size, "rte_eth_rx_burst\n");
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.ipackets not as expected\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
+			"(%d) port_stats.ipackets not as expected",
+			test_params->bonded_port_id);
 
 	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[2]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets not as expected",
+			test_params->slave_port_ids[2]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL (port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL (port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
+			test_params->slave_port_ids[1]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[3], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[3]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL (port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
+			test_params->slave_port_ids[3]);
 
 	/* free mbufs */
 
@@ -2658,7 +2367,6 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 		}
 	}
 
-
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
 }
@@ -2668,70 +2376,49 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 static int
 test_balance_xmit_policy_configuration(void)
 {
-	int retval;
-
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
-			2, 1);
-	if (retval != 0) {
-		printf("Failed to initialize_bonded_device_with_slaves.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1),
+			"Failed to initialize_bonded_device_with_slaves.");
 
 	/* Invalid port id */
-	retval = rte_eth_bond_xmit_policy_set(INVALID_PORT_ID,
-			BALANCE_XMIT_POLICY_LAYER2);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_xmit_policy_set(
+			INVALID_PORT_ID, BALANCE_XMIT_POLICY_LAYER2),
+			"Expected call to failed as invalid port specified.");
 
 	/* Set xmit policy on non bonded device */
-	retval = rte_eth_bond_xmit_policy_set(test_params->slave_port_ids[0],
-			BALANCE_XMIT_POLICY_LAYER2);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_xmit_policy_set(
+			test_params->slave_port_ids[0],	BALANCE_XMIT_POLICY_LAYER2),
+			"Expected call to failed as invalid port specified.");
 
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER2);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
-	if (rte_eth_bond_xmit_policy_get(test_params->bonded_port_id) !=
-			BALANCE_XMIT_POLICY_LAYER2) {
-		printf("balance xmit policy not as expected.\n");
-		return -1;
-	}
 
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER23);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
-	if (rte_eth_bond_xmit_policy_get(test_params->bonded_port_id) !=
-			BALANCE_XMIT_POLICY_LAYER23) {
-		printf("balance xmit policy not as expected.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER2),
+			"Failed to set balance xmit policy.");
 
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER34);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
-	if (rte_eth_bond_xmit_policy_get(test_params->bonded_port_id) !=
-			BALANCE_XMIT_POLICY_LAYER34) {
-		printf("balance xmit policy not as expected.\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_xmit_policy_get(test_params->bonded_port_id),
+			BALANCE_XMIT_POLICY_LAYER2, "balance xmit policy not as expected.");
+
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER23),
+			"Failed to set balance xmit policy.");
+
+	TEST_ASSERT_EQUAL(rte_eth_bond_xmit_policy_get(test_params->bonded_port_id),
+			BALANCE_XMIT_POLICY_LAYER23,
+			"balance xmit policy not as expected.");
+
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER34),
+			"Failed to set balance xmit policy.");
+
+	TEST_ASSERT_EQUAL(rte_eth_bond_xmit_policy_get(test_params->bonded_port_id),
+			BALANCE_XMIT_POLICY_LAYER34,
+			"balance xmit policy not as expected.");
 
 	/* Invalid port id */
-	if (rte_eth_bond_xmit_policy_get(INVALID_PORT_ID) >= 0)
-		return -1;
+	TEST_ASSERT_FAIL(rte_eth_bond_xmit_policy_get(INVALID_PORT_ID),
+			"Expected call to failed as invalid port specified.");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -2746,24 +2433,16 @@ test_balance_l2_tx_burst(void)
 	int burst_size[TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT] = { 10, 15 };
 
 	uint16_t pktlen;
-
-	int retval, i;
+	int i;
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
-			TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT, 1);
-	if (retval != 0) {
-		printf("Failed to initialize_bonded_device_with_slaves.\n");
-		return -1;
-	}
-
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER2);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT, 1),
+			"Failed to initialize_bonded_device_with_slaves.");
 
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER2),
+			"Failed to set balance xmit policy.");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
@@ -2773,54 +2452,50 @@ test_balance_l2_tx_burst(void)
 			dst_addr_0, pktlen);
 
 	/* Generate a burst 1 of packets to transmit */
-	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
+	TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
 			test_params->pkt_udp_hdr, burst_size[0],
-			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[0])
-		return -1;
+			PACKET_BURST_GEN_PKT_LEN, 1), burst_size[0],
+			"failed to generate packet burst");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_1, 0, 0);
 
 	/* Generate a burst 2 of packets to transmit */
-	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
+	TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
 			test_params->pkt_udp_hdr, burst_size[1],
-			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1])
-		return -1;
+			PACKET_BURST_GEN_PKT_LEN, 1), burst_size[1],
+			"failed to generate packet burst");
 
 	/* Send burst 1 on bonded port */
 	for (i = 0; i < TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT; i++) {
-		if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkts_burst[i][0],
-			burst_size[i]) != burst_size[i])
-			return -1;
+		TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+				&pkts_burst[i][0], burst_size[i]),
+				burst_size[i], "Failed to transmit packet burst");
 	}
+
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size[0] + burst_size[1])) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id,
-				(unsigned int)port_stats.opackets, burst_size[0] + burst_size[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)(burst_size[0] + burst_size[1]),
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			burst_size[0] + burst_size[1]);
 
 
 	/* Verify slave ports tx stats */
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size[0]) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[0],
-				(unsigned int)port_stats.opackets, burst_size[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size[0],
+			"Slave Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[0], (unsigned int)port_stats.opackets,
+			burst_size[0]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size[1]) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[1], (
-						unsigned int)port_stats.opackets, burst_size[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size[1],
+			"Slave Port (%d) opackets value (%u) not as expected (%d)\n",
+			test_params->slave_port_ids[1], (unsigned int)port_stats.opackets,
+			burst_size[1]);
 
 	/* Put all slaves down and try and transmit */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
@@ -2830,9 +2505,9 @@ test_balance_l2_tx_burst(void)
 	}
 
 	/* Send burst on bonded port */
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkts_burst[0][0],
-			burst_size[0]) != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, &pkts_burst[0][0], burst_size[0]),
+			0, "Expected zero packet");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -2842,81 +2517,65 @@ static int
 balance_l23_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 		uint8_t toggle_mac_addr, uint8_t toggle_ip_addr)
 {
-	int retval, i;
-	int burst_size_1, burst_size_2, nb_tx_1, nb_tx_2;
+	int i, burst_size_1, burst_size_2, nb_tx_1, nb_tx_2;
 
 	struct rte_mbuf *pkts_burst_1[MAX_PKT_BURST];
 	struct rte_mbuf *pkts_burst_2[MAX_PKT_BURST];
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
-	if (retval != 0) {
-		printf("Failed to initialize_bonded_device_with_slaves.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, 2, 1),
+			"Failed to initialize_bonded_device_with_slaves.");
 
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER23);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER23),
+			"Failed to set balance xmit policy.");
 
 	burst_size_1 = 20;
 	burst_size_2 = 10;
 
-	if (burst_size_1 > MAX_PKT_BURST || burst_size_2 > MAX_PKT_BURST) {
-		printf("Burst size specified is greater than supported.\n");
-		return -1;
-	}
+	TEST_ASSERT(burst_size_1 < MAX_PKT_BURST || burst_size_2 < MAX_PKT_BURST,
+			"Burst size specified is greater than supported.");
 
 	/* Generate test bursts of packets to transmit */
-	if (generate_test_burst(pkts_burst_1, burst_size_1, vlan_enabled, ipv4,
-			0, 0, 0) != burst_size_1)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			pkts_burst_1, burst_size_1, vlan_enabled, ipv4, 0, 0, 0),
+			burst_size_1, "failed to generate packet burst");
 
-	if (generate_test_burst(pkts_burst_2, burst_size_2, vlan_enabled, ipv4,
-			toggle_mac_addr, toggle_ip_addr, 0) != burst_size_2)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2, burst_size_2, vlan_enabled, ipv4,
+			toggle_mac_addr, toggle_ip_addr, 0), burst_size_2,
+			"failed to generate packet burst");
 
 	/* Send burst 1 on bonded port */
 	nb_tx_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
 			burst_size_1);
-	if (nb_tx_1 != burst_size_1)
-		return -1;
+	TEST_ASSERT_EQUAL(nb_tx_1, burst_size_1, "tx burst failed");
 
 	/* Send burst 2 on bonded port */
 	nb_tx_2 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_2,
 			burst_size_2);
-	if (nb_tx_2 != burst_size_2)
-		return -1;
+	TEST_ASSERT_EQUAL(nb_tx_2, burst_size_2, "tx burst failed");
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(nb_tx_1 + nb_tx_2)) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id,
-				(unsigned int)port_stats.opackets, nb_tx_1 + nb_tx_2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(nb_tx_1 + nb_tx_2),
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			nb_tx_1 + nb_tx_2);
 
 	/* Verify slave ports tx stats */
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)nb_tx_1) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[0],
-				(unsigned int)port_stats.opackets, nb_tx_1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)nb_tx_1,
+			"Slave Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[0], (unsigned int)port_stats.opackets,
+			nb_tx_1);
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.opackets != (uint64_t)nb_tx_2) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[1],
-				(unsigned int)port_stats.opackets, nb_tx_2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,(uint64_t)nb_tx_2,
+			"Slave Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[1], (unsigned int)port_stats.opackets,
+			nb_tx_2);
 
 	/* Put all slaves down and try and transmit */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
@@ -2926,10 +2585,10 @@ balance_l23_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 	}
 
 	/* Send burst on bonded port */
-	nb_tx_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
-			burst_size_1);
-	if (nb_tx_1 != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkts_burst_1,
+			burst_size_1), 0, "Expected zero packet");
+
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -2970,82 +2629,66 @@ balance_l34_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 		uint8_t toggle_mac_addr, uint8_t toggle_ip_addr,
 		uint8_t toggle_udp_port)
 {
-	int retval, i;
-	int burst_size_1, burst_size_2, nb_tx_1, nb_tx_2;
+	int i, burst_size_1, burst_size_2, nb_tx_1, nb_tx_2;
 
 	struct rte_mbuf *pkts_burst_1[MAX_PKT_BURST];
 	struct rte_mbuf *pkts_burst_2[MAX_PKT_BURST];
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
-	if (retval != 0) {
-		printf("Failed to initialize_bonded_device_with_slaves.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, 2, 1),
+			"Failed to initialize_bonded_device_with_slaves.");
 
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER34);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER34),
+			"Failed to set balance xmit policy.");
 
 	burst_size_1 = 20;
 	burst_size_2 = 10;
 
-	if (burst_size_1 > MAX_PKT_BURST || burst_size_2 > MAX_PKT_BURST) {
-		printf("Burst size specified is greater than supported.\n");
-		return -1;
-	}
+	TEST_ASSERT(burst_size_1 < MAX_PKT_BURST || burst_size_2 < MAX_PKT_BURST,
+			"Burst size specified is greater than supported.");
 
 	/* Generate test bursts of packets to transmit */
-	if (generate_test_burst(pkts_burst_1, burst_size_1, vlan_enabled, ipv4, 0,
-			0, 0) != burst_size_1)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			pkts_burst_1, burst_size_1, vlan_enabled, ipv4, 0, 0, 0),
+			burst_size_1, "failed to generate burst");
 
-	if (generate_test_burst(pkts_burst_2, burst_size_2, vlan_enabled, ipv4,
-			toggle_mac_addr, toggle_ip_addr, toggle_udp_port) != burst_size_2)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2, burst_size_2,
+			vlan_enabled, ipv4, toggle_mac_addr, toggle_ip_addr,
+			toggle_udp_port), burst_size_2, "failed to generate burst");
 
 	/* Send burst 1 on bonded port */
 	nb_tx_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
 			burst_size_1);
-	if (nb_tx_1 != burst_size_1)
-		return -1;
+	TEST_ASSERT_EQUAL(nb_tx_1, burst_size_1, "tx burst failed");
 
 	/* Send burst 2 on bonded port */
 	nb_tx_2 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_2,
 			burst_size_2);
-	if (nb_tx_2 != burst_size_2)
-		return -1;
+	TEST_ASSERT_EQUAL(nb_tx_2, burst_size_2, "tx burst failed");
 
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(nb_tx_1 + nb_tx_2)) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id,
-				(unsigned int)port_stats.opackets, nb_tx_1 + nb_tx_2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(nb_tx_1 + nb_tx_2),
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			nb_tx_1 + nb_tx_2);
 
 	/* Verify slave ports tx stats */
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)nb_tx_1) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[0],
-				(unsigned int)port_stats.opackets, nb_tx_1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)nb_tx_1,
+			"Slave Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[0], (unsigned int)port_stats.opackets,
+			nb_tx_1);
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.opackets != (uint64_t)nb_tx_2) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[1],
-				(unsigned int)port_stats.opackets, nb_tx_2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)nb_tx_2,
+			"Slave Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[1], (unsigned int)port_stats.opackets,
+			nb_tx_2);
 
 	/* Put all slaves down and try and transmit */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
@@ -3055,10 +2698,9 @@ balance_l34_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 	}
 
 	/* Send burst on bonded port */
-	nb_tx_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
-			burst_size_1);
-	if (nb_tx_1 != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkts_burst_1,
+			burst_size_1), 0, "Expected zero packet");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -3246,21 +2888,22 @@ test_balance_rx_burst(void)
 	struct rte_eth_stats port_stats;
 
 	int burst_size[TEST_BALANCE_RX_BURST_SLAVE_COUNT] = { 10, 5, 30 };
-	int i, j, nb_rx;
+	int i, j;
 
 	memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 3, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, 3, 1),
+			"Failed to intialise bonded device");
 
 	/* Generate test bursts of packets to transmit */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
-		if (generate_test_burst(&gen_pkt_burst[i][0], burst_size[i], 0, 0, 1,
-				0, 0) != burst_size[i])
-			return -1;
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&gen_pkt_burst[i][0], burst_size[i], 0, 0, 1, 0, 0),
+				burst_size[i],"failed to generate packet burst");
 	}
+
 	/* Add rx data to slaves */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
@@ -3269,56 +2912,44 @@ test_balance_rx_burst(void)
 
 	/* Call rx burst on bonded device */
 	/* Send burst on bonded port */
-	nb_rx = rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
-			MAX_PKT_BURST);
-	if (nb_rx != burst_size[0] + burst_size[1] + burst_size[2]) {
-		printf("balance rx burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_rx_burst(test_params->bonded_port_id, 0,
+			rx_pkt_burst, MAX_PKT_BURST),
+			burst_size[0] + burst_size[1] + burst_size[2],
+			"balance rx burst failed\n");
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size[0] + burst_size[1] +
-			burst_size[2])) {
-		printf("Bonded Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.ipackets,
-				burst_size[0] + burst_size[1] + burst_size[2]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets,
+			(uint64_t)(burst_size[0] + burst_size[1] + burst_size[2]),
+			"Bonded Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.ipackets,
+			burst_size[0] + burst_size[1] + burst_size[2]);
 
 
 	/* Verify bonded slave devices rx counts */
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[0]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[0],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
 				test_params->slave_port_ids[0],
 				(unsigned int)port_stats.ipackets, burst_size[0]);
-		return -1;
-	}
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[1]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[1],
-				(unsigned int)port_stats.ipackets, burst_size[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[1],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[1], (unsigned int)port_stats.ipackets,
+			burst_size[1]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[2]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[2],
-				(unsigned int)port_stats.ipackets, burst_size[2]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[2],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[2], (unsigned int)port_stats.ipackets,
+			burst_size[2]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[3], &port_stats);
-	if (port_stats.ipackets != 0) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[3],
-				(unsigned int)port_stats.ipackets, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[3],	(unsigned int)port_stats.ipackets,
+			0);
 
 	/* free mbufs */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
@@ -3337,48 +2968,37 @@ test_balance_rx_burst(void)
 static int
 test_balance_verify_promiscuous_enable_disable(void)
 {
-	int i, promiscuous_en;
+	int i;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, 4, 1),
+			"Failed to intialise bonded device");
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
 
-	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 1) {
-		printf("Port (%d) promiscuous mode not enabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 1,
+			"Port (%d) promiscuous mode not enabled",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
-		promiscuous_en = rte_eth_promiscuous_get(
+		TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(
+				test_params->slave_port_ids[i]), 1,
+				"Port (%d) promiscuous mode not enabled",
 				test_params->slave_port_ids[i]);
-		if (promiscuous_en != 1) {
-			printf("slave port (%d) promiscuous mode not enabled\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
 	}
 
 	rte_eth_promiscuous_disable(test_params->bonded_port_id);
 
-	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 0) {
-		printf("Port (%d) promiscuous mode not disabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 0,
+			"Port (%d) promiscuous mode not disabled",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
-		promiscuous_en = rte_eth_promiscuous_get(
+		TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(
+				test_params->slave_port_ids[i]), 0,
+				"Port (%d) promiscuous mode not disabled",
 				test_params->slave_port_ids[i]);
-		if (promiscuous_en != 0) {
-			printf("slave port (%d) promiscuous mode not disabled\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -3394,115 +3014,102 @@ test_balance_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, 2, 1),
+			"Failed to intialise bonded device");
 
 	/* Verify that bonded MACs is that of first slave and that the other slave
 	 * MAC hasn't been changed */
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[1]);
 
 	/* change primary and verify that MAC addresses haven't changed */
-	if (rte_eth_bond_primary_set(test_params->bonded_port_id,
-			test_params->slave_port_ids[1]) != 0) {
-		printf("Failed to set bonded port (%d) primary port to (%d)\n",
-				test_params->bonded_port_id, test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(test_params->bonded_port_id,
+			test_params->slave_port_ids[1]),
+			"Failed to set bonded port (%d) primary port to (%d)\n",
+			test_params->bonded_port_id, test_params->slave_port_ids[1]);
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[1]);
 
 	/* stop / start bonded device and verify that primary MAC address is
 	 * propagated to bonded device and slaves */
 
 	rte_eth_dev_stop(test_params->bonded_port_id);
 
-	if (rte_eth_dev_start(test_params->bonded_port_id) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonded_port_id),
+			"Failed to start bonded device");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[1]);
 
 	/* Set explicit MAC address */
-	if (rte_eth_bond_mac_address_set(test_params->bonded_port_id,
-			(struct ether_addr *)bonded_mac) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
+			test_params->bonded_port_id, (struct ether_addr *)bonded_mac),
+			"failed to set MAC");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of bonded port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of bonded port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not as expected\n",
+	TEST_ASSERT_SUCCESS(memcmp(&bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not as expected\n",
 				test_params->slave_port_ids[0]);
-		return -1;
-	}
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of bonded port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of bonded port",
+			test_params->slave_port_ids[1]);
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -3524,32 +3131,27 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
-			TEST_BALANCE_LINK_STATUS_SLAVE_COUNT, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER2),
+			"Failed to set balance xmit policy.");
 
-	if (rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER2)) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
 
 	/* Verify Current Slaves Count /Active Slave Count is */
 	slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id, slaves,
 			RTE_MAX_ETHPORTS);
-	if (slave_count != TEST_BALANCE_LINK_STATUS_SLAVE_COUNT) {
-		printf("Number of slaves (%d) is not as expected (%d).\n", slave_count,
-				TEST_BALANCE_LINK_STATUS_SLAVE_COUNT);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT,
+			"Number of slaves (%d) is not as expected (%d).",
+			slave_count, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT);
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != TEST_BALANCE_LINK_STATUS_SLAVE_COUNT) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT);
 
 	/* Set 2 slaves link status to down */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -3557,106 +3159,80 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[3], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
-			slaves, RTE_MAX_ETHPORTS) != 2) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 2);
-		return -1;
-	}
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.4.1

Part of the diff is not shown here. View the raw message.

#36 lore raw

PATCH v2 5/6 test app: adding support for generating variable sized packets

In reply to a message not in the archive
---
 app/test/packet_burst_generator.c |   22 +++++++---------------
 app/test/packet_burst_generator.h |    6 +++++-
 app/test/test_link_bonding.c      |   14 +++++++++-----
 3 files changed, 21 insertions(+), 21 deletions(-)
app/test/packet_burst_generator.c +7 -15
index 5d539f1..9ce6472 100644
@@ -190,20 +190,12 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */
 
-#define TXONLY_DEF_PACKET_LEN 64
-#define TXONLY_DEF_PACKET_LEN_128 128
-
-uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN;
-uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = {
-		TXONLY_DEF_PACKET_LEN_128,
-};
-
-uint8_t  tx_pkt_nb_segs = 1;
 
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
 		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst)
+		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+		uint8_t pkt_len, uint8_t nb_pkt_segs)
 {
 	int i, nb_pkt = 0;
 	size_t eth_hdr_size;
@@ -220,9 +212,9 @@ nomore_mbuf:
 			break;
 		}
 
-		pkt->pkt.data_len = tx_pkt_seg_lengths[0];
+		pkt->pkt.data_len = pkt_len;
 		pkt_seg = pkt;
-		for (i = 1; i < tx_pkt_nb_segs; i++) {
+		for (i = 1; i < nb_pkt_segs; i++) {
 			pkt_seg->pkt.next = rte_pktmbuf_alloc(mp);
 			if (pkt_seg->pkt.next == NULL) {
 				pkt->pkt.nb_segs = i;
@@ -230,7 +222,7 @@ nomore_mbuf:
 				goto nomore_mbuf;
 			}
 			pkt_seg = pkt_seg->pkt.next;
-			pkt_seg->pkt.data_len = tx_pkt_seg_lengths[i];
+			pkt_seg->pkt.data_len = pkt_len;
 		}
 		pkt_seg->pkt.next = NULL; /* Last segment of packet. */
 
@@ -258,8 +250,8 @@ nomore_mbuf:
 		 * Complete first mbuf of packet and append it to the
 		 * burst of packets to be transmitted.
 		 */
-		pkt->pkt.nb_segs = tx_pkt_nb_segs;
-		pkt->pkt.pkt_len = tx_pkt_length;
+		pkt->pkt.nb_segs = nb_pkt_segs;
+		pkt->pkt.pkt_len = pkt_len;
 		pkt->pkt.vlan_macip.f.l2_len = eth_hdr_size;
 
 		if (ipv4) {
app/test/packet_burst_generator.h +5 -1
index 5b3cd6c..f86589e 100644
@@ -47,6 +47,9 @@ extern "C" {
 #define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \
 		((c & 0xff) << 8) | (d & 0xff))
 
+#define PACKET_BURST_GEN_PKT_LEN 60
+#define PACKET_BURST_GEN_PKT_LEN_128 128
+
 
 void
 initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
@@ -68,7 +71,8 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
 		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst);
+		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+		uint8_t pkt_len, uint8_t nb_pkt_segs);
 
 #ifdef __cplusplus
 }
app/test/test_link_bonding.c +9 -5
index c5aaa80..1c06e2d 100644
@@ -1338,7 +1338,8 @@ generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 	/* Generate burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, vlan, ip_hdr, ipv4,
-			test_params->pkt_udp_hdr, burst_size);
+			test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN_128,
+			1);
 	if (generated_burst_size != burst_size) {
 		printf("Failed to generate packet burst");
 		return -1;
@@ -2056,7 +2057,7 @@ test_activebackup_tx_burst(void)
 	/* Generate a burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size);
+			1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN, 1);
 	if (generated_burst_size != burst_size)
 		return -1;
 
@@ -2709,7 +2710,8 @@ test_balance_l2_tx_burst(void)
 	/* Generate a burst 1 of packets to transmit */
 	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
-			test_params->pkt_udp_hdr, burst_size[0]) != burst_size[0])
+			test_params->pkt_udp_hdr, burst_size[0],
+			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[0])
 		return -1;
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
@@ -2718,7 +2720,8 @@ test_balance_l2_tx_burst(void)
 	/* Generate a burst 2 of packets to transmit */
 	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
-			test_params->pkt_udp_hdr, burst_size[1]) != burst_size[1])
+			test_params->pkt_udp_hdr, burst_size[1],
+			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1])
 		return -1;
 
 	/* Send burst 1 on bonded port */
@@ -3672,7 +3675,8 @@ test_broadcast_tx_burst(void)
 	/* Generate a burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size);
+			1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN,
+			1);
 	if (generated_burst_size != burst_size)
 		return -1;
 
Signature · 1 line
1.7.0.7
#37 lore raw

PATCH v2 6/6 testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist

In reply to a message not in the archive
---
 app/test-pmd/cmdline.c |    2 +-
 app/test-pmd/testpmd.c |    3 ++-
 app/test-pmd/testpmd.h |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
app/test-pmd/cmdline.c +1 -1
index b04a4e8..a0d88df 100644
@@ -3614,7 +3614,7 @@ static void cmd_create_bonded_device_parsed(void *parsed_result,
 
 		/* Update number of ports */
 		nb_ports = rte_eth_dev_count();
-		reconfig(port_id);
+		reconfig(port_id, res->socket);
 		rte_eth_promiscuous_enable(port_id);
 	}
 
app/test-pmd/testpmd.c +2 -1
index a112559..d843f77 100644
@@ -627,7 +627,7 @@ init_config(void)
 
 
 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
 	struct rte_port *port;
 
@@ -646,6 +646,7 @@ reconfig(portid_t new_port_id)
 	/* set flag to initialize port/queue */
 	port->need_reconfig = 1;
 	port->need_reconfig_queues = 1;
+	port->socket_id = socket_id;
 
 	init_port_config();
 }
app/test-pmd/testpmd.h +1 -1
index b8322a2..f34b5d1 100644
@@ -455,7 +455,7 @@ void fwd_config_display(void);
 void rxtx_config_display(void);
 void fwd_config_setup(void);
 void set_def_fwd_config(void);
-void reconfig(portid_t new_port_id);
+void reconfig(portid_t new_port_id, unsigned socket_id);
 int init_fwd_streams(void);
 
 void port_mtu_set(portid_t port_id, uint16_t mtu);
Signature · 1 line
1.7.0.7
#38 lore raw

v4 cover link bonding

In reply to a message not in the archive

v4:
- Rebased to account for changes in master.
- Fix for rte_eth_bond_slaves_get() introduced in v3 patch set
- Addressed issue around disabling/enabling link status polling around adding/ removing slaves devices.

v3 :
- Typo fix for the bond free mbufs patch.
- Rebased to account for changes in the mbuf patches.
- Add support for slave devices which don't support link status interrupts
- Tidy up the link bonding unit test so that all tests use the new test macros.

v2 :
Addresses issues with the logic around the handling of fail transmissions. In this version all modes behave in a manner similar to a standard PMD, returning the number of successfully transmitted mbufs and with the failing mbufs at the end of bufs array for freeing / retransmission by the application software

v1:

This patch set adds support for link status interrupt in the link bonding pmd. It also contains some patches to tidy up the code structure and to of the link bonding code and to fix bugs relating to transmission failures in the under lying slave pmd which could lead to leaked mbufs.

Declan Doherty (8):
bond: link status interrupt support
bond: removing switch statement from rx burst method
bond: fix naming inconsistency in tx_burst_round_robin
bond: free mbufs if transmission fails in bonding tx_burst functions test app: adding support for generating variable sized packet
testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist
bond: lsc polling support
bond: unit test test macro refactor

 app/test-pmd/cmdline.c                     |   65 +-
 app/test-pmd/testpmd.c                     |    3 +-
 app/test-pmd/testpmd.h                     |    2 +-
 app/test/packet_burst_generator.c          |   25 +-
 app/test/packet_burst_generator.h          |    6 +-
 app/test/test.h                            |    7 +-
 app/test/test_link_bonding.c               | 3342 ++++++++++++++--------------
 app/test/virtual_pmd.c                     |   97 +-
 app/test/virtual_pmd.h                     |   53 +-
 lib/librte_pmd_bond/rte_eth_bond.h         |   80 +
 lib/librte_pmd_bond/rte_eth_bond_api.c     |  319 ++-
 lib/librte_pmd_bond/rte_eth_bond_args.c    |   30 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c     |  550 +++--
 lib/librte_pmd_bond/rte_eth_bond_private.h |   71 +-
 14 files changed, 2692 insertions(+), 1958 deletions(-)
Signature · 1 line
1.7.12.2

A message that is not in the archive (sent off-list or not yet received): 1412071079-7355-1-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#40 lore raw

PATCH v4 1/8 bond: link status interrupt support

Adding support for lsc interrupt from bonded device to link bonding library with supporting unit tests in the test application.

---
 app/test/test_link_bonding.c           | 213 +++++++++++++++++++++++++++------
 lib/librte_pmd_bond/rte_eth_bond_api.c |   4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   6 +
 3 files changed, 189 insertions(+), 34 deletions(-)
app/test/test_link_bonding.c +179 -34
index db5b180..cce32ed 100644
@@ -39,6 +39,7 @@
 #include <inttypes.h>
 #include <errno.h>
 #include <sys/queue.h>
+#include <sys/time.h>
 
 #include <rte_byteorder.h>
 #include <rte_common.h>
@@ -224,10 +225,15 @@ static struct rte_eth_txconf tx_conf_default = {
 };
 
 static int
-configure_ethdev(uint8_t port_id, uint8_t start)
+configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 {
 	int q_id;
 
+	if (en_isr)
+		default_pmd_conf.intr_conf.lsc = 1;
+	else
+		default_pmd_conf.intr_conf.lsc = 0;
+
 	if (rte_eth_dev_configure(port_id, test_params->nb_rx_q,
 			test_params->nb_tx_q, &default_pmd_conf) != 0) {
 		goto error;
@@ -312,7 +318,7 @@ test_setup(void)
 
 			printf("Created virtual ethdev %s\n", pmd_name);
 
-			retval = configure_ethdev(test_params->slave_port_ids[i], 1);
+			retval = configure_ethdev(test_params->slave_port_ids[i], 1, 0);
 			if (retval != 0) {
 				printf("Failed to configure virtual ethdev %s\n", pmd_name);
 				return -1;
@@ -341,7 +347,7 @@ test_create_bonded_device(void)
 		TEST_ASSERT(test_params->bonded_port_id >= 0,
 				"Failed to create bonded ethdev %s", BONDED_DEV_NAME);
 
-		TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
+		TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
 				"Failed to configure bonded ethdev %s", BONDED_DEV_NAME);
 	}
 
@@ -1078,12 +1084,12 @@ test_set_explicit_bonded_mac(void)
 
 
 static int
-initialize_bonded_device_with_slaves(uint8_t bonding_mode,
+initialize_bonded_device_with_slaves(uint8_t bonding_mode, uint8_t bond_en_isr,
 		uint8_t number_of_slaves, uint8_t enable_slave)
 {
 	/* configure bonded device */
-	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
-			"Failed to configure bonding port (%d) in mode %d "
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0,
+			bond_en_isr), "Failed to configure bonding port (%d) in mode %d "
 			"with (%d) slaves.", test_params->bonded_port_id, bonding_mode,
 			number_of_slaves);
 
@@ -1116,8 +1122,8 @@ test_adding_slave_after_bonded_device_started(void)
 {
 	int i;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 0) !=
-			0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 0)
+			!= 0)
 		return -1;
 
 	/* Enabled slave devices */
@@ -1141,6 +1147,144 @@ test_adding_slave_after_bonded_device_started(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_STATUS_INTERRUPT_SLAVE_COUNT	4
+#define TEST_LSC_WAIT_TIMEOUT_MS	500
+
+int test_lsc_interupt_count;
+
+static pthread_mutex_t mutex;
+static pthread_cond_t cvar;
+
+static void
+test_bonding_lsc_event_callback(uint8_t port_id __rte_unused,
+		enum rte_eth_event_type type  __rte_unused, void *param __rte_unused)
+{
+	pthread_mutex_lock(&mutex);
+	test_lsc_interupt_count++;
+
+	pthread_cond_signal(&cvar);
+	pthread_mutex_unlock(&mutex);
+}
+
+static inline int
+lsc_timeout(int wait_us)
+{
+	int retval = 0;
+
+	struct timespec ts;
+	struct timeval tp;
+
+	gettimeofday(&tp, NULL);
+
+	/* Convert from timeval to timespec */
+	ts.tv_sec  = tp.tv_sec;
+	ts.tv_nsec = tp.tv_usec * 1000;
+	ts.tv_nsec += wait_us * 1000;
+
+	pthread_mutex_lock(&mutex);
+	if (test_lsc_interupt_count < 1)
+		retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+
+	pthread_mutex_unlock(&mutex);
+
+	return retval;
+}
+
+static int
+test_status_interrupt(void)
+{
+	int slave_count;
+	uint8_t slaves[RTE_MAX_ETHPORTS];
+
+	pthread_mutex_init(&mutex, NULL);
+	pthread_cond_init(&cvar, NULL);
+
+	/* initialized bonding device with T slaves */
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 1,
+			TEST_STATUS_INTERRUPT_SLAVE_COUNT, 1) != 0)
+		return -1;
+
+	test_lsc_interupt_count = 0;
+
+	/* register link status change interrupt callback */
+	rte_eth_dev_callback_register(test_params->bonded_port_id,
+			RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
+			&test_params->bonded_port_id);
+
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+
+	TEST_ASSERT_EQUAL(slave_count, TEST_STATUS_INTERRUPT_SLAVE_COUNT,
+			"Number of active slaves (%d) is not as expected (%d)",
+			slave_count, TEST_STATUS_INTERRUPT_SLAVE_COUNT);
+
+	/* Bring all 4 slaves link status to down and test that we have received a
+	 * lsc interrupts */
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 0);
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[1], 0);
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[2], 0);
+
+	TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+			"Received a link status change interrupt unexpectedly");
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[3], 0);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
+			"timed out waiting for interrupt");
+
+	TEST_ASSERT(test_lsc_interupt_count > 0,
+			"Did not receive link status change interrupt");
+
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+
+	TEST_ASSERT_EQUAL(slave_count, 0,
+			"Number of active slaves (%d) is not as expected (%d)",
+			slave_count, 0);
+
+	/* bring one slave port up so link status will change */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 1);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
+			"timed out waiting for interrupt");
+
+	/* test that we have received another lsc interrupt */
+	TEST_ASSERT(test_lsc_interupt_count > 0,
+			"Did not receive link status change interrupt");
+
+	/* Verify that calling the same slave lsc interrupt doesn't cause another
+	 * lsc interrupt from bonded device */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 1);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) != 0,
+			"received unexpected interrupt");
+
+	TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+			"Did not receive link status change interrupt");
+
+
+	/* unregister lsc callback before exiting */
+	rte_eth_dev_callback_unregister(test_params->bonded_port_id,
+				RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
+				&test_params->bonded_port_id);
+
+	pthread_mutex_destroy(&mutex);
+	pthread_cond_destroy(&cvar);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 static int
 generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 		uint8_t vlan, uint8_t ipv4, uint8_t toggle_dst_mac,
@@ -1209,7 +1353,7 @@ test_roundrobin_tx_burst(void)
 	struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 2, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 2, 1)
 			!= 0)
 		return -1;
 
@@ -1279,7 +1423,7 @@ test_roundrobin_rx_burst_on_single_slave(void)
 	int i, j, nb_rx, burst_size = 25;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1369,7 +1513,7 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1461,7 +1605,7 @@ test_roundrobin_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[2], &expected_mac_addr_2);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1)
 			!= 0)
 		return -1;
 
@@ -1552,7 +1696,7 @@ test_roundrobin_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1616,7 +1760,7 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 	/* Initialize bonded device with TEST_RR_LINK_STATUS_SLAVE_COUNT slaves
 	 * in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
 			TEST_RR_LINK_STATUS_SLAVE_COUNT, 1) != 0)
 		return -1;
 
@@ -1757,7 +1901,7 @@ test_activebackup_tx_burst(void)
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -1854,7 +1998,7 @@ test_activebackup_rx_burst(void)
 	int i, j, nb_rx, burst_size = 17;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
 			!= 0)
 		return -1;
@@ -1948,7 +2092,7 @@ test_activebackup_verify_promiscuous_enable_disable(void)
 	int i, primary_port, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 4, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 4, 1)
 			!= 0)
 		return -1;
 
@@ -2018,7 +2162,7 @@ test_activebackup_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 2, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1)
 			!= 0)
 		return -1;
 
@@ -2157,7 +2301,7 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 	}
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
 			!= 0)
 		return -1;
@@ -2328,7 +2472,7 @@ test_balance_xmit_policy_configuration(void)
 {
 	int retval;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
@@ -2408,7 +2552,7 @@ test_balance_l2_tx_burst(void)
 	int retval, i;
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE,
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
 			TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
@@ -2506,7 +2650,7 @@ balance_l23_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -2634,7 +2778,7 @@ balance_l34_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -2772,7 +2916,7 @@ test_balance_rx_burst(void)
 	memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 3, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 3, 1)
 			!= 0)
 		return -1;
 
@@ -2861,7 +3005,7 @@ test_balance_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1) != 0)
 		return -1;
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
@@ -2915,7 +3059,7 @@ test_balance_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1) != 0)
 		return -1;
 
 	/* Verify that bonded MACs is that of first slave and that the other slave
@@ -3045,7 +3189,7 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
 			TEST_BALANCE_LINK_STATUS_SLAVE_COUNT, 1) != 0)
 		return -1;
 
@@ -3237,7 +3381,7 @@ test_broadcast_tx_burst(void)
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -3327,7 +3471,7 @@ test_broadcast_rx_burst(void)
 	memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 3, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 3, 1) != 0)
 		return -1;
 
 
@@ -3419,7 +3563,7 @@ test_broadcast_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1) != 0)
 		return -1;
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
@@ -3475,7 +3619,7 @@ test_broadcast_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[2], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4, 1) != 0)
 		return -1;
 
 	/* Verify that all MACs are the same as first slave added to bonded
@@ -3575,7 +3719,7 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0,
 			BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
 		return -1;
 
@@ -3711,7 +3855,7 @@ test_reconfigure_bonded_device(void)
 	test_params->nb_rx_q = 4;
 	test_params->nb_tx_q = 4;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0)  != 0) {
+	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
 		printf("failed to reconfigure bonded device");
 		return -1;
 	}
@@ -3720,7 +3864,7 @@ test_reconfigure_bonded_device(void)
 	test_params->nb_rx_q = 2;
 	test_params->nb_tx_q = 2;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0)  != 0) {
+	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
 		printf("failed to reconfigure bonded device with less rx/tx queues");
 		return -1;
 	}
@@ -3768,6 +3912,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_set_bonding_mode),
 		TEST_CASE(test_set_primary_slave),
 		TEST_CASE(test_set_explicit_bonded_mac),
+		TEST_CASE(test_status_interrupt),
 		TEST_CASE(test_adding_slave_after_bonded_device_started),
 		TEST_CASE(test_roundrobin_tx_burst),
 		TEST_CASE(test_roundrobin_rx_burst_on_single_slave),
lib/librte_pmd_bond/rte_eth_bond_api.c +4 -0
index 75f5694..dd33119 100644
@@ -177,6 +177,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	pci_drv->id_table->vendor_id = PCI_ANY_ID;
 	pci_drv->id_table->subsystem_vendor_id = PCI_ANY_ID;
 
+	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
 		RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
@@ -200,6 +202,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
 
+	TAILQ_INIT(&(eth_dev->callbacks));
+
 	eth_dev->data->dev_link.link_status = 0;
 
 	eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
lib/librte_pmd_bond/rte_eth_bond_pmd.c +6 -0
index 08d3b5f..aca2dcf 100644
@@ -918,6 +918,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 	struct rte_eth_link link;
 
 	int i, valid_slave = 0, active_pos = -1;
+	uint8_t lsc_flag = 0;
 
 	if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
 		return;
@@ -963,6 +964,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 			/* If first active slave, then change link status */
 			bonded_eth_dev->data->dev_link.link_status = 1;
 			internals->current_primary_port = port_id;
+			lsc_flag = 1;
 
 			/* Inherit eth dev link properties from first active slave */
 			link_properties_set(bonded_eth_dev,
@@ -987,6 +989,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		/* No active slaves, change link status to down and reset other
 		 * link properties */
 		if (internals->active_slave_count < 1) {
+			lsc_flag = 1;
 			bonded_eth_dev->data->dev_link.link_status = 0;
 
 			link_properties_reset(bonded_eth_dev);
@@ -1002,6 +1005,9 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 				internals->current_primary_port = internals->primary_port;
 		}
 	}
+
+	if (lsc_flag)
+		_rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
 }
 
 struct eth_dev_ops default_dev_ops = {
Signature · 1 line
1.7.12.2
#41 lore raw

PATCH v4 2/8 bond: removing switch statement from rx burst method

In reply to a message not in the archive
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 62 +++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 27 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +35 -27
index aca2dcf..348e28f 100644
@@ -59,33 +59,37 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	internals = bd_rx_q->dev_private;
 
-	switch (internals->mode) {
-	case BONDING_MODE_ROUND_ROBIN:
-	case BONDING_MODE_BROADCAST:
-	case BONDING_MODE_BALANCE:
-		for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
-			/* Offset of pointer to *bufs increases as packets are received
-			 * from other slaves */
-			num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
-					bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
-			if (num_rx_slave) {
-				num_rx_total += num_rx_slave;
-				nb_pkts -= num_rx_slave;
-			}
+	for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
+		/* Offset of pointer to *bufs increases as packets are received
+		 * from other slaves */
+		num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
+				bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
+		if (num_rx_slave) {
+			num_rx_total += num_rx_slave;
+			nb_pkts -= num_rx_slave;
 		}
-		break;
-	case BONDING_MODE_ACTIVE_BACKUP:
-		num_rx_slave = rte_eth_rx_burst(internals->current_primary_port,
-				bd_rx_q->queue_id, bufs, nb_pkts);
-		if (num_rx_slave)
-			num_rx_total = num_rx_slave;
-		break;
 	}
+
 	return num_rx_total;
 }
 
 static uint16_t
-bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
+bond_ethdev_rx_burst_active_backup(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
+{
+	struct bond_dev_private *internals;
+
+	/* Cast to structure, containing bonded device's port id and queue id */
+	struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
+
+	internals = bd_rx_q->dev_private;
+
+	return rte_eth_rx_burst(internals->current_primary_port,
+			bd_rx_q->queue_id, bufs, nb_pkts);
+}
+
+static uint16_t
+bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
 {
 	struct bond_dev_private *dev_private;
@@ -134,7 +138,7 @@ bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
 }
 
 static uint16_t
-bond_ethdev_tx_active_backup(void *queue,
+bond_ethdev_tx_burst_active_backup(void *queue,
 		struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
 	struct bond_dev_private *internals;
@@ -270,7 +274,8 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t slave_count, uint8_t policy)
 }
 
 static uint16_t
-bond_ethdev_tx_balance(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
 {
 	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
@@ -480,22 +485,25 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int mode)
 
 	switch (mode) {
 	case BONDING_MODE_ROUND_ROBIN:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_round_robin;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_round_robin;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	case BONDING_MODE_ACTIVE_BACKUP:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_active_backup;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_active_backup;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup;
 		break;
 	case BONDING_MODE_BALANCE:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_balance;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_balance;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	case BONDING_MODE_BROADCAST:
 		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	default:
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 	internals->mode = mode;
 
 	return 0;
Signature · 1 line
1.7.12.2
#42 lore raw

PATCH v4 3/8 bond: fix naming inconsistency in tx_burst_round_robin

In reply to a message not in the archive
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +5 -5
index 348e28f..66f1650 100644
@@ -92,7 +92,7 @@ static uint16_t
 bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
 {
-	struct bond_dev_private *dev_private;
+	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
 
 	struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_pkts];
@@ -107,13 +107,13 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 	int i, cs_idx = 0;
 
 	bd_tx_q = (struct bond_tx_queue *)queue;
-	dev_private = bd_tx_q->dev_private;
+	internals = bd_tx_q->dev_private;
 
 	/* Copy slave list to protect against slave up/down changes during tx
 	 * bursting */
-	num_of_slaves = dev_private->active_slave_count;
-	memcpy(slaves, dev_private->active_slaves,
-			sizeof(dev_private->active_slaves[0]) * num_of_slaves);
+	num_of_slaves = internals->active_slave_count;
+	memcpy(slaves, internals->active_slaves,
+			sizeof(internals->active_slaves[0]) * num_of_slaves);
 
 	if (num_of_slaves < 1)
 		return num_tx_total;
Signature · 1 line
1.7.12.2
#43 lore raw

PATCH v4 4/8 bond: free mbufs if transmission fails in bonding tx_burst functions

In reply to a message not in the archive
---
 app/test/test_link_bonding.c           | 393 ++++++++++++++++++++++++++++++++-
 app/test/virtual_pmd.c                 |  80 +++++--
 app/test/virtual_pmd.h                 |   7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  83 +++++--
 4 files changed, 525 insertions(+), 38 deletions(-)
app/test/test_link_bonding.c +391 -2
index cce32ed..1a847eb 100644
@@ -663,6 +663,9 @@ enable_bonded_slaves(void)
 	int i;
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
+		virtual_ethdev_tx_burst_fn_set_success(test_params->slave_port_ids[i],
+				1);
+
 		virtual_ethdev_simulate_link_status_interrupt(
 				test_params->slave_port_ids[i], 1);
 	}
@@ -1413,6 +1416,135 @@ test_roundrobin_tx_burst(void)
 }
 
 static int
+verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
+{
+	int i, refcnt;
+
+	for (i = 0; i < nb_mbufs; i++) {
+		refcnt = rte_mbuf_refcnt_read(mbufs[i]);
+		TEST_ASSERT_EQUAL(refcnt, val,
+			"mbuf ref count (%d)is not the expected value (%d)",
+			refcnt, val);
+	}
+	return 0;
+}
+
+
+static void
+free_mbufs(struct rte_mbuf **mbufs, int nb_mbufs)
+{
+	int i;
+
+	for (i = 0; i < nb_mbufs; i++)
+		rte_pktmbuf_free(mbufs[i]);
+}
+
+#define TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT		(2)
+#define TEST_RR_SLAVE_TX_FAIL_BURST_SIZE		(64)
+#define TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT		(22)
+#define TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX	(1)
+
+static int
+test_roundrobin_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
+	struct rte_mbuf *expected_tx_fail_pkts[MAX_PKT_BURST];
+
+	struct rte_eth_stats port_stats;
+
+	int i, first_fail_idx, tx_count;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0,
+			TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	/* Generate test bursts of packets to transmit */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE, 0, 1, 0, 0, 0),
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE,
+			"Failed to generate test packet burst");
+
+	/* Copy references to packets which we expect not to be transmitted */
+	first_fail_idx = (TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			(TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT *
+			TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)) +
+			TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX;
+
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		expected_tx_fail_pkts[i] = pkt_burst[first_fail_idx +
+				(i * TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)];
+	}
+
+	/* Set virtual slave to only fail transmission of
+	 * TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT packets in burst */
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkt_burst,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE);
+
+	TEST_ASSERT_EQUAL(tx_count, TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Transmitted (%d) an unexpected (%d) number of packets", tx_count,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_tx_fail_pkts[i], pkt_burst[i + tx_count],
+				"expected mbuf (%d) pointer %p not expected pointer %p",
+				i, expected_tx_fail_pkts[i], pkt_burst[i + tx_count]);
+	}
+
+	/* Verify bonded port tx stats */
+	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify slave ports tx stats */
+	for (i = 0; i < test_params->bonded_slave_count; i++) {
+		int slave_expected_tx_count;
+
+		rte_eth_stats_get(test_params->slave_port_ids[i], &port_stats);
+
+		slave_expected_tx_count = TEST_RR_SLAVE_TX_FAIL_BURST_SIZE /
+				test_params->bonded_slave_count;
+
+		if (i == TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX)
+			slave_expected_tx_count = slave_expected_tx_count -
+					TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT;
+
+		TEST_ASSERT_EQUAL(port_stats.opackets,
+				(uint64_t)slave_expected_tx_count,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)",
+				test_params->slave_port_ids[i],
+				(unsigned int)port_stats.opackets, slave_expected_tx_count);
+	}
+
+	/* Verify that all mbufs have a ref value of zero */
+	TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkt_burst[tx_count],
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkt_burst[tx_count], TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
+static int
 test_roundrobin_rx_burst_on_single_slave(void)
 {
 	struct rte_mbuf *gen_pkt_burst[MAX_PKT_BURST] = { NULL };
@@ -2900,6 +3032,141 @@ test_balance_l34_tx_burst_ipv6_toggle_udp_port(void)
 	return balance_l34_tx_burst(0, 0, 0, 0, 1);
 }
 
+#define TEST_BAL_SLAVE_TX_FAIL_SLAVE_COUNT			(2)
+#define TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1			(40)
+#define TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2			(20)
+#define TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT		(25)
+#define TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX	(0)
+
+static int
+test_balance_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf *pkts_burst_1[TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1];
+	struct rte_mbuf *pkts_burst_2[TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2];
+
+	struct rte_mbuf *expected_fail_pkts[TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT];
+
+	struct rte_eth_stats port_stats;
+
+	int i, first_tx_fail_idx, tx_count_1, tx_count_2;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0,
+			TEST_BAL_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER2),
+			"Failed to set balance xmit policy.");
+
+
+	/* Generate test bursts for transmission */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_1,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1, 0, 0, 0, 0, 0),
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1,
+			"Failed to generate test packet burst 1");
+
+	first_tx_fail_idx = TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT;
+
+	/* copy mbuf referneces for expected transmission failures */
+	for (i = 0; i < TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		expected_fail_pkts[i] = pkts_burst_1[i + first_tx_fail_idx];
+	}
+
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2, 0, 0, 1, 0, 0),
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
+			"Failed to generate test packet burst 2");
+
+
+	/* Set virtual slave TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX to only fail
+	 * transmission of TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT packets of burst */
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+
+	/* Transmit burst 1 */
+	tx_count_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1);
+
+	TEST_ASSERT_EQUAL(tx_count_1, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Transmitted (%d) packets, expected to transmit (%d) packets",
+			tx_count_1, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_fail_pkts[i], pkts_burst_1[i + tx_count_1],
+				"expected mbuf (%d) pointer %p not expected pointer %p",
+				i, expected_fail_pkts[i], pkts_burst_1[i + tx_count_1]);
+	}
+
+	/* Transmit burst 2 */
+	tx_count_2 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_2,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	TEST_ASSERT_EQUAL(tx_count_2, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
+			"Transmitted (%d) packets, expected to transmit (%d) packets",
+			tx_count_2, TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+
+	/* Verify bonded port tx stats */
+	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)((TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT) +
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2),
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			(TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT) +
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	/* Verify slave ports tx stats */
+
+	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+				TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)",
+				test_params->slave_port_ids[0],
+				(unsigned int)port_stats.opackets,
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+				TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+
+
+
+	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+				(uint64_t)TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)",
+				test_params->slave_port_ids[1],
+				(unsigned int)port_stats.opackets,
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	/* Verify that all mbufs have a ref value of zero */
+	TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkts_burst_1[tx_count_1],
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkts_burst_1[tx_count_1],
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 #define TEST_BALANCE_RX_BURST_SLAVE_COUNT (3)
 
 static int
@@ -3412,7 +3679,7 @@ test_broadcast_tx_burst(void)
 	/* Send burst on bonded port */
 	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
 			burst_size);
-	if (nb_tx != burst_size * test_params->bonded_slave_count) {
+	if (nb_tx != burst_size) {
 		printf("Bonded Port (%d) rx burst failed, packets transmitted value (%u) not as expected (%d)\n",
 				test_params->bonded_port_id,
 				nb_tx, burst_size);
@@ -3455,6 +3722,125 @@ test_broadcast_tx_burst(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+
+#define TEST_BCAST_SLAVE_TX_FAIL_SLAVE_COUNT		(3)
+#define TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE			(40)
+#define TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT	(15)
+#define TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT	(10)
+
+static int
+test_broadcast_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf *pkts_burst[TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE];
+	struct rte_mbuf *expected_fail_pkts[TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT];
+
+	struct rte_eth_stats port_stats;
+
+	int i, tx_count;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0,
+			TEST_BCAST_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	/* Generate test bursts for transmission */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE, 0, 0, 0, 0, 0),
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE,
+			"Failed to generate test packet burst");
+
+	for (i = 0; i < TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT; i++) {
+		expected_fail_pkts[i] = pkts_burst[TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT + i];
+	}
+
+	/* Set virtual slave TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX to only fail
+	 * transmission of TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT packets of burst */
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[0],
+			0);
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[1],
+			0);
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[2],
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[0],
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[1],
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[2],
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+	/* Transmit burst */
+	tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE);
+
+	TEST_ASSERT_EQUAL(tx_count, TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT,
+			"Transmitted (%d) packets, expected to transmit (%d) packets",
+			tx_count, TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_fail_pkts[i], pkts_burst[i + tx_count],
+				"expected mbuf (%d) pointer %p not expected pointer %p",
+				i, expected_fail_pkts[i], pkts_burst[i + tx_count]);
+	}
+
+	/* Verify slave ports tx stats */
+
+	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT,
+			"Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+
+	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT,
+			"Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT,
+			"Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
+
+
+	/* Verify that all mbufs who transmission failed have a ref value of one */
+	TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkts_burst[tx_count],
+			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkts_burst[tx_count],
+		TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 #define BROADCAST_RX_BURST_NUM_OF_SLAVES (3)
 
 static int
@@ -3767,7 +4153,7 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	}
 
 	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[0][0],
-			burst_size) != (burst_size * slave_count)) {
+			burst_size) != burst_size) {
 		printf("rte_eth_tx_burst failed\n");
 		return -1;
 	}
@@ -3915,6 +4301,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_status_interrupt),
 		TEST_CASE(test_adding_slave_after_bonded_device_started),
 		TEST_CASE(test_roundrobin_tx_burst),
+		TEST_CASE(test_roundrobin_tx_burst_slave_tx_fail),
 		TEST_CASE(test_roundrobin_rx_burst_on_single_slave),
 		TEST_CASE(test_roundrobin_rx_burst_on_multiple_slaves),
 		TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),
@@ -3938,11 +4325,13 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_balance_l34_tx_burst_ipv6_toggle_ip_addr),
 		TEST_CASE(test_balance_l34_tx_burst_vlan_ipv6_toggle_ip_addr),
 		TEST_CASE(test_balance_l34_tx_burst_ipv6_toggle_udp_port),
+		TEST_CASE(test_balance_tx_burst_slave_tx_fail),
 		TEST_CASE(test_balance_rx_burst),
 		TEST_CASE(test_balance_verify_promiscuous_enable_disable),
 		TEST_CASE(test_balance_verify_mac_assignment),
 		TEST_CASE(test_balance_verify_slave_link_status_change_behaviour),
 		TEST_CASE(test_broadcast_tx_burst),
+		TEST_CASE(test_broadcast_tx_burst_slave_tx_fail),
 		TEST_CASE(test_broadcast_rx_burst),
 		TEST_CASE(test_broadcast_verify_promiscuous_enable_disable),
 		TEST_CASE(test_broadcast_verify_mac_assignment),
app/test/virtual_pmd.c +62 -18

127 lines not on this page · raw message

app/test/virtual_pmd.h +7 -0
index 766b6ac..3b5c911 100644
@@ -67,6 +67,13 @@ void virtual_ethdev_rx_burst_fn_set_success(uint8_t port_id, uint8_t success);
 
 void virtual_ethdev_tx_burst_fn_set_success(uint8_t port_id, uint8_t success);
 
+/* if a value greater than zero is set for packet_fail_count then virtual
+ * device tx burst function will fail that many packet from burst or all
+ * packets if packet_fail_count is greater than the number of packets in the
+ * burst */
+void virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
+		uint8_t packet_fail_count);
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_pmd_bond/rte_eth_bond_pmd.c +65 -18

135 lines not on this page · raw message

Signature · 1 line
1.7.12.2

A message that is not in the archive (sent off-list or not yet received): 1412071079-7355-5-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#45 lore raw

Re: [PATCH v4 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions

Quoted 859 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Tuesday, September 30, 2014 10:58 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v4 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions

---
 app/test/test_link_bonding.c           | 393
++++++++++++++++++++++++++++++++-
 app/test/virtual_pmd.c                 |  80 +++++--
 app/test/virtual_pmd.h                 |   7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  83 +++++--
 4 files changed, 525 insertions(+), 38 deletions(-)
app/test/test_link_bonding.c +3 -0
index cce32ed..1a847eb 100644
@@ -663,6 +663,9 @@ enable_bonded_slaves(void)
 	int i;
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
+		virtual_ethdev_tx_burst_fn_set_success(test_params-
 >slave_port_ids[i],
+				1);
+
 		virtual_ethdev_simulate_link_status_interrupt(
 				test_params->slave_port_ids[i], 1);
app/test/test_link_bonding.c +50 -0
 	}
@@ -1413,6 +1416,135 @@ test_roundrobin_tx_burst(void)
 }
 
 static int
+verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
+{
+	int i, refcnt;
+
+	for (i = 0; i < nb_mbufs; i++) {
+		refcnt = rte_mbuf_refcnt_read(mbufs[i]);
+		TEST_ASSERT_EQUAL(refcnt, val,
+			"mbuf ref count (%d)is not the expected value (%d)",
+			refcnt, val);
+	}
+	return 0;
+}
+
+
+static void
+free_mbufs(struct rte_mbuf **mbufs, int nb_mbufs)
+{
+	int i;
+
+	for (i = 0; i < nb_mbufs; i++)
+		rte_pktmbuf_free(mbufs[i]);
+}
+
+#define TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT		(2)
+#define TEST_RR_SLAVE_TX_FAIL_BURST_SIZE		(64)
+#define TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT		(22)
+#define TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX	(1)
+
+static int
+test_roundrobin_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
+	struct rte_mbuf *expected_tx_fail_pkts[MAX_PKT_BURST];
+
+	struct rte_eth_stats port_stats;
+
+	int i, first_fail_idx, tx_count;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0,
+			TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	/* Generate test bursts of packets to transmit */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst,
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE, 0, 1, 0, 0, 0),
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE,
+			"Failed to generate test packet burst");
+
+	/* Copy references to packets which we expect not to be

transmitted */

app/test/test_link_bonding.c +8 -0
+	first_fail_idx = (TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			(TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT *
+			TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)) +
+			TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX;
+
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		expected_tx_fail_pkts[i] = pkt_burst[first_fail_idx +
+				(i *

TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)];

app/test/test_link_bonding.c +6 -0
+	}
+
+	/* Set virtual slave to only fail transmission of
+	 * TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT packets in burst */
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params-
Quoted 1 line

slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],

app/test/test_link_bonding.c +4 -0
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params-
Quoted 1 line

slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],

app/test/test_link_bonding.c +3 -0
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0,

pkt_burst,

app/test/test_link_bonding.c +3 -0
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE);
+
+	TEST_ASSERT_EQUAL(tx_count,

TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -

app/test/test_link_bonding.c +2 -0
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Transmitted (%d) an unexpected (%d) number of

packets", tx_count,

app/test/test_link_bonding.c +6 -0
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_tx_fail_pkts[i], pkt_burst[i +

tx_count],

app/test/test_link_bonding.c +1 -0
+				"expected mbuf (%d) pointer %p not

expected pointer %p",

app/test/test_link_bonding.c +1 -0
+				i, expected_tx_fail_pkts[i], pkt_burst[i +

tx_count]);

app/test/test_link_bonding.c +9 -0
+	}
+
+	/* Verify bonded port tx stats */
+	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Bonded Port (%d) opackets value (%u) not as

expected (%d)",

app/test/test_link_bonding.c +1 -0
+			test_params->bonded_port_id, (unsigned

int)port_stats.opackets,

app/test/test_link_bonding.c +8 -0
+			TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify slave ports tx stats */
+	for (i = 0; i < test_params->bonded_slave_count; i++) {
+		int slave_expected_tx_count;
+
+		rte_eth_stats_get(test_params->slave_port_ids[i],

&port_stats);

app/test/test_link_bonding.c +2 -0
+
+		slave_expected_tx_count =

TEST_RR_SLAVE_TX_FAIL_BURST_SIZE /

app/test/test_link_bonding.c +4 -0
+				test_params->bonded_slave_count;
+
+		if (i == TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX)
+			slave_expected_tx_count =

slave_expected_tx_count -
+

	TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT;
app/test/test_link_bonding.c +4 -0
+
+		TEST_ASSERT_EQUAL(port_stats.opackets,
+				(uint64_t)slave_expected_tx_count,
+				"Slave Port (%d) opackets value (%u) not as

expected (%d)",

app/test/test_link_bonding.c +2 -0
+				test_params->slave_port_ids[i],
+				(unsigned int)port_stats.opackets,

slave_expected_tx_count);

app/test/test_link_bonding.c +4 -0
+	}
+
+	/* Verify that all mbufs have a ref value of zero */
+

TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkt_burst[tx_cou
nt],

app/test/test_link_bonding.c +4 -0
+			TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkt_burst[tx_count],

TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);

app/test/test_link_bonding.c +19 -0
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
+static int
 test_roundrobin_rx_burst_on_single_slave(void)
 {
 	struct rte_mbuf *gen_pkt_burst[MAX_PKT_BURST] = { NULL };
@@ -2900,6 +3032,141 @@
 test_balance_l34_tx_burst_ipv6_toggle_udp_port(void)
 	return balance_l34_tx_burst(0, 0, 0, 0, 1);
 }
 
+#define TEST_BAL_SLAVE_TX_FAIL_SLAVE_COUNT			(2)
+#define TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1			(40)
+#define TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2			(20)
+#define TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT		(25)
+#define TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX	(0)
+
+static int
+test_balance_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf
 *pkts_burst_1[TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1];
+	struct rte_mbuf
 *pkts_burst_2[TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2];
+
+	struct rte_mbuf

*expected_fail_pkts[TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT];

app/test/test_link_bonding.c +12 -0
+
+	struct rte_eth_stats port_stats;
+
+	int i, first_tx_fail_idx, tx_count_1, tx_count_2;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0,
+			TEST_BAL_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id,

BALANCE_XMIT_POLICY_LAYER2),

app/test/test_link_bonding.c +6 -0
+			"Failed to set balance xmit policy.");
+
+
+	/* Generate test bursts for transmission */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_1,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1, 0, 0, 0, 0,

0),

app/test/test_link_bonding.c +13 -0
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1,
+			"Failed to generate test packet burst 1");
+
+	first_tx_fail_idx = TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT;
+
+	/* copy mbuf referneces for expected transmission failures */
+	for (i = 0; i < TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		expected_fail_pkts[i] = pkts_burst_1[i + first_tx_fail_idx];
+	}
+
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2,
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2, 0, 0, 1, 0,

0),

app/test/test_link_bonding.c +5 -0
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
+			"Failed to generate test packet burst 2");
+
+
+	/* Set virtual slave TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX

to only fail

app/test/test_link_bonding.c +1 -0
+	 * transmission of TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT

packets of burst */

app/test/test_link_bonding.c +2 -0
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params-
Quoted 1 line

slave_port_ids[TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],

app/test/test_link_bonding.c +4 -0
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params-
Quoted 1 line

slave_port_ids[TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],

app/test/test_link_bonding.c +5 -0
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+
+	/* Transmit burst 1 */
+	tx_count_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0,

pkts_burst_1,

app/test/test_link_bonding.c +3 -0
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1);
+
+	TEST_ASSERT_EQUAL(tx_count_1,

TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -

app/test/test_link_bonding.c +2 -0
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT,
+			"Transmitted (%d) packets, expected to transmit

(%d) packets",

app/test/test_link_bonding.c +1 -0
+			tx_count_1,

TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -

app/test/test_link_bonding.c +5 -0
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+		TEST_ASSERT_EQUAL(expected_fail_pkts[i], pkts_burst_1[i +

tx_count_1],

app/test/test_link_bonding.c +1 -0
+				"expected mbuf (%d) pointer %p not

expected pointer %p",

app/test/test_link_bonding.c +1 -0
+				i, expected_fail_pkts[i], pkts_burst_1[i +

tx_count_1]);

app/test/test_link_bonding.c +4 -0
+	}
+
+	/* Transmit burst 2 */
+	tx_count_2 = rte_eth_tx_burst(test_params->bonded_port_id, 0,

pkts_burst_2,

app/test/test_link_bonding.c +3 -0
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	TEST_ASSERT_EQUAL(tx_count_2,

TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,

app/test/test_link_bonding.c +1 -0
+			"Transmitted (%d) packets, expected to transmit

(%d) packets",

app/test/test_link_bonding.c +1 -0
+			tx_count_2,

TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);

app/test/test_link_bonding.c +7 -0
+
+
+	/* Verify bonded port tx stats */
+	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+
	(uint64_t)((TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
app/test/test_link_bonding.c +3 -0
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT) +
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2),
+			"Bonded Port (%d) opackets value (%u) not as

expected (%d)",

app/test/test_link_bonding.c +1 -0
+			test_params->bonded_port_id, (unsigned

int)port_stats.opackets,

app/test/test_link_bonding.c +11 -0
+			(TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT) +
+			TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	/* Verify slave ports tx stats */
+
+	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+

TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT,

app/test/test_link_bonding.c +1 -0
+				"Slave Port (%d) opackets value (%u) not as

expected (%d)",

app/test/test_link_bonding.c +4 -0
+				test_params->slave_port_ids[0],
+				(unsigned int)port_stats.opackets,
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_1 -
+
	TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
app/test/test_link_bonding.c +8 -0
+
+
+
+
+	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+
	(uint64_t)TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2,
app/test/test_link_bonding.c +1 -0
+				"Slave Port (%d) opackets value (%u) not as

expected (%d)",

app/test/test_link_bonding.c +6 -0
+				test_params->slave_port_ids[1],
+				(unsigned int)port_stats.opackets,
+				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
+
+	/* Verify that all mbufs have a ref value of zero */
+

TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkts_burst_1[tx_
count_1],

app/test/test_link_bonding.c +11 -1
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT, 1),
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkts_burst_1[tx_count_1],
+			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 #define TEST_BALANCE_RX_BURST_SLAVE_COUNT (3)
 
 static int
@@ -3412,7 +3679,7 @@ test_broadcast_tx_burst(void)
 	/* Send burst on bonded port */
 	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0,
 pkts_burst,
 			burst_size);
-	if (nb_tx != burst_size * test_params->bonded_slave_count) {
+	if (nb_tx != burst_size) {
 		printf("Bonded Port (%d) rx burst failed, packets transmitted
 value (%u) not as expected (%d)\n",
app/test/test_link_bonding.c +28 -0
 				test_params->bonded_port_id,
 				nb_tx, burst_size);
@@ -3455,6 +3722,125 @@ test_broadcast_tx_burst(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+
+#define TEST_BCAST_SLAVE_TX_FAIL_SLAVE_COUNT		(3)
+#define TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE			(40)
+#define TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT	(15)
+#define TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT	(10)
+
+static int
+test_broadcast_tx_burst_slave_tx_fail(void)
+{
+	struct rte_mbuf
 *pkts_burst[TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE];
+	struct rte_mbuf
 *expected_fail_pkts[TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT];
+
+	struct rte_eth_stats port_stats;
+
+	int i, tx_count;
+
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0,
+			TEST_BCAST_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	/* Generate test bursts for transmission */
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst,
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE, 0, 0, 0, 0,
 0),
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE,
+			"Failed to generate test packet burst");
+
+	for (i = 0; i < TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT;

i++) {

app/test/test_link_bonding.c +1 -0
+		expected_fail_pkts[i] =

pkts_burst[TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+

	TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT + i];
app/test/test_link_bonding.c +3 -0
+	}
+
+	/* Set virtual slave TEST_BAL_SLAVE_TX_FAIL_FAILING_SLAVE_IDX

to only fail

app/test/test_link_bonding.c +1 -0
+	 * transmission of TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT

packets of burst */

app/test/test_link_bonding.c +13 -0
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[0],
+			0);
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[1],
+			0);
+	virtual_ethdev_tx_burst_fn_set_success(
+			test_params->slave_port_ids[2],
+			0);
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[0],
+
	TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
app/test/test_link_bonding.c +4 -0
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[1],
+
	TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
app/test/test_link_bonding.c +4 -0
+
+	virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+			test_params->slave_port_ids[2],
+
	TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
app/test/test_link_bonding.c +3 -0
+
+	/* Transmit burst */
+	tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0,

pkts_burst,

app/test/test_link_bonding.c +3 -0
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE);
+
+	TEST_ASSERT_EQUAL(tx_count,

TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+
TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT,

app/test/test_link_bonding.c +1 -0
+			"Transmitted (%d) packets, expected to transmit

(%d) packets",

app/test/test_link_bonding.c +2 -1
+			tx_count, TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE
-
+
	TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
app/test/test_link_bonding.c +3 -0
+
+	/* Verify that failed packet are expected failed packets */
+	for (i = 0; i < TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT;

i++) {

app/test/test_link_bonding.c +1 -0
+		TEST_ASSERT_EQUAL(expected_fail_pkts[i], pkts_burst[i +

tx_count],

app/test/test_link_bonding.c +1 -0
+				"expected mbuf (%d) pointer %p not

expected pointer %p",

app/test/test_link_bonding.c +1 -0
+				i, expected_fail_pkts[i], pkts_burst[i +

tx_count]);

app/test/test_link_bonding.c +9 -1
+	}
+
+	/* Verify slave ports tx stats */
+
+	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE
-
+

TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT,

app/test/test_link_bonding.c +1 -0
+			"Port (%d) opackets value (%u) not as expected

(%d)",

app/test/test_link_bonding.c +1 -0
+			test_params->bonded_port_id, (unsigned

int)port_stats.opackets,

app/test/test_link_bonding.c +2 -0
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+
	TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
app/test/test_link_bonding.c +7 -1
+
+
+	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE
-
+

TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT,

app/test/test_link_bonding.c +1 -0
+			"Port (%d) opackets value (%u) not as expected

(%d)",

app/test/test_link_bonding.c +1 -0
+			test_params->bonded_port_id, (unsigned

int)port_stats.opackets,

app/test/test_link_bonding.c +2 -0
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+
	TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
app/test/test_link_bonding.c +6 -1
+
+	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
+
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE
-
+

TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT,

app/test/test_link_bonding.c +1 -0
+			"Port (%d) opackets value (%u) not as expected

(%d)",

app/test/test_link_bonding.c +1 -0
+			test_params->bonded_port_id, (unsigned

int)port_stats.opackets,

app/test/test_link_bonding.c +2 -0
+			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -
+
	TEST_BCAST_SLAVE_TX_FAIL_MAX_PACKETS_COUNT);
app/test/test_link_bonding.c +3 -0
+
+
+	/* Verify that all mbufs who transmission failed have a ref value of

one */
+
TEST_ASSERT_SUCCESS(verify_mbufs_ref_count(&pkts_burst[tx_co
unt],
+
TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT, 1),

app/test/test_link_bonding.c +10 -1
+			"mbufs refcnts not as expected");
+
+	free_mbufs(&pkts_burst[tx_count],
+		TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 #define BROADCAST_RX_BURST_NUM_OF_SLAVES (3)
 
 static int
@@ -3767,7 +4153,7 @@
 test_broadcast_verify_slave_link_status_change_behaviour(void)
 	}
 
 	if (rte_eth_tx_burst(test_params->bonded_port_id, 0,
 &pkt_burst[0][0],
-			burst_size) != (burst_size * slave_count)) {
+			burst_size) != burst_size) {
 		printf("rte_eth_tx_burst failed\n");
app/test/test_link_bonding.c +1 -0
 		return -1;
 	}
@@ -3915,6 +4301,7 @@ static struct unit_test_suite
 link_bonding_test_suite  = {
 		TEST_CASE(test_status_interrupt),
 
 	TEST_CASE(test_adding_slave_after_bonded_device_started),
 		TEST_CASE(test_roundrobin_tx_burst),
+		TEST_CASE(test_roundrobin_tx_burst_slave_tx_fail),
 		TEST_CASE(test_roundrobin_rx_burst_on_single_slave),

TEST_CASE(test_roundrobin_rx_burst_on_multiple_slaves),

TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),

app/test/test_link_bonding.c +1 -0
@@ -3938,11 +4325,13 @@ static struct unit_test_suite
 link_bonding_test_suite  = {
 
 	TEST_CASE(test_balance_l34_tx_burst_ipv6_toggle_ip_addr),
 
 	TEST_CASE(test_balance_l34_tx_burst_vlan_ipv6_toggle_ip_addr),
 
 	TEST_CASE(test_balance_l34_tx_burst_ipv6_toggle_udp_port),
+		TEST_CASE(test_balance_tx_burst_slave_tx_fail),
 		TEST_CASE(test_balance_rx_burst),
 
 	TEST_CASE(test_balance_verify_promiscuous_enable_disable),
 		TEST_CASE(test_balance_verify_mac_assignment),

TEST_CASE(test_balance_verify_slave_link_status_change_behavio
ur),

app/test/test_link_bonding.c +1 -0
 		TEST_CASE(test_broadcast_tx_burst),
+		TEST_CASE(test_broadcast_tx_burst_slave_tx_fail),
 		TEST_CASE(test_broadcast_rx_burst),

TEST_CASE(test_broadcast_verify_promiscuous_enable_disable),

app/test/test_link_bonding.c +0 -0
 		TEST_CASE(test_broadcast_verify_mac_assignment),
app/test/virtual_pmd.c +28 -17
index e861c5b..f9bd841 100644
@@ -48,6 +48,8 @@ struct virtual_ethdev_private {
 
 	struct rte_mbuf *rx_pkt_burst[MAX_PKT_BURST];
 	int rx_pkt_burst_len;
+
+	int tx_burst_fail_count;
 };
 
 struct virtual_ethdev_queue {
@@ -350,42 +352,67 @@ virtual_ethdev_rx_burst_fail(void *queue
 __rte_unused,
 }
 
 static uint16_t
-virtual_ethdev_tx_burst_success(void *queue,
-							 struct rte_mbuf
 **bufs __rte_unused,
-							 uint16_t nb_pkts)
+virtual_ethdev_tx_burst_success(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
 {
+	struct virtual_ethdev_queue *tx_q = (struct virtual_ethdev_queue
 *)queue;
+
 	struct rte_eth_dev *vrtl_eth_dev;
-	struct virtual_ethdev_queue *tx_q;
 	struct virtual_ethdev_private *dev_private;
-	int i;
 
-	tx_q = (struct virtual_ethdev_queue *)queue;
+	int i;
 
 	vrtl_eth_dev = &rte_eth_devices[tx_q->port_id];
+	dev_private = vrtl_eth_dev->data->dev_private;
 
 	if (vrtl_eth_dev->data->dev_link.link_status) {
-		dev_private = vrtl_eth_dev->data->dev_private;
+		/* increment opacket count */
 		dev_private->eth_stats.opackets += nb_pkts;
 
-		return nb_pkts;
-	}
-
-	/* free packets in burst */
-	for (i = 0; i < nb_pkts; i++) {
-		if (bufs[i] != NULL)
+		/* free packets in burst */
+		for (i = 0; i < nb_pkts; i++) {
 			rte_pktmbuf_free(bufs[i]);
+			bufs[i] = NULL;
+		}
 
-		bufs[i] = NULL;
+		return nb_pkts;
 	}
 
 	return 0;
 }
 
-
 static uint16_t
-virtual_ethdev_tx_burst_fail(void *queue __rte_unused,
-		struct rte_mbuf **bufs __rte_unused, uint16_t nb_pkts
 __rte_unused)
+virtual_ethdev_tx_burst_fail(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
 {
+	struct rte_eth_dev *vrtl_eth_dev = NULL;
+	struct virtual_ethdev_queue *tx_q = NULL;
+	struct virtual_ethdev_private *dev_private = NULL;
+
+	int i;
+
+	tx_q = (struct virtual_ethdev_queue *)queue;
+	vrtl_eth_dev = &rte_eth_devices[tx_q->port_id];
+	dev_private = vrtl_eth_dev->data->dev_private;
+
+	if (dev_private->tx_burst_fail_count < nb_pkts) {
+		int successfully_txd = nb_pkts - dev_private-
Quoted 1 line

tx_burst_fail_count;

app/test/virtual_pmd.c +34 -1
+
+		/* increment opacket count */
+		dev_private->eth_stats.opackets += successfully_txd;
+
+		/* free packets in burst */
+		for (i = 0; i < successfully_txd; i++) {
+			/* free packets in burst */
+			if (bufs[i] != NULL)
+				rte_pktmbuf_free(bufs[i]);
+
+			bufs[i] = NULL;
+		}
+
+		return successfully_txd;
+	}
+
 	return 0;
 }
@@ -405,17 +432,34 @@ virtual_ethdev_rx_burst_fn_set_success(uint8_t
 port_id, uint8_t success)
 void
 virtual_ethdev_tx_burst_fn_set_success(uint8_t port_id, uint8_t success)
 {
+	struct virtual_ethdev_private *dev_private = NULL;
 	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
 
+	dev_private = vrtl_eth_dev->data->dev_private;
+
 	if (success)
 		vrtl_eth_dev->tx_pkt_burst =
 virtual_ethdev_tx_burst_success;
 	else
 		vrtl_eth_dev->tx_pkt_burst = virtual_ethdev_tx_burst_fail;
+
+	dev_private->tx_burst_fail_count = 0;
 }
 
+void
+virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
+		uint8_t packet_fail_count)
+{
+	struct virtual_ethdev_private *dev_private = NULL;
+	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
+
+
+	dev_private = vrtl_eth_dev->data->dev_private;
+	dev_private->tx_burst_fail_count = packet_fail_count;
+}
 
 void
-virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id, uint8_t
 link_status)
+virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id,
+		uint8_t link_status)

{

app/test/virtual_pmd.c +0 -0
 	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
app/test/virtual_pmd.h +7 -0
index 766b6ac..3b5c911 100644
@@ -67,6 +67,13 @@ void virtual_ethdev_rx_burst_fn_set_success(uint8_t
 port_id, uint8_t success);
 
 void virtual_ethdev_tx_burst_fn_set_success(uint8_t port_id, uint8_t
 success);
 
+/* if a value greater than zero is set for packet_fail_count then virtual
+ * device tx burst function will fail that many packet from burst or all
+ * packets if packet_fail_count is greater than the number of packets in the
+ * burst */
+void virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
+		uint8_t packet_fail_count);
+
 #ifdef __cplusplus

}
#endif

lib/librte_pmd_bond/rte_eth_bond_pmd.c +2 -2
index 66f1650..2215afe 100644
@@ -101,10 +101,10 @@ bond_ethdev_tx_burst_round_robin(void *queue,
 struct rte_mbuf **bufs,
 	uint8_t num_of_slaves;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	uint16_t num_tx_total = 0;
+	uint16_t num_tx_total = 0, num_tx_slave;
 
 	static int slave_idx = 0;
-	int i, cs_idx = 0;
+	int i, cslave_idx = 0, tx_fail_total = 0;
 
 	bd_tx_q = (struct bond_tx_queue *)queue;
lib/librte_pmd_bond/rte_eth_bond_pmd.c +2 -2
 	internals = bd_tx_q->dev_private;
@@ -120,19 +120,32 @@ bond_ethdev_tx_burst_round_robin(void *queue,
 struct rte_mbuf **bufs,
 
 	/* Populate slaves mbuf with which packets are to be sent on it  */
 	for (i = 0; i < nb_pkts; i++) {
-		cs_idx = (slave_idx + i) % num_of_slaves;
-		slave_bufs[cs_idx][(slave_nb_pkts[cs_idx])++] = bufs[i];
+		cslave_idx = (slave_idx + i) % num_of_slaves;
+		slave_bufs[cslave_idx][(slave_nb_pkts[cslave_idx])++] =
 bufs[i];
 	}
 
 	/* increment current slave index so the next call to tx burst starts on

the

lib/librte_pmd_bond/rte_eth_bond_pmd.c +1 -5
 	 * next slave */
-	slave_idx = ++cs_idx;
+	slave_idx = ++cslave_idx;
 
 	/* Send packet burst on each slave device */
-	for (i = 0; i < num_of_slaves; i++)
-		if (slave_nb_pkts[i] > 0)
-			num_tx_total += rte_eth_tx_burst(slaves[i],
-					bd_tx_q->queue_id, slave_bufs[i],

slave_nb_pkts[i]);

lib/librte_pmd_bond/rte_eth_bond_pmd.c +3 -0
+	for (i = 0; i < num_of_slaves; i++) {
+		if (slave_nb_pkts[i] > 0) {
+			num_tx_slave = rte_eth_tx_burst(slaves[i],

bd_tx_q->queue_id,

lib/librte_pmd_bond/rte_eth_bond_pmd.c +5 -0
+					slave_bufs[i], slave_nb_pkts[i]);
+
+			/* if tx burst fails move packets to end of bufs */
+			if (unlikely(num_tx_slave < slave_nb_pkts[i])) {
+				int tx_fail_slave = slave_nb_pkts[i] -

num_tx_slave;

lib/librte_pmd_bond/rte_eth_bond_pmd.c +5 -0
+
+				tx_fail_total += tx_fail_slave;
+
+				memcpy(&bufs[nb_pkts - tx_fail_total],
+
	&slave_bufs[i][num_tx_slave], tx_fail_slave * sizeof(bufs[0]));
lib/librte_pmd_bond/rte_eth_bond_pmd.c +18 -2
+			}
+			num_tx_total += num_tx_slave;
+		}
+	}
 
 	return num_tx_total;
 }
@@ -283,7 +296,7 @@ bond_ethdev_tx_burst_balance(void *queue, struct
 rte_mbuf **bufs,
 	uint8_t num_of_slaves;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	uint16_t num_tx_total = 0;
+	uint16_t num_tx_total = 0, num_tx_slave = 0, tx_fail_total = 0;
 
 	int i, op_slave_id;
@@ -315,11 +328,23 @@ bond_ethdev_tx_burst_balance(void *queue,
 struct rte_mbuf **bufs,
 	/* Send packet burst on each slave device */
 	for (i = 0; i < num_of_slaves; i++) {
 		if (slave_nb_pkts[i] > 0) {
-			num_tx_total += rte_eth_tx_burst(slaves[i],
 bd_tx_q->queue_id,
+			num_tx_slave = rte_eth_tx_burst(slaves[i],
 bd_tx_q->queue_id,
 					slave_bufs[i], slave_nb_pkts[i]);
+
+			/* if tx burst fails move packets to end of bufs */
+			if (unlikely(num_tx_slave < slave_nb_pkts[i])) {
+				int slave_tx_fail_count = slave_nb_pkts[i] -
 num_tx_slave;
+
+				tx_fail_total += slave_tx_fail_count;
+				memcpy(bufs[nb_pkts - tx_fail_total],
+						slave_bufs[i][num_tx_slave],
 slave_tx_fail_count);
+			}
+
+			num_tx_total += num_tx_slave;
 		}
 	}
 
+
 	return num_tx_total;
 }
@@ -330,12 +355,13 @@ bond_ethdev_tx_burst_broadcast(void *queue,
 struct rte_mbuf **bufs,
 	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
 

lib/librte_pmd_bond/rte_eth_bond_pmd.c bond_ethdev_tx_burst_broadcast(void *queue, · line 365

Quoted 10 lines
lib/librte_pmd_bond/rte_eth_bond_pmd.c +4 -3
-	uint8_t num_of_slaves;
+	uint8_t tx_failed_flag = 0, num_of_slaves;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	uint16_t num_tx_total = 0;
+	uint16_t max_nb_of_tx_pkts = 0;
 
-	int i;
+	int slave_tx_total[RTE_MAX_ETHPORTS];
+	int i, most_scuccesful_tx_slave;

When compiling the library on 32 bits, it fails because of this variable may be uninitialized, so this could be initialized to 0 (also fix the typo).

Quoted 49 lines
lib/librte_pmd_bond/rte_eth_bond_pmd.c +7 -4
 	bd_tx_q = (struct bond_tx_queue *)queue;
 	internals = bd_tx_q->dev_private;
@@ -354,11 +380,32 @@ bond_ethdev_tx_burst_broadcast(void *queue,
 struct rte_mbuf **bufs,
 		rte_mbuf_refcnt_update(bufs[i], num_of_slaves - 1);
 
 	/* Transmit burst on each active slave */
-	for (i = 0; i < num_of_slaves; i++)
-		num_tx_total += rte_eth_tx_burst(slaves[i], bd_tx_q-
 >queue_id,
-				bufs, nb_pkts);
+	for (i = 0; i < num_of_slaves; i++) {
+		slave_tx_total[i] = rte_eth_tx_burst(slaves[i], bd_tx_q-
 >queue_id,
+					bufs, nb_pkts);
 
-	return num_tx_total;
+		if (unlikely(slave_tx_total[i] < nb_pkts))
+			tx_failed_flag = 1;
+
+		/* record the value and slave index for the slave which

transmits the

lib/librte_pmd_bond/rte_eth_bond_pmd.c +9 -0
+		 * maximum number of packets */
+		if (slave_tx_total[i] > max_nb_of_tx_pkts) {
+			max_nb_of_tx_pkts = slave_tx_total[i];
+			most_scuccesful_tx_slave = i;
+		}
+	}
+
+	/* if slaves fail to transmit packets from burst, the calling application
+	 * is not expected to know about multiple references to packets so

we must

lib/librte_pmd_bond/rte_eth_bond_pmd.c +1 -0
+	 * handle failures of all packets except those of the most successful

slave

lib/librte_pmd_bond/rte_eth_bond_pmd.c +6 -0
+	 */
+	if (unlikely(tx_failed_flag))
+		for (i = 0; i < num_of_slaves; i++)
+			if (i != most_scuccesful_tx_slave)
+				while (slave_tx_total[i] < nb_pkts)
+
	rte_pktmbuf_free(bufs[slave_tx_total[i]++]);
lib/librte_pmd_bond/rte_eth_bond_pmd.c +2 -1
+
+	return max_nb_of_tx_pkts;
 }
 
 void
--

1.7.12.2

#46 lore raw

PATCH v4 5/8 test app: adding support for generating variable sized packet bursts

In reply to a message not in the archive
---
 app/test/packet_burst_generator.c | 25 ++++++++-----------------
 app/test/packet_burst_generator.h |  6 +++++-
 app/test/test_link_bonding.c      | 14 +++++++++-----
 3 files changed, 22 insertions(+), 23 deletions(-)
app/test/packet_burst_generator.c +8 -17
index 9e747a4..b2824dc 100644
@@ -74,8 +74,7 @@ static inline void
 copy_buf_to_pkt(void *buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)
 {
 	if (offset + len <= pkt->data_len) {
-		rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset,
-				buf, (size_t) len);
+		rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset, buf, (size_t) len);
 		return;
 	}
 	copy_buf_to_pkt_segs(buf, len, pkt, offset);
@@ -191,20 +190,12 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */
 
-#define TXONLY_DEF_PACKET_LEN 64
-#define TXONLY_DEF_PACKET_LEN_128 128
-
-uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN;
-uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = {
-		TXONLY_DEF_PACKET_LEN_128,
-};
-
-uint8_t  tx_pkt_nb_segs = 1;
 
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
 		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst)
+		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+		uint8_t pkt_len, uint8_t nb_pkt_segs)
 {
 	int i, nb_pkt = 0;
 	size_t eth_hdr_size;
@@ -221,9 +212,9 @@ nomore_mbuf:
 			break;
 		}
 
-		pkt->data_len = tx_pkt_seg_lengths[0];
+		pkt->data_len = pkt_len;
 		pkt_seg = pkt;
-		for (i = 1; i < tx_pkt_nb_segs; i++) {
+		for (i = 1; i < nb_pkt_segs; i++) {
 			pkt_seg->next = rte_pktmbuf_alloc(mp);
 			if (pkt_seg->next == NULL) {
 				pkt->nb_segs = i;
@@ -231,7 +222,7 @@ nomore_mbuf:
 				goto nomore_mbuf;
 			}
 			pkt_seg = pkt_seg->next;
-			pkt_seg->data_len = tx_pkt_seg_lengths[i];
+			pkt_seg->data_len = pkt_len;
 		}
 		pkt_seg->next = NULL; /* Last segment of packet. */
 
@@ -259,8 +250,8 @@ nomore_mbuf:
 		 * Complete first mbuf of packet and append it to the
 		 * burst of packets to be transmitted.
 		 */
-		pkt->nb_segs = tx_pkt_nb_segs;
-		pkt->pkt_len = tx_pkt_length;
+		pkt->nb_segs = nb_pkt_segs;
+		pkt->pkt_len = pkt_len;
 		pkt->l2_len = eth_hdr_size;
 
 		if (ipv4) {
app/test/packet_burst_generator.h +5 -1
index 5b3cd6c..f86589e 100644
@@ -47,6 +47,9 @@ extern "C" {
 #define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \
 		((c & 0xff) << 8) | (d & 0xff))
 
+#define PACKET_BURST_GEN_PKT_LEN 60
+#define PACKET_BURST_GEN_PKT_LEN_128 128
+
 
 void
 initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
@@ -68,7 +71,8 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
 		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst);
+		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+		uint8_t pkt_len, uint8_t nb_pkt_segs);
 
 #ifdef __cplusplus
 }
app/test/test_link_bonding.c +9 -5
index 1a847eb..50355a3 100644
@@ -1338,7 +1338,8 @@ generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 	/* Generate burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, vlan, ip_hdr, ipv4,
-			test_params->pkt_udp_hdr, burst_size);
+			test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN_128,
+			1);
 	if (generated_burst_size != burst_size) {
 		printf("Failed to generate packet burst");
 		return -1;
@@ -2056,7 +2057,7 @@ test_activebackup_tx_burst(void)
 	/* Generate a burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size);
+			1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN, 1);
 	if (generated_burst_size != burst_size)
 		return -1;
 
@@ -2709,7 +2710,8 @@ test_balance_l2_tx_burst(void)
 	/* Generate a burst 1 of packets to transmit */
 	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
-			test_params->pkt_udp_hdr, burst_size[0]) != burst_size[0])
+			test_params->pkt_udp_hdr, burst_size[0],
+			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[0])
 		return -1;
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
@@ -2718,7 +2720,8 @@ test_balance_l2_tx_burst(void)
 	/* Generate a burst 2 of packets to transmit */
 	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
-			test_params->pkt_udp_hdr, burst_size[1]) != burst_size[1])
+			test_params->pkt_udp_hdr, burst_size[1],
+			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1])
 		return -1;
 
 	/* Send burst 1 on bonded port */
@@ -3672,7 +3675,8 @@ test_broadcast_tx_burst(void)
 	/* Generate a burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size);
+			1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN,
+			1);
 	if (generated_burst_size != burst_size)
 		return -1;
 
Signature · 1 line
1.7.12.2

A message that is not in the archive (sent off-list or not yet received): 1412071079-7355-6-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#48 lore raw

Re: [PATCH v4 5/8] test app: adding support for generating variable sized packet bursts

Quoted 184 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Tuesday, September 30, 2014 5:58 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v4 5/8] test app: adding support for generating variable sized packet bursts

---
 app/test/packet_burst_generator.c | 25 ++++++++-----------------
 app/test/packet_burst_generator.h |  6 +++++-
 app/test/test_link_bonding.c      | 14 +++++++++-----
 3 files changed, 22 insertions(+), 23 deletions(-)
app/test/packet_burst_generator.c +1 -2
index 9e747a4..b2824dc 100644
@@ -74,8 +74,7 @@ static inline void
 copy_buf_to_pkt(void *buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)
 {
 	if (offset + len <= pkt->data_len) {
-		rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset,
-				buf, (size_t) len);
+		rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset, buf,
 (size_t) len);
 		return;
 	}
app/test/packet_burst_generator.c +2 -10
 	copy_buf_to_pkt_segs(buf, len, pkt, offset);
@@ -191,20 +190,12 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t
 src_addr,
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char.
 */
 
-#define TXONLY_DEF_PACKET_LEN 64
-#define TXONLY_DEF_PACKET_LEN_128 128
-
-uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN;
-uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = {
-		TXONLY_DEF_PACKET_LEN_128,
-};
-
-uint8_t  tx_pkt_nb_segs = 1;
 
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
 		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst)
+		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+		uint8_t pkt_len, uint8_t nb_pkt_segs)
 {
app/test/packet_burst_generator.c +5 -5
 	int i, nb_pkt = 0;
 	size_t eth_hdr_size;
@@ -221,9 +212,9 @@ nomore_mbuf:
 			break;
 		}
 
-		pkt->data_len = tx_pkt_seg_lengths[0];
+		pkt->data_len = pkt_len;
 		pkt_seg = pkt;
-		for (i = 1; i < tx_pkt_nb_segs; i++) {
+		for (i = 1; i < nb_pkt_segs; i++) {
 			pkt_seg->next = rte_pktmbuf_alloc(mp);
 			if (pkt_seg->next == NULL) {
 				pkt->nb_segs = i;
@@ -231,7 +222,7 @@ nomore_mbuf:
 				goto nomore_mbuf;
 			}
 			pkt_seg = pkt_seg->next;
-			pkt_seg->data_len = tx_pkt_seg_lengths[i];
+			pkt_seg->data_len = pkt_len;
 		}
 		pkt_seg->next = NULL; /* Last segment of packet. */
 
@@ -259,8 +250,8 @@ nomore_mbuf:
 		 * Complete first mbuf of packet and append it to the
 		 * burst of packets to be transmitted.
 		 */
-		pkt->nb_segs = tx_pkt_nb_segs;
-		pkt->pkt_len = tx_pkt_length;
+		pkt->nb_segs = nb_pkt_segs;
+		pkt->pkt_len = pkt_len;
 		pkt->l2_len = eth_hdr_size;
 
 		if (ipv4) {
app/test/packet_burst_generator.h +5 -1
index 5b3cd6c..f86589e 100644
@@ -47,6 +47,9 @@ extern "C" {
 #define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \
 		((c & 0xff) << 8) | (d & 0xff))
 
+#define PACKET_BURST_GEN_PKT_LEN 60
+#define PACKET_BURST_GEN_PKT_LEN_128 128
+
 
 void
 initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
@@ -68,7 +71,8 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t
 src_addr,
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
 		struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst);
+		uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+		uint8_t pkt_len, uint8_t nb_pkt_segs);
 
 #ifdef __cplusplus

}

app/test/test_link_bonding.c +1 -1
index 1a847eb..50355a3 100644
@@ -1338,7 +1338,8 @@ generate_test_burst(struct rte_mbuf **pkts_burst,
 uint16_t burst_size,
 	/* Generate burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params-
 >mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, vlan, ip_hdr,
 ipv4,
-			test_params->pkt_udp_hdr, burst_size);
+			test_params->pkt_udp_hdr, burst_size,

PACKET_BURST_GEN_PKT_LEN_128,

app/test/test_link_bonding.c +2 -1
+			1);
 	if (generated_burst_size != burst_size) {
 		printf("Failed to generate packet burst");
 		return -1;
@@ -2056,7 +2057,7 @@ test_activebackup_tx_burst(void)
 	/* Generate a burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params-
 >mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, 0,
 test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size);
+			1, test_params->pkt_udp_hdr, burst_size,
 PACKET_BURST_GEN_PKT_LEN, 1);
app/test/test_link_bonding.c +2 -1
 	if (generated_burst_size != burst_size)
 		return -1;
@@ -2709,7 +2710,8 @@ test_balance_l2_tx_burst(void)
 	/* Generate a burst 1 of packets to transmit */
 	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
 			test_params->pkt_eth_hdr, 0, test_params-
 >pkt_ipv4_hdr, 1,
-			test_params->pkt_udp_hdr, burst_size[0]) !=
 burst_size[0])
+			test_params->pkt_udp_hdr, burst_size[0],
+			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[0])
 		return -1;
app/test/test_link_bonding.c +2 -1
 	initialize_eth_header(test_params->pkt_eth_hdr,
@@ -2718,7 +2720,8 @@ test_balance_l2_tx_burst(void)
 	/* Generate a burst 2 of packets to transmit */
 	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
 			test_params->pkt_eth_hdr, 0, test_params-
 >pkt_ipv4_hdr, 1,
-			test_params->pkt_udp_hdr, burst_size[1]) !=
 burst_size[1])
+			test_params->pkt_udp_hdr, burst_size[1],
+			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1])
 		return -1;
app/test/test_link_bonding.c +2 -1
 	/* Send burst 1 on bonded port */
@@ -3672,7 +3675,8 @@ test_broadcast_tx_burst(void)
 	/* Generate a burst of packets to transmit */
 	generated_burst_size = generate_packet_burst(test_params-
 >mbuf_pool,
 			pkts_burst,	test_params->pkt_eth_hdr, 0,
 test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size);
+			1, test_params->pkt_udp_hdr, burst_size,
 PACKET_BURST_GEN_PKT_LEN,
+			1);
app/test/test_link_bonding.c +0 -1
 	if (generated_burst_size != burst_size)
 		return -1;
 
--
Quoted 1 line

1.7.12.2

#49 lore raw

PATCH v4 6/8 testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist

In reply to a message not in the archive
---
 app/test-pmd/cmdline.c | 2 +-
 app/test-pmd/testpmd.c | 3 ++-
 app/test-pmd/testpmd.h | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
app/test-pmd/cmdline.c +1 -1
index 225f669..15ca493 100644
@@ -3614,7 +3614,7 @@ static void cmd_create_bonded_device_parsed(void *parsed_result,
 
 		/* Update number of ports */
 		nb_ports = rte_eth_dev_count();
-		reconfig(port_id);
+		reconfig(port_id, res->socket);
 		rte_eth_promiscuous_enable(port_id);
 	}
 
app/test-pmd/testpmd.c +2 -1
index 9f6cdc4..66e3c7c 100644
@@ -628,7 +628,7 @@ init_config(void)
 
 
 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
 	struct rte_port *port;
 
@@ -647,6 +647,7 @@ reconfig(portid_t new_port_id)
 	/* set flag to initialize port/queue */
 	port->need_reconfig = 1;
 	port->need_reconfig_queues = 1;
+	port->socket_id = socket_id;
 
 	init_port_config();
 }
app/test-pmd/testpmd.h +1 -1
index 9cbfeac..5a3423c 100644
@@ -457,7 +457,7 @@ void fwd_config_display(void);
 void rxtx_config_display(void);
 void fwd_config_setup(void);
 void set_def_fwd_config(void);
-void reconfig(portid_t new_port_id);
+void reconfig(portid_t new_port_id, unsigned socket_id);
 int init_fwd_streams(void);
 
 void port_mtu_set(portid_t port_id, uint16_t mtu);
Signature · 1 line
1.7.12.2
#50 lore raw

PATCH v4 7/8 bond: lsc polling support

In reply to a message not in the archive
---
 app/test-pmd/cmdline.c                     |  63 +++++
 app/test/test.h                            |   7 +-
 app/test/test_link_bonding.c               | 258 ++++++++++++-------
 app/test/virtual_pmd.c                     |  17 +-
 app/test/virtual_pmd.h                     |  48 +++-
 lib/librte_pmd_bond/rte_eth_bond.h         |  80 ++++++
 lib/librte_pmd_bond/rte_eth_bond_api.c     | 315 +++++++++++++++--------
 lib/librte_pmd_bond/rte_eth_bond_args.c    |  30 ++-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c     | 393 +++++++++++++++++++++--------
 lib/librte_pmd_bond/rte_eth_bond_private.h |  71 ++++--
 10 files changed, 934 insertions(+), 348 deletions(-)
app/test-pmd/cmdline.c +63 -0
index 15ca493..b14df61 100644
@@ -439,6 +439,9 @@ static void cmd_help_long_parsed(void *parsed_result,
 
 			"set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
+
+			"set bonding mon_period (port_id) (value) \n"
+			"	Set the bonding link status monitoring polling period in ms.\n\n"
 #endif
 
 			, list_pkt_forwarding_modes()
@@ -3705,6 +3708,65 @@ cmdline_parse_inst_t cmd_set_bond_mac_addr = {
 		}
 };
 
+
+/* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
+struct cmd_set_bond_mon_period_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t bonding;
+	cmdline_fixed_string_t mon_period;
+	uint8_t port_num;
+	uint32_t period_ms;
+};
+
+static void cmd_set_bond_mon_period_parsed(void *parsed_result,
+		__attribute__((unused))  struct cmdline *cl,
+		__attribute__((unused)) void *data)
+{
+	struct cmd_set_bond_mon_period_result *res = parsed_result;
+	int ret;
+
+	if (res->port_num >= nb_ports) {
+		printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
+		return;
+	}
+
+	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
+
+	/* check the return value and print it if is < 0 */
+	if (ret < 0)
+		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
+}
+
+cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
+		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
+				set, "set");
+cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
+		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
+				bonding, "bonding");
+cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
+		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
+				mon_period,	"mon_period");
+cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
+		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
+				port_num, UINT8);
+cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
+		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
+				period_ms, UINT32);
+
+cmdline_parse_inst_t cmd_set_bond_mon_period = {
+		.f = cmd_set_bond_mon_period_parsed,
+		.data = (void *) 0,
+		.help_str = "set bonding mon_period (port_id) (period_ms): ",
+		.tokens = {
+				(void *)&cmd_set_bond_mon_period_set,
+				(void *)&cmd_set_bond_mon_period_bonding,
+				(void *)&cmd_set_bond_mon_period_mon_period,
+				(void *)&cmd_set_bond_mon_period_portnum,
+				(void *)&cmd_set_bond_mon_period_period_ms,
+				NULL
+		}
+};
+
 #endif /* RTE_LIBRTE_PMD_BOND */
 
 /* *** SET FORWARDING MODE *** */
@@ -7453,6 +7515,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
+	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
 #endif
 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
app/test/test.h +4 -3
index 98ab804..24b1640 100644
@@ -62,14 +62,15 @@
 
 #define TEST_ASSERT_SUCCESS(val, msg, ...) do {					\
 		if (!(val == 0)) {										\
-			printf("TestCase %s() line %d failed: "			\
-				msg "\n", __func__, __LINE__, ##__VA_ARGS__);	\
+			printf("TestCase %s() line %d failed (err %d): "	\
+				msg "\n", __func__, __LINE__, val,				\
+				##__VA_ARGS__);									\
 			return -1;											\
 		}														\
 } while (0)
 
 #define TEST_ASSERT_FAIL(val, msg, ...) do {					\
-		if (!(val != -1)) {										\
+		if (!(val != 0)) {										\
 			printf("TestCase %s() line %d failed: "			\
 				msg "\n", __func__, __LINE__, ##__VA_ARGS__);	\
 			return -1;											\
app/test/test_link_bonding.c +162 -96

400 lines not on this page · raw message

app/test/virtual_pmd.c +15 -2
index f9bd841..fffaa35 100644
@@ -458,6 +458,14 @@ virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
 }
 
 void
+virtual_ethdev_set_link_status(uint8_t port_id, uint8_t link_status)
+{
+	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
+
+	vrtl_eth_dev->data->dev_link.link_status = link_status;
+}
+
+void
 virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id,
 		uint8_t link_status)
 {
@@ -505,7 +513,7 @@ get_number_of_sockets(void)
 
 int
 virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
-		uint8_t socket_id)
+		uint8_t socket_id, uint8_t isr_support)
 {
 	struct rte_pci_device *pci_dev = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
@@ -555,7 +563,12 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 	pci_dev->numa_node = socket_id;
 	pci_drv->name = virtual_ethdev_driver_name;
 	pci_drv->id_table = id_table;
-	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+
+	if (isr_support)
+		pci_drv->drv_flags |= RTE_PCI_DRV_INTR_LSC;
+	else
+		pci_drv->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;
+
 
 	eth_drv->pci_drv = (struct rte_pci_driver)(*pci_drv);
 	eth_dev->driver = eth_drv;
app/test/virtual_pmd.h +34 -14

72 lines not on this page · raw message

lib/librte_pmd_bond/rte_eth_bond.h +80 -0

86 lines not on this page · raw message

lib/librte_pmd_bond/rte_eth_bond_api.c +210 -105

522 lines not on this page · raw message

lib/librte_pmd_bond/rte_eth_bond_args.c +26 -4
index 11d9816..bbbc69b 100644
@@ -118,7 +118,7 @@ parse_port_id(const char *port_str)
 	}
 
 	if (port_id < 0 || port_id > RTE_MAX_ETHPORTS) {
-		RTE_LOG(ERR, PMD, "Invalid slave port value (%s) specified.\n",
+		RTE_BOND_LOG(ERR, "Slave port specified (%s) outside expected range",
 				port_str);
 		return -1;
 	}
@@ -138,9 +138,10 @@ bond_ethdev_parse_slave_port_kvarg(const char *key __rte_unused,
 
 	if (strcmp(key, PMD_BOND_SLAVE_PORT_KVARG) == 0) {
 		int port_id = parse_port_id(value);
-		if (port_id < 0)
+		if (port_id < 0) {
+			RTE_BOND_LOG(ERR, "Invalid slave port value (%s) specified", value);
 			return -1;
-		else
+		} else
 			slave_ports->slaves[slave_ports->slave_count++] =
 					(uint8_t)port_id;
 	}
@@ -172,6 +173,7 @@ bond_ethdev_parse_slave_mode_kvarg(const char *key __rte_unused,
 	case BONDING_MODE_BROADCAST:
 		return 0;
 	default:
+		RTE_BOND_LOG(ERR, "Invalid slave mode value (%s) specified", value);
 		return -1;
 	}
 }
@@ -191,7 +193,7 @@ bond_ethdev_parse_socket_id_kvarg(const char *key __rte_unused,
 	if (*endptr != 0 || errno != 0)
 		return -1;
 
-	/* validate mode value */
+	/* validate socket id value */
 	if (socket_id >= 0 && socket_id < number_of_sockets()) {
 		*(uint8_t *)extra_args = (uint8_t)socket_id;
 		return 0;
@@ -250,3 +252,23 @@ bond_ethdev_parse_bond_mac_addr_kvarg(const char *key __rte_unused,
 	/* Parse MAC */
 	return cmdline_parse_etheraddr(NULL, value, extra_args);
 }
+
+int
+bond_ethdev_parse_time_ms_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args)
+{
+	uint32_t time_ms;
+	char *endptr;
+
+	if (value == NULL || extra_args == NULL)
+		return -1;
+
+	errno = 0;
+	time_ms = (uint32_t)strtol(value, &endptr, 10);
+	if (*endptr != 0 || errno != 0)
+		return -1;
+
+	*(uint32_t *)extra_args = time_ms;
+
+	return 0;
+}
lib/librte_pmd_bond/rte_eth_bond_pmd.c +294 -99

580 lines not on this page · raw message

lib/librte_pmd_bond/rte_eth_bond_private.h +46 -25

134 lines not on this page · raw message

Signature · 1 line
1.7.12.2
#51 lore raw

PATCH v4 8/8 bond: unit test test macro refactor

In reply to a message not in the archive
---
 app/test/test_link_bonding.c | 2574 +++++++++++++++++-------------------------
 1 file changed, 1036 insertions(+), 1538 deletions(-)
app/test/test_link_bonding.c +1036 -1538
index c32b685..c4fcaf7 100644
@@ -31,6 +31,7 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "unistd.h"
 #include <string.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -265,7 +266,7 @@ static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
 static int
 test_setup(void)
 {
-	int i, retval, nb_mbuf_per_pool;
+	int i, nb_mbuf_per_pool;
 	struct ether_addr *mac_addr = (struct ether_addr *)slave_mac;
 
 	/* Allocate ethernet packet header with space for VLAN header */
@@ -273,10 +274,8 @@ test_setup(void)
 		test_params->pkt_eth_hdr = malloc(sizeof(struct ether_hdr) +
 				sizeof(struct vlan_hdr));
 
-		if (test_params->pkt_eth_hdr == NULL) {
-			printf("ethernet header struct allocation failed!\n");
-			return -1;
-		}
+		TEST_ASSERT_NOT_NULL(test_params->pkt_eth_hdr,
+				"Ethernet header struct allocation failed!");
 	}
 
 	nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX + DEF_PKT_BURST +
@@ -286,10 +285,8 @@ test_setup(void)
 				MBUF_SIZE, MBUF_CACHE_SIZE, sizeof(struct rte_pktmbuf_pool_private),
 				rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,
 				rte_socket_id(), 0);
-		if (test_params->mbuf_pool == NULL) {
-			printf("rte_mempool_create failed\n");
-			return -1;
-		}
+		TEST_ASSERT_NOT_NULL(test_params->mbuf_pool,
+				"rte_mempool_create failed");
 	}
 
 	/* Create / Initialize virtual eth devs */
@@ -303,20 +300,12 @@ test_setup(void)
 
 			test_params->slave_port_ids[i] = virtual_ethdev_create(pmd_name,
 					mac_addr, rte_socket_id(), 1);
-			if (test_params->slave_port_ids[i] < 0) {
-				printf("Failed to create virtual virtual ethdev %s\n", pmd_name);
-				return -1;
-			}
+			TEST_ASSERT(test_params->slave_port_ids[i] >= 0,
+					"Failed to create virtual virtual ethdev %s", pmd_name);
 
-			printf("Created virtual ethdev %s\n", pmd_name);
-
-			retval = configure_ethdev(test_params->slave_port_ids[i], 1, 0);
-			if (retval != 0) {
-				printf("Failed to configure virtual ethdev %s\n", pmd_name);
-				return -1;
-			}
-
-			printf("Configured virtual ethdev %s\n", pmd_name);
+			TEST_ASSERT_SUCCESS(configure_ethdev(
+					test_params->slave_port_ids[i], 1, 0),
+					"Failed to configure virtual ethdev %s", pmd_name);
 		}
 		slaves_initialized = 1;
 	}
@@ -350,14 +339,14 @@ test_create_bonded_device(void)
 	current_slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
 
-	TEST_ASSERT(current_slave_count == 0,
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
 			"Number of slaves %d is great than expected %d.",
 			current_slave_count, 0);
 
 	current_slave_count = rte_eth_bond_active_slaves_get(
 			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS);
 
-	TEST_ASSERT(current_slave_count == 0,
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
 			"Number of active slaves %d is great than expected %d.",
 			current_slave_count, 0);
 
@@ -375,30 +364,21 @@ test_create_bonded_device_with_invalid_params(void)
 	/* Invalid name */
 	port_id = rte_eth_bond_create(NULL, test_params->bonding_mode,
 			rte_socket_id());
-	if (port_id >= 0) {
-		printf("Created bonded device unexpectedly.\n");
-		return -1;
-	}
+	TEST_ASSERT(port_id < 0, "Created bonded device unexpectedly");
 
 	test_params->bonding_mode = INVALID_BONDING_MODE;
 
 	/* Invalid bonding mode */
 	port_id = rte_eth_bond_create(BONDED_DEV_NAME, test_params->bonding_mode,
 			rte_socket_id());
-	if (port_id >= 0) {
-		printf("Created bonded device unexpectedly.\n");
-		return -1;
-	}
+	TEST_ASSERT(port_id < 0, "Created bonded device unexpectedly.");
 
 	test_params->bonding_mode = BONDING_MODE_ROUND_ROBIN;
 
 	/* Invalid socket id */
 	port_id = rte_eth_bond_create(BONDED_DEV_NAME, test_params->bonding_mode,
 			INVALID_SOCKET_ID);
-	if (port_id >= 0) {
-		printf("Created bonded device unexpectedly.\n");
-		return -1;
-	}
+	TEST_ASSERT(port_id < 0, "Created bonded device unexpectedly.");
 
 	return 0;
 }
@@ -436,23 +416,15 @@ test_add_slave_to_bonded_device(void)
 static int
 test_add_slave_to_invalid_bonded_device(void)
 {
-	int retval;
-
 	/* Invalid port ID */
-	retval = rte_eth_bond_slave_add(test_params->bonded_port_id + 5,
-			test_params->slave_port_ids[test_params->bonded_slave_count]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_slave_add(test_params->bonded_port_id + 5,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Expected call to failed as invalid port specified.");
 
 	/* Non bonded device */
-	retval = rte_eth_bond_slave_add(test_params->slave_port_ids[0],
-			test_params->slave_port_ids[test_params->bonded_slave_count]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_slave_add(test_params->slave_port_ids[0],
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Expected call to failed as invalid port specified.");
 
 	return 0;
 }
@@ -504,23 +476,17 @@ test_remove_slave_from_bonded_device(void)
 static int
 test_remove_slave_from_invalid_bonded_device(void)
 {
-	int retval;
-
 	/* Invalid port ID */
-	retval = rte_eth_bond_slave_remove(test_params->bonded_port_id + 5,
-			test_params->slave_port_ids[test_params->bonded_slave_count - 1]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_slave_remove(
+			test_params->bonded_port_id + 5,
+			test_params->slave_port_ids[test_params->bonded_slave_count - 1]),
+			"Expected call to failed as invalid port specified.");
 
 	/* Non bonded device */
-	retval = rte_eth_bond_slave_remove(test_params->slave_port_ids[0],
-			test_params->slave_port_ids[test_params->bonded_slave_count - 1]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_slave_remove(
+			test_params->slave_port_ids[0],
+			test_params->slave_port_ids[test_params->bonded_slave_count - 1]),
+			"Expected call to failed as invalid port specified.");
 
 	return 0;
 }
@@ -530,7 +496,7 @@ static int bonded_id = 2;
 static int
 test_add_already_bonded_slave_to_bonded_device(void)
 {
-	int retval, port_id, current_slave_count;
+	int port_id, current_slave_count;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 	char pmd_name[RTE_ETH_NAME_MAX_LEN];
 
@@ -538,29 +504,22 @@ test_add_already_bonded_slave_to_bonded_device(void)
 
 	current_slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count != 1) {
-		printf("Number of slaves (%d) is not that expected (%d).\n",
-				current_slave_count, 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, 1,
+			"Number of slaves (%d) is not that expected (%d).",
+			current_slave_count, 1);
 
 	snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "%s_%d", BONDED_DEV_NAME, ++bonded_id);
 
 	port_id = rte_eth_bond_create(pmd_name, test_params->bonding_mode,
 			rte_socket_id());
-	if (port_id < 0) {
-		printf("Failed to create bonded device.\n");
-		return -1;
-	}
+	TEST_ASSERT(port_id >= 0, "Failed to create bonded device.");
 
-	retval = rte_eth_bond_slave_add(port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count - 1]);
-	if (retval == 0) {
-		printf("Added slave (%d) to bonded port (%d) unexpectedly.\n",
-				test_params->slave_port_ids[test_params->bonded_slave_count-1],
-				port_id);
-		return -1;
-	}
+	TEST_ASSERT(rte_eth_bond_slave_add(port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count - 1])
+			< 0,
+			"Added slave (%d) to bonded port (%d) unexpectedly.",
+			test_params->slave_port_ids[test_params->bonded_slave_count-1],
+			port_id);
 
 	return test_remove_slave_from_bonded_device();
 }
@@ -569,50 +528,47 @@ test_add_already_bonded_slave_to_bonded_device(void)
 static int
 test_get_slaves_from_bonded_device(void)
 {
-	int retval, current_slave_count;
-
+	int current_slave_count;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = test_add_slave_to_bonded_device();
-	if (retval != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
+			"Failed to add slave to bonded device");
 
 	/* Invalid port id */
 	current_slave_count = rte_eth_bond_slaves_get(INVALID_PORT_ID, slaves,
 			RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid port id unexpectedly succeeded");
 
 	current_slave_count = rte_eth_bond_active_slaves_get(INVALID_PORT_ID,
 			slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid port id unexpectedly succeeded");
 
 	/* Invalid slaves pointer */
 	current_slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id,
 			NULL, RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid slave array unexpectedly succeeded");
 
 	current_slave_count = rte_eth_bond_active_slaves_get(
 			test_params->bonded_port_id, NULL, RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid slave array unexpectedly succeeded");
 
 	/* non bonded device*/
 	current_slave_count = rte_eth_bond_slaves_get(
 			test_params->slave_port_ids[0], NULL, RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid port id unexpectedly succeeded");
 
 	current_slave_count = rte_eth_bond_active_slaves_get(
 			test_params->slave_port_ids[0],	NULL, RTE_MAX_ETHPORTS);
-	if (current_slave_count >= 0)
-		return -1;
+	TEST_ASSERT(current_slave_count < 0,
+			"Invalid port id unexpectedly succeeded");
 
-	retval = test_remove_slave_from_bonded_device();
-	if (retval != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(test_remove_slave_from_bonded_device(),
+			"Failed to remove slaves from bonded device");
 
 	return 0;
 }
@@ -623,15 +579,13 @@ test_add_remove_multiple_slaves_to_from_bonded_device(void)
 {
 	int i;
 
-	for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++) {
-		if (test_add_slave_to_bonded_device() != 0)
-			return -1;
-	}
+	for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++)
+		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
+				"Failed to add slave to bonded device");
 
-	for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++) {
-		if (test_remove_slave_from_bonded_device() != 0)
-			return -1;
-	}
+	for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++)
+		TEST_ASSERT_SUCCESS(test_remove_slave_from_bonded_device(),
+				"Failed to remove slaves from bonded device");
 
 	return 0;
 }
@@ -659,8 +613,8 @@ test_start_bonded_device(void)
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
 	/* Add slave to bonded device*/
-	if (test_add_slave_to_bonded_device() != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
+			"Failed to add slave to bonded device");
 
 	TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonded_port_id),
 		"Failed to start bonded pmd eth device %d.",
@@ -673,43 +627,30 @@ test_start_bonded_device(void)
 
 	current_slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count != test_params->bonded_slave_count) {
-		printf("Number of slaves (%d) is not expected value (%d).\n",
-				current_slave_count, test_params->bonded_slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count,
+			"Number of slaves (%d) is not expected value (%d).",
+			current_slave_count, test_params->bonded_slave_count);
 
 	current_slave_count = rte_eth_bond_active_slaves_get(
 			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count != test_params->bonded_slave_count) {
-		printf("Number of active slaves (%d) is not expected value (%d).\n",
-				current_slave_count, test_params->bonded_slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count,
+			"Number of active slaves (%d) is not expected value (%d).",
+			current_slave_count, test_params->bonded_slave_count);
 
 	current_bonding_mode = rte_eth_bond_mode_get(test_params->bonded_port_id);
-	if (current_bonding_mode != test_params->bonding_mode) {
-		printf("Bonded device mode (%d) is not expected value (%d).\n",
-				current_bonding_mode, test_params->bonding_mode);
-		return -1;
-
-	}
+	TEST_ASSERT_EQUAL(current_bonding_mode, test_params->bonding_mode,
+			"Bonded device mode (%d) is not expected value (%d).\n",
+			current_bonding_mode, test_params->bonding_mode);
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (primary_port != test_params->slave_port_ids[0]) {
-		printf("Primary port (%d) is not expected value (%d).\n",
-				primary_port, test_params->slave_port_ids[0]);
-		return -1;
-
-	}
+	TEST_ASSERT_EQUAL(primary_port, test_params->slave_port_ids[0],
+			"Primary port (%d) is not expected value (%d).",
+			primary_port, test_params->slave_port_ids[0]);
 
 	rte_eth_link_get(test_params->bonded_port_id, &link_status);
-	if (!link_status.link_status) {
-		printf("Bonded port (%d) status (%d) is not expected value (%d).\n",
-				test_params->bonded_port_id, link_status.link_status, 1);
-		return -1;
-
-	}
+	TEST_ASSERT_EQUAL(link_status.link_status, 1,
+			"Bonded port (%d) status (%d) is not expected value (%d).\n",
+			test_params->bonded_port_id, link_status.link_status, 1);
 
 	return 0;
 }
@@ -725,40 +666,32 @@ test_stop_bonded_device(void)
 	rte_eth_dev_stop(test_params->bonded_port_id);
 
 	rte_eth_link_get(test_params->bonded_port_id, &link_status);
-	if (link_status.link_status) {
-		printf("Bonded port (%d) status (%d) is not expected value (%d).\n",
-				test_params->bonded_port_id, link_status.link_status, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(link_status.link_status, 0,
+			"Bonded port (%d) status (%d) is not expected value (%d).",
+			test_params->bonded_port_id, link_status.link_status, 0);
 
 	current_slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count != test_params->bonded_slave_count) {
-		printf("Number of slaves (%d) is not expected value (%d).\n",
-				current_slave_count, test_params->bonded_slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count,
+			"Number of slaves (%d) is not expected value (%d).",
+			current_slave_count, test_params->bonded_slave_count);
 
 	current_slave_count = rte_eth_bond_active_slaves_get(
 			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS);
-	if (current_slave_count != 0) {
-		printf("Number of active slaves (%d) is not expected value (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
+			"Number of active slaves (%d) is not expected value (%d).",
+			current_slave_count, 0);
 
 	return 0;
 }
 
-static int remove_slaves_and_stop_bonded_device(void)
+static int
+remove_slaves_and_stop_bonded_device(void)
 {
 	/* Clean up and remove slaves from bonded device */
-	while (test_params->bonded_slave_count > 0) {
-		if (test_remove_slave_from_bonded_device() != 0) {
-			printf("test_remove_slave_from_bonded_device failed\n");
-			return -1;
-		}
-	}
+	while (test_params->bonded_slave_count > 0)
+		TEST_ASSERT_SUCCESS(test_remove_slave_from_bonded_device(),
+				"test_remove_slave_from_bonded_device failed");
 
 	rte_eth_dev_stop(test_params->bonded_port_id);
 	rte_eth_stats_reset(test_params->bonded_port_id);
@@ -770,8 +703,7 @@ static int remove_slaves_and_stop_bonded_device(void)
 static int
 test_set_bonding_mode(void)
 {
-	int i;
-	int retval, bonding_mode;
+	int i, bonding_mode;
 
 	int bonding_modes[] = { BONDING_MODE_ROUND_ROBIN,
 							BONDING_MODE_ACTIVE_BACKUP,
@@ -781,56 +713,39 @@ test_set_bonding_mode(void)
 	/* Test supported link bonding modes */
 	for (i = 0; i < (int)RTE_DIM(bonding_modes);	i++) {
 		/* Invalid port ID */
-		retval = rte_eth_bond_mode_set(INVALID_PORT_ID, bonding_modes[i]);
-		if (retval == 0) {
-			printf("Expected call to failed as invalid port (%d) specified.\n",
-					INVALID_PORT_ID);
-			return -1;
-		}
+		TEST_ASSERT_FAIL(rte_eth_bond_mode_set(INVALID_PORT_ID,
+				bonding_modes[i]),
+				"Expected call to failed as invalid port (%d) specified.",
+				INVALID_PORT_ID);
 
 		/* Non bonded device */
-		retval = rte_eth_bond_mode_set(test_params->slave_port_ids[0],
-				bonding_modes[i]);
-		if (retval == 0) {
-			printf("Expected call to failed as invalid port (%d) specified.\n",
-					test_params->slave_port_ids[0]);
-			return -1;
-		}
+		TEST_ASSERT_FAIL(rte_eth_bond_mode_set(test_params->slave_port_ids[0],
+				bonding_modes[i]),
+				"Expected call to failed as invalid port (%d) specified.",
+				test_params->slave_port_ids[0]);
 
-		retval = rte_eth_bond_mode_set(test_params->bonded_port_id,
-				bonding_modes[i]);
-		if (retval != 0) {
-			printf("Failed to set link bonding mode on port (%d) to (%d).\n",
-					test_params->bonded_port_id, bonding_modes[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonded_port_id,
+				bonding_modes[i]),
+				"Failed to set link bonding mode on port (%d) to (%d).",
+				test_params->bonded_port_id, bonding_modes[i]);
 
 		bonding_mode = rte_eth_bond_mode_get(test_params->bonded_port_id);
-		if (bonding_mode != bonding_modes[i]) {
-			printf("Link bonding mode (%d) of port (%d) is not expected value (%d).\n",
-					bonding_mode, test_params->bonded_port_id,
-					bonding_modes[i]);
-			return -1;
-		}
-
+		TEST_ASSERT_EQUAL(bonding_mode, bonding_modes[i],
+				"Link bonding mode (%d) of port (%d) is not expected value (%d).",
+				bonding_mode, test_params->bonded_port_id,
+				bonding_modes[i]);
 
 		/* Invalid port ID */
 		bonding_mode = rte_eth_bond_mode_get(INVALID_PORT_ID);
-		if (bonding_mode >= 0) {
-			printf("Expected call to failed as invalid port (%d) specified.\n",
-					INVALID_PORT_ID);
-			return -1;
-		}
-
+		TEST_ASSERT(bonding_mode < 0,
+				"Expected call to failed as invalid port (%d) specified.",
+				INVALID_PORT_ID);
 
 		/* Non bonded device */
 		bonding_mode = rte_eth_bond_mode_get(test_params->slave_port_ids[0]);
-		if (bonding_mode >= 0) {
-			printf("Expected call to failed as invalid port (%d) specified.\n",
-					test_params->slave_port_ids[0]);
-			return -1;
-		}
-
+		TEST_ASSERT(bonding_mode < 0,
+				"Expected call to failed as invalid port (%d) specified.",
+				test_params->slave_port_ids[0]);
 	}
 
 	return remove_slaves_and_stop_bonded_device();
@@ -844,36 +759,24 @@ test_set_primary_slave(void)
 	struct ether_addr *expected_mac_addr;
 
 	/* Add 4 slaves to bonded device */
-	for (i = test_params->bonded_slave_count; i < 4; i++) {
-		retval = test_add_slave_to_bonded_device();
-		if (retval != 0) {
-			printf("Failed to add slave to bonded device.\n");
-			return -1;
-		}
-	}
-	retval = rte_eth_bond_mode_set(test_params->bonded_port_id,
-			BONDING_MODE_ROUND_ROBIN);
-	if (retval != 0) {
-		printf("Failed to set link bonding mode on port (%d) to (%d).\n",
-				test_params->bonded_port_id, BONDING_MODE_ROUND_ROBIN);
-		return -1;
-	}
+	for (i = test_params->bonded_slave_count; i < 4; i++)
+		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
+				"Failed to add slave to bonded device.");
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonded_port_id,
+			BONDING_MODE_ROUND_ROBIN),
+			"Failed to set link bonding mode on port (%d) to (%d).",
+			test_params->bonded_port_id, BONDING_MODE_ROUND_ROBIN);
 
 	/* Invalid port ID */
-	retval = rte_eth_bond_primary_set(INVALID_PORT_ID,
-			test_params->slave_port_ids[i]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_primary_set(INVALID_PORT_ID,
+			test_params->slave_port_ids[i]),
+			"Expected call to failed as invalid port specified.");
 
 	/* Non bonded device */
-	retval = rte_eth_bond_primary_set(test_params->slave_port_ids[i],
-			test_params->slave_port_ids[i]);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_primary_set(test_params->slave_port_ids[i],
+			test_params->slave_port_ids[i]),
+			"Expected call to failed as invalid port specified.");
 
 	/* Set slave as primary
 	 * Verify slave it is now primary slave
@@ -881,32 +784,27 @@ test_set_primary_slave(void)
 	 * Verify that MAC address of all bonded slaves are that of primary slave
 	 */
 	for (i = 0; i < 4; i++) {
-		retval = rte_eth_bond_primary_set(test_params->bonded_port_id,
-				test_params->slave_port_ids[i]);
-		if (retval != 0) {
-			printf("Failed to set bonded port (%d) primary port to (%d)\n",
-					test_params->bonded_port_id,
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(test_params->bonded_port_id,
+				test_params->slave_port_ids[i]),
+				"Failed to set bonded port (%d) primary port to (%d)",
+				test_params->bonded_port_id, test_params->slave_port_ids[i]);
 
 		retval = rte_eth_bond_primary_get(test_params->bonded_port_id);
-		if (retval < 0) {
-			printf("Failed to read primary port from bonded port (%d)\n",
+		TEST_ASSERT(retval >= 0,
+				"Failed to read primary port from bonded port (%d)\n",
 					test_params->bonded_port_id);
-			return -1;
-		} else if (retval != test_params->slave_port_ids[i]) {
-			printf("Bonded port (%d) primary port (%d) not expected value (%d)\n",
-					test_params->bonded_port_id, retval,
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+
+		TEST_ASSERT_EQUAL(retval, test_params->slave_port_ids[i],
+				"Bonded port (%d) primary port (%d) not expected value (%d)\n",
+				test_params->bonded_port_id, retval,
+				test_params->slave_port_ids[i]);
 
 		/* stop/start bonded eth dev to apply new MAC */
 		rte_eth_dev_stop(test_params->bonded_port_id);
 
-		if (rte_eth_dev_start(test_params->bonded_port_id) != 0)
-			return -1;
+		TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonded_port_id),
+				"Failed to start bonded port %d",
+				test_params->bonded_port_id);
 
 		expected_mac_addr = (struct ether_addr *)&slave_mac;
 		expected_mac_addr->addr_bytes[ETHER_ADDR_LEN-1] =
@@ -914,56 +812,44 @@ test_set_primary_slave(void)
 
 		/* Check primary slave MAC */
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(expected_mac_addr, &read_mac_addr, sizeof(read_mac_addr))) {
-			printf("bonded port mac address not set to that of primary port\n");
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(expected_mac_addr, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"bonded port mac address not set to that of primary port\n");
 
 		/* Check bonded MAC */
 		rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-		if (memcmp(&read_mac_addr, &read_mac_addr, sizeof(read_mac_addr))) {
-			printf("bonded port mac address not set to that of primary port\n");
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(&read_mac_addr, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"bonded port mac address not set to that of primary port\n");
 
 		/* Check other slaves MACs */
 		for (j = 0; j < 4; j++) {
 			if (j != i) {
 				rte_eth_macaddr_get(test_params->slave_port_ids[j],
 						&read_mac_addr);
-				if (memcmp(expected_mac_addr, &read_mac_addr,
-						sizeof(read_mac_addr))) {
-					printf("slave port mac address not set to that of primary port\n");
-					return -1;
-				}
+				TEST_ASSERT_SUCCESS(memcmp(expected_mac_addr, &read_mac_addr,
+						sizeof(read_mac_addr)),
+						"slave port mac address not set to that of primary "
+						"port");
 			}
 		}
 	}
 
 
 	/* Test with none existent port */
-	retval = rte_eth_bond_primary_get(test_params->bonded_port_id + 10);
-	if (retval >= 0) {
-		printf("read primary port from expectedly\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_primary_get(test_params->bonded_port_id + 10),
+			"read primary port from expectedly");
 
 	/* Test with slave port */
-	retval = rte_eth_bond_primary_get(test_params->slave_port_ids[0]);
-	if (retval >= 0) {
-		printf("read primary port from expectedly\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_primary_get(test_params->slave_port_ids[0]),
+			"read primary port from expectedly\n");
 
-	if (remove_slaves_and_stop_bonded_device() != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(remove_slaves_and_stop_bonded_device(),
+			"Failed to stop and remove slaves from bonded device");
 
 	/* No slaves  */
-	retval = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (retval >= 0) {
-		printf("read primary port from expectedly\n");
-		return -1;
-	}
+	TEST_ASSERT(rte_eth_bond_primary_get(test_params->bonded_port_id)  < 0,
+			"read primary port from expectedly\n");
 
 	return 0;
 }
@@ -971,7 +857,7 @@ test_set_primary_slave(void)
 static int
 test_set_explicit_bonded_mac(void)
 {
-	int i, retval;
+	int i;
 	struct ether_addr read_mac_addr;
 	struct ether_addr *mac_addr;
 
@@ -980,87 +866,62 @@ test_set_explicit_bonded_mac(void)
 	mac_addr = (struct ether_addr *)explicit_bonded_mac;
 
 	/* Invalid port ID */
-	retval = rte_eth_bond_mac_address_set(INVALID_PORT_ID, mac_addr);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_mac_address_set(INVALID_PORT_ID, mac_addr),
+			"Expected call to failed as invalid port specified.");
 
 	/* Non bonded device */
-	retval = rte_eth_bond_mac_address_set(test_params->slave_port_ids[0],
-			mac_addr);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_mac_address_set(
+			test_params->slave_port_ids[0],	mac_addr),
+			"Expected call to failed as invalid port specified.");
 
 	/* NULL MAC address */
-	retval = rte_eth_bond_mac_address_set(test_params->bonded_port_id, NULL);
-	if (retval == 0) {
-		printf("Expected call to failed as NULL MAC specified\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_mac_address_set(
+			test_params->bonded_port_id, NULL),
+			"Expected call to failed as NULL MAC specified");
 
-	retval = rte_eth_bond_mac_address_set(test_params->bonded_port_id,
-			mac_addr);
-	if (retval != 0) {
-		printf("Failed to set MAC address on bonded port (%d)\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
+			test_params->bonded_port_id, mac_addr),
+			"Failed to set MAC address on bonded port (%d)",
+			test_params->bonded_port_id);
 
 	/* Add 4 slaves to bonded device */
 	for (i = test_params->bonded_slave_count; i < 4; i++) {
-		retval = test_add_slave_to_bonded_device();
-		if (retval != 0) {
-			printf("Failed to add slave to bonded device.\n");
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
+				"Failed to add slave to bonded device.\n");
 	}
 
 	/* Check bonded MAC */
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(mac_addr, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port mac address not set to that of primary port\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(mac_addr, &read_mac_addr, sizeof(read_mac_addr)),
+			"bonded port mac address not set to that of primary port");
 
 	/* Check other slaves MACs */
 	for (i = 0; i < 4; i++) {
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(mac_addr, &read_mac_addr, sizeof(read_mac_addr))) {
-			printf("slave port mac address not set to that of primary port\n");
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(mac_addr, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"slave port mac address not set to that of primary port");
 	}
 
 	/* test resetting mac address on bonded device */
-	if (rte_eth_bond_mac_address_reset(test_params->bonded_port_id) != 0) {
-		printf("Failed to reset MAC address on bonded port (%d)\n",
-				test_params->bonded_port_id);
-
-		return -1;
-	}
-
-	if (rte_eth_bond_mac_address_reset(test_params->slave_port_ids[0]) == 0) {
-		printf("Reset MAC address on bonded port (%d) unexpectedly\n",
-				test_params->slave_port_ids[1]);
+	TEST_ASSERT_SUCCESS(
+			rte_eth_bond_mac_address_reset(test_params->bonded_port_id),
+			"Failed to reset MAC address on bonded port (%d)",
+			test_params->bonded_port_id);
 
-		return -1;
-	}
+	TEST_ASSERT_FAIL(
+			rte_eth_bond_mac_address_reset(test_params->slave_port_ids[0]),
+			"Reset MAC address on bonded port (%d) unexpectedly",
+			test_params->slave_port_ids[1]);
 
 	/* test resetting mac address on bonded device with no slaves */
+	TEST_ASSERT_SUCCESS(remove_slaves_and_stop_bonded_device(),
+			"Failed to remove slaves and stop bonded device");
 
-	if (remove_slaves_and_stop_bonded_device() != 0)
-		return -1;
-
-	if (rte_eth_bond_mac_address_reset(test_params->bonded_port_id) != 0) {
-		printf("Failed to reset MAC address on bonded port (%d)\n",
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_reset(test_params->bonded_port_id),
+			"Failed to reset MAC address on bonded port (%d)",
 				test_params->bonded_port_id);
 
-		return -1;
-	}
-
 	return 0;
 }
 
@@ -1176,9 +1037,10 @@ test_status_interrupt(void)
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
 	/* initialized bonding device with T slaves */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 1,
-			TEST_STATUS_INTERRUPT_SLAVE_COUNT, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 1,
+			TEST_STATUS_INTERRUPT_SLAVE_COUNT, 1),
+			"Failed to initialise bonded device");
 
 	test_lsc_interupt_count = 0;
 
@@ -1310,10 +1172,8 @@ generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 			pkts_burst,	test_params->pkt_eth_hdr, vlan, ip_hdr, ipv4,
 			test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN_128,
 			1);
-	if (generated_burst_size != burst_size) {
-		printf("Failed to generate packet burst");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generated_burst_size, burst_size,
+			"Failed to generate packet burst");
 
 	return generated_burst_size;
 }
@@ -1323,51 +1183,43 @@ generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 static int
 test_roundrobin_tx_burst(void)
 {
-	int i, burst_size, nb_tx;
+	int i, burst_size;
 	struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 2, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 2, 1),
+			"Failed to intialise bonded device");
 
 	burst_size = 20 * test_params->bonded_slave_count;
 
-	if (burst_size > MAX_PKT_BURST) {
-		printf("Burst size specified is greater than supported.\n");
-		return -1;
-	}
+	TEST_ASSERT(burst_size <= MAX_PKT_BURST,
+			"Burst size specified is greater than supported.");
 
 	/* Generate test bursts of packets to transmit */
-	if (generate_test_burst(pkt_burst, burst_size, 0, 1, 0, 0, 0) != burst_size)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst, burst_size, 0, 1, 0, 0, 0),
+			burst_size, "failed to generate test burst");
 
 	/* Send burst on bonded port */
-	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkt_burst,
-			burst_size);
-	if (nb_tx != burst_size)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkt_burst, burst_size), burst_size,
+			"tx burst failed");
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			burst_size);
 
 	/* Verify slave ports tx stats */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_stats_get(test_params->slave_port_ids[i], &port_stats);
-		if (port_stats.opackets !=
-				(uint64_t)burst_size / test_params->bonded_slave_count) {
-			printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-					test_params->bonded_port_id,
-					(unsigned int)port_stats.opackets,
-					burst_size / test_params->bonded_slave_count);
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(port_stats.opackets,
+				(uint64_t)burst_size / test_params->bonded_slave_count,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)\n",
+				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+				burst_size / test_params->bonded_slave_count);
 	}
 
 	/* Put all slaves down and try and transmit */
@@ -1377,10 +1229,9 @@ test_roundrobin_tx_burst(void)
 	}
 
 	/* Send burst on bonded port */
-	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkt_burst,
-			burst_size);
-	if (nb_tx != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+			pkt_burst, burst_size), 0,
+			"tx burst return unexpected value");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -1523,17 +1374,17 @@ test_roundrobin_rx_burst_on_single_slave(void)
 
 	struct rte_eth_stats port_stats;
 
-	int i, j, nb_rx, burst_size = 25;
+	int i, j, burst_size = 25;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
-			0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
+			"Failed to initialize bonded device with slaves");
 
 	/* Generate test bursts of packets to transmit */
-	if (generate_test_burst(gen_pkt_burst, burst_size, 0, 1, 0, 0, 0) !=
-			burst_size)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			gen_pkt_burst, burst_size, 0, 1, 0, 0, 0), burst_size,
+			"burst generation failed");
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		/* Add rx data to slave */
@@ -1542,21 +1393,17 @@ test_roundrobin_rx_burst_on_single_slave(void)
 
 		/* Call rx burst on bonded device */
 		/* Send burst on bonded port */
-		nb_rx = rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
-				MAX_PKT_BURST);
-		if (nb_rx != burst_size) {
-			printf("round-robin rx burst failed");
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(rte_eth_rx_burst(
+				test_params->bonded_port_id, 0, rx_pkt_burst,MAX_PKT_BURST),
+				burst_size, "round-robin rx burst failed");
 
 		/* Verify bonded device rx count */
 		rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-		if (port_stats.ipackets != (uint64_t)burst_size) {
-			printf("Bonded Port (%d) ipackets value (%u) not as expected (%d)\n",
-					test_params->bonded_port_id,
-					(unsigned int)port_stats.ipackets, burst_size);
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
+				"Bonded Port (%d) ipackets value (%u) not as expected (%d)",
+				test_params->bonded_port_id,
+				(unsigned int)port_stats.ipackets, burst_size);
+
 
 
 		/* Verify bonded slave devices rx count */
@@ -1565,19 +1412,15 @@ test_roundrobin_rx_burst_on_single_slave(void)
 			rte_eth_stats_get(test_params->slave_port_ids[j], &port_stats);
 
 			if (i == j) {
-				if (port_stats.ipackets != (uint64_t)burst_size) {
-					printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-							test_params->slave_port_ids[i],
-							(unsigned int)port_stats.ipackets, burst_size);
-					return -1;
-				}
+				TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
+						"Slave Port (%d) ipackets value (%u) not as expected"
+						" (%d)", test_params->slave_port_ids[i],
+						(unsigned int)port_stats.ipackets, burst_size);
 			} else {
-				if (port_stats.ipackets != 0) {
-					printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-							test_params->slave_port_ids[i],
-							(unsigned int)port_stats.ipackets, 0);
-					return -1;
-				}
+				TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
+						"Slave Port (%d) ipackets value (%u) not as expected"
+						" (%d)", test_params->slave_port_ids[i],
+						(unsigned int)port_stats.ipackets, 0);
 			}
 
 			/* Reset bonded slaves stats */
@@ -1614,17 +1457,16 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 	int burst_size[TEST_ROUNDROBIN_TX_BURST_SLAVE_COUNT] = { 15, 13, 36 };
 	int i, nb_rx;
 
-
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
-			0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
+			"Failed to initialize bonded device with slaves");
 
 	/* Generate test bursts of packets to transmit */
 	for (i = 0; i < TEST_ROUNDROBIN_TX_BURST_SLAVE_COUNT; i++) {
-		if (generate_test_burst(&gen_pkt_burst[i][0], burst_size[i], 0, 1, 0, 0,
-				0) != burst_size[i])
-			return -1;
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&gen_pkt_burst[i][0], burst_size[i], 0, 1, 0, 0, 0),
+				burst_size[i], "burst generation failed");
 	}
 
 	/* Add rx data to slaves */
@@ -1635,57 +1477,44 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 
 	/* Call rx burst on bonded device */
 	/* Send burst on bonded port */
-	nb_rx = rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
+	nb_rx = rte_eth_rx_burst( test_params->bonded_port_id, 0, rx_pkt_burst,
 			MAX_PKT_BURST);
-	if (nb_rx != burst_size[0] + burst_size[1] + burst_size[2]) {
-		printf("round-robin rx burst failed (%d != %d)\n", nb_rx,
-				burst_size[0] + burst_size[1] + burst_size[2]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(nb_rx , burst_size[0] + burst_size[1] + burst_size[2],
+			"round-robin rx burst failed (%d != %d)\n", nb_rx,
+			burst_size[0] + burst_size[1] + burst_size[2]);
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size[0] + burst_size[1] +
-			burst_size[2])) {
-		printf("Bonded Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.ipackets,
-				burst_size[0] + burst_size[1] + burst_size[2]);
-		return -1;
-	}
-
+	TEST_ASSERT_EQUAL(port_stats.ipackets,
+			(uint64_t)(burst_size[0] + burst_size[1] + burst_size[2]),
+			"Bonded Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.ipackets,
+			burst_size[0] + burst_size[1] + burst_size[2]);
 
 	/* Verify bonded slave devices rx counts */
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[0]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[0],
-				(unsigned int)port_stats.ipackets, burst_size[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[0],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[0],
+			(unsigned int)port_stats.ipackets, burst_size[0]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[1]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[1],
-				(unsigned int)port_stats.ipackets, burst_size[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[1],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[1], (unsigned int)port_stats.ipackets,
+			burst_size[1]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[2]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[2],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
 				test_params->slave_port_ids[2],
 				(unsigned int)port_stats.ipackets, burst_size[2]);
-		return -1;
-	}
 
 	rte_eth_stats_get(test_params->slave_port_ids[3], &port_stats);
-	if (port_stats.ipackets != 0) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[3],
-				(unsigned int)port_stats.ipackets, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[3],
+			(unsigned int)port_stats.ipackets, 0);
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
@@ -1702,91 +1531,77 @@ test_roundrobin_verify_mac_assignment(void)
 {
 	struct ether_addr read_mac_addr, expected_mac_addr_0, expected_mac_addr_2;
 
-	int i, retval;
+	int i;
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &expected_mac_addr_0);
 	rte_eth_macaddr_get(test_params->slave_port_ids[2], &expected_mac_addr_2);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+				BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
+				"Failed to initialize bonded device with slaves");
 
 	/* Verify that all MACs are the same as first slave added to bonded dev */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(&expected_mac_addr_0, &read_mac_addr,
-				sizeof(read_mac_addr))) {
-			printf("slave port (%d) mac address not set to that of primary port\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"slave port (%d) mac address not set to that of primary port",
+				test_params->slave_port_ids[i]);
 	}
 
 	/* change primary and verify that MAC addresses haven't changed */
-	retval = rte_eth_bond_primary_set(test_params->bonded_port_id,
-			test_params->slave_port_ids[2]);
-	if (retval != 0) {
-		printf("Failed to set bonded port (%d) primary port to (%d)\n",
-				test_params->bonded_port_id, test_params->slave_port_ids[i]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(test_params->bonded_port_id,
+			test_params->slave_port_ids[2]),
+			"Failed to set bonded port (%d) primary port to (%d)",
+			test_params->bonded_port_id, test_params->slave_port_ids[i]);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(&expected_mac_addr_0, &read_mac_addr,
-				sizeof(read_mac_addr))) {
-			printf("slave port (%d) mac address has changed to that of primary port without stop/start toggle of bonded device\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"slave port (%d) mac address has changed to that of primary"
+				" port without stop/start toggle of bonded device",
+				test_params->slave_port_ids[i]);
 	}
 
 	/* stop / start bonded device and verify that primary MAC address is
 	 * propagate to bonded device and slaves */
-
 	rte_eth_dev_stop(test_params->bonded_port_id);
 
-	if (rte_eth_dev_start(test_params->bonded_port_id) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonded_port_id),
+			"Failed to start bonded device");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_2, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of new primary port\n",
-				test_params->slave_port_ids[i]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(
+			memcmp(&expected_mac_addr_2, &read_mac_addr, sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of new primary port",
+			test_params->slave_port_ids[i]);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(&expected_mac_addr_2, &read_mac_addr,
-				sizeof(read_mac_addr))) {
-			printf("slave port (%d) mac address not set to that of new primary port\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_2, &read_mac_addr,
+				sizeof(read_mac_addr)),
+				"slave port (%d) mac address not set to that of new primary"
+				" port", test_params->slave_port_ids[i]);
 	}
 
 	/* Set explicit MAC address */
-	if (rte_eth_bond_mac_address_set(test_params->bonded_port_id,
-			(struct ether_addr *)bonded_mac) != 0) {
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
+			test_params->bonded_port_id, (struct ether_addr *)bonded_mac),
+			"Failed to set MAC");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of new primary port\n",
+	TEST_ASSERT_SUCCESS(memcmp(bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of new primary port",
 				test_params->slave_port_ids[i]);
-		return -1;
-	}
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_macaddr_get(test_params->slave_port_ids[i], &read_mac_addr);
-		if (memcmp(bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-			printf("slave port (%d) mac address not set to that of new primary port\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_SUCCESS(memcmp(bonded_mac, &read_mac_addr,
+				sizeof(read_mac_addr)), "slave port (%d) mac address not set to"
+				"that of new primary port\n", test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -1799,44 +1614,38 @@ test_roundrobin_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
-			0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
+			"Failed to initialize bonded device with slaves");
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
 
 	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 1) {
-		printf("Port (%d) promiscuous mode not enabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(promiscuous_en, 1,
+			"Port (%d) promiscuous mode not enabled",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
-		promiscuous_en = rte_eth_promiscuous_get(test_params->slave_port_ids[i]);
-		if (promiscuous_en != 1) {
-			printf("slave port (%d) promiscuous mode not enabled\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		promiscuous_en = rte_eth_promiscuous_get(
+				test_params->slave_port_ids[i]);
+		TEST_ASSERT_EQUAL(promiscuous_en, 1,
+				"slave port (%d) promiscuous mode not enabled",
+				test_params->slave_port_ids[i]);
 	}
 
 	rte_eth_promiscuous_disable(test_params->bonded_port_id);
 
 	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 0) {
-		printf("Port (%d) promiscuous mode not disabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(promiscuous_en, 0,
+			"Port (%d) promiscuous mode not disabled\n",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
-		promiscuous_en = rte_eth_promiscuous_get(test_params->slave_port_ids[i]);
-		if (promiscuous_en != 0) {
-			printf("slave port (%d) promiscuous mode not disabled\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		promiscuous_en = rte_eth_promiscuous_get(
+				test_params->slave_port_ids[i]);
+		TEST_ASSERT_EQUAL(promiscuous_en, 0,
+				"Port (%d) promiscuous mode not disabled\n",
+				test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -1863,26 +1672,22 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 	/* Initialize bonded device with TEST_RR_LINK_STATUS_SLAVE_COUNT slaves
 	 * in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
-			TEST_RR_LINK_STATUS_SLAVE_COUNT, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, TEST_RR_LINK_STATUS_SLAVE_COUNT, 1),
+			"Failed to initialize bonded device with slaves");
 
 	/* Verify Current Slaves Count /Active Slave Count is */
 	slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id, slaves,
 			RTE_MAX_ETHPORTS);
-	if (slave_count != TEST_RR_LINK_STATUS_SLAVE_COUNT) {
-		printf("Number of slaves (%d) is not as expected (%d).\n", slave_count,
-				TEST_RR_LINK_STATUS_SLAVE_COUNT);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, TEST_RR_LINK_STATUS_SLAVE_COUNT,
+			"Number of slaves (%d) is not as expected (%d).",
+			slave_count, TEST_RR_LINK_STATUS_SLAVE_COUNT);
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != TEST_RR_LINK_STATUS_SLAVE_COUNT) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, TEST_RR_LINK_STATUS_SLAVE_COUNT);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, TEST_RR_LINK_STATUS_SLAVE_COUNT,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, TEST_RR_LINK_STATUS_SLAVE_COUNT);
 
 	/* Set 2 slaves eth_devs link status to down */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -1890,13 +1695,12 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[3], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
-			slaves, RTE_MAX_ETHPORTS) !=
-					TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_SLAVE_COUNT) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_SLAVE_COUNT);
-		return -1;
-	}
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+	TEST_ASSERT_EQUAL(slave_count,
+			TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_SLAVE_COUNT,
+			"Number of active slaves (%d) is not as expected (%d).\n",
+			slave_count, TEST_RR_LINK_STATUS_EXPECTED_ACTIVE_SLAVE_COUNT);
 
 	burst_size = 20;
 
@@ -1907,19 +1711,16 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	 * 3. Verify stats for bonded eth_dev (opackets = burst_size)
 	 * 4. Verify stats for slave eth_devs (s0 = 10, s1 = 0, s2 = 10, s3 = 0)
 	 */
-	if (generate_test_burst(tx_pkt_burst, burst_size, 0, 1, 0, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(
+			generate_test_burst(tx_pkt_burst, burst_size, 0, 1, 0, 0, 0),
+			burst_size, "generate_test_burst failed");
 
 	rte_eth_stats_reset(test_params->bonded_port_id);
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, tx_pkt_burst,
-			burst_size) != burst_size) {
-		printf("rte_eth_tx_burst failed\n");
-		return -1;
-	}
+
+	TEST_ASSERT_EQUAL(
+			rte_eth_tx_burst(test_params->bonded_port_id, 0, tx_pkt_burst,
+			burst_size), burst_size, "rte_eth_tx_burst failed");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
 	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
@@ -1957,27 +1758,24 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	 * 6. Verify stats for slave eth_devs (s0 = 10, s1 = 0, s2 = 10, s3 = 0)
 	 */
 	for (i = 0; i < TEST_RR_LINK_STATUS_SLAVE_COUNT; i++) {
-		if (generate_test_burst(&gen_pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0)
-				!= burst_size) {
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&gen_pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0),
+				burst_size, "failed to generate packet burst");
+
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&gen_pkt_burst[i][0], burst_size);
 	}
 
-	if (rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
-			MAX_PKT_BURST) != burst_size + burst_size) {
-		printf("rte_eth_rx_burst\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_rx_burst(
+			test_params->bonded_port_id, 0, rx_pkt_burst, MAX_PKT_BURST),
+			burst_size + burst_size,
+			"rte_eth_rx_burst failed");
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.ipackets not as expected\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets , (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.ipackets not as expected\n",
+			test_params->bonded_port_id);
 
 	/* free mbufs */
 	for (i = 0; i < MAX_PKT_BURST; i++) {
@@ -1999,7 +1797,6 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 uint8_t polling_slave_mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00 };
 
-#include "unistd.h"
 
 int polling_test_slaves[TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT] = { -1, -1 } ;
 
@@ -2033,7 +1830,8 @@ test_roundrobin_verfiy_polling_slave_link_status_change(void)
 		TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
 				polling_test_slaves[i]),
 				"Failed to add slave %s(%d) to bonded device %d",
-				slave_name, polling_test_slaves[i], test_params->bonded_port_id);
+				slave_name, polling_test_slaves[i],
+				test_params->bonded_port_id);
 	}
 
 	/* Initialize bonded device */
@@ -2095,15 +1893,13 @@ test_roundrobin_verfiy_polling_slave_link_status_change(void)
 static int
 test_activebackup_tx_burst(void)
 {
-	int i, retval, pktlen, primary_port, burst_size, generated_burst_size, nb_tx;
+	int i, pktlen, primary_port, burst_size;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1);
-	if (retval != 0) {
-		printf("Failed to initialize_bonded_device_with_slaves.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0, 1, 1),
+			"Failed to initialize bonded device with slaves");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
@@ -2114,32 +1910,25 @@ test_activebackup_tx_burst(void)
 
 	burst_size = 20 * test_params->bonded_slave_count;
 
-	if (burst_size > MAX_PKT_BURST) {
-		printf("Burst size specified is greater than supported.\n");
-		return -1;
-	}
+	TEST_ASSERT(burst_size < MAX_PKT_BURST,
+			"Burst size specified is greater than supported.");
 
 	/* Generate a burst of packets to transmit */
-	generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
-			pkts_burst,	test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr,
-			1, test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN, 1);
-	if (generated_burst_size != burst_size)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool, pkts_burst,
+			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
+			test_params->pkt_udp_hdr, burst_size, PACKET_BURST_GEN_PKT_LEN, 1),
+			burst_size,	"failed to generate burst correctly");
 
 	/* Send burst on bonded port */
-	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
-			burst_size);
-	if (nb_tx != burst_size)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
+			burst_size),  burst_size, "tx burst failed");
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			burst_size);
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
 
@@ -2147,35 +1936,28 @@ test_activebackup_tx_burst(void)
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		rte_eth_stats_get(test_params->slave_port_ids[i], &port_stats);
 		if (test_params->slave_port_ids[i] == primary_port) {
-			if (port_stats.opackets != (uint64_t)burst_size) {
-				printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-						test_params->bonded_port_id,
-						(unsigned int)port_stats.opackets,
-						burst_size / test_params->bonded_slave_count);
-				return -1;
-			}
+			TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+					"Slave Port (%d) opackets value (%u) not as expected (%d)",
+					test_params->bonded_port_id,
+					(unsigned int)port_stats.opackets,
+					burst_size / test_params->bonded_slave_count);
 		} else {
-			if (port_stats.opackets != 0) {
-				printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-						test_params->bonded_port_id,
-						(unsigned int)port_stats.opackets, 0);
-				return -1;
-			}
+			TEST_ASSERT_EQUAL(port_stats.opackets, 0,
+					"Slave Port (%d) opackets value (%u) not as expected (%d)",
+					test_params->bonded_port_id,
+					(unsigned int)port_stats.opackets, 0);
 		}
 	}
 
 	/* Put all slaves down and try and transmit */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
-
 		virtual_ethdev_simulate_link_status_interrupt(
 				test_params->slave_port_ids[i], 0);
 	}
 
 	/* Send burst on bonded port */
-	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
-			burst_size);
-	if (nb_tx != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+			pkts_burst, burst_size), 0, "Sending empty burst failed");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -2193,78 +1975,63 @@ test_activebackup_rx_burst(void)
 
 	int primary_port;
 
-	int i, j, nb_rx, burst_size = 17;
-
-	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
-			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
-			!= 0)
-		return -1;
+	int i, j, burst_size = 17;
 
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0,
+			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1),
+			"Failed to initialize bonded device with slaves");
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (primary_port < 0) {
-		printf("failed to get primary slave for bonded port (%d)",
-				test_params->bonded_port_id);
-	}
+	TEST_ASSERT(primary_port >= 0,
+			"failed to get primary slave for bonded port (%d)",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		/* Generate test bursts of packets to transmit */
-		if (generate_test_burst(&gen_pkt_burst[0], burst_size, 0, 1, 0, 0, 0)
-				!= burst_size) {
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&gen_pkt_burst[0], burst_size, 0, 1, 0, 0, 0),
+				burst_size, "burst generation failed");
 
 		/* Add rx data to slave */
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&gen_pkt_burst[0], burst_size);
 
 		/* Call rx burst on bonded device */
-		nb_rx = rte_eth_rx_burst(test_params->bonded_port_id, 0,
-				&rx_pkt_burst[0], MAX_PKT_BURST);
-		if (nb_rx < 0) {
-			printf("rte_eth_rx_burst failed\n");
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(rte_eth_rx_burst(test_params->bonded_port_id, 0,
+				&rx_pkt_burst[0], MAX_PKT_BURST), burst_size,
+				"rte_eth_rx_burst failed");
 
 		if (test_params->slave_port_ids[i] == primary_port) {
 			/* Verify bonded device rx count */
 			rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-			if (port_stats.ipackets != (uint64_t)burst_size) {
-				printf("Bonded Port (%d) ipackets value (%u) not as expected (%d)\n",
-						test_params->bonded_port_id,
-						(unsigned int)port_stats.ipackets, burst_size);
-				return -1;
-			}
+			TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
+					"Bonded Port (%d) ipackets value (%u) not as expected (%d)",
+					test_params->bonded_port_id,
+					(unsigned int)port_stats.ipackets, burst_size);
 
 			/* Verify bonded slave devices rx count */
 			for (j = 0; j < test_params->bonded_slave_count; j++) {
 				rte_eth_stats_get(test_params->slave_port_ids[j], &port_stats);
 				if (i == j) {
-					if (port_stats.ipackets != (uint64_t)burst_size) {
-						printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-								test_params->slave_port_ids[i],
-								(unsigned int)port_stats.ipackets, burst_size);
-						return -1;
-					}
+					TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
+							"Slave Port (%d) ipackets value (%u) not as "
+							"expected (%d)", test_params->slave_port_ids[i],
+							(unsigned int)port_stats.ipackets, burst_size);
 				} else {
-					if (port_stats.ipackets != 0) {
-						printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-								test_params->slave_port_ids[i],
-								(unsigned int)port_stats.ipackets, 0);
-						return -1;
-					}
+					TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
+							"Slave Port (%d) ipackets value (%u) not as "
+							"expected (%d)\n", test_params->slave_port_ids[i],
+							(unsigned int)port_stats.ipackets, 0);
 				}
 			}
 		} else {
 			for (j = 0; j < test_params->bonded_slave_count; j++) {
 				rte_eth_stats_get(test_params->slave_port_ids[j], &port_stats);
-				if (port_stats.ipackets != 0) {
-					printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-							test_params->slave_port_ids[i],
-							(unsigned int)port_stats.ipackets, 0);
-					return -1;
-				}
+				TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
+						"Slave Port (%d) ipackets value (%u) not as expected "
+						"(%d)", test_params->slave_port_ids[i],
+						(unsigned int)port_stats.ipackets, 0);
 			}
 		}
 
@@ -2290,61 +2057,48 @@ test_activebackup_verify_promiscuous_enable_disable(void)
 	int i, primary_port, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 4, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0, 4, 1),
+			"Failed to initialize bonded device with slaves");
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (primary_port < 0) {
-		printf("failed to get primary slave for bonded port (%d)",
-				test_params->bonded_port_id);
-	}
+	TEST_ASSERT(primary_port >= 0,
+			"failed to get primary slave for bonded port (%d)",
+			test_params->bonded_port_id);
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
 
-	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 1) {
-		printf("Port (%d) promiscuous mode not enabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 1,
+			"Port (%d) promiscuous mode not enabled",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		promiscuous_en = rte_eth_promiscuous_get(
 				test_params->slave_port_ids[i]);
 		if (primary_port == test_params->slave_port_ids[i]) {
-			if (promiscuous_en != 1) {
-				printf("slave port (%d) promiscuous mode not enabled\n",
-						test_params->slave_port_ids[i]);
-				return -1;
-			}
+			TEST_ASSERT_EQUAL(promiscuous_en, 1,
+					"slave port (%d) promiscuous mode not enabled",
+					test_params->slave_port_ids[i]);
 		} else {
-			if (promiscuous_en != 0) {
-				printf("slave port (%d) promiscuous mode enabled\n",
-						test_params->slave_port_ids[i]);
-				return -1;
-			}
+			TEST_ASSERT_EQUAL(promiscuous_en, 0,
+					"slave port (%d) promiscuous mode enabled",
+					test_params->slave_port_ids[i]);
 		}
 
 	}
 
 	rte_eth_promiscuous_disable(test_params->bonded_port_id);
 
-	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 0) {
-		printf("Port (%d) promiscuous mode not disabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 0,
+			"Port (%d) promiscuous mode not disabled\n",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		promiscuous_en = rte_eth_promiscuous_get(
 				test_params->slave_port_ids[i]);
-		if (promiscuous_en != 0) {
-			printf("slave port (%d) promiscuous mode not disabled\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(promiscuous_en, 0,
+				"slave port (%d) promiscuous mode not disabled\n",
+				test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -2360,117 +2114,102 @@ test_activebackup_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1),
+			"Failed to initialize bonded device with slaves");
 
 	/* Verify that bonded MACs is that of first slave and that the other slave
 	 * MAC hasn't been changed */
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not as expected\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not as expected",
+			test_params->slave_port_ids[1]);
 
 	/* change primary and verify that MAC addresses haven't changed */
-	if (rte_eth_bond_primary_set(test_params->bonded_port_id,
-			test_params->slave_port_ids[1]) != 0) {
-		printf("Failed to set bonded port (%d) primary port to (%d)\n",
-				test_params->bonded_port_id, test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_primary_set(test_params->bonded_port_id,
+			test_params->slave_port_ids[1]), 0,
+			"Failed to set bonded port (%d) primary port to (%d)",
+			test_params->bonded_port_id, test_params->slave_port_ids[1]);
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not as expected\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not as expected",
+			test_params->slave_port_ids[1]);
 
 	/* stop / start bonded device and verify that primary MAC address is
 	 * propagated to bonded device and slaves */
 
 	rte_eth_dev_stop(test_params->bonded_port_id);
 
-	if (rte_eth_dev_start(test_params->bonded_port_id) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonded_port_id),
+			"Failed to start device");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not as expected",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[1]);
 
 	/* Set explicit MAC address */
-	if (rte_eth_bond_mac_address_set(test_params->bonded_port_id,
-			(struct ether_addr *)bonded_mac) != 0) {
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
+			test_params->bonded_port_id, (struct ether_addr *)bonded_mac),
+			"failed to set MAC addres");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of bonded port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of bonded port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not as expected",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of bonded port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of bonded port",
+			test_params->slave_port_ids[1]);
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -2492,38 +2231,32 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Generate packet burst for testing */
-	if (generate_test_burst(&pkt_burst[0][0], burst_size, 0, 1, 0, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[0][0], burst_size, 0, 1, 0, 0, 0), burst_size,
+			"generate_test_burst failed");
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
-			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0,
+			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1),
+			"Failed to initialize bonded device with slaves");
 
 	/* Verify Current Slaves Count /Active Slave Count is */
 	slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id, slaves,
 			RTE_MAX_ETHPORTS);
-	if (slave_count != 4) {
-		printf("Number of slaves (%d) is not as expected (%d).\n",
-				slave_count, 4);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, 4,
+			"Number of slaves (%d) is not as expected (%d).",
+			slave_count, 4);
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != 4) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 4);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, 4,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 4);
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (primary_port != test_params->slave_port_ids[0])
-		printf("Primary port not as expected");
+	TEST_ASSERT_EQUAL(primary_port, test_params->slave_port_ids[0],
+			"Primary port not as expected");
 
 	/* Bring 2 slaves down and verify active slave count */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -2531,12 +2264,10 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[3], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id, slaves,
-			RTE_MAX_ETHPORTS) != 2) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_active_slaves_get(
+			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS), 2,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 2);
 
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[1], 1);
@@ -2549,103 +2280,81 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[0], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id, slaves,
-			RTE_MAX_ETHPORTS) != 3) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 3);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_active_slaves_get(
+			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS), 3,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 3);
 
 	primary_port = rte_eth_bond_primary_get(test_params->bonded_port_id);
-	if (primary_port != test_params->slave_port_ids[2])
-		printf("Primary port not as expected");
+	TEST_ASSERT_EQUAL(primary_port, test_params->slave_port_ids[2],
+			"Primary port not as expected");
 
 	/* Verify that pkts are sent on new primary slave */
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[0][0], burst_size)
-			!= burst_size) {
-		printf("rte_eth_tx_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, &pkt_burst[0][0], burst_size),
+			burst_size,"rte_eth_tx_burst failed");
 
 	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[2]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets not as expected",
+			test_params->slave_port_ids[2]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected\n",
+			test_params->slave_port_ids[0]);
+
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected\n",
+			test_params->slave_port_ids[1]);
+
 	rte_eth_stats_get(test_params->slave_port_ids[3], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[3]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected\n",
+			test_params->slave_port_ids[3]);
 
 	/* Generate packet burst for testing */
 
 	for (i = 0; i < TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT; i++) {
-		if (generate_test_burst(&pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0) !=
-				burst_size)
-			return -1;
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&pkt_burst[i][0], burst_size, 0, 1, 0, 0, 0), burst_size,
+				"generate_test_burst failed");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(
 			test_params->slave_port_ids[i], &pkt_burst[i][0], burst_size);
 	}
 
-	if (rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
-			MAX_PKT_BURST) != burst_size) {
-		printf("rte_eth_rx_burst\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_rx_burst(
+			test_params->bonded_port_id, 0, rx_pkt_burst, MAX_PKT_BURST),
+			burst_size, "rte_eth_rx_burst\n");
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.ipackets not as expected\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
+			"(%d) port_stats.ipackets not as expected",
+			test_params->bonded_port_id);
 
 	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[2]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets not as expected",
+			test_params->slave_port_ids[2]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL (port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL (port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
+			test_params->slave_port_ids[1]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[3], &port_stats);
-	if (port_stats.opackets != 0) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[3]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL (port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
+			test_params->slave_port_ids[3]);
 
 	/* free mbufs */
 
@@ -2658,7 +2367,6 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 		}
 	}
 
-
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
 }
@@ -2668,70 +2376,49 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 static int
 test_balance_xmit_policy_configuration(void)
 {
-	int retval;
-
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
-			2, 1);
-	if (retval != 0) {
-		printf("Failed to initialize_bonded_device_with_slaves.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1),
+			"Failed to initialize_bonded_device_with_slaves.");
 
 	/* Invalid port id */
-	retval = rte_eth_bond_xmit_policy_set(INVALID_PORT_ID,
-			BALANCE_XMIT_POLICY_LAYER2);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_xmit_policy_set(
+			INVALID_PORT_ID, BALANCE_XMIT_POLICY_LAYER2),
+			"Expected call to failed as invalid port specified.");
 
 	/* Set xmit policy on non bonded device */
-	retval = rte_eth_bond_xmit_policy_set(test_params->slave_port_ids[0],
-			BALANCE_XMIT_POLICY_LAYER2);
-	if (retval == 0) {
-		printf("Expected call to failed as invalid port specified.\n");
-		return -1;
-	}
+	TEST_ASSERT_FAIL(rte_eth_bond_xmit_policy_set(
+			test_params->slave_port_ids[0],	BALANCE_XMIT_POLICY_LAYER2),
+			"Expected call to failed as invalid port specified.");
 
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER2);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
-	if (rte_eth_bond_xmit_policy_get(test_params->bonded_port_id) !=
-			BALANCE_XMIT_POLICY_LAYER2) {
-		printf("balance xmit policy not as expected.\n");
-		return -1;
-	}
 
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER23);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
-	if (rte_eth_bond_xmit_policy_get(test_params->bonded_port_id) !=
-			BALANCE_XMIT_POLICY_LAYER23) {
-		printf("balance xmit policy not as expected.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER2),
+			"Failed to set balance xmit policy.");
 
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER34);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
-	if (rte_eth_bond_xmit_policy_get(test_params->bonded_port_id) !=
-			BALANCE_XMIT_POLICY_LAYER34) {
-		printf("balance xmit policy not as expected.\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_xmit_policy_get(test_params->bonded_port_id),
+			BALANCE_XMIT_POLICY_LAYER2, "balance xmit policy not as expected.");
+
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER23),
+			"Failed to set balance xmit policy.");
+
+	TEST_ASSERT_EQUAL(rte_eth_bond_xmit_policy_get(test_params->bonded_port_id),
+			BALANCE_XMIT_POLICY_LAYER23,
+			"balance xmit policy not as expected.");
+
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER34),
+			"Failed to set balance xmit policy.");
+
+	TEST_ASSERT_EQUAL(rte_eth_bond_xmit_policy_get(test_params->bonded_port_id),
+			BALANCE_XMIT_POLICY_LAYER34,
+			"balance xmit policy not as expected.");
 
 	/* Invalid port id */
-	if (rte_eth_bond_xmit_policy_get(INVALID_PORT_ID) >= 0)
-		return -1;
+	TEST_ASSERT_FAIL(rte_eth_bond_xmit_policy_get(INVALID_PORT_ID),
+			"Expected call to failed as invalid port specified.");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -2746,24 +2433,16 @@ test_balance_l2_tx_burst(void)
 	int burst_size[TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT] = { 10, 15 };
 
 	uint16_t pktlen;
-
-	int retval, i;
+	int i;
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
-			TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT, 1);
-	if (retval != 0) {
-		printf("Failed to initialize_bonded_device_with_slaves.\n");
-		return -1;
-	}
-
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER2);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT, 1),
+			"Failed to initialize_bonded_device_with_slaves.");
 
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER2),
+			"Failed to set balance xmit policy.");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
@@ -2773,54 +2452,50 @@ test_balance_l2_tx_burst(void)
 			dst_addr_0, pktlen);
 
 	/* Generate a burst 1 of packets to transmit */
-	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
+	TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
 			test_params->pkt_udp_hdr, burst_size[0],
-			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[0])
-		return -1;
+			PACKET_BURST_GEN_PKT_LEN, 1), burst_size[0],
+			"failed to generate packet burst");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_1, 0, 0);
 
 	/* Generate a burst 2 of packets to transmit */
-	if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
+	TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
 			test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1,
 			test_params->pkt_udp_hdr, burst_size[1],
-			PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1])
-		return -1;
+			PACKET_BURST_GEN_PKT_LEN, 1), burst_size[1],
+			"failed to generate packet burst");
 
 	/* Send burst 1 on bonded port */
 	for (i = 0; i < TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT; i++) {
-		if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkts_burst[i][0],
-			burst_size[i]) != burst_size[i])
-			return -1;
+		TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+				&pkts_burst[i][0], burst_size[i]),
+				burst_size[i], "Failed to transmit packet burst");
 	}
+
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size[0] + burst_size[1])) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id,
-				(unsigned int)port_stats.opackets, burst_size[0] + burst_size[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)(burst_size[0] + burst_size[1]),
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			burst_size[0] + burst_size[1]);
 
 
 	/* Verify slave ports tx stats */
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size[0]) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[0],
-				(unsigned int)port_stats.opackets, burst_size[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size[0],
+			"Slave Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[0], (unsigned int)port_stats.opackets,
+			burst_size[0]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size[1]) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[1], (
-						unsigned int)port_stats.opackets, burst_size[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size[1],
+			"Slave Port (%d) opackets value (%u) not as expected (%d)\n",
+			test_params->slave_port_ids[1], (unsigned int)port_stats.opackets,
+			burst_size[1]);
 
 	/* Put all slaves down and try and transmit */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
@@ -2830,9 +2505,9 @@ test_balance_l2_tx_burst(void)
 	}
 
 	/* Send burst on bonded port */
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkts_burst[0][0],
-			burst_size[0]) != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, &pkts_burst[0][0], burst_size[0]),
+			0, "Expected zero packet");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -2842,81 +2517,65 @@ static int
 balance_l23_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 		uint8_t toggle_mac_addr, uint8_t toggle_ip_addr)
 {
-	int retval, i;
-	int burst_size_1, burst_size_2, nb_tx_1, nb_tx_2;
+	int i, burst_size_1, burst_size_2, nb_tx_1, nb_tx_2;
 
 	struct rte_mbuf *pkts_burst_1[MAX_PKT_BURST];
 	struct rte_mbuf *pkts_burst_2[MAX_PKT_BURST];
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
-	if (retval != 0) {
-		printf("Failed to initialize_bonded_device_with_slaves.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, 2, 1),
+			"Failed to initialize_bonded_device_with_slaves.");
 
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER23);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER23),
+			"Failed to set balance xmit policy.");
 
 	burst_size_1 = 20;
 	burst_size_2 = 10;
 
-	if (burst_size_1 > MAX_PKT_BURST || burst_size_2 > MAX_PKT_BURST) {
-		printf("Burst size specified is greater than supported.\n");
-		return -1;
-	}
+	TEST_ASSERT(burst_size_1 < MAX_PKT_BURST || burst_size_2 < MAX_PKT_BURST,
+			"Burst size specified is greater than supported.");
 
 	/* Generate test bursts of packets to transmit */
-	if (generate_test_burst(pkts_burst_1, burst_size_1, vlan_enabled, ipv4,
-			0, 0, 0) != burst_size_1)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			pkts_burst_1, burst_size_1, vlan_enabled, ipv4, 0, 0, 0),
+			burst_size_1, "failed to generate packet burst");
 
-	if (generate_test_burst(pkts_burst_2, burst_size_2, vlan_enabled, ipv4,
-			toggle_mac_addr, toggle_ip_addr, 0) != burst_size_2)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2, burst_size_2, vlan_enabled, ipv4,
+			toggle_mac_addr, toggle_ip_addr, 0), burst_size_2,
+			"failed to generate packet burst");
 
 	/* Send burst 1 on bonded port */
 	nb_tx_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
 			burst_size_1);
-	if (nb_tx_1 != burst_size_1)
-		return -1;
+	TEST_ASSERT_EQUAL(nb_tx_1, burst_size_1, "tx burst failed");
 
 	/* Send burst 2 on bonded port */
 	nb_tx_2 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_2,
 			burst_size_2);
-	if (nb_tx_2 != burst_size_2)
-		return -1;
+	TEST_ASSERT_EQUAL(nb_tx_2, burst_size_2, "tx burst failed");
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(nb_tx_1 + nb_tx_2)) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id,
-				(unsigned int)port_stats.opackets, nb_tx_1 + nb_tx_2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(nb_tx_1 + nb_tx_2),
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			nb_tx_1 + nb_tx_2);
 
 	/* Verify slave ports tx stats */
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)nb_tx_1) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[0],
-				(unsigned int)port_stats.opackets, nb_tx_1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)nb_tx_1,
+			"Slave Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[0], (unsigned int)port_stats.opackets,
+			nb_tx_1);
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.opackets != (uint64_t)nb_tx_2) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[1],
-				(unsigned int)port_stats.opackets, nb_tx_2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,(uint64_t)nb_tx_2,
+			"Slave Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[1], (unsigned int)port_stats.opackets,
+			nb_tx_2);
 
 	/* Put all slaves down and try and transmit */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
@@ -2926,10 +2585,10 @@ balance_l23_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 	}
 
 	/* Send burst on bonded port */
-	nb_tx_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
-			burst_size_1);
-	if (nb_tx_1 != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkts_burst_1,
+			burst_size_1), 0, "Expected zero packet");
+
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -2970,82 +2629,66 @@ balance_l34_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 		uint8_t toggle_mac_addr, uint8_t toggle_ip_addr,
 		uint8_t toggle_udp_port)
 {
-	int retval, i;
-	int burst_size_1, burst_size_2, nb_tx_1, nb_tx_2;
+	int i, burst_size_1, burst_size_2, nb_tx_1, nb_tx_2;
 
 	struct rte_mbuf *pkts_burst_1[MAX_PKT_BURST];
 	struct rte_mbuf *pkts_burst_2[MAX_PKT_BURST];
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
-	if (retval != 0) {
-		printf("Failed to initialize_bonded_device_with_slaves.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, 2, 1),
+			"Failed to initialize_bonded_device_with_slaves.");
 
-	retval = rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER34);
-	if (retval != 0) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER34),
+			"Failed to set balance xmit policy.");
 
 	burst_size_1 = 20;
 	burst_size_2 = 10;
 
-	if (burst_size_1 > MAX_PKT_BURST || burst_size_2 > MAX_PKT_BURST) {
-		printf("Burst size specified is greater than supported.\n");
-		return -1;
-	}
+	TEST_ASSERT(burst_size_1 < MAX_PKT_BURST || burst_size_2 < MAX_PKT_BURST,
+			"Burst size specified is greater than supported.");
 
 	/* Generate test bursts of packets to transmit */
-	if (generate_test_burst(pkts_burst_1, burst_size_1, vlan_enabled, ipv4, 0,
-			0, 0) != burst_size_1)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			pkts_burst_1, burst_size_1, vlan_enabled, ipv4, 0, 0, 0),
+			burst_size_1, "failed to generate burst");
 
-	if (generate_test_burst(pkts_burst_2, burst_size_2, vlan_enabled, ipv4,
-			toggle_mac_addr, toggle_ip_addr, toggle_udp_port) != burst_size_2)
-		return -1;
+	TEST_ASSERT_EQUAL(generate_test_burst(pkts_burst_2, burst_size_2,
+			vlan_enabled, ipv4, toggle_mac_addr, toggle_ip_addr,
+			toggle_udp_port), burst_size_2, "failed to generate burst");
 
 	/* Send burst 1 on bonded port */
 	nb_tx_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
 			burst_size_1);
-	if (nb_tx_1 != burst_size_1)
-		return -1;
+	TEST_ASSERT_EQUAL(nb_tx_1, burst_size_1, "tx burst failed");
 
 	/* Send burst 2 on bonded port */
 	nb_tx_2 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_2,
 			burst_size_2);
-	if (nb_tx_2 != burst_size_2)
-		return -1;
+	TEST_ASSERT_EQUAL(nb_tx_2, burst_size_2, "tx burst failed");
 
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(nb_tx_1 + nb_tx_2)) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id,
-				(unsigned int)port_stats.opackets, nb_tx_1 + nb_tx_2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(nb_tx_1 + nb_tx_2),
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.opackets,
+			nb_tx_1 + nb_tx_2);
 
 	/* Verify slave ports tx stats */
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)nb_tx_1) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[0],
-				(unsigned int)port_stats.opackets, nb_tx_1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)nb_tx_1,
+			"Slave Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[0], (unsigned int)port_stats.opackets,
+			nb_tx_1);
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.opackets != (uint64_t)nb_tx_2) {
-		printf("Slave Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[1],
-				(unsigned int)port_stats.opackets, nb_tx_2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)nb_tx_2,
+			"Slave Port (%d) opackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[1], (unsigned int)port_stats.opackets,
+			nb_tx_2);
 
 	/* Put all slaves down and try and transmit */
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
@@ -3055,10 +2698,9 @@ balance_l34_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 	}
 
 	/* Send burst on bonded port */
-	nb_tx_1 = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst_1,
-			burst_size_1);
-	if (nb_tx_1 != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkts_burst_1,
+			burst_size_1), 0, "Expected zero packet");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -3246,21 +2888,22 @@ test_balance_rx_burst(void)
 	struct rte_eth_stats port_stats;
 
 	int burst_size[TEST_BALANCE_RX_BURST_SLAVE_COUNT] = { 10, 5, 30 };
-	int i, j, nb_rx;
+	int i, j;
 
 	memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 3, 1)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, 3, 1),
+			"Failed to intialise bonded device");
 
 	/* Generate test bursts of packets to transmit */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
-		if (generate_test_burst(&gen_pkt_burst[i][0], burst_size[i], 0, 0, 1,
-				0, 0) != burst_size[i])
-			return -1;
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&gen_pkt_burst[i][0], burst_size[i], 0, 0, 1, 0, 0),
+				burst_size[i],"failed to generate packet burst");
 	}
+
 	/* Add rx data to slaves */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
@@ -3269,56 +2912,44 @@ test_balance_rx_burst(void)
 
 	/* Call rx burst on bonded device */
 	/* Send burst on bonded port */
-	nb_rx = rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
-			MAX_PKT_BURST);
-	if (nb_rx != burst_size[0] + burst_size[1] + burst_size[2]) {
-		printf("balance rx burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_rx_burst(test_params->bonded_port_id, 0,
+			rx_pkt_burst, MAX_PKT_BURST),
+			burst_size[0] + burst_size[1] + burst_size[2],
+			"balance rx burst failed\n");
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size[0] + burst_size[1] +
-			burst_size[2])) {
-		printf("Bonded Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.ipackets,
-				burst_size[0] + burst_size[1] + burst_size[2]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets,
+			(uint64_t)(burst_size[0] + burst_size[1] + burst_size[2]),
+			"Bonded Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->bonded_port_id, (unsigned int)port_stats.ipackets,
+			burst_size[0] + burst_size[1] + burst_size[2]);
 
 
 	/* Verify bonded slave devices rx counts */
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[0]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[0],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
 				test_params->slave_port_ids[0],
 				(unsigned int)port_stats.ipackets, burst_size[0]);
-		return -1;
-	}
 
 	rte_eth_stats_get(test_params->slave_port_ids[1], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[1]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[1],
-				(unsigned int)port_stats.ipackets, burst_size[1]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[1],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[1], (unsigned int)port_stats.ipackets,
+			burst_size[1]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[2], &port_stats);
-	if (port_stats.ipackets != (uint64_t)burst_size[2]) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[2],
-				(unsigned int)port_stats.ipackets, burst_size[2]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size[2],
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[2], (unsigned int)port_stats.ipackets,
+			burst_size[2]);
 
 	rte_eth_stats_get(test_params->slave_port_ids[3], &port_stats);
-	if (port_stats.ipackets != 0) {
-		printf("Slave Port (%d) ipackets value (%u) not as expected (%d)\n",
-				test_params->slave_port_ids[3],
-				(unsigned int)port_stats.ipackets, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
+			"Slave Port (%d) ipackets value (%u) not as expected (%d)",
+			test_params->slave_port_ids[3],	(unsigned int)port_stats.ipackets,
+			0);
 
 	/* free mbufs */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
@@ -3337,48 +2968,37 @@ test_balance_rx_burst(void)
 static int
 test_balance_verify_promiscuous_enable_disable(void)
 {
-	int i, promiscuous_en;
+	int i;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, 4, 1),
+			"Failed to intialise bonded device");
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
 
-	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 1) {
-		printf("Port (%d) promiscuous mode not enabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 1,
+			"Port (%d) promiscuous mode not enabled",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
-		promiscuous_en = rte_eth_promiscuous_get(
+		TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(
+				test_params->slave_port_ids[i]), 1,
+				"Port (%d) promiscuous mode not enabled",
 				test_params->slave_port_ids[i]);
-		if (promiscuous_en != 1) {
-			printf("slave port (%d) promiscuous mode not enabled\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
 	}
 
 	rte_eth_promiscuous_disable(test_params->bonded_port_id);
 
-	promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
-	if (promiscuous_en != 0) {
-		printf("Port (%d) promiscuous mode not disabled\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 0,
+			"Port (%d) promiscuous mode not disabled",
+			test_params->bonded_port_id);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
-		promiscuous_en = rte_eth_promiscuous_get(
+		TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(
+				test_params->slave_port_ids[i]), 0,
+				"Port (%d) promiscuous mode not disabled",
 				test_params->slave_port_ids[i]);
-		if (promiscuous_en != 0) {
-			printf("slave port (%d) promiscuous mode not disabled\n",
-					test_params->slave_port_ids[i]);
-			return -1;
-		}
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -3394,115 +3014,102 @@ test_balance_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, 2, 1),
+			"Failed to intialise bonded device");
 
 	/* Verify that bonded MACs is that of first slave and that the other slave
 	 * MAC hasn't been changed */
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[1]);
 
 	/* change primary and verify that MAC addresses haven't changed */
-	if (rte_eth_bond_primary_set(test_params->bonded_port_id,
-			test_params->slave_port_ids[1]) != 0) {
-		printf("Failed to set bonded port (%d) primary port to (%d)\n",
-				test_params->bonded_port_id, test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_primary_set(test_params->bonded_port_id,
+			test_params->slave_port_ids[1]),
+			"Failed to set bonded port (%d) primary port to (%d)\n",
+			test_params->bonded_port_id, test_params->slave_port_ids[1]);
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_0, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_0, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[1]);
 
 	/* stop / start bonded device and verify that primary MAC address is
 	 * propagated to bonded device and slaves */
 
 	rte_eth_dev_stop(test_params->bonded_port_id);
 
-	if (rte_eth_dev_start(test_params->bonded_port_id) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params->bonded_port_id),
+			"Failed to start bonded device");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of primary port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of primary port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[0]);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&expected_mac_addr_1, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of primary port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&expected_mac_addr_1, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of primary port",
+			test_params->slave_port_ids[1]);
 
 	/* Set explicit MAC address */
-	if (rte_eth_bond_mac_address_set(test_params->bonded_port_id,
-			(struct ether_addr *)bonded_mac) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
+			test_params->bonded_port_id, (struct ether_addr *)bonded_mac),
+			"failed to set MAC");
 
 	rte_eth_macaddr_get(test_params->bonded_port_id, &read_mac_addr);
-	if (memcmp(&bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("bonded port (%d) mac address not set to that of bonded port\n",
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"bonded port (%d) mac address not set to that of bonded port",
+			test_params->bonded_port_id);
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[0], &read_mac_addr);
-	if (memcmp(&bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not as expected\n",
+	TEST_ASSERT_SUCCESS(memcmp(&bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not as expected\n",
 				test_params->slave_port_ids[0]);
-		return -1;
-	}
 
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &read_mac_addr);
-	if (memcmp(&bonded_mac, &read_mac_addr, sizeof(read_mac_addr))) {
-		printf("slave port (%d) mac address not set to that of bonded port\n",
-				test_params->slave_port_ids[1]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(memcmp(&bonded_mac, &read_mac_addr,
+			sizeof(read_mac_addr)),
+			"slave port (%d) mac address not set to that of bonded port",
+			test_params->slave_port_ids[1]);
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -3524,32 +3131,27 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
-			TEST_BALANCE_LINK_STATUS_SLAVE_COUNT, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BALANCE, 0, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT, 1),
+			"Failed to intialise bonded device");
+
+	TEST_ASSERT_SUCCESS(rte_eth_bond_xmit_policy_set(
+			test_params->bonded_port_id, BALANCE_XMIT_POLICY_LAYER2),
+			"Failed to set balance xmit policy.");
 
-	if (rte_eth_bond_xmit_policy_set(test_params->bonded_port_id,
-			BALANCE_XMIT_POLICY_LAYER2)) {
-		printf("Failed to set balance xmit policy.\n");
-		return -1;
-	}
 
 	/* Verify Current Slaves Count /Active Slave Count is */
 	slave_count = rte_eth_bond_slaves_get(test_params->bonded_port_id, slaves,
 			RTE_MAX_ETHPORTS);
-	if (slave_count != TEST_BALANCE_LINK_STATUS_SLAVE_COUNT) {
-		printf("Number of slaves (%d) is not as expected (%d).\n", slave_count,
-				TEST_BALANCE_LINK_STATUS_SLAVE_COUNT);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT,
+			"Number of slaves (%d) is not as expected (%d).",
+			slave_count, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT);
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != TEST_BALANCE_LINK_STATUS_SLAVE_COUNT) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, TEST_BALANCE_LINK_STATUS_SLAVE_COUNT);
 
 	/* Set 2 slaves link status to down */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -3557,106 +3159,80 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[3], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
-			slaves, RTE_MAX_ETHPORTS) != 2) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 2);
-		return -1;
-	}
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.12.2

Part of the diff is not shown here. View the raw message.

Tested-by
#52 lore raw
In reply to a message not in the archive

This patch has been verified on FC20 with Niantic. The test environment detail information as the following:

CPU: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
OS: Linux 3.11.10-301.fc20.x86_64
GCC: 4.8.2
NIC: Niantic.

Quoted 68 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Tuesday, September 30, 2014 5:58 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v4 0/8] link bonding

v4:
- Rebased to account for changes in master.
- Fix for rte_eth_bond_slaves_get() introduced in v3 patch set
- Addressed issue around disabling/enabling link status polling around adding/
removing slaves devices.

v3 :
- Typo fix for the bond free mbufs patch.
- Rebased to account for changes in the mbuf patches.
- Add support for slave devices which don't support link status interrupts
- Tidy up the link bonding unit test so that all tests use the new test macros.

v2 :
Addresses issues with the logic around the handling of fail transmissions.
In this version all modes behave in a manner similar to a standard PMD, returning the number of successfully transmitted mbufs and with the failing
mbufs at the end of bufs array for freeing / retransmission by the application software

v1:

This patch set adds support for link status interrupt in the link bonding
pmd. It also contains some patches to tidy up the code structure and to of the link bonding code and to fix bugs relating to transmission failures in the under lying slave pmd which could lead to leaked mbufs.

Declan Doherty (8):
bond: link status interrupt support
bond: removing switch statement from rx burst method
bond: fix naming inconsistency in tx_burst_round_robin
bond: free mbufs if transmission fails in bonding tx_burst functions test app: adding support for generating variable sized packet
testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist
bond: lsc polling support
bond: unit test test macro refactor

 app/test-pmd/cmdline.c                     |   65 +-
 app/test-pmd/testpmd.c                     |    3 +-
 app/test-pmd/testpmd.h                     |    2 +-
 app/test/packet_burst_generator.c          |   25 +-
 app/test/packet_burst_generator.h          |    6 +-
 app/test/test.h                            |    7 +-
 app/test/test_link_bonding.c               | 3342 ++++++++++++++------
--------
 app/test/virtual_pmd.c                     |   97 +-
 app/test/virtual_pmd.h                     |   53 +-
 lib/librte_pmd_bond/rte_eth_bond.h         |   80 +
 lib/librte_pmd_bond/rte_eth_bond_api.c     |  319 ++-
 lib/librte_pmd_bond/rte_eth_bond_args.c    |   30 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c     |  550 +++--
 lib/librte_pmd_bond/rte_eth_bond_private.h |   71 +-
 14 files changed, 2692 insertions(+), 1958 deletions(-)

--
1.7.12.2

#53 lore raw
In reply to a message not in the archive
Quoted 62 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Tuesday, September 30, 2014 10:58 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v4 0/8] link bonding

v4:
- Rebased to account for changes in master.
- Fix for rte_eth_bond_slaves_get() introduced in v3 patch set
- Addressed issue around disabling/enabling link status polling around adding/
removing slaves devices.

v3 :
- Typo fix for the bond free mbufs patch.
- Rebased to account for changes in the mbuf patches.
- Add support for slave devices which don't support link status interrupts
- Tidy up the link bonding unit test so that all tests use the new test macros.

v2 :
Addresses issues with the logic around the handling of fail transmissions. In this version all modes behave in a manner similar to a standard PMD, returning the number of successfully transmitted mbufs and with the failing mbufs at the end of bufs array for freeing / retransmission by the application software

v1:

This patch set adds support for link status interrupt in the link bonding pmd. It also contains some patches to tidy up the code structure and to of the link bonding code and to fix bugs relating to transmission failures in the under lying slave pmd which could lead to leaked mbufs.

Declan Doherty (8):
bond: link status interrupt support
bond: removing switch statement from rx burst method
bond: fix naming inconsistency in tx_burst_round_robin
bond: free mbufs if transmission fails in bonding tx_burst functions test app: adding support for generating variable sized packet
testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist
bond: lsc polling support
bond: unit test test macro refactor

 app/test-pmd/cmdline.c                     |   65 +-
 app/test-pmd/testpmd.c                     |    3 +-
 app/test-pmd/testpmd.h                     |    2 +-
 app/test/packet_burst_generator.c          |   25 +-
 app/test/packet_burst_generator.h          |    6 +-
 app/test/test.h                            |    7 +-
 app/test/test_link_bonding.c               | 3342 ++++++++++++++--------------
 app/test/virtual_pmd.c                     |   97 +-
 app/test/virtual_pmd.h                     |   53 +-
 lib/librte_pmd_bond/rte_eth_bond.h         |   80 +
 lib/librte_pmd_bond/rte_eth_bond_api.c     |  319 ++-
 lib/librte_pmd_bond/rte_eth_bond_args.c    |   30 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c     |  550 +++--
 lib/librte_pmd_bond/rte_eth_bond_private.h |   71 +-
 14 files changed, 2692 insertions(+), 1958 deletions(-)
Quoted 2 lines

--
1.7.12.2

#54 lore raw

v5 cover link bonding

In reply to a message not in the archive

v5:
- Fix uninitialized variable in broadcast_tx_burst function which caused a build error in 32-bit build
- Address unit test issue which is exposed by new test in mode 4/5 patch sets

v4:
- Rebased to account for changes in master.
- Fix for rte_eth_bond_slaves_get() introduced in v3 patch set
- Addressed issue around disabling/enabling link status polling around adding/ removing slaves devices.

v3 :
- Typo fix for the bond free mbufs patch.
- Rebased to account for changes in the mbuf patches.
- Add support for slave devices which don't support link status interrupts
- Tidy up the link bonding unit test so that all tests use the new test macros.

v2 :
Addresses issues with the logic around the handling of fail transmissions. In this version all modes behave in a manner similar to a standard PMD, returning the number of successfully transmitted mbufs and with the failing mbufs at the end of bufs array for freeing / retransmission by the application software

v1:

This patch set adds support for link status interrupt in the link bonding pmd. It also contains some patches to tidy up the code structure and to of the link bonding code and to fix bugs relating to transmission failures in the under lying slave pmd which could lead to leaked mbufs.

Declan Doherty (8):
bond: link status interrupt support
bond: removing switch statement from rx burst method
bond: fix naming inconsistency in tx_burst_round_robin
bond: free mbufs if transmission fails in bonding tx_burst functions test app: adding support for generating variable sized packet
testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist
bond: lsc polling support
bond: unit test test macro refactor

 app/test-pmd/cmdline.c                     |   65 +-
 app/test-pmd/testpmd.c                     |    3 +-
 app/test-pmd/testpmd.h                     |    2 +-
 app/test/packet_burst_generator.c          |   25 +-
 app/test/packet_burst_generator.h          |    6 +-
 app/test/test.h                            |    7 +-
 app/test/test_link_bonding.c               | 3342 ++++++++++++++--------------
 app/test/virtual_pmd.c                     |   96 +-
 app/test/virtual_pmd.h                     |   53 +-
 lib/librte_pmd_bond/rte_eth_bond.h         |   80 +
 lib/librte_pmd_bond/rte_eth_bond_api.c     |  319 ++-
 lib/librte_pmd_bond/rte_eth_bond_args.c    |   30 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c     |  550 +++--
 lib/librte_pmd_bond/rte_eth_bond_private.h |   71 +-
 14 files changed, 2691 insertions(+), 1958 deletions(-)
Signature · 1 line
1.7.12.2

A message that is not in the archive (sent off-list or not yet received): 1413291597-27326-1-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#56 lore raw

PATCH v5 1/8 bond: link status interrupt support

Adding support for lsc interrupt from bonded device to link bonding library with supporting unit tests in the test application.

---
 app/test/test_link_bonding.c           | 213 +++++++++++++++++++++++++++------
 lib/librte_pmd_bond/rte_eth_bond_api.c |   4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   6 +
 3 files changed, 189 insertions(+), 34 deletions(-)
app/test/test_link_bonding.c +179 -34
index db5b180..cce32ed 100644
@@ -39,6 +39,7 @@
 #include <inttypes.h>
 #include <errno.h>
 #include <sys/queue.h>
+#include <sys/time.h>
 
 #include <rte_byteorder.h>
 #include <rte_common.h>
@@ -224,10 +225,15 @@ static struct rte_eth_txconf tx_conf_default = {
 };
 
 static int
-configure_ethdev(uint8_t port_id, uint8_t start)
+configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 {
 	int q_id;
 
+	if (en_isr)
+		default_pmd_conf.intr_conf.lsc = 1;
+	else
+		default_pmd_conf.intr_conf.lsc = 0;
+
 	if (rte_eth_dev_configure(port_id, test_params->nb_rx_q,
 			test_params->nb_tx_q, &default_pmd_conf) != 0) {
 		goto error;
@@ -312,7 +318,7 @@ test_setup(void)
 
 			printf("Created virtual ethdev %s\n", pmd_name);
 
-			retval = configure_ethdev(test_params->slave_port_ids[i], 1);
+			retval = configure_ethdev(test_params->slave_port_ids[i], 1, 0);
 			if (retval != 0) {
 				printf("Failed to configure virtual ethdev %s\n", pmd_name);
 				return -1;
@@ -341,7 +347,7 @@ test_create_bonded_device(void)
 		TEST_ASSERT(test_params->bonded_port_id >= 0,
 				"Failed to create bonded ethdev %s", BONDED_DEV_NAME);
 
-		TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
+		TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
 				"Failed to configure bonded ethdev %s", BONDED_DEV_NAME);
 	}
 
@@ -1078,12 +1084,12 @@ test_set_explicit_bonded_mac(void)
 
 
 static int
-initialize_bonded_device_with_slaves(uint8_t bonding_mode,
+initialize_bonded_device_with_slaves(uint8_t bonding_mode, uint8_t bond_en_isr,
 		uint8_t number_of_slaves, uint8_t enable_slave)
 {
 	/* configure bonded device */
-	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
-			"Failed to configure bonding port (%d) in mode %d "
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0,
+			bond_en_isr), "Failed to configure bonding port (%d) in mode %d "
 			"with (%d) slaves.", test_params->bonded_port_id, bonding_mode,
 			number_of_slaves);
 
@@ -1116,8 +1122,8 @@ test_adding_slave_after_bonded_device_started(void)
 {
 	int i;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 0) !=
-			0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 0)
+			!= 0)
 		return -1;
 
 	/* Enabled slave devices */
@@ -1141,6 +1147,144 @@ test_adding_slave_after_bonded_device_started(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_STATUS_INTERRUPT_SLAVE_COUNT	4
+#define TEST_LSC_WAIT_TIMEOUT_MS	500
+
+int test_lsc_interupt_count;
+
+static pthread_mutex_t mutex;
+static pthread_cond_t cvar;
+
+static void
+test_bonding_lsc_event_callback(uint8_t port_id __rte_unused,
+		enum rte_eth_event_type type  __rte_unused, void *param __rte_unused)
+{
+	pthread_mutex_lock(&mutex);
+	test_lsc_interupt_count++;
+
+	pthread_cond_signal(&cvar);
+	pthread_mutex_unlock(&mutex);
+}
+
+static inline int
+lsc_timeout(int wait_us)
+{
+	int retval = 0;
+
+	struct timespec ts;
+	struct timeval tp;
+
+	gettimeofday(&tp, NULL);
+
+	/* Convert from timeval to timespec */
+	ts.tv_sec  = tp.tv_sec;
+	ts.tv_nsec = tp.tv_usec * 1000;
+	ts.tv_nsec += wait_us * 1000;
+
+	pthread_mutex_lock(&mutex);
+	if (test_lsc_interupt_count < 1)
+		retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+
+	pthread_mutex_unlock(&mutex);
+
+	return retval;
+}
+
+static int
+test_status_interrupt(void)
+{
+	int slave_count;
+	uint8_t slaves[RTE_MAX_ETHPORTS];
+
+	pthread_mutex_init(&mutex, NULL);
+	pthread_cond_init(&cvar, NULL);
+
+	/* initialized bonding device with T slaves */
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 1,
+			TEST_STATUS_INTERRUPT_SLAVE_COUNT, 1) != 0)
+		return -1;
+
+	test_lsc_interupt_count = 0;
+
+	/* register link status change interrupt callback */
+	rte_eth_dev_callback_register(test_params->bonded_port_id,
+			RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
+			&test_params->bonded_port_id);
+
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+
+	TEST_ASSERT_EQUAL(slave_count, TEST_STATUS_INTERRUPT_SLAVE_COUNT,
+			"Number of active slaves (%d) is not as expected (%d)",
+			slave_count, TEST_STATUS_INTERRUPT_SLAVE_COUNT);
+
+	/* Bring all 4 slaves link status to down and test that we have received a
+	 * lsc interrupts */
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 0);
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[1], 0);
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[2], 0);
+
+	TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+			"Received a link status change interrupt unexpectedly");
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[3], 0);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
+			"timed out waiting for interrupt");
+
+	TEST_ASSERT(test_lsc_interupt_count > 0,
+			"Did not receive link status change interrupt");
+
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+
+	TEST_ASSERT_EQUAL(slave_count, 0,
+			"Number of active slaves (%d) is not as expected (%d)",
+			slave_count, 0);
+
+	/* bring one slave port up so link status will change */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 1);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
+			"timed out waiting for interrupt");
+
+	/* test that we have received another lsc interrupt */
+	TEST_ASSERT(test_lsc_interupt_count > 0,
+			"Did not receive link status change interrupt");
+
+	/* Verify that calling the same slave lsc interrupt doesn't cause another
+	 * lsc interrupt from bonded device */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_simulate_link_status_interrupt(
+			test_params->slave_port_ids[0], 1);
+
+	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) != 0,
+			"received unexpected interrupt");
+
+	TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+			"Did not receive link status change interrupt");
+
+
+	/* unregister lsc callback before exiting */
+	rte_eth_dev_callback_unregister(test_params->bonded_port_id,
+				RTE_ETH_EVENT_INTR_LSC, test_bonding_lsc_event_callback,
+				&test_params->bonded_port_id);
+
+	pthread_mutex_destroy(&mutex);
+	pthread_cond_destroy(&cvar);
+
+	/* Clean up and remove slaves from bonded device */
+	return remove_slaves_and_stop_bonded_device();
+}
+
 static int
 generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size,
 		uint8_t vlan, uint8_t ipv4, uint8_t toggle_dst_mac,
@@ -1209,7 +1353,7 @@ test_roundrobin_tx_burst(void)
 	struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 2, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 2, 1)
 			!= 0)
 		return -1;
 
@@ -1279,7 +1423,7 @@ test_roundrobin_rx_burst_on_single_slave(void)
 	int i, j, nb_rx, burst_size = 25;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1369,7 +1513,7 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1461,7 +1605,7 @@ test_roundrobin_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[2], &expected_mac_addr_2);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1)
 			!= 0)
 		return -1;
 
@@ -1552,7 +1696,7 @@ test_roundrobin_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 1) !=
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 1) !=
 			0)
 		return -1;
 
@@ -1616,7 +1760,7 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 
 	/* Initialize bonded device with TEST_RR_LINK_STATUS_SLAVE_COUNT slaves
 	 * in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0,
 			TEST_RR_LINK_STATUS_SLAVE_COUNT, 1) != 0)
 		return -1;
 
@@ -1757,7 +1901,7 @@ test_activebackup_tx_burst(void)
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -1854,7 +1998,7 @@ test_activebackup_rx_burst(void)
 	int i, j, nb_rx, burst_size = 17;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
 			!= 0)
 		return -1;
@@ -1948,7 +2092,7 @@ test_activebackup_verify_promiscuous_enable_disable(void)
 	int i, primary_port, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 4, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 4, 1)
 			!= 0)
 		return -1;
 
@@ -2018,7 +2162,7 @@ test_activebackup_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 2, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0, 2, 1)
 			!= 0)
 		return -1;
 
@@ -2157,7 +2301,7 @@ test_activebackup_verify_slave_link_status_change_failover(void)
 	}
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT, 1)
 			!= 0)
 		return -1;
@@ -2328,7 +2472,7 @@ test_balance_xmit_policy_configuration(void)
 {
 	int retval;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP,
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_ACTIVE_BACKUP, 0,
 			2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
@@ -2408,7 +2552,7 @@ test_balance_l2_tx_burst(void)
 	int retval, i;
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE,
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
 			TEST_BALANCE_L2_TX_BURST_SLAVE_COUNT, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
@@ -2506,7 +2650,7 @@ balance_l23_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -2634,7 +2778,7 @@ balance_l34_tx_burst(uint8_t vlan_enabled, uint8_t ipv4,
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -2772,7 +2916,7 @@ test_balance_rx_burst(void)
 	memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 3, 1)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 3, 1)
 			!= 0)
 		return -1;
 
@@ -2861,7 +3005,7 @@ test_balance_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1) != 0)
 		return -1;
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
@@ -2915,7 +3059,7 @@ test_balance_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[1], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 2 slaves in active backup mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 2, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 2, 1) != 0)
 		return -1;
 
 	/* Verify that bonded MACs is that of first slave and that the other slave
@@ -3045,7 +3189,7 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0,
 			TEST_BALANCE_LINK_STATUS_SLAVE_COUNT, 1) != 0)
 		return -1;
 
@@ -3237,7 +3381,7 @@ test_broadcast_tx_burst(void)
 
 	struct rte_eth_stats port_stats;
 
-	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 2, 1);
+	retval = initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 2, 1);
 	if (retval != 0) {
 		printf("Failed to initialize_bonded_device_with_slaves.\n");
 		return -1;
@@ -3327,7 +3471,7 @@ test_broadcast_rx_burst(void)
 	memset(gen_pkt_burst, 0, sizeof(gen_pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 3, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 3, 1) != 0)
 		return -1;
 
 
@@ -3419,7 +3563,7 @@ test_broadcast_verify_promiscuous_enable_disable(void)
 	int i, promiscuous_en;
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BALANCE, 0, 4, 1) != 0)
 		return -1;
 
 	rte_eth_promiscuous_enable(test_params->bonded_port_id);
@@ -3475,7 +3619,7 @@ test_broadcast_verify_mac_assignment(void)
 	rte_eth_macaddr_get(test_params->slave_port_ids[2], &expected_mac_addr_1);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 4, 1) != 0)
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4, 1) != 0)
 		return -1;
 
 	/* Verify that all MACs are the same as first slave added to bonded
@@ -3575,7 +3719,7 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	memset(pkt_burst, 0, sizeof(pkt_burst));
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST,
+	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0,
 			BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
 		return -1;
 
@@ -3711,7 +3855,7 @@ test_reconfigure_bonded_device(void)
 	test_params->nb_rx_q = 4;
 	test_params->nb_tx_q = 4;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0)  != 0) {
+	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
 		printf("failed to reconfigure bonded device");
 		return -1;
 	}
@@ -3720,7 +3864,7 @@ test_reconfigure_bonded_device(void)
 	test_params->nb_rx_q = 2;
 	test_params->nb_tx_q = 2;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0)  != 0) {
+	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
 		printf("failed to reconfigure bonded device with less rx/tx queues");
 		return -1;
 	}
@@ -3768,6 +3912,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_set_bonding_mode),
 		TEST_CASE(test_set_primary_slave),
 		TEST_CASE(test_set_explicit_bonded_mac),
+		TEST_CASE(test_status_interrupt),
 		TEST_CASE(test_adding_slave_after_bonded_device_started),
 		TEST_CASE(test_roundrobin_tx_burst),
 		TEST_CASE(test_roundrobin_rx_burst_on_single_slave),
lib/librte_pmd_bond/rte_eth_bond_api.c +4 -0
index 75f5694..dd33119 100644
@@ -177,6 +177,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	pci_drv->id_table->vendor_id = PCI_ANY_ID;
 	pci_drv->id_table->subsystem_vendor_id = PCI_ANY_ID;
 
+	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
 		RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
@@ -200,6 +202,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
 
+	TAILQ_INIT(&(eth_dev->callbacks));
+
 	eth_dev->data->dev_link.link_status = 0;
 
 	eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
lib/librte_pmd_bond/rte_eth_bond_pmd.c +6 -0
index 08d3b5f..aca2dcf 100644
@@ -918,6 +918,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 	struct rte_eth_link link;
 
 	int i, valid_slave = 0, active_pos = -1;
+	uint8_t lsc_flag = 0;
 
 	if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
 		return;
@@ -963,6 +964,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 			/* If first active slave, then change link status */
 			bonded_eth_dev->data->dev_link.link_status = 1;
 			internals->current_primary_port = port_id;
+			lsc_flag = 1;
 
 			/* Inherit eth dev link properties from first active slave */
 			link_properties_set(bonded_eth_dev,
@@ -987,6 +989,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		/* No active slaves, change link status to down and reset other
 		 * link properties */
 		if (internals->active_slave_count < 1) {
+			lsc_flag = 1;
 			bonded_eth_dev->data->dev_link.link_status = 0;
 
 			link_properties_reset(bonded_eth_dev);
@@ -1002,6 +1005,9 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 				internals->current_primary_port = internals->primary_port;
 		}
 	}
+
+	if (lsc_flag)
+		_rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
 }
 
 struct eth_dev_ops default_dev_ops = {
Signature · 1 line
1.7.12.2
#57 lore raw

PATCH v5 2/8 bond: removing switch statement from rx burst method

In reply to a message not in the archive
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 62 +++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 27 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +35 -27
index aca2dcf..348e28f 100644
@@ -59,33 +59,37 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	internals = bd_rx_q->dev_private;
 
-	switch (internals->mode) {
-	case BONDING_MODE_ROUND_ROBIN:
-	case BONDING_MODE_BROADCAST:
-	case BONDING_MODE_BALANCE:
-		for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
-			/* Offset of pointer to *bufs increases as packets are received
-			 * from other slaves */
-			num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
-					bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
-			if (num_rx_slave) {
-				num_rx_total += num_rx_slave;
-				nb_pkts -= num_rx_slave;
-			}
+	for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
+		/* Offset of pointer to *bufs increases as packets are received
+		 * from other slaves */
+		num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
+				bd_rx_q->queue_id, bufs + num_rx_total, nb_pkts);
+		if (num_rx_slave) {
+			num_rx_total += num_rx_slave;
+			nb_pkts -= num_rx_slave;
 		}
-		break;
-	case BONDING_MODE_ACTIVE_BACKUP:
-		num_rx_slave = rte_eth_rx_burst(internals->current_primary_port,
-				bd_rx_q->queue_id, bufs, nb_pkts);
-		if (num_rx_slave)
-			num_rx_total = num_rx_slave;
-		break;
 	}
+
 	return num_rx_total;
 }
 
 static uint16_t
-bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
+bond_ethdev_rx_burst_active_backup(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
+{
+	struct bond_dev_private *internals;
+
+	/* Cast to structure, containing bonded device's port id and queue id */
+	struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
+
+	internals = bd_rx_q->dev_private;
+
+	return rte_eth_rx_burst(internals->current_primary_port,
+			bd_rx_q->queue_id, bufs, nb_pkts);
+}
+
+static uint16_t
+bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
 {
 	struct bond_dev_private *dev_private;
@@ -134,7 +138,7 @@ bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
 }
 
 static uint16_t
-bond_ethdev_tx_active_backup(void *queue,
+bond_ethdev_tx_burst_active_backup(void *queue,
 		struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
 	struct bond_dev_private *internals;
@@ -270,7 +274,8 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t slave_count, uint8_t policy)
 }
 
 static uint16_t
-bond_ethdev_tx_balance(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
+		uint16_t nb_pkts)
 {
 	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
@@ -480,22 +485,25 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int mode)
 
 	switch (mode) {
 	case BONDING_MODE_ROUND_ROBIN:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_round_robin;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_round_robin;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	case BONDING_MODE_ACTIVE_BACKUP:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_active_backup;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_active_backup;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup;
 		break;
 	case BONDING_MODE_BALANCE:
-		eth_dev->tx_pkt_burst = bond_ethdev_tx_balance;
+		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_balance;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	case BONDING_MODE_BROADCAST:
 		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 	default:
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 	internals->mode = mode;
 
 	return 0;
Signature · 1 line
1.7.12.2
#58 lore raw

PATCH v5 3/8 bond: fix naming inconsistency in tx_burst_round_robin

In reply to a message not in the archive
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +5 -5
index 348e28f..66f1650 100644
@@ -92,7 +92,7 @@ static uint16_t
 bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 		uint16_t nb_pkts)
 {
-	struct bond_dev_private *dev_private;
+	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
 
 	struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_pkts];
@@ -107,13 +107,13 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
 	int i, cs_idx = 0;
 
 	bd_tx_q = (struct bond_tx_queue *)queue;
-	dev_private = bd_tx_q->dev_private;
+	internals = bd_tx_q->dev_private;
 
 	/* Copy slave list to protect against slave up/down changes during tx
 	 * bursting */
-	num_of_slaves = dev_private->active_slave_count;
-	memcpy(slaves, dev_private->active_slaves,
-			sizeof(dev_private->active_slaves[0]) * num_of_slaves);
+	num_of_slaves = internals->active_slave_count;
+	memcpy(slaves, internals->active_slaves,
+			sizeof(internals->active_slaves[0]) * num_of_slaves);
 
 	if (num_of_slaves < 1)
 		return num_tx_total;
Signature · 1 line
1.7.12.2