DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/6] link bonding
@ 2014-08-19 13:51 Declan Doherty
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 1/6] bond: link status interrupt support Declan Doherty
                   ` (14 more replies)
  0 siblings, 15 replies; 91+ messages in thread
From: Declan Doherty @ 2014-08-19 13:51 UTC (permalink / raw)
  To: dev

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(-)

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH 1/6] bond: link status interrupt support
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
@ 2014-08-19 13:51 ` Declan Doherty
  2014-08-20 20:24   ` Sanford, Robert
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 2/6] bond: removing switch statement from rx burst method Declan Doherty
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 91+ messages in thread
From: Declan Doherty @ 2014-08-19 13:51 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 5c1303e..02823b6 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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),
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index 75f5694..dd33119 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -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,
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index d72d6ed..cd3eecf 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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 = {
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH 2/6] bond: removing switch statement from rx burst method
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 1/6] bond: link status interrupt support Declan Doherty
@ 2014-08-19 13:51 ` Declan Doherty
  2014-08-20 20:25   ` Sanford, Robert
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 3/6] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 91+ messages in thread
From: Declan Doherty @ 2014-08-19 13:51 UTC (permalink / raw)
  To: dev

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.

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   62 ++++++++++++++++++--------------
 1 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index cd3eecf..683b146 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH 3/6] bond: fix naming inconsistency in tx_burst_round_robin
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 1/6] bond: link status interrupt support Declan Doherty
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 2/6] bond: removing switch statement from rx burst method Declan Doherty
@ 2014-08-19 13:51 ` Declan Doherty
  2014-08-20 20:25   ` Sanford, Robert
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 91+ messages in thread
From: Declan Doherty @ 2014-08-19 13:51 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 683b146..70123fc 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (2 preceding siblings ...)
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 3/6] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
@ 2014-08-19 13:51 ` Declan Doherty
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 5/6] test app: adding support for generating variable sized packets Declan Doherty
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-08-19 13:51 UTC (permalink / raw)
  To: dev

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


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/test_link_bonding.c           |    4 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   46 +++++++++++++++++++++++++-------
 2 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 02823b6..3c265ee 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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;
 	}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 70123fc..ae9726e 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -101,7 +101,7 @@ 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;
@@ -130,9 +130,17 @@ bond_ethdev_tx_burst_round_robin(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],
+		if (slave_nb_pkts[i] > 0) {
+			num_tx_slave = rte_eth_tx_burst(slaves[i],
 					bd_tx_q->queue_id, slave_bufs[i], slave_nb_pkts[i]);
+			num_tx_total += num_tx_slave;
+
+			/* if tx burst fails, free unsent mbufs */
+			while (unlikely(num_tx_slave < slave_nb_pkts[i])) {
+				rte_pktmbuf_free(slave_bufs[i][num_tx_slave]);
+				num_tx_slave++;
+			}
+		}
 
 	return num_tx_total;
 }
@@ -283,7 +291,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;
 
 	int i, op_slave_id;
 
@@ -315,11 +323,19 @@ 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]);
+			num_tx_total += num_tx_slave;
+
+			/* if tx burst fails, free unsent mbufs */
+			while (unlikely(num_tx_slave < slave_nb_pkts[i])) {
+				rte_pktmbuf_free(slave_bufs[i][num_tx_slave]);
+				num_tx_slave++;
+			}
 		}
 	}
 
+
 	return num_tx_total;
 }
 
@@ -333,7 +349,7 @@ bond_ethdev_tx_burst_broadcast(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_slave = 0, max_tx_pkts = 0;
 
 	int i;
 
@@ -354,11 +370,21 @@ 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++) {
+		num_tx_slave = rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id,
+					bufs, nb_pkts);
 
-	return num_tx_total;
+		if (max_tx_pkts < num_tx_slave)
+			max_tx_pkts = num_tx_slave;
+
+		/* if tx burst fails, free unsent mbufs */
+		while (unlikely(num_tx_slave < nb_pkts)) {
+			rte_pktmbuf_free(bufs[num_tx_slave]);
+			num_tx_slave++;
+		}
+	}
+
+	return max_tx_pkts;
 }
 
 void
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH 5/6] test app: adding support for generating variable sized packets
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (3 preceding siblings ...)
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
@ 2014-08-19 13:51 ` Declan Doherty
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-08-19 13:51 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c
index 5d539f1..9ce6472 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -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) {
diff --git a/app/test/packet_burst_generator.h b/app/test/packet_burst_generator.h
index 5b3cd6c..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -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
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 3c265ee..d31c553 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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;
 
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (4 preceding siblings ...)
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 5/6] test app: adding support for generating variable sized packets Declan Doherty
@ 2014-08-19 13:51 ` Declan Doherty
  2014-08-22  7:41 ` [dpdk-dev] [PATCH 0/6] link bonding Jiajia, SunX
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-08-19 13:51 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 345be11..8cc4937 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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);
 	}
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e8a4b45..58ed03c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index ac86bfe..207eacb 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH 1/6] bond: link status interrupt support
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 1/6] bond: link status interrupt support Declan Doherty
@ 2014-08-20 20:24   ` Sanford, Robert
  0 siblings, 0 replies; 91+ messages in thread
From: Sanford, Robert @ 2014-08-20 20:24 UTC (permalink / raw)
  To: Declan Doherty, dev

Reviewed-by: Robert Sanford <rsanford@akamai.com>


>Adding support for lsc interrupt from bonded device to link
>bonding library with supporting unit tests in the test application.
>
>Signed-off-by: Declan Doherty <declan.doherty@intel.com>
>---
> 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(-)
>
>diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
>index 5c1303e..02823b6 100644
>--- a/app/test/test_link_bonding.c
>+++ b/app/test/test_link_bonding.c
>@@ -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),
>diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c
>b/lib/librte_pmd_bond/rte_eth_bond_api.c
>index 75f5694..dd33119 100644
>--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
>+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
>@@ -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,
>diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>index d72d6ed..cd3eecf 100644
>--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>@@ -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 = {
>--
>1.7.0.7
>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH 2/6] bond: removing switch statement from rx burst method
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 2/6] bond: removing switch statement from rx burst method Declan Doherty
@ 2014-08-20 20:25   ` Sanford, Robert
  0 siblings, 0 replies; 91+ messages in thread
From: Sanford, Robert @ 2014-08-20 20:25 UTC (permalink / raw)
  To: Declan Doherty, dev

Reviewed-by: Robert Sanford <rsanford@akamai.com>


>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.
>
>Signed-off-by: Declan Doherty <declan.doherty@intel.com>
>---
> lib/librte_pmd_bond/rte_eth_bond_pmd.c |   62
>++++++++++++++++++--------------
> 1 files changed, 35 insertions(+), 27 deletions(-)
>
>diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>index cd3eecf..683b146 100644
>--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>@@ -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;
>-- 
>1.7.0.7
>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH 3/6] bond: fix naming inconsistency in tx_burst_round_robin
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 3/6] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
@ 2014-08-20 20:25   ` Sanford, Robert
  0 siblings, 0 replies; 91+ messages in thread
From: Sanford, Robert @ 2014-08-20 20:25 UTC (permalink / raw)
  To: Declan Doherty, dev

Reviewed-by: Robert Sanford <rsanford@akamai.com>


>Renaming struct bond_dev_pritvate *dev_private to internals to match
>convention used in other pmds
>
>Signed-off-by: Declan Doherty <declan.doherty@intel.com>
>---
> lib/librte_pmd_bond/rte_eth_bond_pmd.c |   10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>index 683b146..70123fc 100644
>--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>@@ -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;
>-- 
>1.7.0.7
>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH 0/6] link bonding
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (5 preceding siblings ...)
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
@ 2014-08-22  7:41 ` Jiajia, SunX
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 " Declan Doherty
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 91+ messages in thread
From: Jiajia, SunX @ 2014-08-22  7:41 UTC (permalink / raw)
  To: Doherty, Declan, dev

Tested-by: Jiajia, SunX < sunx.jiajia@intel.com>

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.

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty
> Sent: Tuesday, August 19, 2014 9:52 PM
> To: dev@dpdk.org
> 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(-)

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v2 0/6] link bonding
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (6 preceding siblings ...)
  2014-08-22  7:41 ` [dpdk-dev] [PATCH 0/6] link bonding Jiajia, SunX
@ 2014-09-01  8:31 ` Declan Doherty
  2014-09-02 13:31   ` De Lara Guarch, Pablo
  2014-09-02 18:15   ` Stephen Hemminger
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 1/6] bond: link status interrupt support Declan Doherty
                   ` (6 subsequent siblings)
  14 siblings, 2 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-01  8:31 UTC (permalink / raw)
  To: dev

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(-)

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v2 1/6] bond: link status interrupt support
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (7 preceding siblings ...)
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 " Declan Doherty
@ 2014-09-01  8:31 ` Declan Doherty
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 2/6] bond: removing switch statement from rx burst method Declan Doherty
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-01  8:31 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index db5b180..cce32ed 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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),
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index 75f5694..dd33119 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -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,
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index d72d6ed..cd3eecf 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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 = {
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v2 2/6] bond: removing switch statement from rx burst method
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (8 preceding siblings ...)
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 1/6] bond: link status interrupt support Declan Doherty
@ 2014-09-01  8:31 ` Declan Doherty
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 3/6] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-01  8:31 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   62 ++++++++++++++++++--------------
 1 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index cd3eecf..683b146 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v2 3/6] bond: fix naming inconsistency in tx_burst_round_robin
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (9 preceding siblings ...)
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 2/6] bond: removing switch statement from rx burst method Declan Doherty
@ 2014-09-01  8:31 ` Declan Doherty
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-01  8:31 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 683b146..70123fc 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (10 preceding siblings ...)
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 3/6] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
@ 2014-09-01  8:31 ` Declan Doherty
  2014-09-02  9:22   ` Doherty, Declan
  2014-09-23 13:18   ` [dpdk-dev] [PATCH v3 0/5] link bonding Declan Doherty
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 5/6] test app: adding support for generating variable sized packets Declan Doherty
                   ` (2 subsequent siblings)
  14 siblings, 2 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-01  8:31 UTC (permalink / raw)
  To: dev

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.

 
Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index cce32ed..c5aaa80 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index e861c5b..f9bd841 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -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->tx_burst_fail_count;
+
+		/* 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)
 {
 	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
 
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 766b6ac..3b5c911 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -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
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 70123fc..38cc1ae 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
 	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
 	 * 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]);
+	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,
+					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;
+
+				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]));
+			}
+			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;
 
-	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;
 
 	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
+		 * 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
+	 * handle failures of all packets except those of the most successful slave
+	 */
+	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]++]);
+
+	return max_nb_of_tx_pkts;
 }
 
 void
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v2 5/6] test app: adding support for generating variable sized packets
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (11 preceding siblings ...)
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
@ 2014-09-01  8:31 ` Declan Doherty
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
  14 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-01  8:31 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c
index 5d539f1..9ce6472 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -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) {
diff --git a/app/test/packet_burst_generator.h b/app/test/packet_burst_generator.h
index 5b3cd6c..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -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
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index c5aaa80..1c06e2d 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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;
 
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v2 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (12 preceding siblings ...)
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 5/6] test app: adding support for generating variable sized packets Declan Doherty
@ 2014-09-01  8:31 ` Declan Doherty
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
  14 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-01  8:31 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b04a4e8..a0d88df 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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);
 	}
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index a112559..d843f77 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index b8322a2..f34b5d1 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.7.0.7

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
@ 2014-09-02  9:22   ` Doherty, Declan
  2014-09-02  9:31     ` Thomas Monjalon
  2014-09-23 13:18   ` [dpdk-dev] [PATCH v3 0/5] link bonding Declan Doherty
  1 sibling, 1 reply; 91+ messages in thread
From: Doherty, Declan @ 2014-09-02  9:22 UTC (permalink / raw)
  To: dev

> -----Original Message-----
> From: Doherty, Declan
> Sent: Monday, September 1, 2014 9:31 AM
> To: dev@dpdk.org
> Cc: thomas.monjalon@6wind.com; rsanford@akamai.com; 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.
> 
> 
> Signed-off-by: Declan Doherty <declan.doherty@intel.com>
> ---
.....
> --
> 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.

> +			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -s
> +			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);

should have been 
> +			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

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-09-02  9:22   ` Doherty, Declan
@ 2014-09-02  9:31     ` Thomas Monjalon
  0 siblings, 0 replies; 91+ messages in thread
From: Thomas Monjalon @ 2014-09-02  9:31 UTC (permalink / raw)
  To: Doherty, Declan; +Cc: dev

Hi Declan,

2014-09-02 09:22, Doherty, Declan:
> 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.
> 
> > +			TEST_BCAST_SLAVE_TX_FAIL_BURST_SIZE -s
> > +			TEST_BCAST_SLAVE_TX_FAIL_MIN_PACKETS_COUNT);
> 
> should have been 
> > +			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?

-- 
Thomas

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/6] link bonding
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 " Declan Doherty
@ 2014-09-02 13:31   ` De Lara Guarch, Pablo
  2014-09-02 18:15   ` Stephen Hemminger
  1 sibling, 0 replies; 91+ messages in thread
From: De Lara Guarch, Pablo @ 2014-09-02 13:31 UTC (permalink / raw)
  To: Doherty, Declan, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty
> Sent: Monday, September 01, 2014 9:31 AM
> To: dev@dpdk.org
> 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
> 
>  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 <pablo.de.lara.guarch@intel.com>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/6] link bonding
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 " Declan Doherty
  2014-09-02 13:31   ` De Lara Guarch, Pablo
@ 2014-09-02 18:15   ` Stephen Hemminger
  1 sibling, 0 replies; 91+ messages in thread
From: Stephen Hemminger @ 2014-09-02 18:15 UTC (permalink / raw)
  To: Declan Doherty; +Cc: dev

On Mon,  1 Sep 2014 09:31:23 +0100
Declan Doherty <declan.doherty@intel.com> wrote:

> 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.

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v3 0/5] link bonding
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
  2014-09-02  9:22   ` Doherty, Declan
@ 2014-09-23 13:18   ` Declan Doherty
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 1/5] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
                       ` (4 more replies)
  1 sibling, 5 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-23 13:18 UTC (permalink / raw)
  To: dev

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(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v3 1/5] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-09-23 13:18   ` [dpdk-dev] [PATCH v3 0/5] link bonding Declan Doherty
@ 2014-09-23 13:18     ` Declan Doherty
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 2/5] test app: adding support for generating variable sized packet Declan Doherty
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-23 13:18 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index cce32ed..1a847eb 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index e861c5b..f9bd841 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -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->tx_burst_fail_count;
+
+		/* 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)
 {
 	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
 
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 766b6ac..3b5c911 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -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
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 54d3e38..6018feb 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
 	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
 	 * 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]);
+	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,
+					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;
+
+				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]));
+			}
+			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;
 
-	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;
 
 	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
+		 * 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
+	 * handle failures of all packets except those of the most successful slave
+	 */
+	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]++]);
+
+	return max_nb_of_tx_pkts;
 }
 
 void
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v3 2/5] test app: adding support for generating variable sized packet
  2014-09-23 13:18   ` [dpdk-dev] [PATCH v3 0/5] link bonding Declan Doherty
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 1/5] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
@ 2014-09-23 13:18     ` Declan Doherty
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 3/5] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-23 13:18 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c
index 9e747a4..b2824dc 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -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) {
diff --git a/app/test/packet_burst_generator.h b/app/test/packet_burst_generator.h
index 5b3cd6c..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -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
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 1a847eb..50355a3 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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;
 
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v3 3/5] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist
  2014-09-23 13:18   ` [dpdk-dev] [PATCH v3 0/5] link bonding Declan Doherty
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 1/5] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 2/5] test app: adding support for generating variable sized packet Declan Doherty
@ 2014-09-23 13:18     ` Declan Doherty
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 4/5] bond: lsc polling support Declan Doherty
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 5/5] bond: unit test test macro refactor Declan Doherty
  4 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-23 13:18 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 67321f7..ed76eea 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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);
 	}
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 9f6cdc4..66e3c7c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 142091d..7b78cc5 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v3 4/5] bond: lsc polling support
  2014-09-23 13:18   ` [dpdk-dev] [PATCH v3 0/5] link bonding Declan Doherty
                       ` (2 preceding siblings ...)
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 3/5] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
@ 2014-09-23 13:18     ` Declan Doherty
  2014-09-24 13:16       ` Ananyev, Konstantin
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 5/5] bond: unit test test macro refactor Declan Doherty
  4 siblings, 1 reply; 91+ messages in thread
From: Declan Doherty @ 2014-09-23 13:18 UTC (permalink / raw)
  To: dev

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.


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test.h b/app/test/test.h
index 98ab804..24b1640 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -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;											\
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 50355a3..c32b685 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -234,42 +234,34 @@ configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 	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;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_dev_configure(port_id, test_params->nb_rx_q,
+			test_params->nb_tx_q, &default_pmd_conf),
+			"rte_eth_dev_configure for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++) {
-		if (rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
+	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
 				rte_eth_dev_socket_id(port_id), &rx_conf_default,
-				test_params->mbuf_pool) < 0) {
-			goto error;
-		}
-	}
+				test_params->mbuf_pool) ,
+				"rte_eth_rx_queue_setup for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++) {
-		if (rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
-				rte_eth_dev_socket_id(port_id), &tx_conf_default) < 0) {
-			printf("Failed to setup tx queue (%d).\n", q_id);
-			goto error;
-		}
-	}
+	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
+				rte_eth_dev_socket_id(port_id), &tx_conf_default),
+				"rte_eth_tx_queue_setup for port %d failed", port_id);
 
-	if (start) {
-		if (rte_eth_dev_start(port_id) < 0) {
-			printf("Failed to start device (%d).\n", port_id);
-			goto error;
-		}
-	}
-	return 0;
+	if (start)
+		TEST_ASSERT_SUCCESS(rte_eth_dev_start(port_id),
+				"rte_eth_dev_start for port %d failed", port_id);
 
-error:
-	printf("Failed to configure ethdev %d\n", port_id);
-	return -1;
+	return 0;
 }
 
 static int slaves_initialized;
 
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
+
+
 static int
 test_setup(void)
 {
@@ -310,7 +302,7 @@ test_setup(void)
 			snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_%d", i);
 
 			test_params->slave_port_ids[i] = virtual_ethdev_create(pmd_name,
-					mac_addr, rte_socket_id());
+					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;
@@ -414,34 +406,27 @@ test_create_bonded_device_with_invalid_params(void)
 static int
 test_add_slave_to_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]);
-	if (retval != 0) {
-		printf("Failed to add slave (%d) to bonded port (%d).\n",
-				test_params->bonded_port_id,
-				test_params->slave_port_ids[test_params->bonded_slave_count]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave (%d) to bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count],
+			test_params->bonded_port_id);
 
 	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 + 1) {
-		printf("Number of slaves (%d) is greater than expected (%d).\n",
-				current_slave_count, test_params->bonded_slave_count + 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count + 1,
+			"Number of slaves (%d) is greater than expected (%d).",
+			current_slave_count, test_params->bonded_slave_count + 1);
 
 	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 as expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
+					"Number of active slaves (%d) is not as expected (%d).\n",
+					current_slave_count, 0);
 
 	test_params->bonded_slave_count++;
 
@@ -476,27 +461,23 @@ test_add_slave_to_invalid_bonded_device(void)
 static int
 test_remove_slave_from_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 	struct ether_addr read_mac_addr, *mac_addr;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_remove(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
-	if (retval != 0) {
-		printf("\t Failed to remove slave %d from bonded port (%d).\n",
-				test_params->slave_port_ids[test_params->bonded_slave_count-1],
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_remove(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count-1]),
+			"Failed to remove slave %d from bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count-1],
+			test_params->bonded_port_id);
 
 
 	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 - 1) {
-		printf("Number of slaves (%d) is great than expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count - 1,
+			"Number of slaves (%d) is great than expected (%d).\n",
+			current_slave_count, test_params->bonded_slave_count - 1);
 
 
 	mac_addr = (struct ether_addr *)slave_mac;
@@ -506,10 +487,8 @@ test_remove_slave_from_bonded_device(void)
 	rte_eth_macaddr_get(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1],
 			&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\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
@@ -888,21 +867,20 @@ test_set_primary_slave(void)
 		return -1;
 	}
 
+	/* 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;
+	}
+
 	/* Set slave as primary
 	 * Verify slave it is now primary slave
 	 * Verify that MAC address of bonded device is that of primary slave
 	 * Verify that MAC address of all bonded slaves are that of primary slave
 	 */
 	for (i = 0; i < 4; i++) {
-
-		/* 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;
-		}
-
 		retval = rte_eth_bond_primary_set(test_params->bonded_port_id,
 				test_params->slave_port_ids[i]);
 		if (retval != 0) {
@@ -926,6 +904,7 @@ test_set_primary_slave(void)
 
 		/* 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;
 
@@ -1090,19 +1069,18 @@ static int
 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 */
+	/* Configure bonded device */
 	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);
 
-	while (number_of_slaves > test_params->bonded_slave_count) {
-		/* Add slaves to bonded device */
+	/* Add slaves to bonded device */
+	while (number_of_slaves > test_params->bonded_slave_count)
 		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
 				"Failed to add slave (%d to  bonding port (%d).",
 				test_params->bonded_slave_count - 1,
 				test_params->bonded_port_id);
-	}
 
 	/* Set link bonding mode  */
 	TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonded_port_id,
@@ -1125,9 +1103,9 @@ test_adding_slave_after_bonded_device_started(void)
 {
 	int i;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 0)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 0),
+			"Failed to add slaves to bonded device");
 
 	/* Enabled slave devices */
 	for (i = 0; i < test_params->bonded_slave_count + 1; i++) {
@@ -1135,12 +1113,9 @@ test_adding_slave_after_bonded_device_started(void)
 				test_params->slave_port_ids[i], 1);
 	}
 
-	if (rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]) !=
-					0) {
-		printf("\t Failed to add slave to bonded port.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave to bonded port.\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count]);
@@ -1155,8 +1130,6 @@ test_adding_slave_after_bonded_device_started(void)
 
 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,
@@ -1180,7 +1153,7 @@ lsc_timeout(int wait_us)
 	gettimeofday(&tp, NULL);
 
 	/* Convert from timeval to timespec */
-	ts.tv_sec  = tp.tv_sec;
+	ts.tv_sec = tp.tv_sec;
 	ts.tv_nsec = tp.tv_usec * 1000;
 	ts.tv_nsec += wait_us * 1000;
 
@@ -1190,6 +1163,9 @@ lsc_timeout(int wait_us)
 
 	pthread_mutex_unlock(&mutex);
 
+	if (retval == 0 && test_lsc_interupt_count < 1)
+		return -1;
+
 	return retval;
 }
 
@@ -1199,9 +1175,6 @@ 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)
@@ -1281,9 +1254,6 @@ test_status_interrupt(void)
 				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();
 }
@@ -2025,6 +1995,101 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT (2)
+
+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 } ;
+
+static int
+test_roundrobin_verfiy_polling_slave_link_status_change(void)
+{
+	struct ether_addr *mac_addr = (struct ether_addr *)polling_slave_mac;
+	char slave_name[RTE_ETH_NAME_MAX_LEN];
+
+	int i;
+
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+		/* Generate slave name / MAC address */
+		snprintf(slave_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_poll_%d", i);
+		mac_addr->addr_bytes[ETHER_ADDR_LEN-1] = i;
+
+		/* Create slave devices with no ISR Support */
+		if (polling_test_slaves[i] == -1) {
+			polling_test_slaves[i] = virtual_ethdev_create(slave_name, mac_addr,
+					rte_socket_id(), 0);
+			TEST_ASSERT(polling_test_slaves[i] >= 0,
+					"Failed to create virtual virtual ethdev %s\n", slave_name);
+
+			/* Configure slave */
+			TEST_ASSERT_SUCCESS(configure_ethdev(polling_test_slaves[i], 0, 0),
+					"Failed to configure virtual ethdev %s(%d)", slave_name,
+					polling_test_slaves[i]);
+		}
+
+		/* Add slave to bonded device */
+		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);
+	}
+
+	/* Initialize bonded device */
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 1, 1),
+			"Failed to configure bonded device %d",
+			test_params->bonded_port_id);
+
+
+	/* 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);
+
+	/* link status change callback for first slave link up */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 1);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(15000), "timed out waiting for interrupt");
+
+
+	/* no link status change callback for second slave link up */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 1);
+
+	TEST_ASSERT_FAIL(lsc_timeout(15000), "unexpectedly succeeded");
+
+	/* link status change callback for both slave links down */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 0);
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 0);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(20000), "timed out waiting for interrupt");
+
+	/* Un-Register link status change interrupt callback */
+	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);
+
+
+	/* Clean up and remove slaves from bonded device */
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+
+		TEST_ASSERT_SUCCESS(
+				rte_eth_bond_slave_remove(test_params->bonded_port_id,
+						polling_test_slaves[i]),
+				"Failed to remove slave %d from bonded port (%d)",
+				polling_test_slaves[i], test_params->bonded_port_id);
+	}
+
+	return remove_slaves_and_stop_bonded_device();
+}
+
+
 /** Active Backup Mode Tests */
 
 static int
@@ -4311,6 +4376,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),
 		TEST_CASE(test_roundrobin_verify_mac_assignment),
 		TEST_CASE(test_roundrobin_verify_slave_link_status_change_behaviour),
+		TEST_CASE(test_roundrobin_verfiy_polling_slave_link_status_change),
 		TEST_CASE(test_activebackup_tx_burst),
 		TEST_CASE(test_activebackup_rx_burst),
 		TEST_CASE(test_activebackup_verify_promiscuous_enable_disable),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index f9bd841..fffaa35 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -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;
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 3b5c911..2462853 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -40,38 +40,58 @@ extern "C" {
 
 #include <rte_ether.h>
 
-int virtual_ethdev_init(void);
+int
+virtual_ethdev_init(void);
 
-int virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, uint8_t socket_id);
+int
+virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
+		uint8_t socket_id, uint8_t isr_support);
 
-void virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id, uint8_t link_status);
+void
+virtual_ethdev_set_link_status(uint8_t port_id, uint8_t link_status);
 
-void virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, struct rte_mbuf **pkts_burst, int burst_length);
+void
+virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id,
+		uint8_t link_status);
 
+void
+virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id,
+		struct rte_mbuf **pkts_burst, int burst_length);
 
-/** Control methods for the dev_ops functions pointer to control the behavior of the Virtual PMD */
 
-void virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
+/** Control methods for the dev_ops functions pointer to control the behavior
+ *  of the Virtual PMD */
 
-void virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_link_update_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_burst_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_link_update_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);
+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,
+void
+virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
 		uint8_t packet_fail_count);
 
 #ifdef __cplusplus
diff --git a/lib/librte_pmd_bond/rte_eth_bond.h b/lib/librte_pmd_bond/rte_eth_bond.h
index bd59780..6811c7b 100644
--- a/lib/librte_pmd_bond/rte_eth_bond.h
+++ b/lib/librte_pmd_bond/rte_eth_bond.h
@@ -248,6 +248,86 @@ rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy);
 int
 rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id);
 
+/**
+ * Set the link monitoring frequency (in ms) for monitoring the link status of
+ * slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param internal_ms		Monitoring interval in milliseconds
+ *
+ * @return
+ *	0 on success, negative value otherwise.
+ */
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms);
+
+/**
+ * Get the current link monitoring frequency (in ms) for monitoring of the link
+ * status of slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ *
+ * @return
+ *	Monitoring interval on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id);
+
+
+/**
+ * Set the period in milliseconds for delaying the disabling of a bonded link
+ * when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the disabling of a bonded
+ * link when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id);
+
+/**
+ * Set the period in milliseconds for delaying the enabling of a bonded link
+ * when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the enabling of a bonded
+ * link when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index dd33119..c690ceb 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -39,6 +39,8 @@
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
 
+#define DEFAULT_POLLING_INTERVAL_10_MS (10)
+
 int
 valid_bonded_ethdev(struct rte_eth_dev *eth_dev)
 {
@@ -63,9 +65,8 @@ valid_port_id(uint8_t port_id)
 	/* Verify that port id is valid */
 	int ethdev_count = rte_eth_dev_count();
 	if (port_id >= ethdev_count) {
-		RTE_LOG(ERR, PMD,
-				"%s: port Id %d is greater than rte_eth_dev_count %d\n",
-				__func__, port_id, ethdev_count);
+		RTE_BOND_LOG(ERR, "Port Id %d is greater than rte_eth_dev_count %d",
+				port_id, ethdev_count);
 		return -1;
 	}
 
@@ -81,9 +82,8 @@ valid_bonded_port_id(uint8_t port_id)
 
 	/* Verify that bonded_port_id refers to a bonded port */
 	if (valid_bonded_ethdev(&rte_eth_devices[port_id])) {
-		RTE_LOG(ERR, PMD,
-				"%s: Specified port Id %d is not a bonded eth_dev device\n",
-				__func__, port_id);
+		RTE_BOND_LOG(ERR, "Specified port Id %d is not a bonded eth_dev device",
+				port_id);
 		return -1;
 	}
 
@@ -136,37 +136,36 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	 */
 
 	if (name == NULL) {
-		RTE_LOG(ERR, PMD, "Invalid name specified\n");
+		RTE_BOND_LOG(ERR, "Invalid name specified");
 		goto err;
 	}
 
 	if (socket_id >= number_of_sockets()) {
-		RTE_LOG(ERR, PMD,
-				"%s: invalid socket id specified to create bonded device on.\n",
-				__func__);
+		RTE_BOND_LOG(ERR,
+				"Invalid socket id specified to create bonded device on.");
 		goto err;
 	}
 
 	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
 	if (pci_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci dev on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci dev on socket");
 		goto err;
 	}
 
 	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
 	if (eth_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc eth_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
 		goto err;
 	}
 
 	pci_drv = rte_zmalloc_socket(name, sizeof(*pci_drv), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_drv on socket");
 		goto err;
 	}
 	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_id_table on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
 		goto err;
 	}
 
@@ -181,14 +180,14 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
 		goto err;
 	}
 
 	/* reserve an ethdev entry */
 	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to allocate rte_eth_dev\n");
+		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
 		goto err;
 	}
 
@@ -218,9 +217,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->pci_dev = pci_dev;
 
 	if (bond_ethdev_mode_set(eth_dev, mode)) {
-		RTE_LOG(ERR, PMD,
-				"%s: failed to set bonded device %d mode too %d\n",
-				__func__, eth_dev->data->port_id, mode);
+		RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
+				 eth_dev->data->port_id, mode);
 		goto err;
 	}
 
@@ -228,15 +226,21 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
 	internals->user_defined_mac = 0;
 	internals->link_props_set = 0;
+
+	rte_spinlock_init(&internals->lock);
+
+	internals->link_status_polling_enabled = 0;
+
+	internals->link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS;
+	internals->link_down_delay_ms = 0;
+	internals->link_up_delay_ms = 0;
+
 	internals->slave_count = 0;
 	internals->active_slave_count = 0;
 
 	memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
 	memset(internals->slaves, 0, sizeof(internals->slaves));
 
-	memset(internals->presisted_slaves_conf, 0,
-			sizeof(internals->presisted_slaves_conf));
-
 	return eth_dev->data->port_id;
 
 err:
@@ -253,8 +257,8 @@ err:
 	return -1;
 }
 
-int
-rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
+static int
+__eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
 	struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
 	struct bond_dev_private *internals;
@@ -263,56 +267,43 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	int i, j;
 
-	/* Verify that port id's are valid bonded and slave ports */
-	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_add;
-
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_add;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
 
-	/*
-	 * Verify that new slave device is not already a slave of another bonded
-	 * device */
+	/* Verify that new slave device is not already a slave of another
+	 * bonded device */
 	for (i = rte_eth_dev_count()-1; i >= 0; i--) {
 		if (valid_bonded_ethdev(&rte_eth_devices[i]) == 0) {
 			temp_internals = rte_eth_devices[i].data->dev_private;
+
 			for (j = 0; j < temp_internals->slave_count; j++) {
 				/* Device already a slave of a bonded device */
-				if (temp_internals->slaves[j] == slave_port_id)
-					goto err_add;
+				if (temp_internals->slaves[j].port_id == slave_port_id) {
+					RTE_BOND_LOG(ERR, "Slave port %d is already a slave",
+							slave_port_id);
+					return -1;
+				}
 			}
 		}
 	}
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
-
 	slave_eth_dev = &rte_eth_devices[slave_port_id];
 
-	if (internals->slave_count > 0) {
-		/* Check that new slave device is the same type as the other slaves
-		 * and not repetitive */
-		for (i = 0; i < internals->slave_count; i++) {
-			if (slave_eth_dev->pci_dev->driver->id_table->device_id !=
-					rte_eth_devices[internals->slaves[i]].pci_dev->driver->id_table->device_id ||
-				internals->slaves[i] == slave_port_id)
-				goto err_add;
-		}
-	}
-
 	/* Add slave details to bonded device */
-	internals->slaves[internals->slave_count] = slave_port_id;
-
-	slave_config_store(internals, slave_eth_dev);
+	slave_add(internals, slave_eth_dev);
 
 	if (internals->slave_count < 1) {
-		/* if MAC is not user defined then use MAC of first slave add to bonded
-		 * device */
+		/* if MAC is not user defined then use MAC of first slave add to
+		 * bonded device */
 		if (!internals->user_defined_mac)
 			mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs);
 
 		/* Inherit eth dev link properties from first slave */
-		link_properties_set(bonded_eth_dev, &(slave_eth_dev->data->dev_link));
+		link_properties_set(bonded_eth_dev,
+				&(slave_eth_dev->data->dev_link));
 
 		/* Make primary slave */
 		internals->primary_port = slave_port_id;
@@ -322,10 +313,10 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->link_props_set) {
 			if (link_properties_valid(&(bonded_eth_dev->data->dev_link),
 									  &(slave_eth_dev->data->dev_link))) {
-				RTE_LOG(ERR, PMD,
-						"%s: Slave port %d link speed/duplex not supported\n",
-						__func__, slave_port_id);
-				goto err_add;
+				RTE_BOND_LOG(ERR,
+						"Slave port %d link speed/duplex not supported",
+						slave_port_id);
+				return -1;
 			}
 		} else {
 			link_properties_set(bonded_eth_dev,
@@ -340,9 +331,9 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	if (bonded_eth_dev->data->dev_started) {
 		if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
-			RTE_LOG(ERR, PMD, "rte_bond_slaves_configure: port=%d\n",
+			RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
 					slave_port_id);
-			goto err_add;
+			return -1;
 		}
 	}
 
@@ -356,65 +347,79 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 	if (bonded_eth_dev->data->dev_started) {
 		rte_eth_link_get_nowait(slave_port_id, &link_props);
 
-		 if (link_props.link_status == 1) {
+		 if (link_props.link_status == 1)
 			internals->active_slaves[internals->active_slave_count++] =
 					slave_port_id;
-		}
 	}
-
 	return 0;
 
-err_add:
-	RTE_LOG(ERR, PMD, "Failed to add port %d as slave\n", slave_port_id);
-	return -1;
-
 }
 
+
 int
-rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
+	struct rte_eth_dev *bonded_eth_dev;
 	struct bond_dev_private *internals;
-	struct slave_conf *slave_conf;
 
-	int i;
-	int pos = -1;
+	int retval;
 
 	/* Verify that port id's are valid bonded and slave ports */
 	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_del;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
+
+	return retval;
+}
+
+
+static int
+__eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct bond_dev_private *internals;
+
+	int i, slave_idx = -1;
 
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_del;
+		return -1;
 
 	internals = rte_eth_devices[bonded_port_id].data->dev_private;
 
 	/* first remove from active slave list */
 	for (i = 0; i < internals->active_slave_count; i++) {
 		if (internals->active_slaves[i] == slave_port_id)
-			pos = i;
+			slave_idx = i;
 
 		/* shift active slaves up active array list */
-		if (pos >= 0 && i < (internals->active_slave_count - 1))
+		if (slave_idx >= 0 && i < (internals->active_slave_count - 1))
 			internals->active_slaves[i] = internals->active_slaves[i+1];
 	}
 
-	if (pos >= 0)
+	if (slave_idx >= 0)
 		internals->active_slave_count--;
 
-	pos = -1;
-	/* now remove from slave list */
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == slave_port_id)
-			pos = i;
+	slave_idx = -1;
+	/* now find in slave list */
+	for (i = 0; i < internals->slave_count; i++)
+		if (internals->slaves[i].port_id == slave_port_id) {
+			slave_idx = i;
+			break;
+		}
 
-		/* shift slaves up list */
-		if (pos >= 0 && i < internals->slave_count)
-			internals->slaves[i] = internals->slaves[i+1];
+	if (slave_idx < 0) {
+		RTE_BOND_LOG(ERR, "Couldn't find slave in port list, slave count %d",
+				internals->slave_count);
+		return -1;
 	}
 
-	if (pos < 0)
-		goto err_del;
-
 	/* Un-register link status change callback with bonded device pointer as
 	 * argument*/
 	rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
@@ -422,13 +427,10 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 			&rte_eth_devices[bonded_port_id].data->port_id);
 
 	/* Restore original MAC address of slave device */
-	slave_conf = slave_config_get(internals, slave_port_id);
-
-	mac_address_set(&rte_eth_devices[slave_port_id], &(slave_conf->mac_addr));
+	mac_address_set(&rte_eth_devices[slave_port_id],
+			&(internals->slaves[slave_idx].persisted_mac_addr));
 
-	slave_config_clear(internals, &rte_eth_devices[slave_port_id]);
-
-	internals->slave_count--;
+	slave_remove(internals, &rte_eth_devices[slave_port_id]);
 
 	/*  first slave in the active list will be the primary by default,
 	 *  otherwise use first device in list */
@@ -436,7 +438,7 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->active_slave_count > 0)
 			internals->current_primary_port = internals->active_slaves[0];
 		else if (internals->slave_count > 0)
-			internals->current_primary_port = internals->slaves[0];
+			internals->current_primary_port = internals->slaves[0].port_id;
 		else
 			internals->primary_port = 0;
 	}
@@ -454,12 +456,28 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 	}
 
 	return 0;
+}
 
-err_del:
-	RTE_LOG(ERR, PMD,
-			"Cannot remove slave device (not present in bonded device)\n");
-	return -1;
+int
+rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct rte_eth_dev *bonded_eth_dev;
+	struct bond_dev_private *internals;
+	int retval;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
 
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_remove_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
+
+	return retval;
 }
 
 int
@@ -605,13 +623,13 @@ rte_eth_bond_mac_address_reset(uint8_t bonded_port_id)
 	internals->user_defined_mac = 0;
 
 	if (internals->slave_count > 0) {
-		struct slave_conf *conf;
-		conf = slave_config_get(internals, internals->primary_port);
-
 		/* Set MAC Address of Bonded Device */
-		if (mac_address_set(bonded_eth_dev, &conf->mac_addr) != 0)
+		if (mac_address_set(bonded_eth_dev,
+				&internals->slaves[internals->primary_port].persisted_mac_addr)
+				!= 0) {
+			RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
 			return -1;
-
+		}
 		/* Update all slave devices MAC addresses */
 		return mac_address_slaves_update(bonded_eth_dev);
 	}
@@ -654,3 +672,88 @@ rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id)
 
 	return internals->balance_xmit_policy;
 }
+
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_status_polling_interval_ms = internal_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_status_polling_interval_ms;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_down_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_down_delay_ms;
+}
+
+
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_up_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_up_delay_ms;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_args.c b/lib/librte_pmd_bond/rte_eth_bond_args.c
index 11d9816..bbbc69b 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_args.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_args.c
@@ -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;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 6018feb..6d0fb1b 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -40,6 +40,7 @@
 #include <rte_devargs.h>
 #include <rte_kvargs.h>
 #include <rte_dev.h>
+#include <rte_alarm.h>
 
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
@@ -454,16 +455,16 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr)
 	mac_addr = eth_dev->data->mac_addrs;
 
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", __func__);
+		RTE_BOND_LOG(ERR,  "NULL pointer eth_dev specified");
 		return -1;
 	}
 
 	if (new_mac_addr == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer MAC specified\n", __func__);
+		RTE_BOND_LOG(ERR, "NULL pointer MAC specified");
 		return -1;
 	}
 
-	/* if new MAC is different to current MAC then update */
+	/* If new MAC is different to current MAC then update */
 	if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0)
 		memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr));
 
@@ -485,11 +486,10 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_BALANCE:
 	case BONDING_MODE_BROADCAST:
 		for (i = 0; i < internals->slave_count; i++) {
-			if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
+			if (mac_address_set(&rte_eth_devices[internals->slaves[i].port_id],
 					bonded_eth_dev->data->mac_addrs)) {
-				RTE_LOG(ERR, PMD,
-						"%s: Failed to update port Id %d MAC address\n",
-						__func__, internals->slaves[i]);
+				RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+						internals->slaves[i].port_id);
 				return -1;
 			}
 		}
@@ -497,23 +497,20 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_ACTIVE_BACKUP:
 	default:
 		for (i = 0; i < internals->slave_count; i++) {
-			if (internals->slaves[i] == internals->current_primary_port) {
+			if (internals->slaves[i].port_id ==
+					internals->current_primary_port) {
 				if (mac_address_set(&rte_eth_devices[internals->primary_port],
 						bonded_eth_dev->data->mac_addrs)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->current_primary_port);
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->current_primary_port);
+					return -1;
 				}
 			} else {
-				struct slave_conf *conf =
-						slave_config_get(internals, internals->slaves[i]);
-
-				if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
-						&conf->mac_addr)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->slaves[i]);
-
+				if (mac_address_set(
+						&rte_eth_devices[internals->slaves[i].port_id],
+						&internals->slaves[i].persisted_mac_addr)) {
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->slaves[i].port_id);
 					return -1;
 				}
 			}
@@ -560,37 +557,47 @@ int
 slave_configure(struct rte_eth_dev *bonded_eth_dev,
 		struct rte_eth_dev *slave_eth_dev)
 {
+	struct bond_dev_private *internals = bonded_eth_dev->data->dev_private;
+
 	struct bond_rx_queue *bd_rx_q;
 	struct bond_tx_queue *bd_tx_q;
 
-	int q_id;
+	int errval, q_id;
 
 	/* Stop slave */
 	rte_eth_dev_stop(slave_eth_dev->data->port_id);
 
-	/* Enable interrupts on slave device */
-	slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
+	/* Enable interrupts on slave device if supported */
+	if (slave_eth_dev->driver->pci_drv.drv_flags & RTE_PCI_DRV_INTR_LSC)
+		slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
+	else
+		internals->link_status_polling_enabled = 1;
+
 
-	if (rte_eth_dev_configure(slave_eth_dev->data->port_id,
+	/* Configure device */
+	errval = rte_eth_dev_configure(slave_eth_dev->data->port_id,
 			bonded_eth_dev->data->nb_rx_queues,
 			bonded_eth_dev->data->nb_tx_queues,
-			&(slave_eth_dev->data->dev_conf)) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot configure slave device: port=%u\n",
-				slave_eth_dev->data->port_id);
-		return -1;
+			&(slave_eth_dev->data->dev_conf));
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "Cannot configure slave device: port %u , err (%d)",
+				slave_eth_dev->data->port_id, errval);
+		return errval;
 	}
 
 	/* Setup Rx Queues */
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
 		bd_rx_q = (struct bond_rx_queue *)bonded_eth_dev->data->rx_queues[q_id];
 
-		if (rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_rx_q->nb_rx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_rx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_rx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
@@ -598,69 +605,65 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
 		bd_tx_q = (struct bond_tx_queue *)bonded_eth_dev->data->tx_queues[q_id];
 
-		if (rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_tx_q->nb_tx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&bd_tx_q->tx_conf) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_tx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&bd_tx_q->tx_conf);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_tx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
 	/* Start device */
-	if (rte_eth_dev_start(slave_eth_dev->data->port_id) != 0) {
-		RTE_LOG(ERR, PMD, "rte_eth_dev_start: port=%u\n",
-				slave_eth_dev->data->port_id);
+	errval = rte_eth_dev_start(slave_eth_dev->data->port_id);
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "rte_eth_dev_start: port=%u, err (%d)",
+				slave_eth_dev->data->port_id, errval);
 		return -1;
 	}
 
 	return 0;
 }
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id)
-{
-	int i;
-
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id == slave_port_id)
-			return &internals->presisted_slaves_conf[i];
-	}
-	return NULL;
-}
-
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
 	int i, found = 0;
 
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id ==
-				slave_eth_dev->data->port_id) {
+		if (internals->slaves[i].port_id ==	slave_eth_dev->data->port_id)
 			found = 1;
-			memset(&internals->presisted_slaves_conf[i], 0,
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
-		if (found && i < (internals->slave_count - 1)) {
-			memcpy(&internals->presisted_slaves_conf[i],
-					&internals->presisted_slaves_conf[i+1],
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
+
+		if (found && i < (internals->slave_count - 1))
+			memcpy(&internals->slaves[i], &internals->slaves[i+1],
+					sizeof(internals->slaves[i]));
 	}
+
+	internals->slave_count--;
 }
 
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
-	struct slave_conf *presisted_slave_conf =
-			&internals->presisted_slaves_conf[internals->slave_count];
+	struct bond_slave_details *slave_details =
+			&internals->slaves[internals->slave_count];
+
+	slave_details->port_id = slave_eth_dev->data->port_id;
+	slave_details->last_link_status = 0;
+
+	/* if slave device doesn't support interrupts then we need to enabled
+	 * polling to monitor link status */
+	if (!(slave_eth_dev->pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC))
+		slave_details->link_status_polling_enabled = 1;
 
-	presisted_slave_conf->port_id = slave_eth_dev->data->port_id;
+	slave_details->link_status_wait_to_complete = 0;
 
-	memcpy(&(presisted_slave_conf->mac_addr), slave_eth_dev->data->mac_addrs,
+	memcpy(&(slave_details->persisted_mac_addr), slave_eth_dev->data->mac_addrs,
 			sizeof(struct ether_addr));
 }
 
@@ -683,6 +686,9 @@ bond_ethdev_primary_set(struct bond_dev_private *internals,
 static void
 bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev);
 
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg);
+
 static int
 bond_ethdev_start(struct rte_eth_dev *eth_dev)
 {
@@ -691,31 +697,33 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* slave eth dev will be started by bonded device */
 	if (valid_bonded_ethdev(eth_dev)) {
-		RTE_LOG(ERR, PMD,
-				"%s: user tried to explicitly start a slave eth_dev (%d) of the bonded eth_dev\n",
-				__func__, eth_dev->data->port_id);
+		RTE_BOND_LOG(ERR, "User tried to explicitly start a slave eth_dev (%d)",
+				eth_dev->data->port_id);
 		return -1;
 	}
 
-	eth_dev->data->dev_link.link_status = 1;
+	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 1;
 
 	internals = eth_dev->data->dev_private;
 
 	if (internals->slave_count == 0) {
-		RTE_LOG(ERR, PMD,
-				"%s: Cannot start port since there are no slave devices\n",
-				__func__);
+		RTE_BOND_LOG(ERR, "Cannot start port since there are no slave devices");
 		return -1;
 	}
 
 	if (internals->user_defined_mac == 0) {
-		struct slave_conf *conf = slave_config_get(internals,
-				internals->primary_port);
+		struct ether_addr *new_mac_addr = NULL;
+
+		for (i = 0; i < internals->slave_count; i++)
+			if (internals->slaves[i].port_id == internals->primary_port)
+				new_mac_addr = &internals->slaves[i].persisted_mac_addr;
+
+		if (new_mac_addr == NULL)
+			return -1;
 
-		if (mac_address_set(eth_dev, &(conf->mac_addr)) != 0) {
-			RTE_LOG(ERR, PMD,
-					"bonded port (%d) failed to update mac address",
+		if (mac_address_set(eth_dev, new_mac_addr) != 0) {
+			RTE_BOND_LOG(ERR, "bonded port (%d) failed to update MAC address",
 					eth_dev->data->port_id);
 			return -1;
 		}
@@ -731,11 +739,11 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* Reconfigure each slave device if starting bonded device */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (slave_configure(eth_dev, &(rte_eth_devices[internals->slaves[i]]))
-				!= 0) {
-			RTE_LOG(ERR, PMD, "bonded port "
-					"(%d) failed to reconfigure slave device (%d)\n)",
-					eth_dev->data->port_id, internals->slaves[i]);
+		if (slave_configure(eth_dev,
+				&(rte_eth_devices[internals->slaves[i].port_id])) != 0) {
+			RTE_BOND_LOG(ERR,
+					"bonded port (%d) failed to reconfigure slave device (%d)",
+					eth_dev->data->port_id, internals->slaves[i].port_id);
 			return -1;
 		}
 	}
@@ -743,6 +751,12 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 	if (internals->user_defined_primary_port)
 		bond_ethdev_primary_set(internals, internals->primary_port);
 
+
+	if (internals->link_status_polling_enabled)
+		rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+				bond_ethdev_slave_link_status_change_monitor,
+				(void *)eth_dev);
+
 	return 0;
 }
 
@@ -752,6 +766,7 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 	struct bond_dev_private *internals = eth_dev->data->dev_private;
 
 	internals->active_slave_count = 0;
+	internals->link_status_polling_enabled = 0;
 
 	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 0;
@@ -848,6 +863,57 @@ bond_ethdev_tx_queue_release(void *queue)
 	rte_free(queue);
 }
 
+
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
+{
+	struct rte_eth_dev *bonded_ethdev, *slave_ethdev;
+	struct bond_dev_private *internals;
+
+	int i;
+
+	if (cb_arg == NULL)
+		return;
+
+	bonded_ethdev = (struct rte_eth_dev *)cb_arg;
+	internals = (struct bond_dev_private *)bonded_ethdev->data->dev_private;
+
+	if (!bonded_ethdev->data->dev_started ||
+		!internals->link_status_polling_enabled)
+		return;
+
+	/* If device is currently being configured then don't check slaves link
+	 * status, wait until next period */
+	if (rte_spinlock_trylock(&internals->lock)){
+		for (i = 0; i < internals->slave_count; i++) {
+			if (internals->slaves[i].link_status_polling_enabled) {
+				slave_ethdev = &rte_eth_devices[internals->slaves[i].port_id];
+
+				/* Update slave link status */
+				(*slave_ethdev->dev_ops->link_update)(slave_ethdev,
+						internals->slaves[i].link_status_wait_to_complete);
+
+				/* if link status has changed since last checked then call lsc
+				 * event callback */
+				if (slave_ethdev->data->dev_link.link_status !=
+						internals->slaves[i].last_link_status) {
+					internals->slaves[i].last_link_status =
+							slave_ethdev->data->dev_link.link_status;
+
+					bond_ethdev_lsc_event_callback(internals->slaves[i].port_id,
+							RTE_ETH_EVENT_INTR_LSC,
+							&bonded_ethdev->data->port_id);
+				}
+			}
+		}
+		rte_spinlock_unlock(&internals->lock);
+	}
+
+	/* Set alarm to continue monitoring link status of slave ethdev's */
+	rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+			bond_ethdev_slave_link_status_change_monitor, cb_arg);
+}
+
 static int
 bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev,
 		int wait_to_complete)
@@ -891,7 +957,7 @@ bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	memset(stats, 0, sizeof(*stats));
 
 	for (i = 0; i < internals->slave_count; i++) {
-		rte_eth_stats_get(internals->slaves[i], &slave_stats);
+		rte_eth_stats_get(internals->slaves[i].port_id, &slave_stats);
 
 		stats->ipackets += slave_stats.ipackets;
 		stats->opackets += slave_stats.opackets;
@@ -917,7 +983,7 @@ bond_ethdev_stats_reset(struct rte_eth_dev *dev)
 	int i;
 
 	for (i = 0; i < internals->slave_count; i++)
-		rte_eth_stats_reset(internals->slaves[i]);
+		rte_eth_stats_reset(internals->slaves[i].port_id);
 }
 
 static void
@@ -934,7 +1000,7 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)
 	case BONDING_MODE_BALANCE:
 	case BONDING_MODE_BROADCAST:
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_enable(internals->slaves[i]);
+			rte_eth_promiscuous_enable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -958,7 +1024,7 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	case BONDING_MODE_BALANCE:
 	case BONDING_MODE_BROADCAST:
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_disable(internals->slaves[i]);
+			rte_eth_promiscuous_disable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -967,6 +1033,16 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	}
 }
 
+static void
+bond_ethdev_delayed_lsc_propagation(void *arg)
+{
+	if (arg == NULL)
+		return;
+
+	_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
+			RTE_ETH_EVENT_INTR_LSC);
+}
+
 void
 bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		void *param)
@@ -995,7 +1071,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 
 	/* verify that port_id is a valid slave of bonded port */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == port_id) {
+		if (internals->slaves[i].port_id == port_id) {
 			valid_slave = 1;
 			break;
 		}
@@ -1064,8 +1140,32 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		}
 	}
 
-	if (lsc_flag)
-		_rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
+	if (lsc_flag) {
+		/* Cancel any possible outstanding interrupts if delays are enabled */
+		if (internals->link_up_delay_ms > 0 ||
+			internals->link_down_delay_ms > 0)
+			rte_eal_alarm_cancel(bond_ethdev_delayed_lsc_propagation,
+					bonded_eth_dev);
+
+		if (bonded_eth_dev->data->dev_link.link_status) {
+			if (internals->link_up_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_up_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+
+		} else {
+			if (internals->link_down_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_down_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+		}
+	}
 }
 
 struct eth_dev_ops default_dev_ops = {
@@ -1193,8 +1293,8 @@ bond_init(const char *name, const char *params)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(ERR, EAL,
-				"Transmit policy can be specified only once for bonded device %s\n",
-				name);
+				"Transmit policy can be specified only once for bonded device"
+				" %s\n", name);
 		return -1;
 	}
 
@@ -1236,8 +1336,8 @@ bond_init(const char *name, const char *params)
 				&bond_ethdev_parse_primary_slave_port_id_kvarg,
 				&primary_slave_port_id) < 0) {
 			RTE_LOG(INFO, EAL,
-					"Invalid primary slave port id specified for bonded device %s\n",
-					name);
+					"Invalid primary slave port id specified for bonded device"
+					" %s\n", name);
 			return -1;
 		}
 
@@ -1251,8 +1351,97 @@ bond_init(const char *name, const char *params)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(INFO, EAL,
-				"Primary slave can be specified only once for bonded device %s\n",
-				name);
+				"Primary slave can be specified only once for bonded device"
+				" %s\n", name);
+		return -1;
+	}
+
+	/* Parse link status monitor polling interval */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LSC_POLL_PERIOD_KVARG);
+	if (arg_count == 1) {
+		uint32_t lsc_poll_interval_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LSC_POLL_PERIOD_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&lsc_poll_interval_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid lsc polling interval value specified for bonded"
+					"device %s\n", name);
+			return -1;
+		}
+
+		if (rte_eth_bond_link_monitoring_set(port_id, lsc_poll_interval_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set lsc monitor polling interval (%u ms) on"
+					" bonded device %s\n", lsc_poll_interval_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"LSC polling interval can be specified only once for bonded"
+				"device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link up interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_UP_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_up_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_UP_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_up_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link up propagation delay value specified for "
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_up_prop_delay_set(port_id, link_up_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link up propagation delay (%u ms) on bonded"
+					"device %s\n", link_up_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link up propagation delay can be specified only once for "
+				"bonded device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link down interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_down_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_down_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link down propagation delay value specified for"
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_down_prop_delay_set(port_id, link_down_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link down propagation delay (%u ms) on"
+					" bonded device %s\n", link_down_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link down propagation delay can be specified only once for"
+				" bonded device %s\n", name);
 		return -1;
 	}
 
diff --git a/lib/librte_pmd_bond/rte_eth_bond_private.h b/lib/librte_pmd_bond/rte_eth_bond_private.h
index 60f1e8d..6db5144 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_private.h
+++ b/lib/librte_pmd_bond/rte_eth_bond_private.h
@@ -39,20 +39,27 @@ extern "C" {
 #endif
 
 #include <rte_ethdev.h>
+#include <rte_spinlock.h>
 
 #include "rte_eth_bond.h"
 
-#define PMD_BOND_SLAVE_PORT_KVARG		("slave")
-#define PMD_BOND_PRIMARY_SLAVE_KVARG	("primary")
-#define PMD_BOND_MODE_KVARG				("mode")
-#define PMD_BOND_XMIT_POLICY_KVARG		("xmit_policy")
-#define PMD_BOND_SOCKET_ID_KVARG		("socket_id")
-#define PMD_BOND_MAC_ADDR_KVARG			("mac")
+#define PMD_BOND_SLAVE_PORT_KVARG			("slave")
+#define PMD_BOND_PRIMARY_SLAVE_KVARG		("primary")
+#define PMD_BOND_MODE_KVARG					("mode")
+#define PMD_BOND_XMIT_POLICY_KVARG			("xmit_policy")
+#define PMD_BOND_SOCKET_ID_KVARG			("socket_id")
+#define PMD_BOND_MAC_ADDR_KVARG				("mac")
+#define PMD_BOND_LSC_POLL_PERIOD_KVARG		("lsc_poll_period_ms")
+#define PMD_BOND_LINK_UP_PROP_DELAY_KVARG	("up_delay")
+#define PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG	("down_delay")
 
 #define PMD_BOND_XMIT_POLICY_LAYER2_KVARG	("l2")
 #define PMD_BOND_XMIT_POLICY_LAYER23_KVARG	("l23")
 #define PMD_BOND_XMIT_POLICY_LAYER34_KVARG	("l34")
 
+#define RTE_BOND_LOG(lvl, msg, ...) 		\
+	RTE_LOG(lvl, PMD, "%s(%d) - " msg "\n", __func__, __LINE__, ##__VA_ARGS__);
+
 extern const char *pmd_bond_init_valid_arguments[];
 
 extern const char *driver_name;
@@ -82,27 +89,36 @@ struct bond_tx_queue {
 	/**< Copy of TX configuration structure for queue */
 };
 
-/** Persisted Slave Configuration Structure */
-struct slave_conf {
-	uint8_t port_id;
-	/**< Port Id of slave eth_dev */
-	struct ether_addr mac_addr;
-	/**< Slave eth_dev original MAC address */
-};
+
 /** Bonded slave devices structure */
 struct bond_ethdev_slave_ports {
 	uint8_t slaves[RTE_MAX_ETHPORTS];	/**< Slave port id array */
 	uint8_t slave_count;				/**< Number of slaves */
 };
 
+struct bond_slave_details {
+	uint8_t port_id;
+
+	uint8_t link_status_polling_enabled;
+	uint8_t link_status_wait_to_complete;
+	uint8_t last_link_status;
+
+	/**< Port Id of slave eth_dev */
+	struct ether_addr persisted_mac_addr;
+};
+
 /** Link Bonding PMD device private configuration Structure */
 struct bond_dev_private {
+	uint8_t port_id;					/**< Port Id of Bonded Port */
 	uint8_t mode;						/**< Link Bonding Mode */
 
+	rte_spinlock_t lock;
+
 	uint8_t primary_port;				/**< Primary Slave Port */
 	uint8_t current_primary_port;		/**< Primary Slave Port */
 	uint8_t user_defined_primary_port;
 	/**< Flag for whether primary port is user defined or not */
+
 	uint8_t balance_xmit_policy;
 	/**< Transmit policy - l2 / l23 / l34 for operation in balance mode */
 	uint8_t user_defined_mac;
@@ -110,19 +126,23 @@ struct bond_dev_private {
 	uint8_t promiscuous_en;
 	/**< Enabled/disable promiscuous mode on slave devices */
 	uint8_t link_props_set;
-	/**< Bonded eth_dev link properties set */
+	/**< flag to denote if the link properties are set */
+
+	uint8_t link_status_polling_enabled;
+	uint32_t link_status_polling_interval_ms;
+
+	uint32_t link_down_delay_ms;
+	uint32_t link_up_delay_ms;
 
 	uint16_t nb_rx_queues;			/**< Total number of rx queues */
 	uint16_t nb_tx_queues;			/**< Total number of tx queues*/
 
-	uint8_t slave_count;			/**< Number of active slaves */
-	uint8_t active_slave_count;		/**< Number of slaves */
-
+	uint8_t active_slave_count;		/**< Number of active slaves */
 	uint8_t active_slaves[RTE_MAX_ETHPORTS];	/**< Active slave list */
-	uint8_t slaves[RTE_MAX_ETHPORTS];			/**< Slave list */
 
-	/** Persisted configuration of slaves */
-	struct slave_conf presisted_slaves_conf[RTE_MAX_ETHPORTS];
+	uint8_t slave_count;			/**< Number of bonded slaves */
+	struct bond_slave_details slaves[RTE_MAX_ETHPORTS];
+	/**< Arary of bonded slaves details */
 };
 
 extern struct eth_dev_ops default_dev_ops;
@@ -166,16 +186,13 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id);
-
 void
 bond_ethdev_primary_set(struct bond_dev_private *internals,
 		uint8_t slave_port_id);
@@ -208,6 +225,10 @@ int
 bond_ethdev_parse_bond_mac_addr_kvarg(const char *key __rte_unused,
 		const char *value, void *extra_args);
 
+int
+bond_ethdev_parse_time_ms_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v3 5/5] bond: unit test test macro refactor
  2014-09-23 13:18   ` [dpdk-dev] [PATCH v3 0/5] link bonding Declan Doherty
                       ` (3 preceding siblings ...)
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 4/5] bond: lsc polling support Declan Doherty
@ 2014-09-23 13:18     ` Declan Doherty
  4 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-23 13:18 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/test_link_bonding.c | 2574 +++++++++++++++++-------------------------
 1 files changed, 1036 insertions(+), 1538 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index c32b685..c4fcaf7 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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;
-	}
+	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);
 
 	/* Send to sets of packet burst and verify that they are balanced across
 	 *  slaves */
 	burst_size = 21;
 
-	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");
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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");
+
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, &pkt_burst[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][0],
-			burst_size) != burst_size) {
-		printf("rte_eth_tx_burst failed\n");
-		return -1;
-	}
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size);
 
 	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 (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[2], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[2], (int)port_stats.opackets,
+			burst_size);
 
 	/* verify that all packets get send on primary slave when no other slaves
 	 * are available */
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[2], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id, slaves,
-			RTE_MAX_ETHPORTS) != 1) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_active_slaves_get(
+			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS), 1,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 1);
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][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[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size +
-			burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)(burst_size + burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
-
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[0], 0);
@@ -3668,16 +3244,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 			test_params->slave_port_ids[3], 1);
 
 	for (i = 0; i < TEST_BALANCE_LINK_STATUS_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,
+				"Failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
-
-
 	/* Verify that pkts are not received on slaves with link status down */
 
 	rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
@@ -3685,12 +3259,10 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size * 3)) {
-		printf("(%d) port_stats.ipackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.ipackets,
-				burst_size * 3);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)(burst_size * 3),
+			"(%d) port_stats.ipackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.ipackets,
+			burst_size * 3);
 
 	/* free mbufs allocate for rx testing */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
@@ -3711,16 +3283,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 static int
 test_broadcast_tx_burst(void)
 {
-	int i, pktlen, retval, burst_size, generated_burst_size, nb_tx;
+	int i, pktlen, burst_size;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 
 	struct rte_eth_stats port_stats;
 
-	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;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 2, 1),
+			"Failed to intialise bonded device");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
@@ -3732,46 +3302,37 @@ test_broadcast_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,
+	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);
-	if (generated_burst_size != burst_size)
-		return -1;
+			1), burst_size, "Failed to generate packet burst");
 
 	/* 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) {
-		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);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+			pkts_burst, burst_size), burst_size,
+			"Bonded Port (%d) rx burst failed, packets transmitted value "
+			"not as expected (%d)",
+			test_params->bonded_port_id, burst_size);
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size *
-			test_params->bonded_slave_count) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
-				burst_size);
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)burst_size * test_params->bonded_slave_count,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			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) {
-			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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)\n",
+				test_params->bonded_port_id,
+				(unsigned int)port_stats.opackets, burst_size);
 	}
 
 	/* Put all slaves down and try and transmit */
@@ -3782,10 +3343,9 @@ 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 != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkts_burst, burst_size),  0,
+			"transmitted an unexpected number of packets");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -3921,20 +3481,20 @@ test_broadcast_rx_burst(void)
 	struct rte_eth_stats port_stats;
 
 	int burst_size[BROADCAST_RX_BURST_NUM_OF_SLAVES] = { 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_BROADCAST, 0, 3, 1) != 0)
-		return -1;
-
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 3, 1),
+			"Failed to intialise bonded device");
 
 	/* Generate test bursts of packets to transmit */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; 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 slave 0 */
@@ -3946,57 +3506,44 @@ test_broadcast_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("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[0] + burst_size[1] + burst_size[2],
+			"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[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[0], (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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; i++) {
@@ -4015,48 +3562,38 @@ test_broadcast_rx_burst(void)
 static int
 test_broadcast_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_BROADCAST, 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 */
@@ -4068,45 +3605,39 @@ test_broadcast_verify_mac_assignment(void)
 {
 	struct ether_addr read_mac_addr, expected_mac_addr_0, expected_mac_addr_1;
 
-	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_1);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 4, 1),
+			"Failed to intialise bonded device");
 
 	/* Verify that all MACs are the same as first slave added to bonded
 	 * device */
 	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
@@ -4114,45 +3645,41 @@ test_broadcast_verify_mac_assignment(void)
 
 	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 new primary"
-				" port\n", test_params->slave_port_ids[i]);
-		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 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_1, &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_1, &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 address");
 
 	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_params->slave_port_ids[i]);
-		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 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(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", test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -4174,26 +3701,22 @@ 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, 0,
-			BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+				BONDING_MODE_BROADCAST, 0, BROADCAST_LINK_STATUS_NUM_OF_SLAVES,
+				1), "Failed to intialise bonded device");
 
 	/* 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;
-	}
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+	TEST_ASSERT_EQUAL(slave_count, 4,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 4);
 
 	/* Set 2 slaves link status to down */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -4203,11 +3726,9 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != 2) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, 2,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 2);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++)
 		rte_eth_stats_reset(test_params->slave_port_ids[i]);
@@ -4215,80 +3736,62 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	/* Verify that pkts are not sent on slaves with link status down */
 	burst_size = 21;
 
-	if (generate_test_burst(&pkt_burst[0][0], burst_size, 0, 0, 1, 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, 0, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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\n");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size * slave_count)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size * slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size * slave_count),
+			"(%d) port_stats.opackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size * slave_count);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%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_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[1]);
-		return -1;
-	}
 
 	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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[2]);
-		return -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]);
+
 
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
-		if (generate_test_burst(&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0) !=
-				burst_size) {
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0),
+				burst_size, "failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
 	/* Verify that pkts are not received on slaves with link status down */
+	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");
 
-	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;
-	}
 
 	/* 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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
@@ -4310,19 +3813,14 @@ 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)  != 0) {
-		printf("failed to reconfigure bonded device");
-		return -1;
-	}
-
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device");
 
 	test_params->nb_rx_q = 2;
 	test_params->nb_tx_q = 2;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
-		printf("failed to reconfigure bonded device with less rx/tx queues");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device with less rx/tx queues");
 
 	return 0;
 }
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/5] bond: lsc polling support
  2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 4/5] bond: lsc polling support Declan Doherty
@ 2014-09-24 13:16       ` Ananyev, Konstantin
  0 siblings, 0 replies; 91+ messages in thread
From: Ananyev, Konstantin @ 2014-09-24 13:16 UTC (permalink / raw)
  To: Doherty, Declan, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty
> Sent: Tuesday, September 23, 2014 2:18 PM
> To: dev@dpdk.org
> 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.
> 
> 
> Signed-off-by: Declan Doherty <declan.doherty@intel.com>
> ---
>  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(-)
> 
> --
> 1.7.4.1

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v4 0/8] link bonding
  2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
                   ` (13 preceding siblings ...)
  2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
@ 2014-09-30  9:57 ` Declan Doherty
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 1/8] bond: link status interrupt support Declan Doherty
                     ` (10 more replies)
  14 siblings, 11 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-30  9:57 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v4 1/8] bond: link status interrupt support
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
@ 2014-09-30  9:57   ` Declan Doherty
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 2/8] bond: removing switch statement from rx burst method Declan Doherty
                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-30  9:57 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index db5b180..cce32ed 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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),
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index 75f5694..dd33119 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -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,
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 08d3b5f..aca2dcf 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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 = {
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v4 2/8] bond: removing switch statement from rx burst method
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 1/8] bond: link status interrupt support Declan Doherty
@ 2014-09-30  9:57   ` Declan Doherty
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-30  9:57 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 62 +++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 27 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index aca2dcf..348e28f 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v4 3/8] bond: fix naming inconsistency in tx_burst_round_robin
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 1/8] bond: link status interrupt support Declan Doherty
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 2/8] bond: removing switch statement from rx burst method Declan Doherty
@ 2014-09-30  9:57   ` Declan Doherty
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
                     ` (7 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-30  9:57 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 348e28f..66f1650 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v4 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
                     ` (2 preceding siblings ...)
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
@ 2014-09-30  9:57   ` Declan Doherty
  2014-10-13 15:29     ` De Lara Guarch, Pablo
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 5/8] test app: adding support for generating variable sized packet bursts Declan Doherty
                     ` (6 subsequent siblings)
  10 siblings, 1 reply; 91+ messages in thread
From: Declan Doherty @ 2014-09-30  9:57 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index cce32ed..1a847eb 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index e861c5b..f9bd841 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -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->tx_burst_fail_count;
+
+		/* 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)
 {
 	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
 
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 766b6ac..3b5c911 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -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
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 66f1650..2215afe 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
 	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
 	 * 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]);
+	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,
+					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;
+
+				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]));
+			}
+			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;
 
-	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;
 
 	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
+		 * 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
+	 * handle failures of all packets except those of the most successful slave
+	 */
+	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]++]);
+
+	return max_nb_of_tx_pkts;
 }
 
 void
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v4 5/8] test app: adding support for generating variable sized packet bursts
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
                     ` (3 preceding siblings ...)
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
@ 2014-09-30  9:57   ` Declan Doherty
  2014-10-24  3:22     ` Liang, Cunming
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
                     ` (5 subsequent siblings)
  10 siblings, 1 reply; 91+ messages in thread
From: Declan Doherty @ 2014-09-30  9:57 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c
index 9e747a4..b2824dc 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -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) {
diff --git a/app/test/packet_burst_generator.h b/app/test/packet_burst_generator.h
index 5b3cd6c..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -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
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 1a847eb..50355a3 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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;
 
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v4 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
                     ` (4 preceding siblings ...)
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 5/8] test app: adding support for generating variable sized packet bursts Declan Doherty
@ 2014-09-30  9:57   ` Declan Doherty
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 7/8] bond: lsc polling support Declan Doherty
                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-30  9:57 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 225f669..15ca493 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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);
 	}
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 9f6cdc4..66e3c7c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 9cbfeac..5a3423c 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v4 7/8] bond: lsc polling support
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
                     ` (5 preceding siblings ...)
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
@ 2014-09-30  9:57   ` Declan Doherty
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 8/8] bond: unit test test macro refactor Declan Doherty
                     ` (3 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-30  9:57 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 15ca493..b14df61 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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,
diff --git a/app/test/test.h b/app/test/test.h
index 98ab804..24b1640 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -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;											\
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 50355a3..c32b685 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -234,42 +234,34 @@ configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 	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;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_dev_configure(port_id, test_params->nb_rx_q,
+			test_params->nb_tx_q, &default_pmd_conf),
+			"rte_eth_dev_configure for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++) {
-		if (rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
+	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
 				rte_eth_dev_socket_id(port_id), &rx_conf_default,
-				test_params->mbuf_pool) < 0) {
-			goto error;
-		}
-	}
+				test_params->mbuf_pool) ,
+				"rte_eth_rx_queue_setup for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++) {
-		if (rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
-				rte_eth_dev_socket_id(port_id), &tx_conf_default) < 0) {
-			printf("Failed to setup tx queue (%d).\n", q_id);
-			goto error;
-		}
-	}
+	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
+				rte_eth_dev_socket_id(port_id), &tx_conf_default),
+				"rte_eth_tx_queue_setup for port %d failed", port_id);
 
-	if (start) {
-		if (rte_eth_dev_start(port_id) < 0) {
-			printf("Failed to start device (%d).\n", port_id);
-			goto error;
-		}
-	}
-	return 0;
+	if (start)
+		TEST_ASSERT_SUCCESS(rte_eth_dev_start(port_id),
+				"rte_eth_dev_start for port %d failed", port_id);
 
-error:
-	printf("Failed to configure ethdev %d\n", port_id);
-	return -1;
+	return 0;
 }
 
 static int slaves_initialized;
 
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
+
+
 static int
 test_setup(void)
 {
@@ -310,7 +302,7 @@ test_setup(void)
 			snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_%d", i);
 
 			test_params->slave_port_ids[i] = virtual_ethdev_create(pmd_name,
-					mac_addr, rte_socket_id());
+					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;
@@ -414,34 +406,27 @@ test_create_bonded_device_with_invalid_params(void)
 static int
 test_add_slave_to_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]);
-	if (retval != 0) {
-		printf("Failed to add slave (%d) to bonded port (%d).\n",
-				test_params->bonded_port_id,
-				test_params->slave_port_ids[test_params->bonded_slave_count]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave (%d) to bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count],
+			test_params->bonded_port_id);
 
 	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 + 1) {
-		printf("Number of slaves (%d) is greater than expected (%d).\n",
-				current_slave_count, test_params->bonded_slave_count + 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count + 1,
+			"Number of slaves (%d) is greater than expected (%d).",
+			current_slave_count, test_params->bonded_slave_count + 1);
 
 	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 as expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
+					"Number of active slaves (%d) is not as expected (%d).\n",
+					current_slave_count, 0);
 
 	test_params->bonded_slave_count++;
 
@@ -476,27 +461,23 @@ test_add_slave_to_invalid_bonded_device(void)
 static int
 test_remove_slave_from_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 	struct ether_addr read_mac_addr, *mac_addr;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_remove(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
-	if (retval != 0) {
-		printf("\t Failed to remove slave %d from bonded port (%d).\n",
-				test_params->slave_port_ids[test_params->bonded_slave_count-1],
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_remove(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count-1]),
+			"Failed to remove slave %d from bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count-1],
+			test_params->bonded_port_id);
 
 
 	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 - 1) {
-		printf("Number of slaves (%d) is great than expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count - 1,
+			"Number of slaves (%d) is great than expected (%d).\n",
+			current_slave_count, test_params->bonded_slave_count - 1);
 
 
 	mac_addr = (struct ether_addr *)slave_mac;
@@ -506,10 +487,8 @@ test_remove_slave_from_bonded_device(void)
 	rte_eth_macaddr_get(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1],
 			&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\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
@@ -888,21 +867,20 @@ test_set_primary_slave(void)
 		return -1;
 	}
 
+	/* 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;
+	}
+
 	/* Set slave as primary
 	 * Verify slave it is now primary slave
 	 * Verify that MAC address of bonded device is that of primary slave
 	 * Verify that MAC address of all bonded slaves are that of primary slave
 	 */
 	for (i = 0; i < 4; i++) {
-
-		/* 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;
-		}
-
 		retval = rte_eth_bond_primary_set(test_params->bonded_port_id,
 				test_params->slave_port_ids[i]);
 		if (retval != 0) {
@@ -926,6 +904,7 @@ test_set_primary_slave(void)
 
 		/* 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;
 
@@ -1090,19 +1069,18 @@ static int
 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 */
+	/* Configure bonded device */
 	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);
 
-	while (number_of_slaves > test_params->bonded_slave_count) {
-		/* Add slaves to bonded device */
+	/* Add slaves to bonded device */
+	while (number_of_slaves > test_params->bonded_slave_count)
 		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
 				"Failed to add slave (%d to  bonding port (%d).",
 				test_params->bonded_slave_count - 1,
 				test_params->bonded_port_id);
-	}
 
 	/* Set link bonding mode  */
 	TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonded_port_id,
@@ -1125,9 +1103,9 @@ test_adding_slave_after_bonded_device_started(void)
 {
 	int i;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 0)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 0),
+			"Failed to add slaves to bonded device");
 
 	/* Enabled slave devices */
 	for (i = 0; i < test_params->bonded_slave_count + 1; i++) {
@@ -1135,12 +1113,9 @@ test_adding_slave_after_bonded_device_started(void)
 				test_params->slave_port_ids[i], 1);
 	}
 
-	if (rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]) !=
-					0) {
-		printf("\t Failed to add slave to bonded port.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave to bonded port.\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count]);
@@ -1155,8 +1130,6 @@ test_adding_slave_after_bonded_device_started(void)
 
 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,
@@ -1180,7 +1153,7 @@ lsc_timeout(int wait_us)
 	gettimeofday(&tp, NULL);
 
 	/* Convert from timeval to timespec */
-	ts.tv_sec  = tp.tv_sec;
+	ts.tv_sec = tp.tv_sec;
 	ts.tv_nsec = tp.tv_usec * 1000;
 	ts.tv_nsec += wait_us * 1000;
 
@@ -1190,6 +1163,9 @@ lsc_timeout(int wait_us)
 
 	pthread_mutex_unlock(&mutex);
 
+	if (retval == 0 && test_lsc_interupt_count < 1)
+		return -1;
+
 	return retval;
 }
 
@@ -1199,9 +1175,6 @@ 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)
@@ -1281,9 +1254,6 @@ test_status_interrupt(void)
 				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();
 }
@@ -2025,6 +1995,101 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT (2)
+
+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 } ;
+
+static int
+test_roundrobin_verfiy_polling_slave_link_status_change(void)
+{
+	struct ether_addr *mac_addr = (struct ether_addr *)polling_slave_mac;
+	char slave_name[RTE_ETH_NAME_MAX_LEN];
+
+	int i;
+
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+		/* Generate slave name / MAC address */
+		snprintf(slave_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_poll_%d", i);
+		mac_addr->addr_bytes[ETHER_ADDR_LEN-1] = i;
+
+		/* Create slave devices with no ISR Support */
+		if (polling_test_slaves[i] == -1) {
+			polling_test_slaves[i] = virtual_ethdev_create(slave_name, mac_addr,
+					rte_socket_id(), 0);
+			TEST_ASSERT(polling_test_slaves[i] >= 0,
+					"Failed to create virtual virtual ethdev %s\n", slave_name);
+
+			/* Configure slave */
+			TEST_ASSERT_SUCCESS(configure_ethdev(polling_test_slaves[i], 0, 0),
+					"Failed to configure virtual ethdev %s(%d)", slave_name,
+					polling_test_slaves[i]);
+		}
+
+		/* Add slave to bonded device */
+		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);
+	}
+
+	/* Initialize bonded device */
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 1, 1),
+			"Failed to configure bonded device %d",
+			test_params->bonded_port_id);
+
+
+	/* 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);
+
+	/* link status change callback for first slave link up */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 1);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(15000), "timed out waiting for interrupt");
+
+
+	/* no link status change callback for second slave link up */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 1);
+
+	TEST_ASSERT_FAIL(lsc_timeout(15000), "unexpectedly succeeded");
+
+	/* link status change callback for both slave links down */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 0);
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 0);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(20000), "timed out waiting for interrupt");
+
+	/* Un-Register link status change interrupt callback */
+	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);
+
+
+	/* Clean up and remove slaves from bonded device */
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+
+		TEST_ASSERT_SUCCESS(
+				rte_eth_bond_slave_remove(test_params->bonded_port_id,
+						polling_test_slaves[i]),
+				"Failed to remove slave %d from bonded port (%d)",
+				polling_test_slaves[i], test_params->bonded_port_id);
+	}
+
+	return remove_slaves_and_stop_bonded_device();
+}
+
+
 /** Active Backup Mode Tests */
 
 static int
@@ -4311,6 +4376,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),
 		TEST_CASE(test_roundrobin_verify_mac_assignment),
 		TEST_CASE(test_roundrobin_verify_slave_link_status_change_behaviour),
+		TEST_CASE(test_roundrobin_verfiy_polling_slave_link_status_change),
 		TEST_CASE(test_activebackup_tx_burst),
 		TEST_CASE(test_activebackup_rx_burst),
 		TEST_CASE(test_activebackup_verify_promiscuous_enable_disable),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index f9bd841..fffaa35 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -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;
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 3b5c911..2462853 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -40,38 +40,58 @@ extern "C" {
 
 #include <rte_ether.h>
 
-int virtual_ethdev_init(void);
+int
+virtual_ethdev_init(void);
 
-int virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, uint8_t socket_id);
+int
+virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
+		uint8_t socket_id, uint8_t isr_support);
 
-void virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id, uint8_t link_status);
+void
+virtual_ethdev_set_link_status(uint8_t port_id, uint8_t link_status);
 
-void virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, struct rte_mbuf **pkts_burst, int burst_length);
+void
+virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id,
+		uint8_t link_status);
 
+void
+virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id,
+		struct rte_mbuf **pkts_burst, int burst_length);
 
-/** Control methods for the dev_ops functions pointer to control the behavior of the Virtual PMD */
 
-void virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
+/** Control methods for the dev_ops functions pointer to control the behavior
+ *  of the Virtual PMD */
 
-void virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_link_update_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_burst_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_link_update_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);
+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,
+void
+virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
 		uint8_t packet_fail_count);
 
 #ifdef __cplusplus
diff --git a/lib/librte_pmd_bond/rte_eth_bond.h b/lib/librte_pmd_bond/rte_eth_bond.h
index bd59780..6811c7b 100644
--- a/lib/librte_pmd_bond/rte_eth_bond.h
+++ b/lib/librte_pmd_bond/rte_eth_bond.h
@@ -248,6 +248,86 @@ rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy);
 int
 rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id);
 
+/**
+ * Set the link monitoring frequency (in ms) for monitoring the link status of
+ * slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param internal_ms		Monitoring interval in milliseconds
+ *
+ * @return
+ *	0 on success, negative value otherwise.
+ */
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms);
+
+/**
+ * Get the current link monitoring frequency (in ms) for monitoring of the link
+ * status of slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ *
+ * @return
+ *	Monitoring interval on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id);
+
+
+/**
+ * Set the period in milliseconds for delaying the disabling of a bonded link
+ * when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the disabling of a bonded
+ * link when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id);
+
+/**
+ * Set the period in milliseconds for delaying the enabling of a bonded link
+ * when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the enabling of a bonded
+ * link when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index dd33119..f146bda 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -39,6 +39,8 @@
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
 
+#define DEFAULT_POLLING_INTERVAL_10_MS (10)
+
 int
 valid_bonded_ethdev(struct rte_eth_dev *eth_dev)
 {
@@ -63,9 +65,8 @@ valid_port_id(uint8_t port_id)
 	/* Verify that port id is valid */
 	int ethdev_count = rte_eth_dev_count();
 	if (port_id >= ethdev_count) {
-		RTE_LOG(ERR, PMD,
-				"%s: port Id %d is greater than rte_eth_dev_count %d\n",
-				__func__, port_id, ethdev_count);
+		RTE_BOND_LOG(ERR, "Port Id %d is greater than rte_eth_dev_count %d",
+				port_id, ethdev_count);
 		return -1;
 	}
 
@@ -81,9 +82,8 @@ valid_bonded_port_id(uint8_t port_id)
 
 	/* Verify that bonded_port_id refers to a bonded port */
 	if (valid_bonded_ethdev(&rte_eth_devices[port_id])) {
-		RTE_LOG(ERR, PMD,
-				"%s: Specified port Id %d is not a bonded eth_dev device\n",
-				__func__, port_id);
+		RTE_BOND_LOG(ERR, "Specified port Id %d is not a bonded eth_dev device",
+				port_id);
 		return -1;
 	}
 
@@ -136,37 +136,36 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	 */
 
 	if (name == NULL) {
-		RTE_LOG(ERR, PMD, "Invalid name specified\n");
+		RTE_BOND_LOG(ERR, "Invalid name specified");
 		goto err;
 	}
 
 	if (socket_id >= number_of_sockets()) {
-		RTE_LOG(ERR, PMD,
-				"%s: invalid socket id specified to create bonded device on.\n",
-				__func__);
+		RTE_BOND_LOG(ERR,
+				"Invalid socket id specified to create bonded device on.");
 		goto err;
 	}
 
 	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
 	if (pci_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci dev on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci dev on socket");
 		goto err;
 	}
 
 	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
 	if (eth_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc eth_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
 		goto err;
 	}
 
 	pci_drv = rte_zmalloc_socket(name, sizeof(*pci_drv), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_drv on socket");
 		goto err;
 	}
 	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_id_table on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
 		goto err;
 	}
 
@@ -181,14 +180,14 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
 		goto err;
 	}
 
 	/* reserve an ethdev entry */
 	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to allocate rte_eth_dev\n");
+		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
 		goto err;
 	}
 
@@ -218,25 +217,31 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->pci_dev = pci_dev;
 
 	if (bond_ethdev_mode_set(eth_dev, mode)) {
-		RTE_LOG(ERR, PMD,
-				"%s: failed to set bonded device %d mode too %d\n",
-				__func__, eth_dev->data->port_id, mode);
+		RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
+				 eth_dev->data->port_id, mode);
 		goto err;
 	}
 
+	rte_spinlock_init(&internals->lock);
+
+	internals->port_id = eth_dev->data->port_id;
 	internals->current_primary_port = 0;
 	internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
 	internals->user_defined_mac = 0;
 	internals->link_props_set = 0;
+
+	internals->link_status_polling_enabled = 0;
+
+	internals->link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS;
+	internals->link_down_delay_ms = 0;
+	internals->link_up_delay_ms = 0;
+
 	internals->slave_count = 0;
 	internals->active_slave_count = 0;
 
 	memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
 	memset(internals->slaves, 0, sizeof(internals->slaves));
 
-	memset(internals->presisted_slaves_conf, 0,
-			sizeof(internals->presisted_slaves_conf));
-
 	return eth_dev->data->port_id;
 
 err:
@@ -253,8 +258,8 @@ err:
 	return -1;
 }
 
-int
-rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
+static int
+__eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
 	struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
 	struct bond_dev_private *internals;
@@ -263,56 +268,43 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	int i, j;
 
-	/* Verify that port id's are valid bonded and slave ports */
-	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_add;
-
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_add;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
 
-	/*
-	 * Verify that new slave device is not already a slave of another bonded
-	 * device */
+	/* Verify that new slave device is not already a slave of another
+	 * bonded device */
 	for (i = rte_eth_dev_count()-1; i >= 0; i--) {
 		if (valid_bonded_ethdev(&rte_eth_devices[i]) == 0) {
 			temp_internals = rte_eth_devices[i].data->dev_private;
+
 			for (j = 0; j < temp_internals->slave_count; j++) {
 				/* Device already a slave of a bonded device */
-				if (temp_internals->slaves[j] == slave_port_id)
-					goto err_add;
+				if (temp_internals->slaves[j].port_id == slave_port_id) {
+					RTE_BOND_LOG(ERR, "Slave port %d is already a slave",
+							slave_port_id);
+					return -1;
+				}
 			}
 		}
 	}
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
-
 	slave_eth_dev = &rte_eth_devices[slave_port_id];
 
-	if (internals->slave_count > 0) {
-		/* Check that new slave device is the same type as the other slaves
-		 * and not repetitive */
-		for (i = 0; i < internals->slave_count; i++) {
-			if (slave_eth_dev->pci_dev->driver->id_table->device_id !=
-					rte_eth_devices[internals->slaves[i]].pci_dev->driver->id_table->device_id ||
-				internals->slaves[i] == slave_port_id)
-				goto err_add;
-		}
-	}
-
 	/* Add slave details to bonded device */
-	internals->slaves[internals->slave_count] = slave_port_id;
-
-	slave_config_store(internals, slave_eth_dev);
+	slave_add(internals, slave_eth_dev);
 
 	if (internals->slave_count < 1) {
-		/* if MAC is not user defined then use MAC of first slave add to bonded
-		 * device */
+		/* if MAC is not user defined then use MAC of first slave add to
+		 * bonded device */
 		if (!internals->user_defined_mac)
 			mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs);
 
 		/* Inherit eth dev link properties from first slave */
-		link_properties_set(bonded_eth_dev, &(slave_eth_dev->data->dev_link));
+		link_properties_set(bonded_eth_dev,
+				&(slave_eth_dev->data->dev_link));
 
 		/* Make primary slave */
 		internals->primary_port = slave_port_id;
@@ -322,10 +314,10 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->link_props_set) {
 			if (link_properties_valid(&(bonded_eth_dev->data->dev_link),
 									  &(slave_eth_dev->data->dev_link))) {
-				RTE_LOG(ERR, PMD,
-						"%s: Slave port %d link speed/duplex not supported\n",
-						__func__, slave_port_id);
-				goto err_add;
+				RTE_BOND_LOG(ERR,
+						"Slave port %d link speed/duplex not supported",
+						slave_port_id);
+				return -1;
 			}
 		} else {
 			link_properties_set(bonded_eth_dev,
@@ -340,9 +332,9 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	if (bonded_eth_dev->data->dev_started) {
 		if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
-			RTE_LOG(ERR, PMD, "rte_bond_slaves_configure: port=%d\n",
+			RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
 					slave_port_id);
-			goto err_add;
+			return -1;
 		}
 	}
 
@@ -356,65 +348,79 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 	if (bonded_eth_dev->data->dev_started) {
 		rte_eth_link_get_nowait(slave_port_id, &link_props);
 
-		 if (link_props.link_status == 1) {
+		 if (link_props.link_status == 1)
 			internals->active_slaves[internals->active_slave_count++] =
 					slave_port_id;
-		}
 	}
-
 	return 0;
 
-err_add:
-	RTE_LOG(ERR, PMD, "Failed to add port %d as slave\n", slave_port_id);
-	return -1;
-
 }
 
+
 int
-rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
+	struct rte_eth_dev *bonded_eth_dev;
 	struct bond_dev_private *internals;
-	struct slave_conf *slave_conf;
 
-	int i;
-	int pos = -1;
+	int retval;
 
 	/* Verify that port id's are valid bonded and slave ports */
 	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_del;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
+
+	return retval;
+}
+
+
+static int
+__eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct bond_dev_private *internals;
+
+	int i, slave_idx = -1;
 
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_del;
+		return -1;
 
 	internals = rte_eth_devices[bonded_port_id].data->dev_private;
 
 	/* first remove from active slave list */
 	for (i = 0; i < internals->active_slave_count; i++) {
 		if (internals->active_slaves[i] == slave_port_id)
-			pos = i;
+			slave_idx = i;
 
 		/* shift active slaves up active array list */
-		if (pos >= 0 && i < (internals->active_slave_count - 1))
+		if (slave_idx >= 0 && i < (internals->active_slave_count - 1))
 			internals->active_slaves[i] = internals->active_slaves[i+1];
 	}
 
-	if (pos >= 0)
+	if (slave_idx >= 0)
 		internals->active_slave_count--;
 
-	pos = -1;
-	/* now remove from slave list */
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == slave_port_id)
-			pos = i;
+	slave_idx = -1;
+	/* now find in slave list */
+	for (i = 0; i < internals->slave_count; i++)
+		if (internals->slaves[i].port_id == slave_port_id) {
+			slave_idx = i;
+			break;
+		}
 
-		/* shift slaves up list */
-		if (pos >= 0 && i < internals->slave_count)
-			internals->slaves[i] = internals->slaves[i+1];
+	if (slave_idx < 0) {
+		RTE_BOND_LOG(ERR, "Couldn't find slave in port list, slave count %d",
+				internals->slave_count);
+		return -1;
 	}
 
-	if (pos < 0)
-		goto err_del;
-
 	/* Un-register link status change callback with bonded device pointer as
 	 * argument*/
 	rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
@@ -422,13 +428,10 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 			&rte_eth_devices[bonded_port_id].data->port_id);
 
 	/* Restore original MAC address of slave device */
-	slave_conf = slave_config_get(internals, slave_port_id);
+	mac_address_set(&rte_eth_devices[slave_port_id],
+			&(internals->slaves[slave_idx].persisted_mac_addr));
 
-	mac_address_set(&rte_eth_devices[slave_port_id], &(slave_conf->mac_addr));
-
-	slave_config_clear(internals, &rte_eth_devices[slave_port_id]);
-
-	internals->slave_count--;
+	slave_remove(internals, &rte_eth_devices[slave_port_id]);
 
 	/*  first slave in the active list will be the primary by default,
 	 *  otherwise use first device in list */
@@ -436,7 +439,7 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->active_slave_count > 0)
 			internals->current_primary_port = internals->active_slaves[0];
 		else if (internals->slave_count > 0)
-			internals->current_primary_port = internals->slaves[0];
+			internals->current_primary_port = internals->slaves[0].port_id;
 		else
 			internals->primary_port = 0;
 	}
@@ -454,12 +457,28 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 	}
 
 	return 0;
+}
 
-err_del:
-	RTE_LOG(ERR, PMD,
-			"Cannot remove slave device (not present in bonded device)\n");
-	return -1;
+int
+rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct rte_eth_dev *bonded_eth_dev;
+	struct bond_dev_private *internals;
+	int retval;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_remove_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
 
+	return retval;
 }
 
 int
@@ -524,6 +543,7 @@ int
 rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 {
 	struct bond_dev_private *internals;
+	int i;
 
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
@@ -536,10 +556,10 @@ rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 	if (internals->slave_count > len)
 		return -1;
 
-	memcpy(slaves, internals->slaves, internals->slave_count);
+	for (i = 0; i < internals->slave_count; i++)
+		slaves[i] = internals->slaves[i].port_id;
 
 	return internals->slave_count;
-
 }
 
 int
@@ -605,13 +625,13 @@ rte_eth_bond_mac_address_reset(uint8_t bonded_port_id)
 	internals->user_defined_mac = 0;
 
 	if (internals->slave_count > 0) {
-		struct slave_conf *conf;
-		conf = slave_config_get(internals, internals->primary_port);
-
 		/* Set MAC Address of Bonded Device */
-		if (mac_address_set(bonded_eth_dev, &conf->mac_addr) != 0)
+		if (mac_address_set(bonded_eth_dev,
+				&internals->slaves[internals->primary_port].persisted_mac_addr)
+				!= 0) {
+			RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
 			return -1;
-
+		}
 		/* Update all slave devices MAC addresses */
 		return mac_address_slaves_update(bonded_eth_dev);
 	}
@@ -654,3 +674,88 @@ rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id)
 
 	return internals->balance_xmit_policy;
 }
+
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_status_polling_interval_ms = internal_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_status_polling_interval_ms;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_down_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_down_delay_ms;
+}
+
+
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_up_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_up_delay_ms;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_args.c b/lib/librte_pmd_bond/rte_eth_bond_args.c
index 11d9816..bbbc69b 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_args.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_args.c
@@ -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;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 2215afe..2a953d1 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -40,6 +40,7 @@
 #include <rte_devargs.h>
 #include <rte_kvargs.h>
 #include <rte_dev.h>
+#include <rte_alarm.h>
 
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
@@ -454,16 +455,16 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr)
 	mac_addr = eth_dev->data->mac_addrs;
 
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", __func__);
+		RTE_BOND_LOG(ERR,  "NULL pointer eth_dev specified");
 		return -1;
 	}
 
 	if (new_mac_addr == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer MAC specified\n", __func__);
+		RTE_BOND_LOG(ERR, "NULL pointer MAC specified");
 		return -1;
 	}
 
-	/* if new MAC is different to current MAC then update */
+	/* If new MAC is different to current MAC then update */
 	if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0)
 		memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr));
 
@@ -485,11 +486,10 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_BALANCE:
 	case BONDING_MODE_BROADCAST:
 		for (i = 0; i < internals->slave_count; i++) {
-			if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
+			if (mac_address_set(&rte_eth_devices[internals->slaves[i].port_id],
 					bonded_eth_dev->data->mac_addrs)) {
-				RTE_LOG(ERR, PMD,
-						"%s: Failed to update port Id %d MAC address\n",
-						__func__, internals->slaves[i]);
+				RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+						internals->slaves[i].port_id);
 				return -1;
 			}
 		}
@@ -497,23 +497,20 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_ACTIVE_BACKUP:
 	default:
 		for (i = 0; i < internals->slave_count; i++) {
-			if (internals->slaves[i] == internals->current_primary_port) {
+			if (internals->slaves[i].port_id ==
+					internals->current_primary_port) {
 				if (mac_address_set(&rte_eth_devices[internals->primary_port],
 						bonded_eth_dev->data->mac_addrs)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->current_primary_port);
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->current_primary_port);
+					return -1;
 				}
 			} else {
-				struct slave_conf *conf =
-						slave_config_get(internals, internals->slaves[i]);
-
-				if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
-						&conf->mac_addr)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->slaves[i]);
-
+				if (mac_address_set(
+						&rte_eth_devices[internals->slaves[i].port_id],
+						&internals->slaves[i].persisted_mac_addr)) {
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->slaves[i].port_id);
 					return -1;
 				}
 			}
@@ -563,34 +560,39 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	struct bond_rx_queue *bd_rx_q;
 	struct bond_tx_queue *bd_tx_q;
 
-	int q_id;
+	int errval, q_id;
 
 	/* Stop slave */
 	rte_eth_dev_stop(slave_eth_dev->data->port_id);
 
-	/* Enable interrupts on slave device */
-	slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
+	/* Enable interrupts on slave device if supported */
+	if (slave_eth_dev->driver->pci_drv.drv_flags & RTE_PCI_DRV_INTR_LSC)
+		slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
 
-	if (rte_eth_dev_configure(slave_eth_dev->data->port_id,
+	/* Configure device */
+	errval = rte_eth_dev_configure(slave_eth_dev->data->port_id,
 			bonded_eth_dev->data->nb_rx_queues,
 			bonded_eth_dev->data->nb_tx_queues,
-			&(slave_eth_dev->data->dev_conf)) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot configure slave device: port=%u\n",
-				slave_eth_dev->data->port_id);
-		return -1;
+			&(slave_eth_dev->data->dev_conf));
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "Cannot configure slave device: port %u , err (%d)",
+				slave_eth_dev->data->port_id, errval);
+		return errval;
 	}
 
 	/* Setup Rx Queues */
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
 		bd_rx_q = (struct bond_rx_queue *)bonded_eth_dev->data->rx_queues[q_id];
 
-		if (rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_rx_q->nb_rx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_rx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_rx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
@@ -598,69 +600,77 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
 		bd_tx_q = (struct bond_tx_queue *)bonded_eth_dev->data->tx_queues[q_id];
 
-		if (rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_tx_q->nb_tx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&bd_tx_q->tx_conf) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_tx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&bd_tx_q->tx_conf);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_tx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
 	/* Start device */
-	if (rte_eth_dev_start(slave_eth_dev->data->port_id) != 0) {
-		RTE_LOG(ERR, PMD, "rte_eth_dev_start: port=%u\n",
-				slave_eth_dev->data->port_id);
+	errval = rte_eth_dev_start(slave_eth_dev->data->port_id);
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "rte_eth_dev_start: port=%u, err (%d)",
+				slave_eth_dev->data->port_id, errval);
 		return -1;
 	}
 
 	return 0;
 }
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id)
-{
-	int i;
-
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id == slave_port_id)
-			return &internals->presisted_slaves_conf[i];
-	}
-	return NULL;
-}
-
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
 	int i, found = 0;
 
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id ==
-				slave_eth_dev->data->port_id) {
+		if (internals->slaves[i].port_id ==	slave_eth_dev->data->port_id)
 			found = 1;
-			memset(&internals->presisted_slaves_conf[i], 0,
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
-		if (found && i < (internals->slave_count - 1)) {
-			memcpy(&internals->presisted_slaves_conf[i],
-					&internals->presisted_slaves_conf[i+1],
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
+
+		if (found && i < (internals->slave_count - 1))
+			memcpy(&internals->slaves[i], &internals->slaves[i+1],
+					sizeof(internals->slaves[i]));
 	}
+
+	internals->slave_count--;
 }
 
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg);
+
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
-	struct slave_conf *presisted_slave_conf =
-			&internals->presisted_slaves_conf[internals->slave_count];
+	struct bond_slave_details *slave_details =
+			&internals->slaves[internals->slave_count];
+
+	slave_details->port_id = slave_eth_dev->data->port_id;
+	slave_details->last_link_status = 0;
+
+	/* If slave device doesn't support interrupts then we need to enabled
+	 * polling to monitor link status */
+	if (!(slave_eth_dev->pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
+		slave_details->link_status_poll_enabled = 1;
+
+		if (!internals->link_status_polling_enabled) {
+			internals->link_status_polling_enabled = 1;
 
-	presisted_slave_conf->port_id = slave_eth_dev->data->port_id;
+			rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+					bond_ethdev_slave_link_status_change_monitor,
+					(void *)&rte_eth_devices[internals->port_id]);
+		}
+	}
 
-	memcpy(&(presisted_slave_conf->mac_addr), slave_eth_dev->data->mac_addrs,
+	slave_details->link_status_wait_to_complete = 0;
+
+	memcpy(&(slave_details->persisted_mac_addr), slave_eth_dev->data->mac_addrs,
 			sizeof(struct ether_addr));
 }
 
@@ -691,31 +701,33 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* slave eth dev will be started by bonded device */
 	if (valid_bonded_ethdev(eth_dev)) {
-		RTE_LOG(ERR, PMD,
-				"%s: user tried to explicitly start a slave eth_dev (%d) of the bonded eth_dev\n",
-				__func__, eth_dev->data->port_id);
+		RTE_BOND_LOG(ERR, "User tried to explicitly start a slave eth_dev (%d)",
+				eth_dev->data->port_id);
 		return -1;
 	}
 
-	eth_dev->data->dev_link.link_status = 1;
+	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 1;
 
 	internals = eth_dev->data->dev_private;
 
 	if (internals->slave_count == 0) {
-		RTE_LOG(ERR, PMD,
-				"%s: Cannot start port since there are no slave devices\n",
-				__func__);
+		RTE_BOND_LOG(ERR, "Cannot start port since there are no slave devices");
 		return -1;
 	}
 
 	if (internals->user_defined_mac == 0) {
-		struct slave_conf *conf = slave_config_get(internals,
-				internals->primary_port);
+		struct ether_addr *new_mac_addr = NULL;
+
+		for (i = 0; i < internals->slave_count; i++)
+			if (internals->slaves[i].port_id == internals->primary_port)
+				new_mac_addr = &internals->slaves[i].persisted_mac_addr;
+
+		if (new_mac_addr == NULL)
+			return -1;
 
-		if (mac_address_set(eth_dev, &(conf->mac_addr)) != 0) {
-			RTE_LOG(ERR, PMD,
-					"bonded port (%d) failed to update mac address",
+		if (mac_address_set(eth_dev, new_mac_addr) != 0) {
+			RTE_BOND_LOG(ERR, "bonded port (%d) failed to update MAC address",
 					eth_dev->data->port_id);
 			return -1;
 		}
@@ -731,11 +743,11 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* Reconfigure each slave device if starting bonded device */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (slave_configure(eth_dev, &(rte_eth_devices[internals->slaves[i]]))
-				!= 0) {
-			RTE_LOG(ERR, PMD, "bonded port "
-					"(%d) failed to reconfigure slave device (%d)\n)",
-					eth_dev->data->port_id, internals->slaves[i]);
+		if (slave_configure(eth_dev,
+				&(rte_eth_devices[internals->slaves[i].port_id])) != 0) {
+			RTE_BOND_LOG(ERR,
+					"bonded port (%d) failed to reconfigure slave device (%d)",
+					eth_dev->data->port_id, internals->slaves[i].port_id);
 			return -1;
 		}
 	}
@@ -752,6 +764,7 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 	struct bond_dev_private *internals = eth_dev->data->dev_private;
 
 	internals->active_slave_count = 0;
+	internals->link_status_polling_enabled = 0;
 
 	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 0;
@@ -845,6 +858,65 @@ bond_ethdev_tx_queue_release(void *queue)
 	rte_free(queue);
 }
 
+
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
+{
+	struct rte_eth_dev *bonded_ethdev, *slave_ethdev;
+	struct bond_dev_private *internals;
+
+	/* Default value for polling slave found is true as we don't want to
+	 * disable the polling thread if we cannot get the lock */
+	int i, polling_slave_found = 1;
+
+	if (cb_arg == NULL)
+		return;
+
+	bonded_ethdev = (struct rte_eth_dev *)cb_arg;
+	internals = (struct bond_dev_private *)bonded_ethdev->data->dev_private;
+
+	if (!bonded_ethdev->data->dev_started ||
+		!internals->link_status_polling_enabled)
+		return;
+
+	/* If device is currently being configured then don't check slaves link
+	 * status, wait until next period */
+	if (rte_spinlock_trylock(&internals->lock)){
+		if (internals->slave_count > 0)
+			polling_slave_found = 0;
+
+		for (i = 0; i < internals->slave_count; i++) {
+			if (!internals->slaves[i].link_status_poll_enabled)
+				continue;
+
+			slave_ethdev = &rte_eth_devices[internals->slaves[i].port_id];
+			polling_slave_found = 1;
+
+			/* Update slave link status */
+			(*slave_ethdev->dev_ops->link_update)(slave_ethdev,
+					internals->slaves[i].link_status_wait_to_complete);
+
+			/* if link status has changed since last checked then call lsc
+			 * event callback */
+			if (slave_ethdev->data->dev_link.link_status !=
+					internals->slaves[i].last_link_status) {
+				internals->slaves[i].last_link_status =
+						slave_ethdev->data->dev_link.link_status;
+
+				bond_ethdev_lsc_event_callback(internals->slaves[i].port_id,
+						RTE_ETH_EVENT_INTR_LSC,
+						&bonded_ethdev->data->port_id);
+			}
+		}
+		rte_spinlock_unlock(&internals->lock);
+	}
+
+	if (polling_slave_found)
+		/* Set alarm to continue monitoring link status of slave ethdev's */
+		rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+				bond_ethdev_slave_link_status_change_monitor, cb_arg);
+}
+
 static int
 bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev,
 		int wait_to_complete)
@@ -888,7 +960,7 @@ bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	memset(stats, 0, sizeof(*stats));
 
 	for (i = 0; i < internals->slave_count; i++) {
-		rte_eth_stats_get(internals->slaves[i], &slave_stats);
+		rte_eth_stats_get(internals->slaves[i].port_id, &slave_stats);
 
 		stats->ipackets += slave_stats.ipackets;
 		stats->opackets += slave_stats.opackets;
@@ -914,7 +986,7 @@ bond_ethdev_stats_reset(struct rte_eth_dev *dev)
 	int i;
 
 	for (i = 0; i < internals->slave_count; i++)
-		rte_eth_stats_reset(internals->slaves[i]);
+		rte_eth_stats_reset(internals->slaves[i].port_id);
 }
 
 static void
@@ -931,7 +1003,7 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)
 	case BONDING_MODE_BALANCE:
 	case BONDING_MODE_BROADCAST:
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_enable(internals->slaves[i]);
+			rte_eth_promiscuous_enable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -955,7 +1027,7 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	case BONDING_MODE_BALANCE:
 	case BONDING_MODE_BROADCAST:
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_disable(internals->slaves[i]);
+			rte_eth_promiscuous_disable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -964,6 +1036,16 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	}
 }
 
+static void
+bond_ethdev_delayed_lsc_propagation(void *arg)
+{
+	if (arg == NULL)
+		return;
+
+	_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
+			RTE_ETH_EVENT_INTR_LSC);
+}
+
 void
 bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		void *param)
@@ -992,7 +1074,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 
 	/* verify that port_id is a valid slave of bonded port */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == port_id) {
+		if (internals->slaves[i].port_id == port_id) {
 			valid_slave = 1;
 			break;
 		}
@@ -1061,8 +1143,32 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		}
 	}
 
-	if (lsc_flag)
-		_rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
+	if (lsc_flag) {
+		/* Cancel any possible outstanding interrupts if delays are enabled */
+		if (internals->link_up_delay_ms > 0 ||
+			internals->link_down_delay_ms > 0)
+			rte_eal_alarm_cancel(bond_ethdev_delayed_lsc_propagation,
+					bonded_eth_dev);
+
+		if (bonded_eth_dev->data->dev_link.link_status) {
+			if (internals->link_up_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_up_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+
+		} else {
+			if (internals->link_down_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_down_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+		}
+	}
 }
 
 struct eth_dev_ops default_dev_ops = {
@@ -1212,8 +1318,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(ERR, EAL,
-				"Transmit policy can be specified only once for bonded device %s\n",
-				name);
+				"Transmit policy can be specified only once for bonded device"
+				" %s\n", name);
 		return -1;
 	}
 
@@ -1255,8 +1361,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				&bond_ethdev_parse_primary_slave_port_id_kvarg,
 				&primary_slave_port_id) < 0) {
 			RTE_LOG(INFO, EAL,
-					"Invalid primary slave port id specified for bonded device %s\n",
-					name);
+					"Invalid primary slave port id specified for bonded device"
+					" %s\n", name);
 			return -1;
 		}
 
@@ -1270,8 +1376,97 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(INFO, EAL,
-				"Primary slave can be specified only once for bonded device %s\n",
-				name);
+				"Primary slave can be specified only once for bonded device"
+				" %s\n", name);
+		return -1;
+	}
+
+	/* Parse link status monitor polling interval */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LSC_POLL_PERIOD_KVARG);
+	if (arg_count == 1) {
+		uint32_t lsc_poll_interval_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LSC_POLL_PERIOD_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&lsc_poll_interval_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid lsc polling interval value specified for bonded"
+					"device %s\n", name);
+			return -1;
+		}
+
+		if (rte_eth_bond_link_monitoring_set(port_id, lsc_poll_interval_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set lsc monitor polling interval (%u ms) on"
+					" bonded device %s\n", lsc_poll_interval_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"LSC polling interval can be specified only once for bonded"
+				"device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link up interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_UP_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_up_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_UP_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_up_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link up propagation delay value specified for "
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_up_prop_delay_set(port_id, link_up_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link up propagation delay (%u ms) on bonded"
+					"device %s\n", link_up_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link up propagation delay can be specified only once for "
+				"bonded device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link down interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_down_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_down_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link down propagation delay value specified for"
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_down_prop_delay_set(port_id, link_down_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link down propagation delay (%u ms) on"
+					" bonded device %s\n", link_down_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link down propagation delay can be specified only once for"
+				" bonded device %s\n", name);
 		return -1;
 	}
 
diff --git a/lib/librte_pmd_bond/rte_eth_bond_private.h b/lib/librte_pmd_bond/rte_eth_bond_private.h
index 1db6e4d..78f4196 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_private.h
+++ b/lib/librte_pmd_bond/rte_eth_bond_private.h
@@ -39,20 +39,27 @@ extern "C" {
 #endif
 
 #include <rte_ethdev.h>
+#include <rte_spinlock.h>
 
 #include "rte_eth_bond.h"
 
-#define PMD_BOND_SLAVE_PORT_KVARG		("slave")
-#define PMD_BOND_PRIMARY_SLAVE_KVARG	("primary")
-#define PMD_BOND_MODE_KVARG				("mode")
-#define PMD_BOND_XMIT_POLICY_KVARG		("xmit_policy")
-#define PMD_BOND_SOCKET_ID_KVARG		("socket_id")
-#define PMD_BOND_MAC_ADDR_KVARG			("mac")
+#define PMD_BOND_SLAVE_PORT_KVARG			("slave")
+#define PMD_BOND_PRIMARY_SLAVE_KVARG		("primary")
+#define PMD_BOND_MODE_KVARG					("mode")
+#define PMD_BOND_XMIT_POLICY_KVARG			("xmit_policy")
+#define PMD_BOND_SOCKET_ID_KVARG			("socket_id")
+#define PMD_BOND_MAC_ADDR_KVARG				("mac")
+#define PMD_BOND_LSC_POLL_PERIOD_KVARG		("lsc_poll_period_ms")
+#define PMD_BOND_LINK_UP_PROP_DELAY_KVARG	("up_delay")
+#define PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG	("down_delay")
 
 #define PMD_BOND_XMIT_POLICY_LAYER2_KVARG	("l2")
 #define PMD_BOND_XMIT_POLICY_LAYER23_KVARG	("l23")
 #define PMD_BOND_XMIT_POLICY_LAYER34_KVARG	("l34")
 
+#define RTE_BOND_LOG(lvl, msg, ...) 		\
+	RTE_LOG(lvl, PMD, "%s(%d) - " msg "\n", __func__, __LINE__, ##__VA_ARGS__);
+
 extern const char *pmd_bond_init_valid_arguments[];
 
 extern const char *driver_name;
@@ -82,27 +89,36 @@ struct bond_tx_queue {
 	/**< Copy of TX configuration structure for queue */
 };
 
-/** Persisted Slave Configuration Structure */
-struct slave_conf {
-	uint8_t port_id;
-	/**< Port Id of slave eth_dev */
-	struct ether_addr mac_addr;
-	/**< Slave eth_dev original MAC address */
-};
+
 /** Bonded slave devices structure */
 struct bond_ethdev_slave_ports {
 	uint8_t slaves[RTE_MAX_ETHPORTS];	/**< Slave port id array */
 	uint8_t slave_count;				/**< Number of slaves */
 };
 
+struct bond_slave_details {
+	uint8_t port_id;
+
+	uint8_t link_status_poll_enabled;
+	uint8_t link_status_wait_to_complete;
+	uint8_t last_link_status;
+
+	/**< Port Id of slave eth_dev */
+	struct ether_addr persisted_mac_addr;
+};
+
 /** Link Bonding PMD device private configuration Structure */
 struct bond_dev_private {
+	uint8_t port_id;					/**< Port Id of Bonded Port */
 	uint8_t mode;						/**< Link Bonding Mode */
 
+	rte_spinlock_t lock;
+
 	uint8_t primary_port;				/**< Primary Slave Port */
 	uint8_t current_primary_port;		/**< Primary Slave Port */
 	uint8_t user_defined_primary_port;
 	/**< Flag for whether primary port is user defined or not */
+
 	uint8_t balance_xmit_policy;
 	/**< Transmit policy - l2 / l23 / l34 for operation in balance mode */
 	uint8_t user_defined_mac;
@@ -110,19 +126,23 @@ struct bond_dev_private {
 	uint8_t promiscuous_en;
 	/**< Enabled/disable promiscuous mode on slave devices */
 	uint8_t link_props_set;
-	/**< Bonded eth_dev link properties set */
+	/**< flag to denote if the link properties are set */
+
+	uint8_t link_status_polling_enabled;
+	uint32_t link_status_polling_interval_ms;
+
+	uint32_t link_down_delay_ms;
+	uint32_t link_up_delay_ms;
 
 	uint16_t nb_rx_queues;			/**< Total number of rx queues */
 	uint16_t nb_tx_queues;			/**< Total number of tx queues*/
 
-	uint8_t slave_count;			/**< Number of active slaves */
-	uint8_t active_slave_count;		/**< Number of slaves */
-
+	uint8_t active_slave_count;		/**< Number of active slaves */
 	uint8_t active_slaves[RTE_MAX_ETHPORTS];	/**< Active slave list */
-	uint8_t slaves[RTE_MAX_ETHPORTS];			/**< Slave list */
 
-	/** Persisted configuration of slaves */
-	struct slave_conf presisted_slaves_conf[RTE_MAX_ETHPORTS];
+	uint8_t slave_count;			/**< Number of bonded slaves */
+	struct bond_slave_details slaves[RTE_MAX_ETHPORTS];
+	/**< Arary of bonded slaves details */
 
 	struct rte_kvargs *kvlist;
 };
@@ -168,16 +188,13 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id);
-
 void
 bond_ethdev_primary_set(struct bond_dev_private *internals,
 		uint8_t slave_port_id);
@@ -210,6 +227,10 @@ int
 bond_ethdev_parse_bond_mac_addr_kvarg(const char *key __rte_unused,
 		const char *value, void *extra_args);
 
+int
+bond_ethdev_parse_time_ms_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v4 8/8] bond: unit test test macro refactor
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
                     ` (6 preceding siblings ...)
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 7/8] bond: lsc polling support Declan Doherty
@ 2014-09-30  9:57   ` Declan Doherty
  2014-10-08  8:49   ` [dpdk-dev] [PATCH v4 0/8] link bonding Jiajia, SunX
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-09-30  9:57 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/test_link_bonding.c | 2574 +++++++++++++++++-------------------------
 1 file changed, 1036 insertions(+), 1538 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index c32b685..c4fcaf7 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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;
-	}
+	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);
 
 	/* Send to sets of packet burst and verify that they are balanced across
 	 *  slaves */
 	burst_size = 21;
 
-	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");
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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");
+
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, &pkt_burst[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][0],
-			burst_size) != burst_size) {
-		printf("rte_eth_tx_burst failed\n");
-		return -1;
-	}
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size);
 
 	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 (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[2], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[2], (int)port_stats.opackets,
+			burst_size);
 
 	/* verify that all packets get send on primary slave when no other slaves
 	 * are available */
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[2], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id, slaves,
-			RTE_MAX_ETHPORTS) != 1) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_active_slaves_get(
+			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS), 1,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 1);
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][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[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size +
-			burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)(burst_size + burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
-
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[0], 0);
@@ -3668,16 +3244,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 			test_params->slave_port_ids[3], 1);
 
 	for (i = 0; i < TEST_BALANCE_LINK_STATUS_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,
+				"Failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
-
-
 	/* Verify that pkts are not received on slaves with link status down */
 
 	rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
@@ -3685,12 +3259,10 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size * 3)) {
-		printf("(%d) port_stats.ipackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.ipackets,
-				burst_size * 3);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)(burst_size * 3),
+			"(%d) port_stats.ipackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.ipackets,
+			burst_size * 3);
 
 	/* free mbufs allocate for rx testing */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
@@ -3711,16 +3283,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 static int
 test_broadcast_tx_burst(void)
 {
-	int i, pktlen, retval, burst_size, generated_burst_size, nb_tx;
+	int i, pktlen, burst_size;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 
 	struct rte_eth_stats port_stats;
 
-	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;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 2, 1),
+			"Failed to intialise bonded device");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
@@ -3732,46 +3302,37 @@ test_broadcast_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,
+	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);
-	if (generated_burst_size != burst_size)
-		return -1;
+			1), burst_size, "Failed to generate packet burst");
 
 	/* 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) {
-		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);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+			pkts_burst, burst_size), burst_size,
+			"Bonded Port (%d) rx burst failed, packets transmitted value "
+			"not as expected (%d)",
+			test_params->bonded_port_id, burst_size);
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size *
-			test_params->bonded_slave_count) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
-				burst_size);
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)burst_size * test_params->bonded_slave_count,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			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) {
-			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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)\n",
+				test_params->bonded_port_id,
+				(unsigned int)port_stats.opackets, burst_size);
 	}
 
 	/* Put all slaves down and try and transmit */
@@ -3782,10 +3343,9 @@ 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 != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkts_burst, burst_size),  0,
+			"transmitted an unexpected number of packets");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -3921,20 +3481,20 @@ test_broadcast_rx_burst(void)
 	struct rte_eth_stats port_stats;
 
 	int burst_size[BROADCAST_RX_BURST_NUM_OF_SLAVES] = { 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_BROADCAST, 0, 3, 1) != 0)
-		return -1;
-
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 3, 1),
+			"Failed to intialise bonded device");
 
 	/* Generate test bursts of packets to transmit */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; 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 slave 0 */
@@ -3946,57 +3506,44 @@ test_broadcast_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("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[0] + burst_size[1] + burst_size[2],
+			"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[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[0], (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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; i++) {
@@ -4015,48 +3562,38 @@ test_broadcast_rx_burst(void)
 static int
 test_broadcast_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_BROADCAST, 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 */
@@ -4068,45 +3605,39 @@ test_broadcast_verify_mac_assignment(void)
 {
 	struct ether_addr read_mac_addr, expected_mac_addr_0, expected_mac_addr_1;
 
-	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_1);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 4, 1),
+			"Failed to intialise bonded device");
 
 	/* Verify that all MACs are the same as first slave added to bonded
 	 * device */
 	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
@@ -4114,45 +3645,41 @@ test_broadcast_verify_mac_assignment(void)
 
 	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 new primary"
-				" port\n", test_params->slave_port_ids[i]);
-		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 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_1, &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_1, &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 address");
 
 	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_params->slave_port_ids[i]);
-		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 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(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", test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -4174,26 +3701,22 @@ 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, 0,
-			BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+				BONDING_MODE_BROADCAST, 0, BROADCAST_LINK_STATUS_NUM_OF_SLAVES,
+				1), "Failed to intialise bonded device");
 
 	/* 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;
-	}
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+	TEST_ASSERT_EQUAL(slave_count, 4,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 4);
 
 	/* Set 2 slaves link status to down */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -4203,11 +3726,9 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != 2) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, 2,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 2);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++)
 		rte_eth_stats_reset(test_params->slave_port_ids[i]);
@@ -4215,80 +3736,62 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	/* Verify that pkts are not sent on slaves with link status down */
 	burst_size = 21;
 
-	if (generate_test_burst(&pkt_burst[0][0], burst_size, 0, 0, 1, 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, 0, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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\n");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size * slave_count)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size * slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size * slave_count),
+			"(%d) port_stats.opackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size * slave_count);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%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_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[1]);
-		return -1;
-	}
 
 	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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[2]);
-		return -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]);
+
 
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
-		if (generate_test_burst(&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0) !=
-				burst_size) {
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0),
+				burst_size, "failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
 	/* Verify that pkts are not received on slaves with link status down */
+	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");
 
-	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;
-	}
 
 	/* 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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
@@ -4310,19 +3813,14 @@ 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)  != 0) {
-		printf("failed to reconfigure bonded device");
-		return -1;
-	}
-
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device");
 
 	test_params->nb_rx_q = 2;
 	test_params->nb_tx_q = 2;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
-		printf("failed to reconfigure bonded device with less rx/tx queues");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device with less rx/tx queues");
 
 	return 0;
 }
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v4 0/8] link bonding
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
                     ` (7 preceding siblings ...)
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 8/8] bond: unit test test macro refactor Declan Doherty
@ 2014-10-08  8:49   ` Jiajia, SunX
  2014-10-09 19:20   ` De Lara Guarch, Pablo
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
  10 siblings, 0 replies; 91+ messages in thread
From: Jiajia, SunX @ 2014-10-08  8:49 UTC (permalink / raw)
  To: Doherty, Declan, dev

Tested-by: Jiajia, SunX <sunx.jiajia@intel.com>

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.

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty
> Sent: Tuesday, September 30, 2014 5:58 PM
> To: dev@dpdk.org
> 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

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v4 0/8] link bonding
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
                     ` (8 preceding siblings ...)
  2014-10-08  8:49   ` [dpdk-dev] [PATCH v4 0/8] link bonding Jiajia, SunX
@ 2014-10-09 19:20   ` De Lara Guarch, Pablo
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
  10 siblings, 0 replies; 91+ messages in thread
From: De Lara Guarch, Pablo @ 2014-10-09 19:20 UTC (permalink / raw)
  To: Doherty, Declan, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty
> Sent: Tuesday, September 30, 2014 10:58 AM
> To: dev@dpdk.org
> 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

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v4 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
@ 2014-10-13 15:29     ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 91+ messages in thread
From: De Lara Guarch, Pablo @ 2014-10-13 15:29 UTC (permalink / raw)
  To: Doherty, Declan, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty
> Sent: Tuesday, September 30, 2014 10:58 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v4 4/8] bond: free mbufs if transmission fails in
> bonding tx_burst functions
> 
> 
> Signed-off-by: Declan Doherty <declan.doherty@intel.com>
> ---
>  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(-)
> 
> diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
> index cce32ed..1a847eb 100644
> --- a/app/test/test_link_bonding.c
> +++ b/app/test/test_link_bonding.c
> @@ -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_cou
> nt],
> +			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_co
> unt],
> +
> 	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_behavio
> ur),
>  		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),
> diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
> index e861c5b..f9bd841 100644
> --- a/app/test/virtual_pmd.c
> +++ b/app/test/virtual_pmd.c
> @@ -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-
> >tx_burst_fail_count;
> +
> +		/* 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)
>  {
>  	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
> 
> diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
> index 766b6ac..3b5c911 100644
> --- a/app/test/virtual_pmd.h
> +++ b/app/test/virtual_pmd.h
> @@ -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
> diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> index 66f1650..2215afe 100644
> --- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> +++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> @@ -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;
>  	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
>  	 * 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]);
> +	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,
> +					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;
> +
> +				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]));
> +			}
> +			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;
> 
> -	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).

> 
>  	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
> +		 * 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
> +	 * handle failures of all packets except those of the most successful
> slave
> +	 */
> +	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]++]);
> +
> +	return max_nb_of_tx_pkts;
>  }
> 
>  void
> --
> 1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v5 0/8] link bonding
  2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
                     ` (9 preceding siblings ...)
  2014-10-09 19:20   ` De Lara Guarch, Pablo
@ 2014-10-14 12:59   ` Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 1/8] bond: link status interrupt support Declan Doherty
                       ` (10 more replies)
  10 siblings, 11 replies; 91+ messages in thread
From: Declan Doherty @ 2014-10-14 12:59 UTC (permalink / raw)
  To: dev

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(-)

-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v5 1/8] bond: link status interrupt support
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
@ 2014-10-14 12:59     ` Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 2/8] bond: removing switch statement from rx burst method Declan Doherty
                       ` (9 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-10-14 12:59 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index db5b180..cce32ed 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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),
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index 75f5694..dd33119 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -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,
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 08d3b5f..aca2dcf 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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 = {
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v5 2/8] bond: removing switch statement from rx burst method
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 1/8] bond: link status interrupt support Declan Doherty
@ 2014-10-14 12:59     ` Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
                       ` (8 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-10-14 12:59 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 62 +++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 27 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index aca2dcf..348e28f 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v5 3/8] bond: fix naming inconsistency in tx_burst_round_robin
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 1/8] bond: link status interrupt support Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 2/8] bond: removing switch statement from rx burst method Declan Doherty
@ 2014-10-14 12:59     ` Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
                       ` (7 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-10-14 12:59 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 348e28f..66f1650 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v5 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
                       ` (2 preceding siblings ...)
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
@ 2014-10-14 12:59     ` Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 5/8] test app: adding support for generating variable sized packet Declan Doherty
                       ` (6 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-10-14 12:59 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/test_link_bonding.c           | 393 ++++++++++++++++++++++++++++++++-
 app/test/virtual_pmd.c                 |  79 +++++--
 app/test/virtual_pmd.h                 |   7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  83 +++++--
 4 files changed, 524 insertions(+), 38 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index cce32ed..1a847eb 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index e861c5b..72f527e 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -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,66 @@ 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;
+		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->tx_burst_fail_count;
+
+		/* 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 +431,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)
 {
 	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
 
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 766b6ac..3b5c911 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -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
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 66f1650..7f75763 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -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;
 	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
 	 * 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]);
+	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,
+					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;
+
+				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]));
+			}
+			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;
 
-	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_successful_tx_slave = -1;
 
 	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
+		 * maximum number of packets */
+		if (slave_tx_total[i] > max_nb_of_tx_pkts) {
+			max_nb_of_tx_pkts = slave_tx_total[i];
+			most_successful_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
+	 * handle failures of all packets except those of the most successful slave
+	 */
+	if (unlikely(tx_failed_flag))
+		for (i = 0; i < num_of_slaves; i++)
+			if (i != most_successful_tx_slave)
+				while (slave_tx_total[i] < nb_pkts)
+					rte_pktmbuf_free(bufs[slave_tx_total[i]++]);
+
+	return max_nb_of_tx_pkts;
 }
 
 void
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v5 5/8] test app: adding support for generating variable sized packet
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
                       ` (3 preceding siblings ...)
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
@ 2014-10-14 12:59     ` Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
                       ` (5 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-10-14 12:59 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c
index 9e747a4..b2824dc 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -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) {
diff --git a/app/test/packet_burst_generator.h b/app/test/packet_burst_generator.h
index 5b3cd6c..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -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
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 1a847eb..50355a3 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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;
 
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v5 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
                       ` (4 preceding siblings ...)
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 5/8] test app: adding support for generating variable sized packet Declan Doherty
@ 2014-10-14 12:59     ` Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 7/8] bond: lsc polling support Declan Doherty
                       ` (4 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-10-14 12:59 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0b972f9..e9cf53e 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3618,7 +3618,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);
 	}
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index f76406f..5740804 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -630,7 +630,7 @@ init_config(void)
 
 
 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
 	struct rte_port *port;
 
@@ -649,6 +649,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();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 9cbfeac..5a3423c 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v5 7/8] bond: lsc polling support
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
                       ` (5 preceding siblings ...)
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
@ 2014-10-14 12:59     ` Declan Doherty
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 8/8] bond: unit test test macro refactor Declan Doherty
                       ` (3 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-10-14 12:59 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index e9cf53e..490893d 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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()
@@ -3709,6 +3712,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 *** */
@@ -7457,6 +7519,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,
diff --git a/app/test/test.h b/app/test/test.h
index 98ab804..24b1640 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -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;											\
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 50355a3..c32b685 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -234,42 +234,34 @@ configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 	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;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_dev_configure(port_id, test_params->nb_rx_q,
+			test_params->nb_tx_q, &default_pmd_conf),
+			"rte_eth_dev_configure for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++) {
-		if (rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
+	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
 				rte_eth_dev_socket_id(port_id), &rx_conf_default,
-				test_params->mbuf_pool) < 0) {
-			goto error;
-		}
-	}
+				test_params->mbuf_pool) ,
+				"rte_eth_rx_queue_setup for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++) {
-		if (rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
-				rte_eth_dev_socket_id(port_id), &tx_conf_default) < 0) {
-			printf("Failed to setup tx queue (%d).\n", q_id);
-			goto error;
-		}
-	}
+	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
+				rte_eth_dev_socket_id(port_id), &tx_conf_default),
+				"rte_eth_tx_queue_setup for port %d failed", port_id);
 
-	if (start) {
-		if (rte_eth_dev_start(port_id) < 0) {
-			printf("Failed to start device (%d).\n", port_id);
-			goto error;
-		}
-	}
-	return 0;
+	if (start)
+		TEST_ASSERT_SUCCESS(rte_eth_dev_start(port_id),
+				"rte_eth_dev_start for port %d failed", port_id);
 
-error:
-	printf("Failed to configure ethdev %d\n", port_id);
-	return -1;
+	return 0;
 }
 
 static int slaves_initialized;
 
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
+
+
 static int
 test_setup(void)
 {
@@ -310,7 +302,7 @@ test_setup(void)
 			snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_%d", i);
 
 			test_params->slave_port_ids[i] = virtual_ethdev_create(pmd_name,
-					mac_addr, rte_socket_id());
+					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;
@@ -414,34 +406,27 @@ test_create_bonded_device_with_invalid_params(void)
 static int
 test_add_slave_to_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]);
-	if (retval != 0) {
-		printf("Failed to add slave (%d) to bonded port (%d).\n",
-				test_params->bonded_port_id,
-				test_params->slave_port_ids[test_params->bonded_slave_count]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave (%d) to bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count],
+			test_params->bonded_port_id);
 
 	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 + 1) {
-		printf("Number of slaves (%d) is greater than expected (%d).\n",
-				current_slave_count, test_params->bonded_slave_count + 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count + 1,
+			"Number of slaves (%d) is greater than expected (%d).",
+			current_slave_count, test_params->bonded_slave_count + 1);
 
 	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 as expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
+					"Number of active slaves (%d) is not as expected (%d).\n",
+					current_slave_count, 0);
 
 	test_params->bonded_slave_count++;
 
@@ -476,27 +461,23 @@ test_add_slave_to_invalid_bonded_device(void)
 static int
 test_remove_slave_from_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 	struct ether_addr read_mac_addr, *mac_addr;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_remove(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
-	if (retval != 0) {
-		printf("\t Failed to remove slave %d from bonded port (%d).\n",
-				test_params->slave_port_ids[test_params->bonded_slave_count-1],
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_remove(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count-1]),
+			"Failed to remove slave %d from bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count-1],
+			test_params->bonded_port_id);
 
 
 	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 - 1) {
-		printf("Number of slaves (%d) is great than expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count - 1,
+			"Number of slaves (%d) is great than expected (%d).\n",
+			current_slave_count, test_params->bonded_slave_count - 1);
 
 
 	mac_addr = (struct ether_addr *)slave_mac;
@@ -506,10 +487,8 @@ test_remove_slave_from_bonded_device(void)
 	rte_eth_macaddr_get(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1],
 			&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\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
@@ -888,21 +867,20 @@ test_set_primary_slave(void)
 		return -1;
 	}
 
+	/* 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;
+	}
+
 	/* Set slave as primary
 	 * Verify slave it is now primary slave
 	 * Verify that MAC address of bonded device is that of primary slave
 	 * Verify that MAC address of all bonded slaves are that of primary slave
 	 */
 	for (i = 0; i < 4; i++) {
-
-		/* 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;
-		}
-
 		retval = rte_eth_bond_primary_set(test_params->bonded_port_id,
 				test_params->slave_port_ids[i]);
 		if (retval != 0) {
@@ -926,6 +904,7 @@ test_set_primary_slave(void)
 
 		/* 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;
 
@@ -1090,19 +1069,18 @@ static int
 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 */
+	/* Configure bonded device */
 	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);
 
-	while (number_of_slaves > test_params->bonded_slave_count) {
-		/* Add slaves to bonded device */
+	/* Add slaves to bonded device */
+	while (number_of_slaves > test_params->bonded_slave_count)
 		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
 				"Failed to add slave (%d to  bonding port (%d).",
 				test_params->bonded_slave_count - 1,
 				test_params->bonded_port_id);
-	}
 
 	/* Set link bonding mode  */
 	TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonded_port_id,
@@ -1125,9 +1103,9 @@ test_adding_slave_after_bonded_device_started(void)
 {
 	int i;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 0)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 0),
+			"Failed to add slaves to bonded device");
 
 	/* Enabled slave devices */
 	for (i = 0; i < test_params->bonded_slave_count + 1; i++) {
@@ -1135,12 +1113,9 @@ test_adding_slave_after_bonded_device_started(void)
 				test_params->slave_port_ids[i], 1);
 	}
 
-	if (rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]) !=
-					0) {
-		printf("\t Failed to add slave to bonded port.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave to bonded port.\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count]);
@@ -1155,8 +1130,6 @@ test_adding_slave_after_bonded_device_started(void)
 
 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,
@@ -1180,7 +1153,7 @@ lsc_timeout(int wait_us)
 	gettimeofday(&tp, NULL);
 
 	/* Convert from timeval to timespec */
-	ts.tv_sec  = tp.tv_sec;
+	ts.tv_sec = tp.tv_sec;
 	ts.tv_nsec = tp.tv_usec * 1000;
 	ts.tv_nsec += wait_us * 1000;
 
@@ -1190,6 +1163,9 @@ lsc_timeout(int wait_us)
 
 	pthread_mutex_unlock(&mutex);
 
+	if (retval == 0 && test_lsc_interupt_count < 1)
+		return -1;
+
 	return retval;
 }
 
@@ -1199,9 +1175,6 @@ 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)
@@ -1281,9 +1254,6 @@ test_status_interrupt(void)
 				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();
 }
@@ -2025,6 +1995,101 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT (2)
+
+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 } ;
+
+static int
+test_roundrobin_verfiy_polling_slave_link_status_change(void)
+{
+	struct ether_addr *mac_addr = (struct ether_addr *)polling_slave_mac;
+	char slave_name[RTE_ETH_NAME_MAX_LEN];
+
+	int i;
+
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+		/* Generate slave name / MAC address */
+		snprintf(slave_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_poll_%d", i);
+		mac_addr->addr_bytes[ETHER_ADDR_LEN-1] = i;
+
+		/* Create slave devices with no ISR Support */
+		if (polling_test_slaves[i] == -1) {
+			polling_test_slaves[i] = virtual_ethdev_create(slave_name, mac_addr,
+					rte_socket_id(), 0);
+			TEST_ASSERT(polling_test_slaves[i] >= 0,
+					"Failed to create virtual virtual ethdev %s\n", slave_name);
+
+			/* Configure slave */
+			TEST_ASSERT_SUCCESS(configure_ethdev(polling_test_slaves[i], 0, 0),
+					"Failed to configure virtual ethdev %s(%d)", slave_name,
+					polling_test_slaves[i]);
+		}
+
+		/* Add slave to bonded device */
+		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);
+	}
+
+	/* Initialize bonded device */
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 1, 1),
+			"Failed to configure bonded device %d",
+			test_params->bonded_port_id);
+
+
+	/* 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);
+
+	/* link status change callback for first slave link up */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 1);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(15000), "timed out waiting for interrupt");
+
+
+	/* no link status change callback for second slave link up */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 1);
+
+	TEST_ASSERT_FAIL(lsc_timeout(15000), "unexpectedly succeeded");
+
+	/* link status change callback for both slave links down */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 0);
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 0);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(20000), "timed out waiting for interrupt");
+
+	/* Un-Register link status change interrupt callback */
+	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);
+
+
+	/* Clean up and remove slaves from bonded device */
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+
+		TEST_ASSERT_SUCCESS(
+				rte_eth_bond_slave_remove(test_params->bonded_port_id,
+						polling_test_slaves[i]),
+				"Failed to remove slave %d from bonded port (%d)",
+				polling_test_slaves[i], test_params->bonded_port_id);
+	}
+
+	return remove_slaves_and_stop_bonded_device();
+}
+
+
 /** Active Backup Mode Tests */
 
 static int
@@ -4311,6 +4376,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),
 		TEST_CASE(test_roundrobin_verify_mac_assignment),
 		TEST_CASE(test_roundrobin_verify_slave_link_status_change_behaviour),
+		TEST_CASE(test_roundrobin_verfiy_polling_slave_link_status_change),
 		TEST_CASE(test_activebackup_tx_burst),
 		TEST_CASE(test_activebackup_rx_burst),
 		TEST_CASE(test_activebackup_verify_promiscuous_enable_disable),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 72f527e..e105c84 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -457,6 +457,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)
 {
@@ -504,7 +512,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;
@@ -554,7 +562,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;
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 3b5c911..2462853 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -40,38 +40,58 @@ extern "C" {
 
 #include <rte_ether.h>
 
-int virtual_ethdev_init(void);
+int
+virtual_ethdev_init(void);
 
-int virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, uint8_t socket_id);
+int
+virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
+		uint8_t socket_id, uint8_t isr_support);
 
-void virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id, uint8_t link_status);
+void
+virtual_ethdev_set_link_status(uint8_t port_id, uint8_t link_status);
 
-void virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, struct rte_mbuf **pkts_burst, int burst_length);
+void
+virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id,
+		uint8_t link_status);
 
+void
+virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id,
+		struct rte_mbuf **pkts_burst, int burst_length);
 
-/** Control methods for the dev_ops functions pointer to control the behavior of the Virtual PMD */
 
-void virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
+/** Control methods for the dev_ops functions pointer to control the behavior
+ *  of the Virtual PMD */
 
-void virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_link_update_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_burst_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_link_update_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);
+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,
+void
+virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
 		uint8_t packet_fail_count);
 
 #ifdef __cplusplus
diff --git a/lib/librte_pmd_bond/rte_eth_bond.h b/lib/librte_pmd_bond/rte_eth_bond.h
index bd59780..6811c7b 100644
--- a/lib/librte_pmd_bond/rte_eth_bond.h
+++ b/lib/librte_pmd_bond/rte_eth_bond.h
@@ -248,6 +248,86 @@ rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy);
 int
 rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id);
 
+/**
+ * Set the link monitoring frequency (in ms) for monitoring the link status of
+ * slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param internal_ms		Monitoring interval in milliseconds
+ *
+ * @return
+ *	0 on success, negative value otherwise.
+ */
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms);
+
+/**
+ * Get the current link monitoring frequency (in ms) for monitoring of the link
+ * status of slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ *
+ * @return
+ *	Monitoring interval on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id);
+
+
+/**
+ * Set the period in milliseconds for delaying the disabling of a bonded link
+ * when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the disabling of a bonded
+ * link when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id);
+
+/**
+ * Set the period in milliseconds for delaying the enabling of a bonded link
+ * when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the enabling of a bonded
+ * link when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index dd33119..f146bda 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -39,6 +39,8 @@
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
 
+#define DEFAULT_POLLING_INTERVAL_10_MS (10)
+
 int
 valid_bonded_ethdev(struct rte_eth_dev *eth_dev)
 {
@@ -63,9 +65,8 @@ valid_port_id(uint8_t port_id)
 	/* Verify that port id is valid */
 	int ethdev_count = rte_eth_dev_count();
 	if (port_id >= ethdev_count) {
-		RTE_LOG(ERR, PMD,
-				"%s: port Id %d is greater than rte_eth_dev_count %d\n",
-				__func__, port_id, ethdev_count);
+		RTE_BOND_LOG(ERR, "Port Id %d is greater than rte_eth_dev_count %d",
+				port_id, ethdev_count);
 		return -1;
 	}
 
@@ -81,9 +82,8 @@ valid_bonded_port_id(uint8_t port_id)
 
 	/* Verify that bonded_port_id refers to a bonded port */
 	if (valid_bonded_ethdev(&rte_eth_devices[port_id])) {
-		RTE_LOG(ERR, PMD,
-				"%s: Specified port Id %d is not a bonded eth_dev device\n",
-				__func__, port_id);
+		RTE_BOND_LOG(ERR, "Specified port Id %d is not a bonded eth_dev device",
+				port_id);
 		return -1;
 	}
 
@@ -136,37 +136,36 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	 */
 
 	if (name == NULL) {
-		RTE_LOG(ERR, PMD, "Invalid name specified\n");
+		RTE_BOND_LOG(ERR, "Invalid name specified");
 		goto err;
 	}
 
 	if (socket_id >= number_of_sockets()) {
-		RTE_LOG(ERR, PMD,
-				"%s: invalid socket id specified to create bonded device on.\n",
-				__func__);
+		RTE_BOND_LOG(ERR,
+				"Invalid socket id specified to create bonded device on.");
 		goto err;
 	}
 
 	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
 	if (pci_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci dev on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci dev on socket");
 		goto err;
 	}
 
 	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
 	if (eth_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc eth_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
 		goto err;
 	}
 
 	pci_drv = rte_zmalloc_socket(name, sizeof(*pci_drv), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_drv on socket");
 		goto err;
 	}
 	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_id_table on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
 		goto err;
 	}
 
@@ -181,14 +180,14 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
 		goto err;
 	}
 
 	/* reserve an ethdev entry */
 	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to allocate rte_eth_dev\n");
+		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
 		goto err;
 	}
 
@@ -218,25 +217,31 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->pci_dev = pci_dev;
 
 	if (bond_ethdev_mode_set(eth_dev, mode)) {
-		RTE_LOG(ERR, PMD,
-				"%s: failed to set bonded device %d mode too %d\n",
-				__func__, eth_dev->data->port_id, mode);
+		RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
+				 eth_dev->data->port_id, mode);
 		goto err;
 	}
 
+	rte_spinlock_init(&internals->lock);
+
+	internals->port_id = eth_dev->data->port_id;
 	internals->current_primary_port = 0;
 	internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
 	internals->user_defined_mac = 0;
 	internals->link_props_set = 0;
+
+	internals->link_status_polling_enabled = 0;
+
+	internals->link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS;
+	internals->link_down_delay_ms = 0;
+	internals->link_up_delay_ms = 0;
+
 	internals->slave_count = 0;
 	internals->active_slave_count = 0;
 
 	memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
 	memset(internals->slaves, 0, sizeof(internals->slaves));
 
-	memset(internals->presisted_slaves_conf, 0,
-			sizeof(internals->presisted_slaves_conf));
-
 	return eth_dev->data->port_id;
 
 err:
@@ -253,8 +258,8 @@ err:
 	return -1;
 }
 
-int
-rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
+static int
+__eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
 	struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
 	struct bond_dev_private *internals;
@@ -263,56 +268,43 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	int i, j;
 
-	/* Verify that port id's are valid bonded and slave ports */
-	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_add;
-
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_add;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
 
-	/*
-	 * Verify that new slave device is not already a slave of another bonded
-	 * device */
+	/* Verify that new slave device is not already a slave of another
+	 * bonded device */
 	for (i = rte_eth_dev_count()-1; i >= 0; i--) {
 		if (valid_bonded_ethdev(&rte_eth_devices[i]) == 0) {
 			temp_internals = rte_eth_devices[i].data->dev_private;
+
 			for (j = 0; j < temp_internals->slave_count; j++) {
 				/* Device already a slave of a bonded device */
-				if (temp_internals->slaves[j] == slave_port_id)
-					goto err_add;
+				if (temp_internals->slaves[j].port_id == slave_port_id) {
+					RTE_BOND_LOG(ERR, "Slave port %d is already a slave",
+							slave_port_id);
+					return -1;
+				}
 			}
 		}
 	}
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
-
 	slave_eth_dev = &rte_eth_devices[slave_port_id];
 
-	if (internals->slave_count > 0) {
-		/* Check that new slave device is the same type as the other slaves
-		 * and not repetitive */
-		for (i = 0; i < internals->slave_count; i++) {
-			if (slave_eth_dev->pci_dev->driver->id_table->device_id !=
-					rte_eth_devices[internals->slaves[i]].pci_dev->driver->id_table->device_id ||
-				internals->slaves[i] == slave_port_id)
-				goto err_add;
-		}
-	}
-
 	/* Add slave details to bonded device */
-	internals->slaves[internals->slave_count] = slave_port_id;
-
-	slave_config_store(internals, slave_eth_dev);
+	slave_add(internals, slave_eth_dev);
 
 	if (internals->slave_count < 1) {
-		/* if MAC is not user defined then use MAC of first slave add to bonded
-		 * device */
+		/* if MAC is not user defined then use MAC of first slave add to
+		 * bonded device */
 		if (!internals->user_defined_mac)
 			mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs);
 
 		/* Inherit eth dev link properties from first slave */
-		link_properties_set(bonded_eth_dev, &(slave_eth_dev->data->dev_link));
+		link_properties_set(bonded_eth_dev,
+				&(slave_eth_dev->data->dev_link));
 
 		/* Make primary slave */
 		internals->primary_port = slave_port_id;
@@ -322,10 +314,10 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->link_props_set) {
 			if (link_properties_valid(&(bonded_eth_dev->data->dev_link),
 									  &(slave_eth_dev->data->dev_link))) {
-				RTE_LOG(ERR, PMD,
-						"%s: Slave port %d link speed/duplex not supported\n",
-						__func__, slave_port_id);
-				goto err_add;
+				RTE_BOND_LOG(ERR,
+						"Slave port %d link speed/duplex not supported",
+						slave_port_id);
+				return -1;
 			}
 		} else {
 			link_properties_set(bonded_eth_dev,
@@ -340,9 +332,9 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	if (bonded_eth_dev->data->dev_started) {
 		if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
-			RTE_LOG(ERR, PMD, "rte_bond_slaves_configure: port=%d\n",
+			RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
 					slave_port_id);
-			goto err_add;
+			return -1;
 		}
 	}
 
@@ -356,65 +348,79 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 	if (bonded_eth_dev->data->dev_started) {
 		rte_eth_link_get_nowait(slave_port_id, &link_props);
 
-		 if (link_props.link_status == 1) {
+		 if (link_props.link_status == 1)
 			internals->active_slaves[internals->active_slave_count++] =
 					slave_port_id;
-		}
 	}
-
 	return 0;
 
-err_add:
-	RTE_LOG(ERR, PMD, "Failed to add port %d as slave\n", slave_port_id);
-	return -1;
-
 }
 
+
 int
-rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
+	struct rte_eth_dev *bonded_eth_dev;
 	struct bond_dev_private *internals;
-	struct slave_conf *slave_conf;
 
-	int i;
-	int pos = -1;
+	int retval;
 
 	/* Verify that port id's are valid bonded and slave ports */
 	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_del;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
+
+	return retval;
+}
+
+
+static int
+__eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct bond_dev_private *internals;
+
+	int i, slave_idx = -1;
 
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_del;
+		return -1;
 
 	internals = rte_eth_devices[bonded_port_id].data->dev_private;
 
 	/* first remove from active slave list */
 	for (i = 0; i < internals->active_slave_count; i++) {
 		if (internals->active_slaves[i] == slave_port_id)
-			pos = i;
+			slave_idx = i;
 
 		/* shift active slaves up active array list */
-		if (pos >= 0 && i < (internals->active_slave_count - 1))
+		if (slave_idx >= 0 && i < (internals->active_slave_count - 1))
 			internals->active_slaves[i] = internals->active_slaves[i+1];
 	}
 
-	if (pos >= 0)
+	if (slave_idx >= 0)
 		internals->active_slave_count--;
 
-	pos = -1;
-	/* now remove from slave list */
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == slave_port_id)
-			pos = i;
+	slave_idx = -1;
+	/* now find in slave list */
+	for (i = 0; i < internals->slave_count; i++)
+		if (internals->slaves[i].port_id == slave_port_id) {
+			slave_idx = i;
+			break;
+		}
 
-		/* shift slaves up list */
-		if (pos >= 0 && i < internals->slave_count)
-			internals->slaves[i] = internals->slaves[i+1];
+	if (slave_idx < 0) {
+		RTE_BOND_LOG(ERR, "Couldn't find slave in port list, slave count %d",
+				internals->slave_count);
+		return -1;
 	}
 
-	if (pos < 0)
-		goto err_del;
-
 	/* Un-register link status change callback with bonded device pointer as
 	 * argument*/
 	rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
@@ -422,13 +428,10 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 			&rte_eth_devices[bonded_port_id].data->port_id);
 
 	/* Restore original MAC address of slave device */
-	slave_conf = slave_config_get(internals, slave_port_id);
+	mac_address_set(&rte_eth_devices[slave_port_id],
+			&(internals->slaves[slave_idx].persisted_mac_addr));
 
-	mac_address_set(&rte_eth_devices[slave_port_id], &(slave_conf->mac_addr));
-
-	slave_config_clear(internals, &rte_eth_devices[slave_port_id]);
-
-	internals->slave_count--;
+	slave_remove(internals, &rte_eth_devices[slave_port_id]);
 
 	/*  first slave in the active list will be the primary by default,
 	 *  otherwise use first device in list */
@@ -436,7 +439,7 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->active_slave_count > 0)
 			internals->current_primary_port = internals->active_slaves[0];
 		else if (internals->slave_count > 0)
-			internals->current_primary_port = internals->slaves[0];
+			internals->current_primary_port = internals->slaves[0].port_id;
 		else
 			internals->primary_port = 0;
 	}
@@ -454,12 +457,28 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 	}
 
 	return 0;
+}
 
-err_del:
-	RTE_LOG(ERR, PMD,
-			"Cannot remove slave device (not present in bonded device)\n");
-	return -1;
+int
+rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct rte_eth_dev *bonded_eth_dev;
+	struct bond_dev_private *internals;
+	int retval;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_remove_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
 
+	return retval;
 }
 
 int
@@ -524,6 +543,7 @@ int
 rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 {
 	struct bond_dev_private *internals;
+	int i;
 
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
@@ -536,10 +556,10 @@ rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 	if (internals->slave_count > len)
 		return -1;
 
-	memcpy(slaves, internals->slaves, internals->slave_count);
+	for (i = 0; i < internals->slave_count; i++)
+		slaves[i] = internals->slaves[i].port_id;
 
 	return internals->slave_count;
-
 }
 
 int
@@ -605,13 +625,13 @@ rte_eth_bond_mac_address_reset(uint8_t bonded_port_id)
 	internals->user_defined_mac = 0;
 
 	if (internals->slave_count > 0) {
-		struct slave_conf *conf;
-		conf = slave_config_get(internals, internals->primary_port);
-
 		/* Set MAC Address of Bonded Device */
-		if (mac_address_set(bonded_eth_dev, &conf->mac_addr) != 0)
+		if (mac_address_set(bonded_eth_dev,
+				&internals->slaves[internals->primary_port].persisted_mac_addr)
+				!= 0) {
+			RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
 			return -1;
-
+		}
 		/* Update all slave devices MAC addresses */
 		return mac_address_slaves_update(bonded_eth_dev);
 	}
@@ -654,3 +674,88 @@ rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id)
 
 	return internals->balance_xmit_policy;
 }
+
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_status_polling_interval_ms = internal_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_status_polling_interval_ms;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_down_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_down_delay_ms;
+}
+
+
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_up_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_up_delay_ms;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_args.c b/lib/librte_pmd_bond/rte_eth_bond_args.c
index 11d9816..bbbc69b 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_args.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_args.c
@@ -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;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 7f75763..7a4a647 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -40,6 +40,7 @@
 #include <rte_devargs.h>
 #include <rte_kvargs.h>
 #include <rte_dev.h>
+#include <rte_alarm.h>
 
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
@@ -454,16 +455,16 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr)
 	mac_addr = eth_dev->data->mac_addrs;
 
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", __func__);
+		RTE_BOND_LOG(ERR,  "NULL pointer eth_dev specified");
 		return -1;
 	}
 
 	if (new_mac_addr == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer MAC specified\n", __func__);
+		RTE_BOND_LOG(ERR, "NULL pointer MAC specified");
 		return -1;
 	}
 
-	/* if new MAC is different to current MAC then update */
+	/* If new MAC is different to current MAC then update */
 	if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0)
 		memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr));
 
@@ -485,11 +486,10 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_BALANCE:
 	case BONDING_MODE_BROADCAST:
 		for (i = 0; i < internals->slave_count; i++) {
-			if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
+			if (mac_address_set(&rte_eth_devices[internals->slaves[i].port_id],
 					bonded_eth_dev->data->mac_addrs)) {
-				RTE_LOG(ERR, PMD,
-						"%s: Failed to update port Id %d MAC address\n",
-						__func__, internals->slaves[i]);
+				RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+						internals->slaves[i].port_id);
 				return -1;
 			}
 		}
@@ -497,23 +497,20 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_ACTIVE_BACKUP:
 	default:
 		for (i = 0; i < internals->slave_count; i++) {
-			if (internals->slaves[i] == internals->current_primary_port) {
+			if (internals->slaves[i].port_id ==
+					internals->current_primary_port) {
 				if (mac_address_set(&rte_eth_devices[internals->primary_port],
 						bonded_eth_dev->data->mac_addrs)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->current_primary_port);
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->current_primary_port);
+					return -1;
 				}
 			} else {
-				struct slave_conf *conf =
-						slave_config_get(internals, internals->slaves[i]);
-
-				if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
-						&conf->mac_addr)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->slaves[i]);
-
+				if (mac_address_set(
+						&rte_eth_devices[internals->slaves[i].port_id],
+						&internals->slaves[i].persisted_mac_addr)) {
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->slaves[i].port_id);
 					return -1;
 				}
 			}
@@ -563,34 +560,39 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	struct bond_rx_queue *bd_rx_q;
 	struct bond_tx_queue *bd_tx_q;
 
-	int q_id;
+	int errval, q_id;
 
 	/* Stop slave */
 	rte_eth_dev_stop(slave_eth_dev->data->port_id);
 
-	/* Enable interrupts on slave device */
-	slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
+	/* Enable interrupts on slave device if supported */
+	if (slave_eth_dev->driver->pci_drv.drv_flags & RTE_PCI_DRV_INTR_LSC)
+		slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
 
-	if (rte_eth_dev_configure(slave_eth_dev->data->port_id,
+	/* Configure device */
+	errval = rte_eth_dev_configure(slave_eth_dev->data->port_id,
 			bonded_eth_dev->data->nb_rx_queues,
 			bonded_eth_dev->data->nb_tx_queues,
-			&(slave_eth_dev->data->dev_conf)) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot configure slave device: port=%u\n",
-				slave_eth_dev->data->port_id);
-		return -1;
+			&(slave_eth_dev->data->dev_conf));
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "Cannot configure slave device: port %u , err (%d)",
+				slave_eth_dev->data->port_id, errval);
+		return errval;
 	}
 
 	/* Setup Rx Queues */
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
 		bd_rx_q = (struct bond_rx_queue *)bonded_eth_dev->data->rx_queues[q_id];
 
-		if (rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_rx_q->nb_rx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_rx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_rx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
@@ -598,69 +600,77 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
 		bd_tx_q = (struct bond_tx_queue *)bonded_eth_dev->data->tx_queues[q_id];
 
-		if (rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_tx_q->nb_tx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&bd_tx_q->tx_conf) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_tx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&bd_tx_q->tx_conf);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_tx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
 	/* Start device */
-	if (rte_eth_dev_start(slave_eth_dev->data->port_id) != 0) {
-		RTE_LOG(ERR, PMD, "rte_eth_dev_start: port=%u\n",
-				slave_eth_dev->data->port_id);
+	errval = rte_eth_dev_start(slave_eth_dev->data->port_id);
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "rte_eth_dev_start: port=%u, err (%d)",
+				slave_eth_dev->data->port_id, errval);
 		return -1;
 	}
 
 	return 0;
 }
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id)
-{
-	int i;
-
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id == slave_port_id)
-			return &internals->presisted_slaves_conf[i];
-	}
-	return NULL;
-}
-
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
 	int i, found = 0;
 
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id ==
-				slave_eth_dev->data->port_id) {
+		if (internals->slaves[i].port_id ==	slave_eth_dev->data->port_id)
 			found = 1;
-			memset(&internals->presisted_slaves_conf[i], 0,
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
-		if (found && i < (internals->slave_count - 1)) {
-			memcpy(&internals->presisted_slaves_conf[i],
-					&internals->presisted_slaves_conf[i+1],
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
+
+		if (found && i < (internals->slave_count - 1))
+			memcpy(&internals->slaves[i], &internals->slaves[i+1],
+					sizeof(internals->slaves[i]));
 	}
+
+	internals->slave_count--;
 }
 
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg);
+
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
-	struct slave_conf *presisted_slave_conf =
-			&internals->presisted_slaves_conf[internals->slave_count];
+	struct bond_slave_details *slave_details =
+			&internals->slaves[internals->slave_count];
+
+	slave_details->port_id = slave_eth_dev->data->port_id;
+	slave_details->last_link_status = 0;
+
+	/* If slave device doesn't support interrupts then we need to enabled
+	 * polling to monitor link status */
+	if (!(slave_eth_dev->pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
+		slave_details->link_status_poll_enabled = 1;
+
+		if (!internals->link_status_polling_enabled) {
+			internals->link_status_polling_enabled = 1;
 
-	presisted_slave_conf->port_id = slave_eth_dev->data->port_id;
+			rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+					bond_ethdev_slave_link_status_change_monitor,
+					(void *)&rte_eth_devices[internals->port_id]);
+		}
+	}
 
-	memcpy(&(presisted_slave_conf->mac_addr), slave_eth_dev->data->mac_addrs,
+	slave_details->link_status_wait_to_complete = 0;
+
+	memcpy(&(slave_details->persisted_mac_addr), slave_eth_dev->data->mac_addrs,
 			sizeof(struct ether_addr));
 }
 
@@ -691,31 +701,33 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* slave eth dev will be started by bonded device */
 	if (valid_bonded_ethdev(eth_dev)) {
-		RTE_LOG(ERR, PMD,
-				"%s: user tried to explicitly start a slave eth_dev (%d) of the bonded eth_dev\n",
-				__func__, eth_dev->data->port_id);
+		RTE_BOND_LOG(ERR, "User tried to explicitly start a slave eth_dev (%d)",
+				eth_dev->data->port_id);
 		return -1;
 	}
 
-	eth_dev->data->dev_link.link_status = 1;
+	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 1;
 
 	internals = eth_dev->data->dev_private;
 
 	if (internals->slave_count == 0) {
-		RTE_LOG(ERR, PMD,
-				"%s: Cannot start port since there are no slave devices\n",
-				__func__);
+		RTE_BOND_LOG(ERR, "Cannot start port since there are no slave devices");
 		return -1;
 	}
 
 	if (internals->user_defined_mac == 0) {
-		struct slave_conf *conf = slave_config_get(internals,
-				internals->primary_port);
+		struct ether_addr *new_mac_addr = NULL;
+
+		for (i = 0; i < internals->slave_count; i++)
+			if (internals->slaves[i].port_id == internals->primary_port)
+				new_mac_addr = &internals->slaves[i].persisted_mac_addr;
+
+		if (new_mac_addr == NULL)
+			return -1;
 
-		if (mac_address_set(eth_dev, &(conf->mac_addr)) != 0) {
-			RTE_LOG(ERR, PMD,
-					"bonded port (%d) failed to update mac address",
+		if (mac_address_set(eth_dev, new_mac_addr) != 0) {
+			RTE_BOND_LOG(ERR, "bonded port (%d) failed to update MAC address",
 					eth_dev->data->port_id);
 			return -1;
 		}
@@ -731,11 +743,11 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* Reconfigure each slave device if starting bonded device */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (slave_configure(eth_dev, &(rte_eth_devices[internals->slaves[i]]))
-				!= 0) {
-			RTE_LOG(ERR, PMD, "bonded port "
-					"(%d) failed to reconfigure slave device (%d)\n)",
-					eth_dev->data->port_id, internals->slaves[i]);
+		if (slave_configure(eth_dev,
+				&(rte_eth_devices[internals->slaves[i].port_id])) != 0) {
+			RTE_BOND_LOG(ERR,
+					"bonded port (%d) failed to reconfigure slave device (%d)",
+					eth_dev->data->port_id, internals->slaves[i].port_id);
 			return -1;
 		}
 	}
@@ -752,6 +764,7 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 	struct bond_dev_private *internals = eth_dev->data->dev_private;
 
 	internals->active_slave_count = 0;
+	internals->link_status_polling_enabled = 0;
 
 	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 0;
@@ -845,6 +858,65 @@ bond_ethdev_tx_queue_release(void *queue)
 	rte_free(queue);
 }
 
+
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
+{
+	struct rte_eth_dev *bonded_ethdev, *slave_ethdev;
+	struct bond_dev_private *internals;
+
+	/* Default value for polling slave found is true as we don't want to
+	 * disable the polling thread if we cannot get the lock */
+	int i, polling_slave_found = 1;
+
+	if (cb_arg == NULL)
+		return;
+
+	bonded_ethdev = (struct rte_eth_dev *)cb_arg;
+	internals = (struct bond_dev_private *)bonded_ethdev->data->dev_private;
+
+	if (!bonded_ethdev->data->dev_started ||
+		!internals->link_status_polling_enabled)
+		return;
+
+	/* If device is currently being configured then don't check slaves link
+	 * status, wait until next period */
+	if (rte_spinlock_trylock(&internals->lock)){
+		if (internals->slave_count > 0)
+			polling_slave_found = 0;
+
+		for (i = 0; i < internals->slave_count; i++) {
+			if (!internals->slaves[i].link_status_poll_enabled)
+				continue;
+
+			slave_ethdev = &rte_eth_devices[internals->slaves[i].port_id];
+			polling_slave_found = 1;
+
+			/* Update slave link status */
+			(*slave_ethdev->dev_ops->link_update)(slave_ethdev,
+					internals->slaves[i].link_status_wait_to_complete);
+
+			/* if link status has changed since last checked then call lsc
+			 * event callback */
+			if (slave_ethdev->data->dev_link.link_status !=
+					internals->slaves[i].last_link_status) {
+				internals->slaves[i].last_link_status =
+						slave_ethdev->data->dev_link.link_status;
+
+				bond_ethdev_lsc_event_callback(internals->slaves[i].port_id,
+						RTE_ETH_EVENT_INTR_LSC,
+						&bonded_ethdev->data->port_id);
+			}
+		}
+		rte_spinlock_unlock(&internals->lock);
+	}
+
+	if (polling_slave_found)
+		/* Set alarm to continue monitoring link status of slave ethdev's */
+		rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+				bond_ethdev_slave_link_status_change_monitor, cb_arg);
+}
+
 static int
 bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev,
 		int wait_to_complete)
@@ -888,7 +960,7 @@ bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	memset(stats, 0, sizeof(*stats));
 
 	for (i = 0; i < internals->slave_count; i++) {
-		rte_eth_stats_get(internals->slaves[i], &slave_stats);
+		rte_eth_stats_get(internals->slaves[i].port_id, &slave_stats);
 
 		stats->ipackets += slave_stats.ipackets;
 		stats->opackets += slave_stats.opackets;
@@ -914,7 +986,7 @@ bond_ethdev_stats_reset(struct rte_eth_dev *dev)
 	int i;
 
 	for (i = 0; i < internals->slave_count; i++)
-		rte_eth_stats_reset(internals->slaves[i]);
+		rte_eth_stats_reset(internals->slaves[i].port_id);
 }
 
 static void
@@ -931,7 +1003,7 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)
 	case BONDING_MODE_BALANCE:
 	case BONDING_MODE_BROADCAST:
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_enable(internals->slaves[i]);
+			rte_eth_promiscuous_enable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -955,7 +1027,7 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	case BONDING_MODE_BALANCE:
 	case BONDING_MODE_BROADCAST:
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_disable(internals->slaves[i]);
+			rte_eth_promiscuous_disable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -964,6 +1036,16 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	}
 }
 
+static void
+bond_ethdev_delayed_lsc_propagation(void *arg)
+{
+	if (arg == NULL)
+		return;
+
+	_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
+			RTE_ETH_EVENT_INTR_LSC);
+}
+
 void
 bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		void *param)
@@ -992,7 +1074,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 
 	/* verify that port_id is a valid slave of bonded port */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == port_id) {
+		if (internals->slaves[i].port_id == port_id) {
 			valid_slave = 1;
 			break;
 		}
@@ -1061,8 +1143,32 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		}
 	}
 
-	if (lsc_flag)
-		_rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
+	if (lsc_flag) {
+		/* Cancel any possible outstanding interrupts if delays are enabled */
+		if (internals->link_up_delay_ms > 0 ||
+			internals->link_down_delay_ms > 0)
+			rte_eal_alarm_cancel(bond_ethdev_delayed_lsc_propagation,
+					bonded_eth_dev);
+
+		if (bonded_eth_dev->data->dev_link.link_status) {
+			if (internals->link_up_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_up_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+
+		} else {
+			if (internals->link_down_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_down_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+		}
+	}
 }
 
 struct eth_dev_ops default_dev_ops = {
@@ -1212,8 +1318,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(ERR, EAL,
-				"Transmit policy can be specified only once for bonded device %s\n",
-				name);
+				"Transmit policy can be specified only once for bonded device"
+				" %s\n", name);
 		return -1;
 	}
 
@@ -1255,8 +1361,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				&bond_ethdev_parse_primary_slave_port_id_kvarg,
 				&primary_slave_port_id) < 0) {
 			RTE_LOG(INFO, EAL,
-					"Invalid primary slave port id specified for bonded device %s\n",
-					name);
+					"Invalid primary slave port id specified for bonded device"
+					" %s\n", name);
 			return -1;
 		}
 
@@ -1270,8 +1376,97 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(INFO, EAL,
-				"Primary slave can be specified only once for bonded device %s\n",
-				name);
+				"Primary slave can be specified only once for bonded device"
+				" %s\n", name);
+		return -1;
+	}
+
+	/* Parse link status monitor polling interval */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LSC_POLL_PERIOD_KVARG);
+	if (arg_count == 1) {
+		uint32_t lsc_poll_interval_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LSC_POLL_PERIOD_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&lsc_poll_interval_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid lsc polling interval value specified for bonded"
+					"device %s\n", name);
+			return -1;
+		}
+
+		if (rte_eth_bond_link_monitoring_set(port_id, lsc_poll_interval_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set lsc monitor polling interval (%u ms) on"
+					" bonded device %s\n", lsc_poll_interval_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"LSC polling interval can be specified only once for bonded"
+				"device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link up interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_UP_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_up_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_UP_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_up_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link up propagation delay value specified for "
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_up_prop_delay_set(port_id, link_up_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link up propagation delay (%u ms) on bonded"
+					"device %s\n", link_up_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link up propagation delay can be specified only once for "
+				"bonded device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link down interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_down_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_down_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link down propagation delay value specified for"
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_down_prop_delay_set(port_id, link_down_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link down propagation delay (%u ms) on"
+					" bonded device %s\n", link_down_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link down propagation delay can be specified only once for"
+				" bonded device %s\n", name);
 		return -1;
 	}
 
diff --git a/lib/librte_pmd_bond/rte_eth_bond_private.h b/lib/librte_pmd_bond/rte_eth_bond_private.h
index 1db6e4d..78f4196 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_private.h
+++ b/lib/librte_pmd_bond/rte_eth_bond_private.h
@@ -39,20 +39,27 @@ extern "C" {
 #endif
 
 #include <rte_ethdev.h>
+#include <rte_spinlock.h>
 
 #include "rte_eth_bond.h"
 
-#define PMD_BOND_SLAVE_PORT_KVARG		("slave")
-#define PMD_BOND_PRIMARY_SLAVE_KVARG	("primary")
-#define PMD_BOND_MODE_KVARG				("mode")
-#define PMD_BOND_XMIT_POLICY_KVARG		("xmit_policy")
-#define PMD_BOND_SOCKET_ID_KVARG		("socket_id")
-#define PMD_BOND_MAC_ADDR_KVARG			("mac")
+#define PMD_BOND_SLAVE_PORT_KVARG			("slave")
+#define PMD_BOND_PRIMARY_SLAVE_KVARG		("primary")
+#define PMD_BOND_MODE_KVARG					("mode")
+#define PMD_BOND_XMIT_POLICY_KVARG			("xmit_policy")
+#define PMD_BOND_SOCKET_ID_KVARG			("socket_id")
+#define PMD_BOND_MAC_ADDR_KVARG				("mac")
+#define PMD_BOND_LSC_POLL_PERIOD_KVARG		("lsc_poll_period_ms")
+#define PMD_BOND_LINK_UP_PROP_DELAY_KVARG	("up_delay")
+#define PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG	("down_delay")
 
 #define PMD_BOND_XMIT_POLICY_LAYER2_KVARG	("l2")
 #define PMD_BOND_XMIT_POLICY_LAYER23_KVARG	("l23")
 #define PMD_BOND_XMIT_POLICY_LAYER34_KVARG	("l34")
 
+#define RTE_BOND_LOG(lvl, msg, ...) 		\
+	RTE_LOG(lvl, PMD, "%s(%d) - " msg "\n", __func__, __LINE__, ##__VA_ARGS__);
+
 extern const char *pmd_bond_init_valid_arguments[];
 
 extern const char *driver_name;
@@ -82,27 +89,36 @@ struct bond_tx_queue {
 	/**< Copy of TX configuration structure for queue */
 };
 
-/** Persisted Slave Configuration Structure */
-struct slave_conf {
-	uint8_t port_id;
-	/**< Port Id of slave eth_dev */
-	struct ether_addr mac_addr;
-	/**< Slave eth_dev original MAC address */
-};
+
 /** Bonded slave devices structure */
 struct bond_ethdev_slave_ports {
 	uint8_t slaves[RTE_MAX_ETHPORTS];	/**< Slave port id array */
 	uint8_t slave_count;				/**< Number of slaves */
 };
 
+struct bond_slave_details {
+	uint8_t port_id;
+
+	uint8_t link_status_poll_enabled;
+	uint8_t link_status_wait_to_complete;
+	uint8_t last_link_status;
+
+	/**< Port Id of slave eth_dev */
+	struct ether_addr persisted_mac_addr;
+};
+
 /** Link Bonding PMD device private configuration Structure */
 struct bond_dev_private {
+	uint8_t port_id;					/**< Port Id of Bonded Port */
 	uint8_t mode;						/**< Link Bonding Mode */
 
+	rte_spinlock_t lock;
+
 	uint8_t primary_port;				/**< Primary Slave Port */
 	uint8_t current_primary_port;		/**< Primary Slave Port */
 	uint8_t user_defined_primary_port;
 	/**< Flag for whether primary port is user defined or not */
+
 	uint8_t balance_xmit_policy;
 	/**< Transmit policy - l2 / l23 / l34 for operation in balance mode */
 	uint8_t user_defined_mac;
@@ -110,19 +126,23 @@ struct bond_dev_private {
 	uint8_t promiscuous_en;
 	/**< Enabled/disable promiscuous mode on slave devices */
 	uint8_t link_props_set;
-	/**< Bonded eth_dev link properties set */
+	/**< flag to denote if the link properties are set */
+
+	uint8_t link_status_polling_enabled;
+	uint32_t link_status_polling_interval_ms;
+
+	uint32_t link_down_delay_ms;
+	uint32_t link_up_delay_ms;
 
 	uint16_t nb_rx_queues;			/**< Total number of rx queues */
 	uint16_t nb_tx_queues;			/**< Total number of tx queues*/
 
-	uint8_t slave_count;			/**< Number of active slaves */
-	uint8_t active_slave_count;		/**< Number of slaves */
-
+	uint8_t active_slave_count;		/**< Number of active slaves */
 	uint8_t active_slaves[RTE_MAX_ETHPORTS];	/**< Active slave list */
-	uint8_t slaves[RTE_MAX_ETHPORTS];			/**< Slave list */
 
-	/** Persisted configuration of slaves */
-	struct slave_conf presisted_slaves_conf[RTE_MAX_ETHPORTS];
+	uint8_t slave_count;			/**< Number of bonded slaves */
+	struct bond_slave_details slaves[RTE_MAX_ETHPORTS];
+	/**< Arary of bonded slaves details */
 
 	struct rte_kvargs *kvlist;
 };
@@ -168,16 +188,13 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id);
-
 void
 bond_ethdev_primary_set(struct bond_dev_private *internals,
 		uint8_t slave_port_id);
@@ -210,6 +227,10 @@ int
 bond_ethdev_parse_bond_mac_addr_kvarg(const char *key __rte_unused,
 		const char *value, void *extra_args);
 
+int
+bond_ethdev_parse_time_ms_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v5 8/8] bond: unit test test macro refactor
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
                       ` (6 preceding siblings ...)
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 7/8] bond: lsc polling support Declan Doherty
@ 2014-10-14 12:59     ` Declan Doherty
  2014-10-14 15:59     ` [dpdk-dev] [PATCH v5 0/8] link bonding De Lara Guarch, Pablo
                       ` (2 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-10-14 12:59 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/test_link_bonding.c | 2574 +++++++++++++++++-------------------------
 1 file changed, 1036 insertions(+), 1538 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index c32b685..c4fcaf7 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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;
-	}
+	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);
 
 	/* Send to sets of packet burst and verify that they are balanced across
 	 *  slaves */
 	burst_size = 21;
 
-	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");
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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");
+
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, &pkt_burst[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][0],
-			burst_size) != burst_size) {
-		printf("rte_eth_tx_burst failed\n");
-		return -1;
-	}
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size);
 
 	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 (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[2], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[2], (int)port_stats.opackets,
+			burst_size);
 
 	/* verify that all packets get send on primary slave when no other slaves
 	 * are available */
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[2], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id, slaves,
-			RTE_MAX_ETHPORTS) != 1) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_active_slaves_get(
+			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS), 1,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 1);
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][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[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size +
-			burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)(burst_size + burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
-
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[0], 0);
@@ -3668,16 +3244,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 			test_params->slave_port_ids[3], 1);
 
 	for (i = 0; i < TEST_BALANCE_LINK_STATUS_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,
+				"Failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
-
-
 	/* Verify that pkts are not received on slaves with link status down */
 
 	rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
@@ -3685,12 +3259,10 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size * 3)) {
-		printf("(%d) port_stats.ipackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.ipackets,
-				burst_size * 3);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)(burst_size * 3),
+			"(%d) port_stats.ipackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.ipackets,
+			burst_size * 3);
 
 	/* free mbufs allocate for rx testing */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
@@ -3711,16 +3283,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 static int
 test_broadcast_tx_burst(void)
 {
-	int i, pktlen, retval, burst_size, generated_burst_size, nb_tx;
+	int i, pktlen, burst_size;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 
 	struct rte_eth_stats port_stats;
 
-	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;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 2, 1),
+			"Failed to intialise bonded device");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
@@ -3732,46 +3302,37 @@ test_broadcast_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,
+	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);
-	if (generated_burst_size != burst_size)
-		return -1;
+			1), burst_size, "Failed to generate packet burst");
 
 	/* 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) {
-		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);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+			pkts_burst, burst_size), burst_size,
+			"Bonded Port (%d) rx burst failed, packets transmitted value "
+			"not as expected (%d)",
+			test_params->bonded_port_id, burst_size);
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size *
-			test_params->bonded_slave_count) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
-				burst_size);
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)burst_size * test_params->bonded_slave_count,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			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) {
-			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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)\n",
+				test_params->bonded_port_id,
+				(unsigned int)port_stats.opackets, burst_size);
 	}
 
 	/* Put all slaves down and try and transmit */
@@ -3782,10 +3343,9 @@ 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 != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkts_burst, burst_size),  0,
+			"transmitted an unexpected number of packets");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -3921,20 +3481,20 @@ test_broadcast_rx_burst(void)
 	struct rte_eth_stats port_stats;
 
 	int burst_size[BROADCAST_RX_BURST_NUM_OF_SLAVES] = { 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_BROADCAST, 0, 3, 1) != 0)
-		return -1;
-
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 3, 1),
+			"Failed to intialise bonded device");
 
 	/* Generate test bursts of packets to transmit */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; 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 slave 0 */
@@ -3946,57 +3506,44 @@ test_broadcast_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("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[0] + burst_size[1] + burst_size[2],
+			"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[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[0], (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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; i++) {
@@ -4015,48 +3562,38 @@ test_broadcast_rx_burst(void)
 static int
 test_broadcast_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_BROADCAST, 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 */
@@ -4068,45 +3605,39 @@ test_broadcast_verify_mac_assignment(void)
 {
 	struct ether_addr read_mac_addr, expected_mac_addr_0, expected_mac_addr_1;
 
-	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_1);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 4, 1),
+			"Failed to intialise bonded device");
 
 	/* Verify that all MACs are the same as first slave added to bonded
 	 * device */
 	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
@@ -4114,45 +3645,41 @@ test_broadcast_verify_mac_assignment(void)
 
 	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 new primary"
-				" port\n", test_params->slave_port_ids[i]);
-		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 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_1, &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_1, &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 address");
 
 	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_params->slave_port_ids[i]);
-		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 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(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", test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -4174,26 +3701,22 @@ 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, 0,
-			BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+				BONDING_MODE_BROADCAST, 0, BROADCAST_LINK_STATUS_NUM_OF_SLAVES,
+				1), "Failed to intialise bonded device");
 
 	/* 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;
-	}
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+	TEST_ASSERT_EQUAL(slave_count, 4,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 4);
 
 	/* Set 2 slaves link status to down */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -4203,11 +3726,9 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != 2) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, 2,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 2);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++)
 		rte_eth_stats_reset(test_params->slave_port_ids[i]);
@@ -4215,80 +3736,62 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	/* Verify that pkts are not sent on slaves with link status down */
 	burst_size = 21;
 
-	if (generate_test_burst(&pkt_burst[0][0], burst_size, 0, 0, 1, 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, 0, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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\n");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size * slave_count)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size * slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size * slave_count),
+			"(%d) port_stats.opackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size * slave_count);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%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_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[1]);
-		return -1;
-	}
 
 	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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[2]);
-		return -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]);
+
 
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
-		if (generate_test_burst(&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0) !=
-				burst_size) {
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0),
+				burst_size, "failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
 	/* Verify that pkts are not received on slaves with link status down */
+	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");
 
-	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;
-	}
 
 	/* 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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
@@ -4310,19 +3813,14 @@ 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)  != 0) {
-		printf("failed to reconfigure bonded device");
-		return -1;
-	}
-
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device");
 
 	test_params->nb_rx_q = 2;
 	test_params->nb_tx_q = 2;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
-		printf("failed to reconfigure bonded device with less rx/tx queues");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device with less rx/tx queues");
 
 	return 0;
 }
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/8] link bonding
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
                       ` (7 preceding siblings ...)
  2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 8/8] bond: unit test test macro refactor Declan Doherty
@ 2014-10-14 15:59     ` De Lara Guarch, Pablo
  2014-11-05  3:10     ` Jiajia, SunX
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
  10 siblings, 0 replies; 91+ messages in thread
From: De Lara Guarch, Pablo @ 2014-10-14 15:59 UTC (permalink / raw)
  To: Doherty, Declan, dev



> -----Original Message-----
> From: Doherty, Declan
> Sent: Tuesday, October 14, 2014 2:00 PM
> To: dev@dpdk.org
> Cc: Jiajia, SunX; De Lara Guarch, Pablo; thomas.monjalon@6wind.com;
> Doherty, Declan
> Subject: [PATCH v5 0/8] link bonding
> 
> 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
> 
[..]
> 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(-)
> 
> --
> 1.7.12.2

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v4 5/8] test app: adding support for generating variable sized packet bursts
  2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 5/8] test app: adding support for generating variable sized packet bursts Declan Doherty
@ 2014-10-24  3:22     ` Liang, Cunming
  0 siblings, 0 replies; 91+ messages in thread
From: Liang, Cunming @ 2014-10-24  3:22 UTC (permalink / raw)
  To: dev, Doherty, Declan



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty
> Sent: Tuesday, September 30, 2014 5:58 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v4 5/8] test app: adding support for generating
> variable sized packet bursts
> 
> 
> Signed-off-by: Declan Doherty <declan.doherty@intel.com>
> ---
>  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(-)
> 
> diff --git a/app/test/packet_burst_generator.c
> b/app/test/packet_burst_generator.c
> index 9e747a4..b2824dc 100644
> --- a/app/test/packet_burst_generator.c
> +++ b/app/test/packet_burst_generator.c
> @@ -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) {
> diff --git a/app/test/packet_burst_generator.h
> b/app/test/packet_burst_generator.h
> index 5b3cd6c..f86589e 100644
> --- a/app/test/packet_burst_generator.h
> +++ b/app/test/packet_burst_generator.h
> @@ -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
>  }
> diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
> index 1a847eb..50355a3 100644
> --- a/app/test/test_link_bonding.c
> +++ b/app/test/test_link_bonding.c
> @@ -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;
> 
> --
> 1.7.12.2

Acked-by: Cunming Liang <cunming.liang@intel.com>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/8] link bonding
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
                       ` (8 preceding siblings ...)
  2014-10-14 15:59     ` [dpdk-dev] [PATCH v5 0/8] link bonding De Lara Guarch, Pablo
@ 2014-11-05  3:10     ` Jiajia, SunX
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
  10 siblings, 0 replies; 91+ messages in thread
From: Jiajia, SunX @ 2014-11-05  3:10 UTC (permalink / raw)
  To: Doherty, Declan, dev

Tested-by: Jiajia, SunX <sunx.jiajia@intel.com> 
- Tested Commit: f7aaae2fe6f7f9a78eab7313d77e92b934693b5d
- OS: Fedora20 3.11.10-301.fc20.x86_64 and 3.16.6-200.fc20.x86_64
- GCC: gcc version 4.8.2
- CPU: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
- NIC: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection [8086:10fb]
- Default x86_64-native-linuxapp-gcc configuration
- Total 18 cases, 18 passed, 0 failed

TOPO:
* Connections ports between tester/ixia and DUT
  - TESTER(Or IXIA)-------DUT
  - portA------------------port0
  - portB------------------port1
  - portC------------------port2
  - portD------------------port3
* Connections ports between tester/ixia and switch and DUT
  - TESTER(Or IXIA)-------SWITCH
  -                       SWITCH---------DUT
  - TESTER(Or IXIA)----------------------DUT
  - portA------------------switch
  -                        switch----------port0
  -                        switch----------port1
  -                        switch----------port2
  - portB----------------------------------port3


Test Setup#1 for Functional test
================================

Tester has 4 ports(portA--portD), and DUT has 4 ports(port0--port3), then connect portA to port0, portB to port1, portC to port2, portD to port3. 


Test Setup#2 for Functional test
================================

Tester has 2 ports(portA--portB), DUT has 4 ports(port0--port3), and a switch that supports IEEE 802.3ad Dynamic link aggregation, then connect port0-port2 to the switch for dynamic link aggregation, connect portA to aggregated interface on the switch, connect portB to port3.


- Case: Basic bonding--Create bonded devices and slaves
  Description: 
		Use Setup#1.
		Create bonded device and add some ports as salve of bonded device,
            Then removed slaves or added slaves or change the bonding primary slave
            Or change bonding mode and so on.
  Expected test result:
            Verify the basic functions are normal.

- Case: Basic bonding--MAC Address Test
  Description: 
		Use Setup#1.
		Create bonded device and add some ports as slaves of bonded device,
            Check that the changes of  the bonded device and slave MAC 
  Expected test result:
            Verify the behavior of bonded device and slave according to the mode.

- Case: Basic bonding--Device Promiscuous Mode Test
  Description: 
		Use Setup#1.
		Create bonded device and add some ports as slaves of bonded device,
            Set promiscuous mode on or off, then send packets to the bonded device
            Or slaves.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves according to the mode.

- Case: Mode 0(Round Robin) TX/RX test
  Description: 
		Use Setup#1.
		Create bonded device with mode 0 and add 3 ports as slaves of bonded device,
            Forward packets between bonded device and unbounded device, start to forward,
            And send packets to unbound device or slaves.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 0.

- Case: Mode 0(Round Robin) Bring one slave link down
  Description: 
		Use Setup#1.
		Create bonded device with mode 0 and add 3 ports as slaves of bonded device,
            Forward packets between bonded device and unbounded device, start to forward,
            Bring the link on either port 0, 1 or 2 down. And send packets to unbound 
            device or slaves.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 0.

- Case: Mode 0(Round Robin) Bring all slave links down
  Description: 
		Use Setup#1.
		Create bonded device with mode 0 and add 3 ports as slaves of bonded device,
            Forward packets between bonded device and unbounded device, start to forward,
            Bring the links down on all bonded ports. And send packets to unbound 
            device or slaves.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 0.

- Case: Mode 1(Active Backup) TX/RX Test
  Description: 
		Use Setup#1.
		Create bonded device with mode 1 and add 3 ports as slaves of bonded device,
            Forward packets between bonded device and unbounded device, start to forward,
            And send packets to unbound device or slaves.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 1.

- Case: Mode 1(Active Backup) Change active slave, RX/TX test
  Description: 
		Use Setup#1.
		Continuing from previous test case.Change the active slave port from port0 
            to port1.Verify that the bonded device's MAC has changed to slave1's MAC.

            testpmd> set bonding primary 1 4 

           Repeat the transmission and reception(TX/RX) test verify that data is now 
           transmitted and received through the new active slave and no longer through
           port0  
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 1.

- Case: Mode 1(Active Backup) Link up/down active eth dev
  Description: 
		Use Setup#1.

           Bring link between port A and port0 down. If tester is ixia, can use 
           IxExplorer to set the "Simulate Cable Disconnect" at the port property.  
           Verify that the active slave has been changed from port0. Repeat the 
           transmission and reception test verify that data is now transmitted and
           received through the new active slave and no longer through port0

           Bring port0 to link down at the remote end.Verify the active slave has been changed from port0.
           send 100 packets to port3.

           testpmd> show port stats 4----(Verify port3 have 100 rx packets,meanwhile
          port4 have 100 tx packets,the current primary port have 100 tx packets,and port0
          doesn`t have any packet)
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 1. 

- Case: Mode 1(Active Backup) Bring all slave links down
  Description: 
		Use Setup#1.
            Bring all slave ports of bonded port down.
            Verify that bonded callback for link down is called and no active slaves. 
            Verify that data cannot be sent or received through bonded port. Send 100 packets 
            to port3 and verify that bonded port can't TX 100 packets.

            Bring port 0-2 to link down at the remote end. Verify port4 has been link down and has no active slave.
            Send 100 rx packets to port3. 

         testpmd> show port stats 4----(Verify port3 have 100 rx packets,meanwhile 
                                        port4 doesn`t have any packet)
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 1.

- Case: Mode 2(Balance XOR) TX Load Balance test
  Description: 
		Use Setup#1.
            Bonded port will activate each slave eth dev based on the following hash function:

             ((dst_mac XOR src_mac) % (number of slave ports))

            Send 300 packets from IXIA port D to non-bonded port(port3),and verify these packets 
            will be forwarded to bonded device. The bonded device will transimit these packets to all slaves.
            Verify that each slave receive correct number of packets according to the policy. The total number
            of packets which received by slave should be equal as 300 packets. 

            Create 3 streams in the IXIA,which streams source MAC are 00:00:03:00:0F:00,
            00:00:03:00:0F:01,00:00:03:00:0F:02 respectively (make sure generate different value by
            the policy ((dst_mac XOR src_mac) % (number of slave ports)) ) and dest MAC all is 
            90:E2:BA:4A:54:80(this value should been your unbonded port address). Respectively
            send 100 packets to port3 by the 3 streams.

            testpmd> show port stats all----(Verify port3 have 300 rx packets,
            port4 have 300 tx packets,and port 0-2 have 100 tx packets respectively)

  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 2.

- Case: Mode 2(Balance XOR) TX Load Balance Link down
  Description: 
		Use Setup#1.
		ring link down of one slave.
            Send 300 packets from non-bonded port(port3), and verify these 
		packets will be forwarded to bonded device. 
            Verify that each active slave receive correct number of packets
            (according to the mode policy), and the down slave will not receive packets.
		Link down slave 0 at the remote end.Create 3 streams in the IXIA like case13.
		Then respectively send 100 packets to port3 by the 3 streams.

  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 2.

- Case: Mode 2(Balance XOR) Bring all slave links down
  Description: 
		Use Setup#1.
		Bring all slave links down.
		Verify that bonded callback for link down is called.
		Verify no packet can be sent.

		Bring all slaves to link down at the remote end.Create 
		3 streams in the IXIA like case13.Then respectively send 100 packets 
		to port3 by the 3 streams.

		testpmd> show port info 4----(Verify bonding port has been linked down)
   	      testpmd> show port stats all----(Verify port3 have 300 rx packets,meanwhile
							 port 0,1,2 and 4 don`t have any packet)
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 2.


- Case: Mode 2(Balance XOR) Layer 3+4 forwarding 	
  Description: 
		Use Setup#1.
		Use "xmit_hash_policy()" to change to this forwarding mode
		Create a stream of traffic which will exercise all slave ports using the transmit policy 

   		 ((SRC_PORT XOR DST_PORT) XOR ((SRC_IP XOR DST_IP) AND 0xffff) % # of Slaves

		Transmit data through bonded device, verify TX packet count for each slave port is as expected

		Create 3 streams on a port which is mapped with unbonded port 3 at the IXIA end.
	      And set different IP by the transmit policy.Then send 100 packets on each stream.

           testpmd> show port stats all----(Verify port3 have 300 rx packets,
				meanwhile port4 have 300 rx packets, port 0-2 have 100 tx packets respectively)

		Add Vlan tag in the previouse 3 streams. Everthing else remains the same. 
		Then send 100 packets on each stream. Verify the packet statics is the same as above.  

   	      testpmd> show port stats all----(Verify port3  
		have 300 rx packets,meanwhile port4 have 300 rx packets,port 0-2 have 100 tx packets respecitvely)
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 2.

- Case: Mode 2(Balance XOR) RX test
  Description: 
		Use Setup#1.
		Send 100 packets to each bonded slaves(port0,1,2)
		Verify that each slave receives 100 packets and the bonded device receive a total 300 packets.
		Verify that the bonded device forwards 300 packets to the non-bonded port(port4).

		Send 100 packets to port0,1,2 respectively.

    		testpmd> show port stats all----(Verify port0,1,2 have 100 tx packets respectively 
				and port4 have 300 rx packets,and port3 have 300 tx packets)

  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 2.

- Case: Mode 3(Broadcast) TX/RX Test
  Description: 
		Use Setup#1.
		Add ports 0-2 as slave devices to the bonded port 4. Make all slaves
	      to be active slaves on bonded device. 

            RX: Send a packet stream(100 packets) from port A on the traffic
		    generator to be forwarded through the bonded port4 to port3.
		    Verify the sum of the packets transmitted from the traffic generator
		    portA is equal the total received packets on port0, port4 and portD(Traffic generator).

               testpmd> show port stats all---(Verify port0 receive 100 packets, 
				and port4 receive 100 packets, and port3 transmit 100 packets)

           TX: Send a packet stream(100 packets) from portD on the traffic generator 
               to be forwarded through port3 to the bonded port4. Verify the sum of 
               the packets(100packets) transmitted from the traffic generator port is equal the total 
               received packets on port4, portA and transmitted to port0.
    
          testpmd> show port stats all---(Verify port3 RX 100 packets, 
                    and port0,1,2 TX 100 packets,port4 has 300 TX packets)
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 3.


- Case: Mode 3(Broadcast) Bring one slave link down
  Description: 
		Use Setup#1.
		Bring one slave port link down. Send 100 packets through portD to port3,
	      then port3 forwards to bondede device(port4), verify that the bonded device 
		and other slaves TX the correct number of packets(100 packets for each port).
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 3.

- Case: Mode 3(Broadcast) Bring all slave links down
  Description: 
		Use Setup#1.
		Bring all slave ports of bonded port down
		Verify that bonded callback for link down is called
		Verify that data cannot be sent or received through bonded port.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 3.



> -----Original Message-----
> From: Doherty, Declan
> Sent: Tuesday, October 14, 2014 9:00 PM
> To: dev@dpdk.org
> Cc: Jiajia, SunX; De Lara Guarch, Pablo; thomas.monjalon@6wind.com;
> Doherty, Declan
> Subject: [PATCH v5 0/8] link bonding
> 
> 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(-)
> 
> --
> 1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v6 0/8] link bonding
  2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
                       ` (9 preceding siblings ...)
  2014-11-05  3:10     ` Jiajia, SunX
@ 2014-11-07 12:22     ` Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 1/8] bond: link status interrupt support Declan Doherty
                         ` (10 more replies)
  10 siblings, 11 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-07 12:22 UTC (permalink / raw)
  To: dev

v6:
- Re-based to dpdk.org addressing associated issues for MBUF_REFCNT
- Added details to testpmd user guide for new command to set link status polling interval.

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                | 3347 ++++++++++++++-------------
 app/test/virtual_pmd.c                      |   96 +-
 app/test/virtual_pmd.h                      |   53 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   19 +
 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     |   28 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c      |  553 +++--
 lib/librte_pmd_bond/rte_eth_bond_private.h  |   71 +-
 15 files changed, 2715 insertions(+), 1959 deletions(-)

-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v6 1/8] bond: link status interrupt support
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
@ 2014-11-07 12:22       ` Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 2/8] bond: removing switch statement from rx burst method Declan Doherty
                         ` (9 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-07 12:22 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 214d2a2..e1c5596 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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);
 	}
 
@@ -1081,12 +1087,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);
 
@@ -1119,8 +1125,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 */
@@ -1144,6 +1150,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,
@@ -1212,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;
 
@@ -1282,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;
 
@@ -1372,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;
 
@@ -1464,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;
 
@@ -1555,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;
 
@@ -1619,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;
 
@@ -1760,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;
@@ -1857,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;
@@ -1951,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;
 
@@ -2021,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;
 
@@ -2160,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;
@@ -2331,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");
@@ -2411,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");
@@ -2509,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;
@@ -2637,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;
@@ -2775,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;
 
@@ -2864,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);
@@ -2918,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
@@ -3048,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;
 
@@ -3241,7 +3385,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;
@@ -3331,7 +3475,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;
 
 
@@ -3423,7 +3567,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);
@@ -3479,7 +3623,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
@@ -3579,7 +3723,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;
 
@@ -3716,7 +3860,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;
 	}
@@ -3725,7 +3869,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;
 	}
@@ -3773,6 +3917,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),
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index 75f5694..dd33119 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -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,
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 147028b..de0cd56 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -930,6 +930,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;
@@ -975,6 +976,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,
@@ -999,6 +1001,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);
@@ -1014,6 +1017,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.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v6 2/8] bond: removing switch statement from rx burst method
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 1/8] bond: link status interrupt support Declan Doherty
@ 2014-11-07 12:22       ` Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
                         ` (8 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-07 12:22 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 65 +++++++++++++++++++---------------
 1 file changed, 36 insertions(+), 29 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index de0cd56..f2fe930 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -59,35 +59,38 @@ 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:
-#ifdef RTE_MBUF_REFCNT
-	case BONDING_MODE_BROADCAST:
-#endif
-	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;
@@ -136,7 +139,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;
@@ -272,7 +275,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;
@@ -486,24 +490,27 @@ 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;
 #ifdef RTE_MBUF_REFCNT
 	case BONDING_MODE_BROADCAST:
 		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 #endif
 	default:
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 	internals->mode = mode;
 
 	return 0;
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v6 3/8] bond: fix naming inconsistency in tx_burst_round_robin
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 1/8] bond: link status interrupt support Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 2/8] bond: removing switch statement from rx burst method Declan Doherty
@ 2014-11-07 12:22       ` Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
                         ` (7 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-07 12:22 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index f2fe930..6e770af 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -93,7 +93,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];
@@ -108,13 +108,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;
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v6 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
                         ` (2 preceding siblings ...)
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
@ 2014-11-07 12:22       ` Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 5/8] test app: adding support for generating variable sized packet Declan Doherty
                         ` (6 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-07 12:22 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/test_link_bonding.c           | 393 ++++++++++++++++++++++++++++++++-
 app/test/virtual_pmd.c                 |  79 +++++--
 app/test/virtual_pmd.h                 |   7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  83 +++++--
 4 files changed, 524 insertions(+), 38 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index e1c5596..af19066 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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);
 	}
@@ -1416,6 +1419,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 };
@@ -2903,6 +3035,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
@@ -3416,7 +3683,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);
@@ -3459,6 +3726,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
@@ -3771,7 +4157,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;
 	}
@@ -3920,6 +4306,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),
@@ -3943,12 +4330,14 @@ 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),
 #ifdef RTE_MBUF_REFCNT
 		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),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index e861c5b..72f527e 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -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,66 @@ 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;
+		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->tx_burst_fail_count;
+
+		/* 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 +431,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)
 {
 	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
 
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 766b6ac..3b5c911 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -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
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 6e770af..2a86402 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -102,10 +102,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;
 	internals = bd_tx_q->dev_private;
@@ -121,19 +121,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
 	 * 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]);
+	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,
+					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;
+
+				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]));
+			}
+			num_tx_total += num_tx_slave;
+		}
+	}
 
 	return num_tx_total;
 }
@@ -284,7 +297,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;
 
@@ -316,11 +329,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;
 }
 
@@ -332,12 +357,13 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct rte_mbuf **bufs,
 	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
 
-	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_successful_tx_slave = -1;
 
 	bd_tx_q = (struct bond_tx_queue *)queue;
 	internals = bd_tx_q->dev_private;
@@ -356,11 +382,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
+		 * maximum number of packets */
+		if (slave_tx_total[i] > max_nb_of_tx_pkts) {
+			max_nb_of_tx_pkts = slave_tx_total[i];
+			most_successful_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
+	 * handle failures of all packets except those of the most successful slave
+	 */
+	if (unlikely(tx_failed_flag))
+		for (i = 0; i < num_of_slaves; i++)
+			if (i != most_successful_tx_slave)
+				while (slave_tx_total[i] < nb_pkts)
+					rte_pktmbuf_free(bufs[slave_tx_total[i]++]);
+
+	return max_nb_of_tx_pkts;
 }
 #endif
 
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v6 5/8] test app: adding support for generating variable sized packet
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
                         ` (3 preceding siblings ...)
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
@ 2014-11-07 12:22       ` Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
                         ` (5 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-07 12:22 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c
index 9e747a4..b2824dc 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -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) {
diff --git a/app/test/packet_burst_generator.h b/app/test/packet_burst_generator.h
index 5b3cd6c..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -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
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index af19066..547ee78 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -1341,7 +1341,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;
@@ -2059,7 +2060,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;
 
@@ -2712,7 +2713,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,
@@ -2721,7 +2723,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 */
@@ -3676,7 +3679,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;
 
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v6 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
                         ` (4 preceding siblings ...)
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 5/8] test app: adding support for generating variable sized packet Declan Doherty
@ 2014-11-07 12:22       ` Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 7/8] bond: lsc polling support Declan Doherty
                         ` (4 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-07 12:22 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4c3fc76..be12c13 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3642,7 +3642,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);
 	}
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index f76406f..5740804 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -630,7 +630,7 @@ init_config(void)
 
 
 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
 	struct rte_port *port;
 
@@ -649,6 +649,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();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 9cbfeac..5a3423c 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v6 7/8] bond: lsc polling support
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
                         ` (5 preceding siblings ...)
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
@ 2014-11-07 12:22       ` Declan Doherty
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 8/8] bond: unit test test macro refactor Declan Doherty
                         ` (3 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-07 12:22 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test-pmd/cmdline.c                      |  63 +++++
 app/test/test.h                             |   7 +-
 app/test/test_link_bonding.c                | 265 ++++++++++++-------
 app/test/virtual_pmd.c                      |  17 +-
 app/test/virtual_pmd.h                      |  48 +++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  19 ++
 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     |  28 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c      | 393 +++++++++++++++++++++-------
 lib/librte_pmd_bond/rte_eth_bond_private.h  |  71 +++--
 11 files changed, 958 insertions(+), 348 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index be12c13..ee8c121 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -462,6 +462,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()
@@ -3733,6 +3736,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 *** */
@@ -7787,6 +7849,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,
diff --git a/app/test/test.h b/app/test/test.h
index 98ab804..24b1640 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -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;											\
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 547ee78..4aa57a7 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -234,42 +234,34 @@ configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 	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;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_dev_configure(port_id, test_params->nb_rx_q,
+			test_params->nb_tx_q, &default_pmd_conf),
+			"rte_eth_dev_configure for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++) {
-		if (rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
+	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
 				rte_eth_dev_socket_id(port_id), &rx_conf_default,
-				test_params->mbuf_pool) < 0) {
-			goto error;
-		}
-	}
+				test_params->mbuf_pool) ,
+				"rte_eth_rx_queue_setup for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++) {
-		if (rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
-				rte_eth_dev_socket_id(port_id), &tx_conf_default) < 0) {
-			printf("Failed to setup tx queue (%d).\n", q_id);
-			goto error;
-		}
-	}
+	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
+				rte_eth_dev_socket_id(port_id), &tx_conf_default),
+				"rte_eth_tx_queue_setup for port %d failed", port_id);
 
-	if (start) {
-		if (rte_eth_dev_start(port_id) < 0) {
-			printf("Failed to start device (%d).\n", port_id);
-			goto error;
-		}
-	}
-	return 0;
+	if (start)
+		TEST_ASSERT_SUCCESS(rte_eth_dev_start(port_id),
+				"rte_eth_dev_start for port %d failed", port_id);
 
-error:
-	printf("Failed to configure ethdev %d\n", port_id);
-	return -1;
+	return 0;
 }
 
 static int slaves_initialized;
 
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
+
+
 static int
 test_setup(void)
 {
@@ -310,7 +302,7 @@ test_setup(void)
 			snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_%d", i);
 
 			test_params->slave_port_ids[i] = virtual_ethdev_create(pmd_name,
-					mac_addr, rte_socket_id());
+					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;
@@ -414,34 +406,27 @@ test_create_bonded_device_with_invalid_params(void)
 static int
 test_add_slave_to_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]);
-	if (retval != 0) {
-		printf("Failed to add slave (%d) to bonded port (%d).\n",
-				test_params->bonded_port_id,
-				test_params->slave_port_ids[test_params->bonded_slave_count]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave (%d) to bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count],
+			test_params->bonded_port_id);
 
 	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 + 1) {
-		printf("Number of slaves (%d) is greater than expected (%d).\n",
-				current_slave_count, test_params->bonded_slave_count + 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count + 1,
+			"Number of slaves (%d) is greater than expected (%d).",
+			current_slave_count, test_params->bonded_slave_count + 1);
 
 	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 as expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
+					"Number of active slaves (%d) is not as expected (%d).\n",
+					current_slave_count, 0);
 
 	test_params->bonded_slave_count++;
 
@@ -476,27 +461,23 @@ test_add_slave_to_invalid_bonded_device(void)
 static int
 test_remove_slave_from_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 	struct ether_addr read_mac_addr, *mac_addr;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_remove(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
-	if (retval != 0) {
-		printf("\t Failed to remove slave %d from bonded port (%d).\n",
-				test_params->slave_port_ids[test_params->bonded_slave_count-1],
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_remove(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count-1]),
+			"Failed to remove slave %d from bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count-1],
+			test_params->bonded_port_id);
 
 
 	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 - 1) {
-		printf("Number of slaves (%d) is great than expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count - 1,
+			"Number of slaves (%d) is great than expected (%d).\n",
+			current_slave_count, test_params->bonded_slave_count - 1);
 
 
 	mac_addr = (struct ether_addr *)slave_mac;
@@ -506,10 +487,8 @@ test_remove_slave_from_bonded_device(void)
 	rte_eth_macaddr_get(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1],
 			&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\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
@@ -891,21 +870,20 @@ test_set_primary_slave(void)
 		return -1;
 	}
 
+	/* 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;
+	}
+
 	/* Set slave as primary
 	 * Verify slave it is now primary slave
 	 * Verify that MAC address of bonded device is that of primary slave
 	 * Verify that MAC address of all bonded slaves are that of primary slave
 	 */
 	for (i = 0; i < 4; i++) {
-
-		/* 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;
-		}
-
 		retval = rte_eth_bond_primary_set(test_params->bonded_port_id,
 				test_params->slave_port_ids[i]);
 		if (retval != 0) {
@@ -929,6 +907,7 @@ test_set_primary_slave(void)
 
 		/* 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;
 
@@ -1093,19 +1072,18 @@ static int
 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 */
+	/* Configure bonded device */
 	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);
 
-	while (number_of_slaves > test_params->bonded_slave_count) {
-		/* Add slaves to bonded device */
+	/* Add slaves to bonded device */
+	while (number_of_slaves > test_params->bonded_slave_count)
 		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
 				"Failed to add slave (%d to  bonding port (%d).",
 				test_params->bonded_slave_count - 1,
 				test_params->bonded_port_id);
-	}
 
 	/* Set link bonding mode  */
 	TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonded_port_id,
@@ -1128,9 +1106,9 @@ test_adding_slave_after_bonded_device_started(void)
 {
 	int i;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 0)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 0),
+			"Failed to add slaves to bonded device");
 
 	/* Enabled slave devices */
 	for (i = 0; i < test_params->bonded_slave_count + 1; i++) {
@@ -1138,12 +1116,9 @@ test_adding_slave_after_bonded_device_started(void)
 				test_params->slave_port_ids[i], 1);
 	}
 
-	if (rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]) !=
-					0) {
-		printf("\t Failed to add slave to bonded port.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave to bonded port.\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count]);
@@ -1158,8 +1133,6 @@ test_adding_slave_after_bonded_device_started(void)
 
 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,
@@ -1183,7 +1156,7 @@ lsc_timeout(int wait_us)
 	gettimeofday(&tp, NULL);
 
 	/* Convert from timeval to timespec */
-	ts.tv_sec  = tp.tv_sec;
+	ts.tv_sec = tp.tv_sec;
 	ts.tv_nsec = tp.tv_usec * 1000;
 	ts.tv_nsec += wait_us * 1000;
 
@@ -1193,6 +1166,9 @@ lsc_timeout(int wait_us)
 
 	pthread_mutex_unlock(&mutex);
 
+	if (retval == 0 && test_lsc_interupt_count < 1)
+		return -1;
+
 	return retval;
 }
 
@@ -1202,9 +1178,6 @@ 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)
@@ -1284,9 +1257,6 @@ test_status_interrupt(void)
 				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();
 }
@@ -1419,6 +1389,7 @@ test_roundrobin_tx_burst(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#ifdef RTE_MBUF_REFCNT
 static int
 verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
 {
@@ -1432,6 +1403,7 @@ verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
 	}
 	return 0;
 }
+#endif
 
 
 static void
@@ -1537,11 +1509,12 @@ test_roundrobin_tx_burst_slave_tx_fail(void)
 				(unsigned int)port_stats.opackets, slave_expected_tx_count);
 	}
 
+#ifdef RTE_MBUF_REFCNT
 	/* 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");
-
+#endif
 	free_mbufs(&pkt_burst[tx_count], TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
 
 	/* Clean up and remove slaves from bonded device */
@@ -2028,6 +2001,101 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT (2)
+
+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 } ;
+
+static int
+test_roundrobin_verfiy_polling_slave_link_status_change(void)
+{
+	struct ether_addr *mac_addr = (struct ether_addr *)polling_slave_mac;
+	char slave_name[RTE_ETH_NAME_MAX_LEN];
+
+	int i;
+
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+		/* Generate slave name / MAC address */
+		snprintf(slave_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_poll_%d", i);
+		mac_addr->addr_bytes[ETHER_ADDR_LEN-1] = i;
+
+		/* Create slave devices with no ISR Support */
+		if (polling_test_slaves[i] == -1) {
+			polling_test_slaves[i] = virtual_ethdev_create(slave_name, mac_addr,
+					rte_socket_id(), 0);
+			TEST_ASSERT(polling_test_slaves[i] >= 0,
+					"Failed to create virtual virtual ethdev %s\n", slave_name);
+
+			/* Configure slave */
+			TEST_ASSERT_SUCCESS(configure_ethdev(polling_test_slaves[i], 0, 0),
+					"Failed to configure virtual ethdev %s(%d)", slave_name,
+					polling_test_slaves[i]);
+		}
+
+		/* Add slave to bonded device */
+		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);
+	}
+
+	/* Initialize bonded device */
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 1, 1),
+			"Failed to configure bonded device %d",
+			test_params->bonded_port_id);
+
+
+	/* 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);
+
+	/* link status change callback for first slave link up */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 1);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(15000), "timed out waiting for interrupt");
+
+
+	/* no link status change callback for second slave link up */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 1);
+
+	TEST_ASSERT_FAIL(lsc_timeout(15000), "unexpectedly succeeded");
+
+	/* link status change callback for both slave links down */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 0);
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 0);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(20000), "timed out waiting for interrupt");
+
+	/* Un-Register link status change interrupt callback */
+	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);
+
+
+	/* Clean up and remove slaves from bonded device */
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+
+		TEST_ASSERT_SUCCESS(
+				rte_eth_bond_slave_remove(test_params->bonded_port_id,
+						polling_test_slaves[i]),
+				"Failed to remove slave %d from bonded port (%d)",
+				polling_test_slaves[i], test_params->bonded_port_id);
+	}
+
+	return remove_slaves_and_stop_bonded_device();
+}
+
+
 /** Active Backup Mode Tests */
 
 static int
@@ -3161,10 +3229,12 @@ test_balance_tx_burst_slave_tx_fail(void)
 				(unsigned int)port_stats.opackets,
 				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
 
+#ifdef RTE_MBUF_REFCNT
 	/* 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");
+#endif
 
 	free_mbufs(&pkts_burst_1[tx_count_1],
 			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
@@ -4316,6 +4386,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),
 		TEST_CASE(test_roundrobin_verify_mac_assignment),
 		TEST_CASE(test_roundrobin_verify_slave_link_status_change_behaviour),
+		TEST_CASE(test_roundrobin_verfiy_polling_slave_link_status_change),
 		TEST_CASE(test_activebackup_tx_burst),
 		TEST_CASE(test_activebackup_rx_burst),
 		TEST_CASE(test_activebackup_verify_promiscuous_enable_disable),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 72f527e..e105c84 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -457,6 +457,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)
 {
@@ -504,7 +512,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;
@@ -554,7 +562,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;
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 3b5c911..2462853 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -40,38 +40,58 @@ extern "C" {
 
 #include <rte_ether.h>
 
-int virtual_ethdev_init(void);
+int
+virtual_ethdev_init(void);
 
-int virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, uint8_t socket_id);
+int
+virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
+		uint8_t socket_id, uint8_t isr_support);
 
-void virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id, uint8_t link_status);
+void
+virtual_ethdev_set_link_status(uint8_t port_id, uint8_t link_status);
 
-void virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, struct rte_mbuf **pkts_burst, int burst_length);
+void
+virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id,
+		uint8_t link_status);
 
+void
+virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id,
+		struct rte_mbuf **pkts_burst, int burst_length);
 
-/** Control methods for the dev_ops functions pointer to control the behavior of the Virtual PMD */
 
-void virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
+/** Control methods for the dev_ops functions pointer to control the behavior
+ *  of the Virtual PMD */
 
-void virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_link_update_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_burst_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_link_update_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);
+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,
+void
+virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
 		uint8_t packet_fail_count);
 
 #ifdef __cplusplus
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index c0d0033..394f4bf 100755
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1479,6 +1479,25 @@ For example, set a Link Bonding device (port 10) to use a balance policy of laye
 
     testpmd> set bonding xmit_balance_policy 10 l34
 
+
+set bonding mon_period
+~~~~~~~~~~~~~~~~~~~~~~
+
+Set the link status monitoring polling period in milliseconds for a bonding devicie.
+
+This adds support for PMD slave devices which do not support link status interrupts.
+When the mon_period is set to a value greater than 0 then all PMD's which do not support
+link status ISR will be queried every polling interval to check if their link status has changed.
+
+set bonding mon_period (port_id) (value)
+
+For example, to set the link status monitoring polling period of bonded device (port 5) to 150ms
+
+.. code-block:: console
+
+    testpmd> set bonding mon_period 5 150
+
+ 
 show bonding config
 ~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/librte_pmd_bond/rte_eth_bond.h b/lib/librte_pmd_bond/rte_eth_bond.h
index 344ca1e..2ed4f7c 100644
--- a/lib/librte_pmd_bond/rte_eth_bond.h
+++ b/lib/librte_pmd_bond/rte_eth_bond.h
@@ -249,6 +249,86 @@ rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy);
 int
 rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id);
 
+/**
+ * Set the link monitoring frequency (in ms) for monitoring the link status of
+ * slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param internal_ms		Monitoring interval in milliseconds
+ *
+ * @return
+ *	0 on success, negative value otherwise.
+ */
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms);
+
+/**
+ * Get the current link monitoring frequency (in ms) for monitoring of the link
+ * status of slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ *
+ * @return
+ *	Monitoring interval on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id);
+
+
+/**
+ * Set the period in milliseconds for delaying the disabling of a bonded link
+ * when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the disabling of a bonded
+ * link when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id);
+
+/**
+ * Set the period in milliseconds for delaying the enabling of a bonded link
+ * when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the enabling of a bonded
+ * link when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index dd33119..f146bda 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -39,6 +39,8 @@
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
 
+#define DEFAULT_POLLING_INTERVAL_10_MS (10)
+
 int
 valid_bonded_ethdev(struct rte_eth_dev *eth_dev)
 {
@@ -63,9 +65,8 @@ valid_port_id(uint8_t port_id)
 	/* Verify that port id is valid */
 	int ethdev_count = rte_eth_dev_count();
 	if (port_id >= ethdev_count) {
-		RTE_LOG(ERR, PMD,
-				"%s: port Id %d is greater than rte_eth_dev_count %d\n",
-				__func__, port_id, ethdev_count);
+		RTE_BOND_LOG(ERR, "Port Id %d is greater than rte_eth_dev_count %d",
+				port_id, ethdev_count);
 		return -1;
 	}
 
@@ -81,9 +82,8 @@ valid_bonded_port_id(uint8_t port_id)
 
 	/* Verify that bonded_port_id refers to a bonded port */
 	if (valid_bonded_ethdev(&rte_eth_devices[port_id])) {
-		RTE_LOG(ERR, PMD,
-				"%s: Specified port Id %d is not a bonded eth_dev device\n",
-				__func__, port_id);
+		RTE_BOND_LOG(ERR, "Specified port Id %d is not a bonded eth_dev device",
+				port_id);
 		return -1;
 	}
 
@@ -136,37 +136,36 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	 */
 
 	if (name == NULL) {
-		RTE_LOG(ERR, PMD, "Invalid name specified\n");
+		RTE_BOND_LOG(ERR, "Invalid name specified");
 		goto err;
 	}
 
 	if (socket_id >= number_of_sockets()) {
-		RTE_LOG(ERR, PMD,
-				"%s: invalid socket id specified to create bonded device on.\n",
-				__func__);
+		RTE_BOND_LOG(ERR,
+				"Invalid socket id specified to create bonded device on.");
 		goto err;
 	}
 
 	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
 	if (pci_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci dev on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci dev on socket");
 		goto err;
 	}
 
 	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
 	if (eth_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc eth_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
 		goto err;
 	}
 
 	pci_drv = rte_zmalloc_socket(name, sizeof(*pci_drv), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_drv on socket");
 		goto err;
 	}
 	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_id_table on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
 		goto err;
 	}
 
@@ -181,14 +180,14 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
 		goto err;
 	}
 
 	/* reserve an ethdev entry */
 	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to allocate rte_eth_dev\n");
+		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
 		goto err;
 	}
 
@@ -218,25 +217,31 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->pci_dev = pci_dev;
 
 	if (bond_ethdev_mode_set(eth_dev, mode)) {
-		RTE_LOG(ERR, PMD,
-				"%s: failed to set bonded device %d mode too %d\n",
-				__func__, eth_dev->data->port_id, mode);
+		RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
+				 eth_dev->data->port_id, mode);
 		goto err;
 	}
 
+	rte_spinlock_init(&internals->lock);
+
+	internals->port_id = eth_dev->data->port_id;
 	internals->current_primary_port = 0;
 	internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
 	internals->user_defined_mac = 0;
 	internals->link_props_set = 0;
+
+	internals->link_status_polling_enabled = 0;
+
+	internals->link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS;
+	internals->link_down_delay_ms = 0;
+	internals->link_up_delay_ms = 0;
+
 	internals->slave_count = 0;
 	internals->active_slave_count = 0;
 
 	memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
 	memset(internals->slaves, 0, sizeof(internals->slaves));
 
-	memset(internals->presisted_slaves_conf, 0,
-			sizeof(internals->presisted_slaves_conf));
-
 	return eth_dev->data->port_id;
 
 err:
@@ -253,8 +258,8 @@ err:
 	return -1;
 }
 
-int
-rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
+static int
+__eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
 	struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
 	struct bond_dev_private *internals;
@@ -263,56 +268,43 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	int i, j;
 
-	/* Verify that port id's are valid bonded and slave ports */
-	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_add;
-
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_add;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
 
-	/*
-	 * Verify that new slave device is not already a slave of another bonded
-	 * device */
+	/* Verify that new slave device is not already a slave of another
+	 * bonded device */
 	for (i = rte_eth_dev_count()-1; i >= 0; i--) {
 		if (valid_bonded_ethdev(&rte_eth_devices[i]) == 0) {
 			temp_internals = rte_eth_devices[i].data->dev_private;
+
 			for (j = 0; j < temp_internals->slave_count; j++) {
 				/* Device already a slave of a bonded device */
-				if (temp_internals->slaves[j] == slave_port_id)
-					goto err_add;
+				if (temp_internals->slaves[j].port_id == slave_port_id) {
+					RTE_BOND_LOG(ERR, "Slave port %d is already a slave",
+							slave_port_id);
+					return -1;
+				}
 			}
 		}
 	}
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
-
 	slave_eth_dev = &rte_eth_devices[slave_port_id];
 
-	if (internals->slave_count > 0) {
-		/* Check that new slave device is the same type as the other slaves
-		 * and not repetitive */
-		for (i = 0; i < internals->slave_count; i++) {
-			if (slave_eth_dev->pci_dev->driver->id_table->device_id !=
-					rte_eth_devices[internals->slaves[i]].pci_dev->driver->id_table->device_id ||
-				internals->slaves[i] == slave_port_id)
-				goto err_add;
-		}
-	}
-
 	/* Add slave details to bonded device */
-	internals->slaves[internals->slave_count] = slave_port_id;
-
-	slave_config_store(internals, slave_eth_dev);
+	slave_add(internals, slave_eth_dev);
 
 	if (internals->slave_count < 1) {
-		/* if MAC is not user defined then use MAC of first slave add to bonded
-		 * device */
+		/* if MAC is not user defined then use MAC of first slave add to
+		 * bonded device */
 		if (!internals->user_defined_mac)
 			mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs);
 
 		/* Inherit eth dev link properties from first slave */
-		link_properties_set(bonded_eth_dev, &(slave_eth_dev->data->dev_link));
+		link_properties_set(bonded_eth_dev,
+				&(slave_eth_dev->data->dev_link));
 
 		/* Make primary slave */
 		internals->primary_port = slave_port_id;
@@ -322,10 +314,10 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->link_props_set) {
 			if (link_properties_valid(&(bonded_eth_dev->data->dev_link),
 									  &(slave_eth_dev->data->dev_link))) {
-				RTE_LOG(ERR, PMD,
-						"%s: Slave port %d link speed/duplex not supported\n",
-						__func__, slave_port_id);
-				goto err_add;
+				RTE_BOND_LOG(ERR,
+						"Slave port %d link speed/duplex not supported",
+						slave_port_id);
+				return -1;
 			}
 		} else {
 			link_properties_set(bonded_eth_dev,
@@ -340,9 +332,9 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	if (bonded_eth_dev->data->dev_started) {
 		if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
-			RTE_LOG(ERR, PMD, "rte_bond_slaves_configure: port=%d\n",
+			RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
 					slave_port_id);
-			goto err_add;
+			return -1;
 		}
 	}
 
@@ -356,65 +348,79 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 	if (bonded_eth_dev->data->dev_started) {
 		rte_eth_link_get_nowait(slave_port_id, &link_props);
 
-		 if (link_props.link_status == 1) {
+		 if (link_props.link_status == 1)
 			internals->active_slaves[internals->active_slave_count++] =
 					slave_port_id;
-		}
 	}
-
 	return 0;
 
-err_add:
-	RTE_LOG(ERR, PMD, "Failed to add port %d as slave\n", slave_port_id);
-	return -1;
-
 }
 
+
 int
-rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
+	struct rte_eth_dev *bonded_eth_dev;
 	struct bond_dev_private *internals;
-	struct slave_conf *slave_conf;
 
-	int i;
-	int pos = -1;
+	int retval;
 
 	/* Verify that port id's are valid bonded and slave ports */
 	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_del;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
+
+	return retval;
+}
+
+
+static int
+__eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct bond_dev_private *internals;
+
+	int i, slave_idx = -1;
 
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_del;
+		return -1;
 
 	internals = rte_eth_devices[bonded_port_id].data->dev_private;
 
 	/* first remove from active slave list */
 	for (i = 0; i < internals->active_slave_count; i++) {
 		if (internals->active_slaves[i] == slave_port_id)
-			pos = i;
+			slave_idx = i;
 
 		/* shift active slaves up active array list */
-		if (pos >= 0 && i < (internals->active_slave_count - 1))
+		if (slave_idx >= 0 && i < (internals->active_slave_count - 1))
 			internals->active_slaves[i] = internals->active_slaves[i+1];
 	}
 
-	if (pos >= 0)
+	if (slave_idx >= 0)
 		internals->active_slave_count--;
 
-	pos = -1;
-	/* now remove from slave list */
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == slave_port_id)
-			pos = i;
+	slave_idx = -1;
+	/* now find in slave list */
+	for (i = 0; i < internals->slave_count; i++)
+		if (internals->slaves[i].port_id == slave_port_id) {
+			slave_idx = i;
+			break;
+		}
 
-		/* shift slaves up list */
-		if (pos >= 0 && i < internals->slave_count)
-			internals->slaves[i] = internals->slaves[i+1];
+	if (slave_idx < 0) {
+		RTE_BOND_LOG(ERR, "Couldn't find slave in port list, slave count %d",
+				internals->slave_count);
+		return -1;
 	}
 
-	if (pos < 0)
-		goto err_del;
-
 	/* Un-register link status change callback with bonded device pointer as
 	 * argument*/
 	rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
@@ -422,13 +428,10 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 			&rte_eth_devices[bonded_port_id].data->port_id);
 
 	/* Restore original MAC address of slave device */
-	slave_conf = slave_config_get(internals, slave_port_id);
+	mac_address_set(&rte_eth_devices[slave_port_id],
+			&(internals->slaves[slave_idx].persisted_mac_addr));
 
-	mac_address_set(&rte_eth_devices[slave_port_id], &(slave_conf->mac_addr));
-
-	slave_config_clear(internals, &rte_eth_devices[slave_port_id]);
-
-	internals->slave_count--;
+	slave_remove(internals, &rte_eth_devices[slave_port_id]);
 
 	/*  first slave in the active list will be the primary by default,
 	 *  otherwise use first device in list */
@@ -436,7 +439,7 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->active_slave_count > 0)
 			internals->current_primary_port = internals->active_slaves[0];
 		else if (internals->slave_count > 0)
-			internals->current_primary_port = internals->slaves[0];
+			internals->current_primary_port = internals->slaves[0].port_id;
 		else
 			internals->primary_port = 0;
 	}
@@ -454,12 +457,28 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 	}
 
 	return 0;
+}
 
-err_del:
-	RTE_LOG(ERR, PMD,
-			"Cannot remove slave device (not present in bonded device)\n");
-	return -1;
+int
+rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct rte_eth_dev *bonded_eth_dev;
+	struct bond_dev_private *internals;
+	int retval;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_remove_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
 
+	return retval;
 }
 
 int
@@ -524,6 +543,7 @@ int
 rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 {
 	struct bond_dev_private *internals;
+	int i;
 
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
@@ -536,10 +556,10 @@ rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 	if (internals->slave_count > len)
 		return -1;
 
-	memcpy(slaves, internals->slaves, internals->slave_count);
+	for (i = 0; i < internals->slave_count; i++)
+		slaves[i] = internals->slaves[i].port_id;
 
 	return internals->slave_count;
-
 }
 
 int
@@ -605,13 +625,13 @@ rte_eth_bond_mac_address_reset(uint8_t bonded_port_id)
 	internals->user_defined_mac = 0;
 
 	if (internals->slave_count > 0) {
-		struct slave_conf *conf;
-		conf = slave_config_get(internals, internals->primary_port);
-
 		/* Set MAC Address of Bonded Device */
-		if (mac_address_set(bonded_eth_dev, &conf->mac_addr) != 0)
+		if (mac_address_set(bonded_eth_dev,
+				&internals->slaves[internals->primary_port].persisted_mac_addr)
+				!= 0) {
+			RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
 			return -1;
-
+		}
 		/* Update all slave devices MAC addresses */
 		return mac_address_slaves_update(bonded_eth_dev);
 	}
@@ -654,3 +674,88 @@ rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id)
 
 	return internals->balance_xmit_policy;
 }
+
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_status_polling_interval_ms = internal_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_status_polling_interval_ms;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_down_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_down_delay_ms;
+}
+
+
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_up_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_up_delay_ms;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_args.c b/lib/librte_pmd_bond/rte_eth_bond_args.c
index 05a2b07..d8ce681 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_args.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_args.c
@@ -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;
 	}
@@ -174,6 +175,7 @@ bond_ethdev_parse_slave_mode_kvarg(const char *key __rte_unused,
 #endif
 		return 0;
 	default:
+		RTE_BOND_LOG(ERR, "Invalid slave mode value (%s) specified", value);
 		return -1;
 	}
 }
@@ -252,3 +254,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;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 2a86402..b82a817 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -40,6 +40,7 @@
 #include <rte_devargs.h>
 #include <rte_kvargs.h>
 #include <rte_dev.h>
+#include <rte_alarm.h>
 
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
@@ -457,16 +458,16 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr)
 	mac_addr = eth_dev->data->mac_addrs;
 
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", __func__);
+		RTE_BOND_LOG(ERR,  "NULL pointer eth_dev specified");
 		return -1;
 	}
 
 	if (new_mac_addr == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer MAC specified\n", __func__);
+		RTE_BOND_LOG(ERR, "NULL pointer MAC specified");
 		return -1;
 	}
 
-	/* if new MAC is different to current MAC then update */
+	/* If new MAC is different to current MAC then update */
 	if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0)
 		memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr));
 
@@ -490,11 +491,10 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_BROADCAST:
 #endif
 		for (i = 0; i < internals->slave_count; i++) {
-			if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
+			if (mac_address_set(&rte_eth_devices[internals->slaves[i].port_id],
 					bonded_eth_dev->data->mac_addrs)) {
-				RTE_LOG(ERR, PMD,
-						"%s: Failed to update port Id %d MAC address\n",
-						__func__, internals->slaves[i]);
+				RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+						internals->slaves[i].port_id);
 				return -1;
 			}
 		}
@@ -502,23 +502,20 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_ACTIVE_BACKUP:
 	default:
 		for (i = 0; i < internals->slave_count; i++) {
-			if (internals->slaves[i] == internals->current_primary_port) {
+			if (internals->slaves[i].port_id ==
+					internals->current_primary_port) {
 				if (mac_address_set(&rte_eth_devices[internals->primary_port],
 						bonded_eth_dev->data->mac_addrs)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->current_primary_port);
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->current_primary_port);
+					return -1;
 				}
 			} else {
-				struct slave_conf *conf =
-						slave_config_get(internals, internals->slaves[i]);
-
-				if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
-						&conf->mac_addr)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->slaves[i]);
-
+				if (mac_address_set(
+						&rte_eth_devices[internals->slaves[i].port_id],
+						&internals->slaves[i].persisted_mac_addr)) {
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->slaves[i].port_id);
 					return -1;
 				}
 			}
@@ -570,34 +567,39 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	struct bond_rx_queue *bd_rx_q;
 	struct bond_tx_queue *bd_tx_q;
 
-	int q_id;
+	int errval, q_id;
 
 	/* Stop slave */
 	rte_eth_dev_stop(slave_eth_dev->data->port_id);
 
-	/* Enable interrupts on slave device */
-	slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
+	/* Enable interrupts on slave device if supported */
+	if (slave_eth_dev->driver->pci_drv.drv_flags & RTE_PCI_DRV_INTR_LSC)
+		slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
 
-	if (rte_eth_dev_configure(slave_eth_dev->data->port_id,
+	/* Configure device */
+	errval = rte_eth_dev_configure(slave_eth_dev->data->port_id,
 			bonded_eth_dev->data->nb_rx_queues,
 			bonded_eth_dev->data->nb_tx_queues,
-			&(slave_eth_dev->data->dev_conf)) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot configure slave device: port=%u\n",
-				slave_eth_dev->data->port_id);
-		return -1;
+			&(slave_eth_dev->data->dev_conf));
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "Cannot configure slave device: port %u , err (%d)",
+				slave_eth_dev->data->port_id, errval);
+		return errval;
 	}
 
 	/* Setup Rx Queues */
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
 		bd_rx_q = (struct bond_rx_queue *)bonded_eth_dev->data->rx_queues[q_id];
 
-		if (rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_rx_q->nb_rx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_rx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_rx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
@@ -605,69 +607,77 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
 		bd_tx_q = (struct bond_tx_queue *)bonded_eth_dev->data->tx_queues[q_id];
 
-		if (rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_tx_q->nb_tx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&bd_tx_q->tx_conf) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_tx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&bd_tx_q->tx_conf);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_tx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
 	/* Start device */
-	if (rte_eth_dev_start(slave_eth_dev->data->port_id) != 0) {
-		RTE_LOG(ERR, PMD, "rte_eth_dev_start: port=%u\n",
-				slave_eth_dev->data->port_id);
+	errval = rte_eth_dev_start(slave_eth_dev->data->port_id);
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "rte_eth_dev_start: port=%u, err (%d)",
+				slave_eth_dev->data->port_id, errval);
 		return -1;
 	}
 
 	return 0;
 }
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id)
-{
-	int i;
-
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id == slave_port_id)
-			return &internals->presisted_slaves_conf[i];
-	}
-	return NULL;
-}
-
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
 	int i, found = 0;
 
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id ==
-				slave_eth_dev->data->port_id) {
+		if (internals->slaves[i].port_id ==	slave_eth_dev->data->port_id)
 			found = 1;
-			memset(&internals->presisted_slaves_conf[i], 0,
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
-		if (found && i < (internals->slave_count - 1)) {
-			memcpy(&internals->presisted_slaves_conf[i],
-					&internals->presisted_slaves_conf[i+1],
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
+
+		if (found && i < (internals->slave_count - 1))
+			memcpy(&internals->slaves[i], &internals->slaves[i+1],
+					sizeof(internals->slaves[i]));
 	}
+
+	internals->slave_count--;
 }
 
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg);
+
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
-	struct slave_conf *presisted_slave_conf =
-			&internals->presisted_slaves_conf[internals->slave_count];
+	struct bond_slave_details *slave_details =
+			&internals->slaves[internals->slave_count];
+
+	slave_details->port_id = slave_eth_dev->data->port_id;
+	slave_details->last_link_status = 0;
+
+	/* If slave device doesn't support interrupts then we need to enabled
+	 * polling to monitor link status */
+	if (!(slave_eth_dev->pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
+		slave_details->link_status_poll_enabled = 1;
+
+		if (!internals->link_status_polling_enabled) {
+			internals->link_status_polling_enabled = 1;
 
-	presisted_slave_conf->port_id = slave_eth_dev->data->port_id;
+			rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+					bond_ethdev_slave_link_status_change_monitor,
+					(void *)&rte_eth_devices[internals->port_id]);
+		}
+	}
 
-	memcpy(&(presisted_slave_conf->mac_addr), slave_eth_dev->data->mac_addrs,
+	slave_details->link_status_wait_to_complete = 0;
+
+	memcpy(&(slave_details->persisted_mac_addr), slave_eth_dev->data->mac_addrs,
 			sizeof(struct ether_addr));
 }
 
@@ -698,31 +708,33 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* slave eth dev will be started by bonded device */
 	if (valid_bonded_ethdev(eth_dev)) {
-		RTE_LOG(ERR, PMD,
-				"%s: user tried to explicitly start a slave eth_dev (%d) of the bonded eth_dev\n",
-				__func__, eth_dev->data->port_id);
+		RTE_BOND_LOG(ERR, "User tried to explicitly start a slave eth_dev (%d)",
+				eth_dev->data->port_id);
 		return -1;
 	}
 
-	eth_dev->data->dev_link.link_status = 1;
+	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 1;
 
 	internals = eth_dev->data->dev_private;
 
 	if (internals->slave_count == 0) {
-		RTE_LOG(ERR, PMD,
-				"%s: Cannot start port since there are no slave devices\n",
-				__func__);
+		RTE_BOND_LOG(ERR, "Cannot start port since there are no slave devices");
 		return -1;
 	}
 
 	if (internals->user_defined_mac == 0) {
-		struct slave_conf *conf = slave_config_get(internals,
-				internals->primary_port);
+		struct ether_addr *new_mac_addr = NULL;
+
+		for (i = 0; i < internals->slave_count; i++)
+			if (internals->slaves[i].port_id == internals->primary_port)
+				new_mac_addr = &internals->slaves[i].persisted_mac_addr;
+
+		if (new_mac_addr == NULL)
+			return -1;
 
-		if (mac_address_set(eth_dev, &(conf->mac_addr)) != 0) {
-			RTE_LOG(ERR, PMD,
-					"bonded port (%d) failed to update mac address",
+		if (mac_address_set(eth_dev, new_mac_addr) != 0) {
+			RTE_BOND_LOG(ERR, "bonded port (%d) failed to update MAC address",
 					eth_dev->data->port_id);
 			return -1;
 		}
@@ -738,11 +750,11 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* Reconfigure each slave device if starting bonded device */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (slave_configure(eth_dev, &(rte_eth_devices[internals->slaves[i]]))
-				!= 0) {
-			RTE_LOG(ERR, PMD, "bonded port "
-					"(%d) failed to reconfigure slave device (%d)\n)",
-					eth_dev->data->port_id, internals->slaves[i]);
+		if (slave_configure(eth_dev,
+				&(rte_eth_devices[internals->slaves[i].port_id])) != 0) {
+			RTE_BOND_LOG(ERR,
+					"bonded port (%d) failed to reconfigure slave device (%d)",
+					eth_dev->data->port_id, internals->slaves[i].port_id);
 			return -1;
 		}
 	}
@@ -759,6 +771,7 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 	struct bond_dev_private *internals = eth_dev->data->dev_private;
 
 	internals->active_slave_count = 0;
+	internals->link_status_polling_enabled = 0;
 
 	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 0;
@@ -852,6 +865,65 @@ bond_ethdev_tx_queue_release(void *queue)
 	rte_free(queue);
 }
 
+
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
+{
+	struct rte_eth_dev *bonded_ethdev, *slave_ethdev;
+	struct bond_dev_private *internals;
+
+	/* Default value for polling slave found is true as we don't want to
+	 * disable the polling thread if we cannot get the lock */
+	int i, polling_slave_found = 1;
+
+	if (cb_arg == NULL)
+		return;
+
+	bonded_ethdev = (struct rte_eth_dev *)cb_arg;
+	internals = (struct bond_dev_private *)bonded_ethdev->data->dev_private;
+
+	if (!bonded_ethdev->data->dev_started ||
+		!internals->link_status_polling_enabled)
+		return;
+
+	/* If device is currently being configured then don't check slaves link
+	 * status, wait until next period */
+	if (rte_spinlock_trylock(&internals->lock)){
+		if (internals->slave_count > 0)
+			polling_slave_found = 0;
+
+		for (i = 0; i < internals->slave_count; i++) {
+			if (!internals->slaves[i].link_status_poll_enabled)
+				continue;
+
+			slave_ethdev = &rte_eth_devices[internals->slaves[i].port_id];
+			polling_slave_found = 1;
+
+			/* Update slave link status */
+			(*slave_ethdev->dev_ops->link_update)(slave_ethdev,
+					internals->slaves[i].link_status_wait_to_complete);
+
+			/* if link status has changed since last checked then call lsc
+			 * event callback */
+			if (slave_ethdev->data->dev_link.link_status !=
+					internals->slaves[i].last_link_status) {
+				internals->slaves[i].last_link_status =
+						slave_ethdev->data->dev_link.link_status;
+
+				bond_ethdev_lsc_event_callback(internals->slaves[i].port_id,
+						RTE_ETH_EVENT_INTR_LSC,
+						&bonded_ethdev->data->port_id);
+			}
+		}
+		rte_spinlock_unlock(&internals->lock);
+	}
+
+	if (polling_slave_found)
+		/* Set alarm to continue monitoring link status of slave ethdev's */
+		rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+				bond_ethdev_slave_link_status_change_monitor, cb_arg);
+}
+
 static int
 bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev,
 		int wait_to_complete)
@@ -895,7 +967,7 @@ bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	memset(stats, 0, sizeof(*stats));
 
 	for (i = 0; i < internals->slave_count; i++) {
-		rte_eth_stats_get(internals->slaves[i], &slave_stats);
+		rte_eth_stats_get(internals->slaves[i].port_id, &slave_stats);
 
 		stats->ipackets += slave_stats.ipackets;
 		stats->opackets += slave_stats.opackets;
@@ -921,7 +993,7 @@ bond_ethdev_stats_reset(struct rte_eth_dev *dev)
 	int i;
 
 	for (i = 0; i < internals->slave_count; i++)
-		rte_eth_stats_reset(internals->slaves[i]);
+		rte_eth_stats_reset(internals->slaves[i].port_id);
 }
 
 static void
@@ -940,7 +1012,7 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)
 	case BONDING_MODE_BROADCAST:
 #endif
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_enable(internals->slaves[i]);
+			rte_eth_promiscuous_enable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -966,7 +1038,7 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	case BONDING_MODE_BROADCAST:
 #endif
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_disable(internals->slaves[i]);
+			rte_eth_promiscuous_disable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -975,6 +1047,16 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	}
 }
 
+static void
+bond_ethdev_delayed_lsc_propagation(void *arg)
+{
+	if (arg == NULL)
+		return;
+
+	_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
+			RTE_ETH_EVENT_INTR_LSC);
+}
+
 void
 bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		void *param)
@@ -1003,7 +1085,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 
 	/* verify that port_id is a valid slave of bonded port */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == port_id) {
+		if (internals->slaves[i].port_id == port_id) {
 			valid_slave = 1;
 			break;
 		}
@@ -1072,8 +1154,32 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		}
 	}
 
-	if (lsc_flag)
-		_rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
+	if (lsc_flag) {
+		/* Cancel any possible outstanding interrupts if delays are enabled */
+		if (internals->link_up_delay_ms > 0 ||
+			internals->link_down_delay_ms > 0)
+			rte_eal_alarm_cancel(bond_ethdev_delayed_lsc_propagation,
+					bonded_eth_dev);
+
+		if (bonded_eth_dev->data->dev_link.link_status) {
+			if (internals->link_up_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_up_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+
+		} else {
+			if (internals->link_down_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_down_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+		}
+	}
 }
 
 struct eth_dev_ops default_dev_ops = {
@@ -1223,8 +1329,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(ERR, EAL,
-				"Transmit policy can be specified only once for bonded device %s\n",
-				name);
+				"Transmit policy can be specified only once for bonded device"
+				" %s\n", name);
 		return -1;
 	}
 
@@ -1266,8 +1372,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				&bond_ethdev_parse_primary_slave_port_id_kvarg,
 				&primary_slave_port_id) < 0) {
 			RTE_LOG(INFO, EAL,
-					"Invalid primary slave port id specified for bonded device %s\n",
-					name);
+					"Invalid primary slave port id specified for bonded device"
+					" %s\n", name);
 			return -1;
 		}
 
@@ -1281,8 +1387,97 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(INFO, EAL,
-				"Primary slave can be specified only once for bonded device %s\n",
-				name);
+				"Primary slave can be specified only once for bonded device"
+				" %s\n", name);
+		return -1;
+	}
+
+	/* Parse link status monitor polling interval */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LSC_POLL_PERIOD_KVARG);
+	if (arg_count == 1) {
+		uint32_t lsc_poll_interval_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LSC_POLL_PERIOD_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&lsc_poll_interval_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid lsc polling interval value specified for bonded"
+					"device %s\n", name);
+			return -1;
+		}
+
+		if (rte_eth_bond_link_monitoring_set(port_id, lsc_poll_interval_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set lsc monitor polling interval (%u ms) on"
+					" bonded device %s\n", lsc_poll_interval_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"LSC polling interval can be specified only once for bonded"
+				"device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link up interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_UP_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_up_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_UP_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_up_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link up propagation delay value specified for "
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_up_prop_delay_set(port_id, link_up_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link up propagation delay (%u ms) on bonded"
+					"device %s\n", link_up_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link up propagation delay can be specified only once for "
+				"bonded device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link down interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_down_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_down_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link down propagation delay value specified for"
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_down_prop_delay_set(port_id, link_down_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link down propagation delay (%u ms) on"
+					" bonded device %s\n", link_down_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link down propagation delay can be specified only once for"
+				" bonded device %s\n", name);
 		return -1;
 	}
 
diff --git a/lib/librte_pmd_bond/rte_eth_bond_private.h b/lib/librte_pmd_bond/rte_eth_bond_private.h
index 1db6e4d..78f4196 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_private.h
+++ b/lib/librte_pmd_bond/rte_eth_bond_private.h
@@ -39,20 +39,27 @@ extern "C" {
 #endif
 
 #include <rte_ethdev.h>
+#include <rte_spinlock.h>
 
 #include "rte_eth_bond.h"
 
-#define PMD_BOND_SLAVE_PORT_KVARG		("slave")
-#define PMD_BOND_PRIMARY_SLAVE_KVARG	("primary")
-#define PMD_BOND_MODE_KVARG				("mode")
-#define PMD_BOND_XMIT_POLICY_KVARG		("xmit_policy")
-#define PMD_BOND_SOCKET_ID_KVARG		("socket_id")
-#define PMD_BOND_MAC_ADDR_KVARG			("mac")
+#define PMD_BOND_SLAVE_PORT_KVARG			("slave")
+#define PMD_BOND_PRIMARY_SLAVE_KVARG		("primary")
+#define PMD_BOND_MODE_KVARG					("mode")
+#define PMD_BOND_XMIT_POLICY_KVARG			("xmit_policy")
+#define PMD_BOND_SOCKET_ID_KVARG			("socket_id")
+#define PMD_BOND_MAC_ADDR_KVARG				("mac")
+#define PMD_BOND_LSC_POLL_PERIOD_KVARG		("lsc_poll_period_ms")
+#define PMD_BOND_LINK_UP_PROP_DELAY_KVARG	("up_delay")
+#define PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG	("down_delay")
 
 #define PMD_BOND_XMIT_POLICY_LAYER2_KVARG	("l2")
 #define PMD_BOND_XMIT_POLICY_LAYER23_KVARG	("l23")
 #define PMD_BOND_XMIT_POLICY_LAYER34_KVARG	("l34")
 
+#define RTE_BOND_LOG(lvl, msg, ...) 		\
+	RTE_LOG(lvl, PMD, "%s(%d) - " msg "\n", __func__, __LINE__, ##__VA_ARGS__);
+
 extern const char *pmd_bond_init_valid_arguments[];
 
 extern const char *driver_name;
@@ -82,27 +89,36 @@ struct bond_tx_queue {
 	/**< Copy of TX configuration structure for queue */
 };
 
-/** Persisted Slave Configuration Structure */
-struct slave_conf {
-	uint8_t port_id;
-	/**< Port Id of slave eth_dev */
-	struct ether_addr mac_addr;
-	/**< Slave eth_dev original MAC address */
-};
+
 /** Bonded slave devices structure */
 struct bond_ethdev_slave_ports {
 	uint8_t slaves[RTE_MAX_ETHPORTS];	/**< Slave port id array */
 	uint8_t slave_count;				/**< Number of slaves */
 };
 
+struct bond_slave_details {
+	uint8_t port_id;
+
+	uint8_t link_status_poll_enabled;
+	uint8_t link_status_wait_to_complete;
+	uint8_t last_link_status;
+
+	/**< Port Id of slave eth_dev */
+	struct ether_addr persisted_mac_addr;
+};
+
 /** Link Bonding PMD device private configuration Structure */
 struct bond_dev_private {
+	uint8_t port_id;					/**< Port Id of Bonded Port */
 	uint8_t mode;						/**< Link Bonding Mode */
 
+	rte_spinlock_t lock;
+
 	uint8_t primary_port;				/**< Primary Slave Port */
 	uint8_t current_primary_port;		/**< Primary Slave Port */
 	uint8_t user_defined_primary_port;
 	/**< Flag for whether primary port is user defined or not */
+
 	uint8_t balance_xmit_policy;
 	/**< Transmit policy - l2 / l23 / l34 for operation in balance mode */
 	uint8_t user_defined_mac;
@@ -110,19 +126,23 @@ struct bond_dev_private {
 	uint8_t promiscuous_en;
 	/**< Enabled/disable promiscuous mode on slave devices */
 	uint8_t link_props_set;
-	/**< Bonded eth_dev link properties set */
+	/**< flag to denote if the link properties are set */
+
+	uint8_t link_status_polling_enabled;
+	uint32_t link_status_polling_interval_ms;
+
+	uint32_t link_down_delay_ms;
+	uint32_t link_up_delay_ms;
 
 	uint16_t nb_rx_queues;			/**< Total number of rx queues */
 	uint16_t nb_tx_queues;			/**< Total number of tx queues*/
 
-	uint8_t slave_count;			/**< Number of active slaves */
-	uint8_t active_slave_count;		/**< Number of slaves */
-
+	uint8_t active_slave_count;		/**< Number of active slaves */
 	uint8_t active_slaves[RTE_MAX_ETHPORTS];	/**< Active slave list */
-	uint8_t slaves[RTE_MAX_ETHPORTS];			/**< Slave list */
 
-	/** Persisted configuration of slaves */
-	struct slave_conf presisted_slaves_conf[RTE_MAX_ETHPORTS];
+	uint8_t slave_count;			/**< Number of bonded slaves */
+	struct bond_slave_details slaves[RTE_MAX_ETHPORTS];
+	/**< Arary of bonded slaves details */
 
 	struct rte_kvargs *kvlist;
 };
@@ -168,16 +188,13 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id);
-
 void
 bond_ethdev_primary_set(struct bond_dev_private *internals,
 		uint8_t slave_port_id);
@@ -210,6 +227,10 @@ int
 bond_ethdev_parse_bond_mac_addr_kvarg(const char *key __rte_unused,
 		const char *value, void *extra_args);
 
+int
+bond_ethdev_parse_time_ms_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v6 8/8] bond: unit test test macro refactor
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
                         ` (6 preceding siblings ...)
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 7/8] bond: lsc polling support Declan Doherty
@ 2014-11-07 12:22       ` Declan Doherty
  2014-11-07 16:40       ` [dpdk-dev] [PATCH v6 0/8] link bonding De Lara Guarch, Pablo
                         ` (2 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-07 12:22 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/test_link_bonding.c | 2574 +++++++++++++++++-------------------------
 1 file changed, 1036 insertions(+), 1538 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 4aa57a7..aa6a52f 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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,
@@ -784,56 +716,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();
@@ -847,36 +762,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
@@ -884,32 +787,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] =
@@ -917,56 +815,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;
 }
@@ -974,7 +860,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;
 
@@ -983,87 +869,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;
 }
 
@@ -1179,9 +1040,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;
 
@@ -1313,10 +1175,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;
 }
@@ -1326,51 +1186,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 */
@@ -1380,10 +1232,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();
@@ -1529,17 +1380,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 */
@@ -1548,21 +1399,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 */
@@ -1571,19 +1418,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 */
@@ -1620,17 +1463,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 */
@@ -1641,57 +1483,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++) {
@@ -1708,91 +1537,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 */
@@ -1805,44 +1620,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 */
@@ -1869,26 +1678,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(
@@ -1896,13 +1701,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;
 
@@ -1913,19 +1717,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,
@@ -1963,27 +1764,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++) {
@@ -2005,7 +1803,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 } ;
 
@@ -2039,7 +1836,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 */
@@ -2101,15 +1899,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);
@@ -2120,32 +1916,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);
 
@@ -2153,35 +1942,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();
@@ -2199,78 +1981,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);
 			}
 		}
 
@@ -2296,61 +2063,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 */
@@ -2366,117 +2120,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();
@@ -2498,38 +2237,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(
@@ -2537,12 +2270,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);
@@ -2555,103 +2286,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 */
 
@@ -2664,7 +2373,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();
 }
@@ -2674,70 +2382,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();
@@ -2752,24 +2439,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);
@@ -2779,54 +2458,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++) {
@@ -2836,9 +2511,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();
@@ -2848,81 +2523,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++) {
@@ -2932,10 +2591,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();
@@ -2976,82 +2635,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++) {
@@ -3061,10 +2704,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();
@@ -3254,21 +2896,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],
@@ -3277,56 +2920,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++) {
@@ -3345,48 +2976,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 */
@@ -3402,115 +3022,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();
@@ -3532,32 +3139,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(
@@ -3565,106 +3167,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;
-	}
+	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);
 
 	/* Send to sets of packet burst and verify that they are balanced across
 	 *  slaves */
 	burst_size = 21;
 
-	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");
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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");
+
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, &pkt_burst[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][0],
-			burst_size) != burst_size) {
-		printf("rte_eth_tx_burst failed\n");
-		return -1;
-	}
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size);
 
 	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 (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[2], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[2], (int)port_stats.opackets,
+			burst_size);
 
 	/* verify that all packets get send on primary slave when no other slaves
 	 * are available */
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[2], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id, slaves,
-			RTE_MAX_ETHPORTS) != 1) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_active_slaves_get(
+			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS), 1,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 1);
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][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[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size +
-			burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)(burst_size + burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
-
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[0], 0);
@@ -3676,16 +3252,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 			test_params->slave_port_ids[3], 1);
 
 	for (i = 0; i < TEST_BALANCE_LINK_STATUS_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,
+				"Failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
-
-
 	/* Verify that pkts are not received on slaves with link status down */
 
 	rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
@@ -3693,12 +3267,10 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size * 3)) {
-		printf("(%d) port_stats.ipackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.ipackets,
-				burst_size * 3);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)(burst_size * 3),
+			"(%d) port_stats.ipackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.ipackets,
+			burst_size * 3);
 
 	/* free mbufs allocate for rx testing */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
@@ -3720,16 +3292,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 static int
 test_broadcast_tx_burst(void)
 {
-	int i, pktlen, retval, burst_size, generated_burst_size, nb_tx;
+	int i, pktlen, burst_size;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 
 	struct rte_eth_stats port_stats;
 
-	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;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 2, 1),
+			"Failed to intialise bonded device");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
@@ -3741,46 +3311,37 @@ test_broadcast_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,
+	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);
-	if (generated_burst_size != burst_size)
-		return -1;
+			1), burst_size, "Failed to generate packet burst");
 
 	/* 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) {
-		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);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+			pkts_burst, burst_size), burst_size,
+			"Bonded Port (%d) rx burst failed, packets transmitted value "
+			"not as expected (%d)",
+			test_params->bonded_port_id, burst_size);
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size *
-			test_params->bonded_slave_count) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
-				burst_size);
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)burst_size * test_params->bonded_slave_count,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			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) {
-			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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)\n",
+				test_params->bonded_port_id,
+				(unsigned int)port_stats.opackets, burst_size);
 	}
 
 	/* Put all slaves down and try and transmit */
@@ -3791,10 +3352,9 @@ 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 != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkts_burst, burst_size),  0,
+			"transmitted an unexpected number of packets");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -3930,20 +3490,20 @@ test_broadcast_rx_burst(void)
 	struct rte_eth_stats port_stats;
 
 	int burst_size[BROADCAST_RX_BURST_NUM_OF_SLAVES] = { 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_BROADCAST, 0, 3, 1) != 0)
-		return -1;
-
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 3, 1),
+			"Failed to intialise bonded device");
 
 	/* Generate test bursts of packets to transmit */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; 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 slave 0 */
@@ -3955,57 +3515,44 @@ test_broadcast_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("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[0] + burst_size[1] + burst_size[2],
+			"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[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[0], (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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; i++) {
@@ -4024,48 +3571,38 @@ test_broadcast_rx_burst(void)
 static int
 test_broadcast_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_BROADCAST, 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 */
@@ -4077,45 +3614,39 @@ test_broadcast_verify_mac_assignment(void)
 {
 	struct ether_addr read_mac_addr, expected_mac_addr_0, expected_mac_addr_1;
 
-	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_1);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 4, 1),
+			"Failed to intialise bonded device");
 
 	/* Verify that all MACs are the same as first slave added to bonded
 	 * device */
 	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
@@ -4123,45 +3654,41 @@ test_broadcast_verify_mac_assignment(void)
 
 	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 new primary"
-				" port\n", test_params->slave_port_ids[i]);
-		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 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_1, &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_1, &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 address");
 
 	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_params->slave_port_ids[i]);
-		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 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(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", test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -4183,26 +3710,22 @@ 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, 0,
-			BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+				BONDING_MODE_BROADCAST, 0, BROADCAST_LINK_STATUS_NUM_OF_SLAVES,
+				1), "Failed to intialise bonded device");
 
 	/* 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;
-	}
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+	TEST_ASSERT_EQUAL(slave_count, 4,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 4);
 
 	/* Set 2 slaves link status to down */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -4212,11 +3735,9 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != 2) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, 2,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 2);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++)
 		rte_eth_stats_reset(test_params->slave_port_ids[i]);
@@ -4224,80 +3745,62 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	/* Verify that pkts are not sent on slaves with link status down */
 	burst_size = 21;
 
-	if (generate_test_burst(&pkt_burst[0][0], burst_size, 0, 0, 1, 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, 0, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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\n");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size * slave_count)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size * slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size * slave_count),
+			"(%d) port_stats.opackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size * slave_count);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%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_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[1]);
-		return -1;
-	}
 
 	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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[2]);
-		return -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]);
+
 
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
-		if (generate_test_burst(&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0) !=
-				burst_size) {
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0),
+				burst_size, "failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
 	/* Verify that pkts are not received on slaves with link status down */
+	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");
 
-	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;
-	}
 
 	/* 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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
@@ -4320,19 +3823,14 @@ 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)  != 0) {
-		printf("failed to reconfigure bonded device");
-		return -1;
-	}
-
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device");
 
 	test_params->nb_rx_q = 2;
 	test_params->nb_tx_q = 2;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
-		printf("failed to reconfigure bonded device with less rx/tx queues");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device with less rx/tx queues");
 
 	return 0;
 }
-- 
1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/8] link bonding
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
                         ` (7 preceding siblings ...)
  2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 8/8] bond: unit test test macro refactor Declan Doherty
@ 2014-11-07 16:40       ` De Lara Guarch, Pablo
  2014-11-21 17:07         ` Doherty, Declan
  2014-11-21  8:59       ` Jiajia, SunX
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
  10 siblings, 1 reply; 91+ messages in thread
From: De Lara Guarch, Pablo @ 2014-11-07 16:40 UTC (permalink / raw)
  To: Doherty, Declan, dev



> -----Original Message-----
> From: Doherty, Declan
> Sent: Friday, November 07, 2014 12:23 PM
> To: dev@dpdk.org
> Cc: De Lara Guarch, Pablo; thomas.monjalon@6wind.com; Doherty, Declan
> Subject: [PATCH v6 0/8] link bonding
> 
> v6:
> - Re-based to dpdk.org addressing associated issues for MBUF_REFCNT
> - Added details to testpmd user guide for new command to set link status
> polling interval.
> 
> 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                | 3347 ++++++++++++++-------------
>  app/test/virtual_pmd.c                      |   96 +-
>  app/test/virtual_pmd.h                      |   53 +-
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |   19 +
>  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     |   28 +-
>  lib/librte_pmd_bond/rte_eth_bond_pmd.c      |  553 +++--
>  lib/librte_pmd_bond/rte_eth_bond_private.h  |   71 +-
>  15 files changed, 2715 insertions(+), 1959 deletions(-)
> 
> --
> 1.7.12.2

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/8] link bonding
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
                         ` (8 preceding siblings ...)
  2014-11-07 16:40       ` [dpdk-dev] [PATCH v6 0/8] link bonding De Lara Guarch, Pablo
@ 2014-11-21  8:59       ` Jiajia, SunX
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
  10 siblings, 0 replies; 91+ messages in thread
From: Jiajia, SunX @ 2014-11-21  8:59 UTC (permalink / raw)
  To: Doherty, Declan, dev

Tested-by: Jiajia, SunX <sunx.jiajia@intel.com>
- Tested Commit: f7aaae2fe6f7f9a78eab7313d77e92b934693b5d
- OS: Fedora20 3.11.10-301.fc20.x86_64 and 3.16.6-200.fc20.x86_64
- GCC: gcc version 4.8.2
- CPU: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
- NIC: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection [8086:10fb]
- Default x86_64-native-linuxapp-gcc configuration
- Total 18 cases, 18 passed, 0 failed

TOPO:
* Connections ports between tester/ixia and DUT
  - TESTER(Or IXIA)-------DUT
  - portA------------------port0
  - portB------------------port1
  - portC------------------port2
  - portD------------------port3
* Connections ports between tester/ixia and switch and DUT
  - TESTER(Or IXIA)-------SWITCH
  -                       SWITCH---------DUT
  - TESTER(Or IXIA)----------------------DUT
  - portA------------------switch
  -                        switch----------port0
  -                        switch----------port1
  -                        switch----------port2
  - portB----------------------------------port3


Test Setup#1 for Functional test
================================

Tester has 4 ports(portA--portD), and DUT has 4 ports(port0--port3), then connect portA to port0, portB to port1, portC to port2, portD to port3. 


Test Setup#2 for Functional test
================================

Tester has 2 ports(portA--portB), DUT has 4 ports(port0--port3), and a switch that supports IEEE 802.3ad Dynamic link aggregation, then connect port0-port2 to the switch for dynamic link aggregation, connect portA to aggregated interface on the switch, connect portB to port3.


- Case: Basic bonding--Create bonded devices and slaves
  Description: 
		Use Setup#1.
		Create bonded device and add some ports as salve of bonded device,
            Then removed slaves or added slaves or change the bonding primary slave
            Or change bonding mode and so on.
  Expected test result:
            Verify the basic functions are normal.

- Case: Basic bonding--MAC Address Test
  Description: 
		Use Setup#1.
		Create bonded device and add some ports as slaves of bonded device,
            Check that the changes of  the bonded device and slave MAC
  Expected test result:
            Verify the behavior of bonded device and slave according to the mode.

- Case: Basic bonding--Device Promiscuous Mode Test
  Description: 
		Use Setup#1.
		Create bonded device and add some ports as slaves of bonded device,
            Set promiscuous mode on or off, then send packets to the bonded device
            Or slaves.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves according to the mode.

- Case: Mode 0(Round Robin) TX/RX test
  Description: 
		Use Setup#1.
		Create bonded device with mode 0 and add 3 ports as slaves of bonded device,
            Forward packets between bonded device and unbounded device, start to forward,
            And send packets to unbound device or slaves.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 0.

- Case: Mode 0(Round Robin) Bring one slave link down
  Description: 
		Use Setup#1.
		Create bonded device with mode 0 and add 3 ports as slaves of bonded device,
            Forward packets between bonded device and unbounded device, start to forward,
            Bring the link on either port 0, 1 or 2 down. And send packets to unbound 
            device or slaves.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 0.

- Case: Mode 0(Round Robin) Bring all slave links down
  Description: 
		Use Setup#1.
		Create bonded device with mode 0 and add 3 ports as slaves of bonded device,
            Forward packets between bonded device and unbounded device, start to forward,
            Bring the links down on all bonded ports. And send packets to unbound 
            device or slaves.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 0.

- Case: Mode 1(Active Backup) TX/RX Test
  Description: 
		Use Setup#1.
		Create bonded device with mode 1 and add 3 ports as slaves of bonded device,
            Forward packets between bonded device and unbounded device, start to forward,
            And send packets to unbound device or slaves.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 1.

- Case: Mode 1(Active Backup) Change active slave, RX/TX test
  Description: 
		Use Setup#1.
		Continuing from previous test case.Change the active slave port from port0 
            to port1.Verify that the bonded device's MAC has changed to slave1's MAC.

            testpmd> set bonding primary 1 4 

           Repeat the transmission and reception(TX/RX) test verify that data is now 
           transmitted and received through the new active slave and no longer through
           port0
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 1.

- Case: Mode 1(Active Backup) Link up/down active eth dev
  Description: 
		Use Setup#1.

           Bring link between port A and port0 down. If tester is ixia, can use 
           IxExplorer to set the "Simulate Cable Disconnect" at the port property.  
           Verify that the active slave has been changed from port0. Repeat the 
           transmission and reception test verify that data is now transmitted and
           received through the new active slave and no longer through port0

           Bring port0 to link down at the remote end.Verify the active slave has been changed from port0.
           send 100 packets to port3.

           testpmd> show port stats 4----(Verify port3 have 100 rx packets,meanwhile
          port4 have 100 tx packets,the current primary port have 100 tx packets,and port0
          doesn`t have any packet)
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 1. 

- Case: Mode 1(Active Backup) Bring all slave links down
  Description: 
		Use Setup#1.
            Bring all slave ports of bonded port down.
            Verify that bonded callback for link down is called and no active slaves. 
            Verify that data cannot be sent or received through bonded port. Send 100 packets 
            to port3 and verify that bonded port can't TX 100 packets.

            Bring port 0-2 to link down at the remote end. Verify port4 has been link down and has no active slave.
            Send 100 rx packets to port3. 

         testpmd> show port stats 4----(Verify port3 have 100 rx packets,meanwhile 
                                        port4 doesn`t have any packet)
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 1.

- Case: Mode 2(Balance XOR) TX Load Balance test
  Description: 
		Use Setup#1.
            Bonded port will activate each slave eth dev based on the following hash function:

             ((dst_mac XOR src_mac) % (number of slave ports))

            Send 300 packets from IXIA port D to non-bonded port(port3),and verify these packets 
            will be forwarded to bonded device. The bonded device will transimit these packets to all slaves.
            Verify that each slave receive correct number of packets according to the policy. The total number
            of packets which received by slave should be equal as 300 packets. 

            Create 3 streams in the IXIA,which streams source MAC are 00:00:03:00:0F:00,
            00:00:03:00:0F:01,00:00:03:00:0F:02 respectively (make sure generate different value by
            the policy ((dst_mac XOR src_mac) % (number of slave ports)) ) and dest MAC all is 
            90:E2:BA:4A:54:80(this value should been your unbonded port address). Respectively
            send 100 packets to port3 by the 3 streams.

            testpmd> show port stats all----(Verify port3 have 300 rx packets,
            port4 have 300 tx packets,and port 0-2 have 100 tx packets respectively)

  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 2.

- Case: Mode 2(Balance XOR) TX Load Balance Link down
  Description: 
		Use Setup#1.
		ring link down of one slave.
            Send 300 packets from non-bonded port(port3), and verify these 
		packets will be forwarded to bonded device. 
            Verify that each active slave receive correct number of packets
            (according to the mode policy), and the down slave will not receive packets.
		Link down slave 0 at the remote end.Create 3 streams in the IXIA like case13.
		Then respectively send 100 packets to port3 by the 3 streams.

  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 2.

- Case: Mode 2(Balance XOR) Bring all slave links down
  Description: 
		Use Setup#1.
		Bring all slave links down.
		Verify that bonded callback for link down is called.
		Verify no packet can be sent.

		Bring all slaves to link down at the remote end.Create 
		3 streams in the IXIA like case13.Then respectively send 100 packets 
		to port3 by the 3 streams.

		testpmd> show port info 4----(Verify bonding port has been linked down)
   	      testpmd> show port stats all----(Verify port3 have 300 rx packets,meanwhile
							 port 0,1,2 and 4 don`t have any packet)
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 2.


- Case: Mode 2(Balance XOR) Layer 3+4 forwarding 	
  Description: 
		Use Setup#1.
		Use "xmit_hash_policy()" to change to this forwarding mode
		Create a stream of traffic which will exercise all slave ports using the transmit policy 

   		 ((SRC_PORT XOR DST_PORT) XOR ((SRC_IP XOR DST_IP) AND 0xffff) % # of Slaves

		Transmit data through bonded device, verify TX packet count for each slave port is as expected

		Create 3 streams on a port which is mapped with unbonded port 3 at the IXIA end.
	      And set different IP by the transmit policy.Then send 100 packets on each stream.

           testpmd> show port stats all----(Verify port3 have 300 rx packets,
				meanwhile port4 have 300 rx packets, port 0-2 have 100 tx packets respectively)

		Add Vlan tag in the previouse 3 streams. Everthing else remains the same. 
		Then send 100 packets on each stream. Verify the packet statics is the same as above.  

   	      testpmd> show port stats all----(Verify port3  
		have 300 rx packets,meanwhile port4 have 300 rx packets,port 0-2 have 100 tx packets respecitvely)
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 2.

- Case: Mode 2(Balance XOR) RX test
  Description: 
		Use Setup#1.
		Send 100 packets to each bonded slaves(port0,1,2)
		Verify that each slave receives 100 packets and the bonded device receive a total 300 packets.
		Verify that the bonded device forwards 300 packets to the non-bonded port(port4).

		Send 100 packets to port0,1,2 respectively.

    		testpmd> show port stats all----(Verify port0,1,2 have 100 tx packets respectively 
				and port4 have 300 rx packets,and port3 have 300 tx packets)

  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 2.

- Case: Mode 3(Broadcast) TX/RX Test
  Description: 
		Use Setup#1.
		Add ports 0-2 as slave devices to the bonded port 4. Make all slaves
	      to be active slaves on bonded device. 

            RX: Send a packet stream(100 packets) from port A on the traffic
		    generator to be forwarded through the bonded port4 to port3.
		    Verify the sum of the packets transmitted from the traffic generator
		    portA is equal the total received packets on port0, port4 and portD(Traffic generator).

               testpmd> show port stats all---(Verify port0 receive 100 packets, 
				and port4 receive 100 packets, and port3 transmit 100 packets)

           TX: Send a packet stream(100 packets) from portD on the traffic generator 
               to be forwarded through port3 to the bonded port4. Verify the sum of 
               the packets(100packets) transmitted from the traffic generator port is equal the total 
               received packets on port4, portA and transmitted to port0.
    
          testpmd> show port stats all---(Verify port3 RX 100 packets, 
                    and port0,1,2 TX 100 packets,port4 has 300 TX packets)
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 3.


- Case: Mode 3(Broadcast) Bring one slave link down
  Description: 
		Use Setup#1.
		Bring one slave port link down. Send 100 packets through portD to port3,
	      then port3 forwards to bondede device(port4), verify that the bonded device 
		and other slaves TX the correct number of packets(100 packets for each port).
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 3.

- Case: Mode 3(Broadcast) Bring all slave links down
  Description: 
		Use Setup#1.
		Bring all slave ports of bonded port down
		Verify that bonded callback for link down is called
		Verify that data cannot be sent or received through bonded port.
  Expected test result:
            Verify the RX/TX status of bonded device and slaves in mode 3.

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty
> Sent: Friday, November 07, 2014 8:23 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v6 0/8] link bonding
> 
> v6:
> - Re-based to dpdk.org addressing associated issues for MBUF_REFCNT
> - Added details to testpmd user guide for new command to set link
> status polling interval.
> 
> 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                | 3347 ++++++++++++++-----
> --------
>  app/test/virtual_pmd.c                      |   96 +-
>  app/test/virtual_pmd.h                      |   53 +-
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |   19 +
>  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     |   28 +-
>  lib/librte_pmd_bond/rte_eth_bond_pmd.c      |  553 +++--
>  lib/librte_pmd_bond/rte_eth_bond_private.h  |   71 +-
>  15 files changed, 2715 insertions(+), 1959 deletions(-)
> 
> --
> 1.7.12.2

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/8] link bonding
  2014-11-07 16:40       ` [dpdk-dev] [PATCH v6 0/8] link bonding De Lara Guarch, Pablo
@ 2014-11-21 17:07         ` Doherty, Declan
  2014-11-21 18:36           ` Thomas Monjalon
  0 siblings, 1 reply; 91+ messages in thread
From: Doherty, Declan @ 2014-11-21 17:07 UTC (permalink / raw)
  To: dev; +Cc: homas.monjalon

Hey Thomas, have you had a chance to have a look at this patchset, if you have any comments or issues can you let me know asap, as the patch sets for link bonding modes 4 & 5 are dependent on this set and I don't want to be blocking them from the next release candidate.

Thanks 
Declan

> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Friday, November 7, 2014 4:41 PM
> To: Doherty, Declan; dev@dpdk.org
> Cc: thomas.monjalon@6wind.com
> Subject: RE: [PATCH v6 0/8] link bonding
> 
> 
> 
> > -----Original Message-----
> > From: Doherty, Declan
> > Sent: Friday, November 07, 2014 12:23 PM
> > To: dev@dpdk.org
> > Cc: De Lara Guarch, Pablo; thomas.monjalon@6wind.com; Doherty, Declan
> > Subject: [PATCH v6 0/8] link bonding
> >
> > v6:
> > - Re-based to dpdk.org addressing associated issues for MBUF_REFCNT
> > - Added details to testpmd user guide for new command to set link status
> > polling interval.
> >
> > 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                | 3347 ++++++++++++++-------------
> >  app/test/virtual_pmd.c                      |   96 +-
> >  app/test/virtual_pmd.h                      |   53 +-
> >  doc/guides/testpmd_app_ug/testpmd_funcs.rst |   19 +
> >  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     |   28 +-
> >  lib/librte_pmd_bond/rte_eth_bond_pmd.c      |  553 +++--
> >  lib/librte_pmd_bond/rte_eth_bond_private.h  |   71 +-
> >  15 files changed, 2715 insertions(+), 1959 deletions(-)
> >
> > --
> > 1.7.12.2
> 
> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/8] link bonding
  2014-11-21 17:07         ` Doherty, Declan
@ 2014-11-21 18:36           ` Thomas Monjalon
  2014-11-23 13:40             ` Thomas Monjalon
  0 siblings, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2014-11-21 18:36 UTC (permalink / raw)
  To: Doherty, Declan; +Cc: dev

2014-11-21 17:07, Doherty, Declan:
> Hey Thomas, have you had a chance to have a look at this patchset, if you
> have any comments or issues can you let me know asap, as the patch sets for
> link bonding modes 4 & 5 are dependent on this set and I don't want to be
> blocking them from the next release candidate.

Declan, your patchset doesn't touch anything else than the bonding area
(except socket_id parameter in testpmd), it is acked and it has a test
report since today.
You are the author (and implicit maintainer) of bonding, so I consider
I don't need to review this patchset.

Conclusion: yes, it should be applied shortly.

-- 
Thomas

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/8] link bonding
  2014-11-21 18:36           ` Thomas Monjalon
@ 2014-11-23 13:40             ` Thomas Monjalon
  0 siblings, 0 replies; 91+ messages in thread
From: Thomas Monjalon @ 2014-11-23 13:40 UTC (permalink / raw)
  To: Doherty, Declan; +Cc: dev

2014-11-21 19:36, Thomas Monjalon:
> 2014-11-21 17:07, Doherty, Declan:
> > Hey Thomas, have you had a chance to have a look at this patchset, if you
> > have any comments or issues can you let me know asap, as the patch sets for
> > link bonding modes 4 & 5 are dependent on this set and I don't want to be
> > blocking them from the next release candidate.
> 
> Declan, your patchset doesn't touch anything else than the bonding area
> (except socket_id parameter in testpmd), it is acked and it has a test
> report since today.
> You are the author (and implicit maintainer) of bonding, so I consider
> I don't need to review this patchset.
> 
> Conclusion: yes, it should be applied shortly.

Actually no, checkpatch says this patchset is not ready.
Some errors:
TYPO_SPELLING: 'interupt' may be misspelled - perhaps 'interrupt'?
TYPO_SPELLING: 'addres' may be misspelled - perhaps 'address'?
BRACES: braces {} are not necessary for single statement blocks
SPACING: space prohibited before semicolon
MISSING_SPACE: break quoted strings at a space character
TRAILING_SEMICOLON: macros should not use a trailing semicolon
SPACING: space prohibited after that open parenthesis '('

Please fix and send a v7.
Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 0/7] link bonding
  2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
                         ` (9 preceding siblings ...)
  2014-11-21  8:59       ` Jiajia, SunX
@ 2014-11-24 12:27       ` Declan Doherty
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 1/7] bond: link status interrupt support Declan Doherty
                           ` (8 more replies)
  10 siblings, 9 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 12:27 UTC (permalink / raw)
  To: dev

v7:
- Fixes for checkpatch issues and typo fixes
- Removed patch "test app: adding support for generating variable sized" as this
  was already committed in commit aca4360340f169dcc11b1a9be955b44de8b9f6eb
  
v6:
- Re-based to dpdk.org addressing associated issues for MBUF_REFCNT
- Added details to testpmd user guide for new command to set link status polling interval.

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:
- Re-based 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.
- Re-based 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 (7):
  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
  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           |   11 +-
 app/test/packet_burst_generator.h           |   15 +-
 app/test/test.h                             |    7 +-
 app/test/test_link_bonding.c                | 3371 ++++++++++++++-------------
 app/test/virtual_pmd.c                      |   95 +-
 app/test/virtual_pmd.h                      |   53 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   19 +
 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     |   28 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c      |  553 ++++--
 lib/librte_pmd_bond/rte_eth_bond_private.h  |   71 +-
 15 files changed, 2719 insertions(+), 1973 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 1/7] bond: link status interrupt support
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
@ 2014-11-24 12:27         ` Declan Doherty
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 2/7] bond: removing switch statement from rx burst method Declan Doherty
                           ` (7 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 12:27 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index d407e4f..1245c49 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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);
 	}
 
@@ -1081,12 +1087,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);
 
@@ -1119,8 +1125,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 */
@@ -1144,6 +1150,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,
@@ -1215,7 +1359,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;
 
@@ -1285,7 +1429,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;
 
@@ -1375,7 +1519,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;
 
@@ -1467,7 +1611,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;
 
@@ -1558,7 +1702,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;
 
@@ -1622,7 +1766,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;
 
@@ -1763,7 +1907,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;
@@ -1863,7 +2007,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;
@@ -1957,7 +2101,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;
 
@@ -2027,7 +2171,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;
 
@@ -2166,7 +2310,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;
@@ -2337,7 +2481,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");
@@ -2417,7 +2561,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");
@@ -2519,7 +2663,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;
@@ -2647,7 +2791,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;
@@ -2785,7 +2929,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;
 
@@ -2874,7 +3018,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);
@@ -2928,7 +3072,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
@@ -3058,7 +3202,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;
 
@@ -3251,7 +3395,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;
@@ -3344,7 +3488,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;
 
 
@@ -3436,7 +3580,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);
@@ -3492,7 +3636,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
@@ -3592,7 +3736,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;
 
@@ -3729,7 +3873,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;
 	}
@@ -3738,7 +3882,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;
 	}
@@ -3786,6 +3930,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),
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index 75f5694..dd33119 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -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,
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 147028b..de0cd56 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -930,6 +930,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;
@@ -975,6 +976,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,
@@ -999,6 +1001,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);
@@ -1014,6 +1017,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.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 2/7] bond: removing switch statement from rx burst method
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 1/7] bond: link status interrupt support Declan Doherty
@ 2014-11-24 12:27         ` Declan Doherty
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 3/7] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
                           ` (6 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 12:27 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   65 +++++++++++++++++--------------
 1 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index de0cd56..f2fe930 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -59,35 +59,38 @@ 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:
-#ifdef RTE_MBUF_REFCNT
-	case BONDING_MODE_BROADCAST:
-#endif
-	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;
@@ -136,7 +139,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;
@@ -272,7 +275,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;
@@ -486,24 +490,27 @@ 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;
 #ifdef RTE_MBUF_REFCNT
 	case BONDING_MODE_BROADCAST:
 		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 #endif
 	default:
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 	internals->mode = mode;
 
 	return 0;
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 3/7] bond: fix naming inconsistency in tx_burst_round_robin
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 1/7] bond: link status interrupt support Declan Doherty
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 2/7] bond: removing switch statement from rx burst method Declan Doherty
@ 2014-11-24 12:27         ` Declan Doherty
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 4/7] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
                           ` (5 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 12:27 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index f2fe930..6e770af 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -93,7 +93,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];
@@ -108,13 +108,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;
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 4/7] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
                           ` (2 preceding siblings ...)
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 3/7] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
@ 2014-11-24 12:27         ` Declan Doherty
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 5/7] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
                           ` (4 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 12:27 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/packet_burst_generator.c      |   11 +-
 app/test/packet_burst_generator.h      |   15 +-
 app/test/test_link_bonding.c           |  435 ++++++++++++++++++++++++++++++--
 app/test/virtual_pmd.c                 |   78 +++++--
 app/test/virtual_pmd.h                 |    7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   83 +++++--
 6 files changed, 551 insertions(+), 78 deletions(-)

diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c
index 017139b..b2824dc 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -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,12 +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. */
 
+
 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 pkt_len,
-		      uint8_t nb_pkt_segs)
+		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 pkt_len, uint8_t nb_pkt_segs)
 {
 	int i, nb_pkt = 0;
 	size_t eth_hdr_size;
diff --git a/app/test/packet_burst_generator.h b/app/test/packet_burst_generator.h
index fe992ac..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -47,13 +47,13 @@ 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
+#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,
-		      struct ether_addr *dst_mac, uint8_t vlan_enabled,
-		      uint16_t van_id);
+		struct ether_addr *dst_mac, uint8_t vlan_enabled, uint16_t van_id);
 
 uint16_t
 initialize_udp_header(struct udp_hdr *udp_hdr, uint16_t src_port,
@@ -70,10 +70,9 @@ 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 pkt_len,
-		      uint8_t nb_pkt_segs);
+		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 pkt_len, uint8_t nb_pkt_segs);
 
 #ifdef __cplusplus
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 1245c49..185ce73 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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);
 	}
@@ -1336,12 +1339,10 @@ 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,
-				      PACKET_BURST_GEN_PKT_LEN_128, 1);
+	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, PACKET_BURST_GEN_PKT_LEN_128,
+			1);
 	if (generated_burst_size != burst_size) {
 		printf("Failed to generate packet burst");
 		return -1;
@@ -1419,6 +1420,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 };
@@ -1928,12 +2058,9 @@ 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,
-				      PACKET_BURST_GEN_PKT_LEN, 1);
+	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;
 
@@ -2585,10 +2712,9 @@ 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],
-				  PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[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;
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
@@ -2596,10 +2722,9 @@ 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],
-				  PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1])
+			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;
 
 	/* Send burst 1 on bonded port */
@@ -2913,6 +3038,140 @@ 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
@@ -3417,19 +3676,17 @@ 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,
-				      PACKET_BURST_GEN_PKT_LEN, 1);
+	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;
 
 	/* 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);
@@ -3472,6 +3729,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
@@ -3784,7 +4160,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;
 	}
@@ -3933,6 +4309,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),
@@ -3956,12 +4333,14 @@ 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),
 #ifdef RTE_MBUF_REFCNT
 		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),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index e861c5b..81d4be3 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -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,65 @@ 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;
+		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->tx_burst_fail_count;
+
+		/* 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 +430,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)
 {
 	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
 
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 766b6ac..3b5c911 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -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
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 6e770af..2a86402 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -102,10 +102,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;
 	internals = bd_tx_q->dev_private;
@@ -121,19 +121,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
 	 * 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]);
+	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,
+					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;
+
+				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]));
+			}
+			num_tx_total += num_tx_slave;
+		}
+	}
 
 	return num_tx_total;
 }
@@ -284,7 +297,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;
 
@@ -316,11 +329,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;
 }
 
@@ -332,12 +357,13 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct rte_mbuf **bufs,
 	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
 
-	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_successful_tx_slave = -1;
 
 	bd_tx_q = (struct bond_tx_queue *)queue;
 	internals = bd_tx_q->dev_private;
@@ -356,11 +382,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
+		 * maximum number of packets */
+		if (slave_tx_total[i] > max_nb_of_tx_pkts) {
+			max_nb_of_tx_pkts = slave_tx_total[i];
+			most_successful_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
+	 * handle failures of all packets except those of the most successful slave
+	 */
+	if (unlikely(tx_failed_flag))
+		for (i = 0; i < num_of_slaves; i++)
+			if (i != most_successful_tx_slave)
+				while (slave_tx_total[i] < nb_pkts)
+					rte_pktmbuf_free(bufs[slave_tx_total[i]++]);
+
+	return max_nb_of_tx_pkts;
 }
 #endif
 
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 5/7] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
                           ` (3 preceding siblings ...)
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 4/7] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
@ 2014-11-24 12:27         ` Declan Doherty
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 6/7] bond: lsc polling support Declan Doherty
                           ` (3 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 12:27 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4c3fc76..be12c13 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3642,7 +3642,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);
 	}
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 12adafa..8a4190b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -630,7 +630,7 @@ init_config(void)
 
 
 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
 	struct rte_port *port;
 
@@ -649,6 +649,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();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 9cbfeac..5a3423c 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 6/7] bond: lsc polling support
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
                           ` (4 preceding siblings ...)
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 5/7] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
@ 2014-11-24 12:27         ` Declan Doherty
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 7/7] bond: unit test test macro refactor Declan Doherty
                           ` (2 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 12:27 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test-pmd/cmdline.c                      |   63 +++++
 app/test/test.h                             |    7 +-
 app/test/test_link_bonding.c                |  265 ++++++++++++-------
 app/test/virtual_pmd.c                      |   17 +-
 app/test/virtual_pmd.h                      |   48 +++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   19 ++
 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     |   28 ++-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c      |  393 ++++++++++++++++++++-------
 lib/librte_pmd_bond/rte_eth_bond_private.h  |   71 +++--
 11 files changed, 958 insertions(+), 348 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index be12c13..af8f907 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -462,6 +462,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()
@@ -3733,6 +3736,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 *** */
@@ -7787,6 +7849,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,
diff --git a/app/test/test.h b/app/test/test.h
index bd44a7f..d5b6951 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -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;											\
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 185ce73..f428193 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -234,42 +234,34 @@ configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 	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;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_dev_configure(port_id, test_params->nb_rx_q,
+			test_params->nb_tx_q, &default_pmd_conf),
+			"rte_eth_dev_configure for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++) {
-		if (rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
+	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
 				rte_eth_dev_socket_id(port_id), &rx_conf_default,
-				test_params->mbuf_pool) < 0) {
-			goto error;
-		}
-	}
+				test_params->mbuf_pool) ,
+				"rte_eth_rx_queue_setup for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++) {
-		if (rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
-				rte_eth_dev_socket_id(port_id), &tx_conf_default) < 0) {
-			printf("Failed to setup tx queue (%d).\n", q_id);
-			goto error;
-		}
-	}
+	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
+				rte_eth_dev_socket_id(port_id), &tx_conf_default),
+				"rte_eth_tx_queue_setup for port %d failed", port_id);
 
-	if (start) {
-		if (rte_eth_dev_start(port_id) < 0) {
-			printf("Failed to start device (%d).\n", port_id);
-			goto error;
-		}
-	}
-	return 0;
+	if (start)
+		TEST_ASSERT_SUCCESS(rte_eth_dev_start(port_id),
+				"rte_eth_dev_start for port %d failed", port_id);
 
-error:
-	printf("Failed to configure ethdev %d\n", port_id);
-	return -1;
+	return 0;
 }
 
 static int slaves_initialized;
 
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
+
+
 static int
 test_setup(void)
 {
@@ -310,7 +302,7 @@ test_setup(void)
 			snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_%d", i);
 
 			test_params->slave_port_ids[i] = virtual_ethdev_create(pmd_name,
-					mac_addr, rte_socket_id());
+					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;
@@ -414,34 +406,27 @@ test_create_bonded_device_with_invalid_params(void)
 static int
 test_add_slave_to_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]);
-	if (retval != 0) {
-		printf("Failed to add slave (%d) to bonded port (%d).\n",
-				test_params->bonded_port_id,
-				test_params->slave_port_ids[test_params->bonded_slave_count]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave (%d) to bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count],
+			test_params->bonded_port_id);
 
 	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 + 1) {
-		printf("Number of slaves (%d) is greater than expected (%d).\n",
-				current_slave_count, test_params->bonded_slave_count + 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count + 1,
+			"Number of slaves (%d) is greater than expected (%d).",
+			current_slave_count, test_params->bonded_slave_count + 1);
 
 	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 as expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
+					"Number of active slaves (%d) is not as expected (%d).\n",
+					current_slave_count, 0);
 
 	test_params->bonded_slave_count++;
 
@@ -476,27 +461,23 @@ test_add_slave_to_invalid_bonded_device(void)
 static int
 test_remove_slave_from_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 	struct ether_addr read_mac_addr, *mac_addr;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_remove(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
-	if (retval != 0) {
-		printf("\t Failed to remove slave %d from bonded port (%d).\n",
-				test_params->slave_port_ids[test_params->bonded_slave_count-1],
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_remove(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count-1]),
+			"Failed to remove slave %d from bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count-1],
+			test_params->bonded_port_id);
 
 
 	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 - 1) {
-		printf("Number of slaves (%d) is great than expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count - 1,
+			"Number of slaves (%d) is great than expected (%d).\n",
+			current_slave_count, test_params->bonded_slave_count - 1);
 
 
 	mac_addr = (struct ether_addr *)slave_mac;
@@ -506,10 +487,8 @@ test_remove_slave_from_bonded_device(void)
 	rte_eth_macaddr_get(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1],
 			&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\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
@@ -891,21 +870,20 @@ test_set_primary_slave(void)
 		return -1;
 	}
 
+	/* 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;
+	}
+
 	/* Set slave as primary
 	 * Verify slave it is now primary slave
 	 * Verify that MAC address of bonded device is that of primary slave
 	 * Verify that MAC address of all bonded slaves are that of primary slave
 	 */
 	for (i = 0; i < 4; i++) {
-
-		/* 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;
-		}
-
 		retval = rte_eth_bond_primary_set(test_params->bonded_port_id,
 				test_params->slave_port_ids[i]);
 		if (retval != 0) {
@@ -929,6 +907,7 @@ test_set_primary_slave(void)
 
 		/* 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;
 
@@ -1093,19 +1072,18 @@ static int
 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 */
+	/* Configure bonded device */
 	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);
 
-	while (number_of_slaves > test_params->bonded_slave_count) {
-		/* Add slaves to bonded device */
+	/* Add slaves to bonded device */
+	while (number_of_slaves > test_params->bonded_slave_count)
 		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
 				"Failed to add slave (%d to  bonding port (%d).",
 				test_params->bonded_slave_count - 1,
 				test_params->bonded_port_id);
-	}
 
 	/* Set link bonding mode  */
 	TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonded_port_id,
@@ -1128,9 +1106,9 @@ test_adding_slave_after_bonded_device_started(void)
 {
 	int i;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 0)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 0),
+			"Failed to add slaves to bonded device");
 
 	/* Enabled slave devices */
 	for (i = 0; i < test_params->bonded_slave_count + 1; i++) {
@@ -1138,12 +1116,9 @@ test_adding_slave_after_bonded_device_started(void)
 				test_params->slave_port_ids[i], 1);
 	}
 
-	if (rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]) !=
-					0) {
-		printf("\t Failed to add slave to bonded port.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave to bonded port.\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count]);
@@ -1158,8 +1133,6 @@ test_adding_slave_after_bonded_device_started(void)
 
 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,
@@ -1183,7 +1156,7 @@ lsc_timeout(int wait_us)
 	gettimeofday(&tp, NULL);
 
 	/* Convert from timeval to timespec */
-	ts.tv_sec  = tp.tv_sec;
+	ts.tv_sec = tp.tv_sec;
 	ts.tv_nsec = tp.tv_usec * 1000;
 	ts.tv_nsec += wait_us * 1000;
 
@@ -1193,6 +1166,9 @@ lsc_timeout(int wait_us)
 
 	pthread_mutex_unlock(&mutex);
 
+	if (retval == 0 && test_lsc_interupt_count < 1)
+		return -1;
+
 	return retval;
 }
 
@@ -1202,9 +1178,6 @@ 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)
@@ -1284,9 +1257,6 @@ test_status_interrupt(void)
 				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();
 }
@@ -1419,6 +1389,7 @@ test_roundrobin_tx_burst(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#ifdef RTE_MBUF_REFCNT
 static int
 verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
 {
@@ -1432,6 +1403,7 @@ verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
 	}
 	return 0;
 }
+#endif
 
 
 static void
@@ -1537,11 +1509,12 @@ test_roundrobin_tx_burst_slave_tx_fail(void)
 				(unsigned int)port_stats.opackets, slave_expected_tx_count);
 	}
 
+#ifdef RTE_MBUF_REFCNT
 	/* 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");
-
+#endif
 	free_mbufs(&pkt_burst[tx_count], TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
 
 	/* Clean up and remove slaves from bonded device */
@@ -2028,6 +2001,101 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT (2)
+
+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 };
+
+static int
+test_roundrobin_verfiy_polling_slave_link_status_change(void)
+{
+	struct ether_addr *mac_addr = (struct ether_addr *)polling_slave_mac;
+	char slave_name[RTE_ETH_NAME_MAX_LEN];
+
+	int i;
+
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+		/* Generate slave name / MAC address */
+		snprintf(slave_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_poll_%d", i);
+		mac_addr->addr_bytes[ETHER_ADDR_LEN-1] = i;
+
+		/* Create slave devices with no ISR Support */
+		if (polling_test_slaves[i] == -1) {
+			polling_test_slaves[i] = virtual_ethdev_create(slave_name, mac_addr,
+					rte_socket_id(), 0);
+			TEST_ASSERT(polling_test_slaves[i] >= 0,
+					"Failed to create virtual virtual ethdev %s\n", slave_name);
+
+			/* Configure slave */
+			TEST_ASSERT_SUCCESS(configure_ethdev(polling_test_slaves[i], 0, 0),
+					"Failed to configure virtual ethdev %s(%d)", slave_name,
+					polling_test_slaves[i]);
+		}
+
+		/* Add slave to bonded device */
+		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);
+	}
+
+	/* Initialize bonded device */
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 1, 1),
+			"Failed to configure bonded device %d",
+			test_params->bonded_port_id);
+
+
+	/* 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);
+
+	/* link status change callback for first slave link up */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 1);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(15000), "timed out waiting for interrupt");
+
+
+	/* no link status change callback for second slave link up */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 1);
+
+	TEST_ASSERT_FAIL(lsc_timeout(15000), "unexpectedly succeeded");
+
+	/* link status change callback for both slave links down */
+	test_lsc_interupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 0);
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 0);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(20000), "timed out waiting for interrupt");
+
+	/* Un-Register link status change interrupt callback */
+	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);
+
+
+	/* Clean up and remove slaves from bonded device */
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+
+		TEST_ASSERT_SUCCESS(
+				rte_eth_bond_slave_remove(test_params->bonded_port_id,
+						polling_test_slaves[i]),
+				"Failed to remove slave %d from bonded port (%d)",
+				polling_test_slaves[i], test_params->bonded_port_id);
+	}
+
+	return remove_slaves_and_stop_bonded_device();
+}
+
+
 /** Active Backup Mode Tests */
 
 static int
@@ -3160,10 +3228,12 @@ test_balance_tx_burst_slave_tx_fail(void)
 				(unsigned int)port_stats.opackets,
 				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
 
+#ifdef RTE_MBUF_REFCNT
 	/* 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");
+#endif
 
 	free_mbufs(&pkts_burst_1[tx_count_1],
 			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
@@ -4315,6 +4385,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),
 		TEST_CASE(test_roundrobin_verify_mac_assignment),
 		TEST_CASE(test_roundrobin_verify_slave_link_status_change_behaviour),
+		TEST_CASE(test_roundrobin_verfiy_polling_slave_link_status_change),
 		TEST_CASE(test_activebackup_tx_burst),
 		TEST_CASE(test_activebackup_rx_burst),
 		TEST_CASE(test_activebackup_verify_promiscuous_enable_disable),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 81d4be3..e7be98b 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -456,6 +456,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)
 {
@@ -503,7 +511,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;
@@ -553,7 +561,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;
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 3b5c911..2462853 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -40,38 +40,58 @@ extern "C" {
 
 #include <rte_ether.h>
 
-int virtual_ethdev_init(void);
+int
+virtual_ethdev_init(void);
 
-int virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, uint8_t socket_id);
+int
+virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
+		uint8_t socket_id, uint8_t isr_support);
 
-void virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id, uint8_t link_status);
+void
+virtual_ethdev_set_link_status(uint8_t port_id, uint8_t link_status);
 
-void virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, struct rte_mbuf **pkts_burst, int burst_length);
+void
+virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id,
+		uint8_t link_status);
 
+void
+virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id,
+		struct rte_mbuf **pkts_burst, int burst_length);
 
-/** Control methods for the dev_ops functions pointer to control the behavior of the Virtual PMD */
 
-void virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
+/** Control methods for the dev_ops functions pointer to control the behavior
+ *  of the Virtual PMD */
 
-void virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_link_update_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_burst_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_link_update_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);
+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,
+void
+virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
 		uint8_t packet_fail_count);
 
 #ifdef __cplusplus
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index c0d0033..93fd3d4 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1479,6 +1479,25 @@ For example, set a Link Bonding device (port 10) to use a balance policy of laye
 
     testpmd> set bonding xmit_balance_policy 10 l34
 
+
+set bonding mon_period
+~~~~~~~~~~~~~~~~~~~~~~
+
+Set the link status monitoring polling period in milliseconds for a bonding devicie.
+
+This adds support for PMD slave devices which do not support link status interrupts.
+When the mon_period is set to a value greater than 0 then all PMD's which do not support
+link status ISR will be queried every polling interval to check if their link status has changed.
+
+set bonding mon_period (port_id) (value)
+
+For example, to set the link status monitoring polling period of bonded device (port 5) to 150ms
+
+.. code-block:: console
+
+    testpmd> set bonding mon_period 5 150
+
+
 show bonding config
 ~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/librte_pmd_bond/rte_eth_bond.h b/lib/librte_pmd_bond/rte_eth_bond.h
index 344ca1e..2ed4f7c 100644
--- a/lib/librte_pmd_bond/rte_eth_bond.h
+++ b/lib/librte_pmd_bond/rte_eth_bond.h
@@ -249,6 +249,86 @@ rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy);
 int
 rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id);
 
+/**
+ * Set the link monitoring frequency (in ms) for monitoring the link status of
+ * slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param internal_ms		Monitoring interval in milliseconds
+ *
+ * @return
+ *	0 on success, negative value otherwise.
+ */
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms);
+
+/**
+ * Get the current link monitoring frequency (in ms) for monitoring of the link
+ * status of slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ *
+ * @return
+ *	Monitoring interval on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id);
+
+
+/**
+ * Set the period in milliseconds for delaying the disabling of a bonded link
+ * when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the disabling of a bonded
+ * link when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id);
+
+/**
+ * Set the period in milliseconds for delaying the enabling of a bonded link
+ * when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the enabling of a bonded
+ * link when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index dd33119..f146bda 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -39,6 +39,8 @@
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
 
+#define DEFAULT_POLLING_INTERVAL_10_MS (10)
+
 int
 valid_bonded_ethdev(struct rte_eth_dev *eth_dev)
 {
@@ -63,9 +65,8 @@ valid_port_id(uint8_t port_id)
 	/* Verify that port id is valid */
 	int ethdev_count = rte_eth_dev_count();
 	if (port_id >= ethdev_count) {
-		RTE_LOG(ERR, PMD,
-				"%s: port Id %d is greater than rte_eth_dev_count %d\n",
-				__func__, port_id, ethdev_count);
+		RTE_BOND_LOG(ERR, "Port Id %d is greater than rte_eth_dev_count %d",
+				port_id, ethdev_count);
 		return -1;
 	}
 
@@ -81,9 +82,8 @@ valid_bonded_port_id(uint8_t port_id)
 
 	/* Verify that bonded_port_id refers to a bonded port */
 	if (valid_bonded_ethdev(&rte_eth_devices[port_id])) {
-		RTE_LOG(ERR, PMD,
-				"%s: Specified port Id %d is not a bonded eth_dev device\n",
-				__func__, port_id);
+		RTE_BOND_LOG(ERR, "Specified port Id %d is not a bonded eth_dev device",
+				port_id);
 		return -1;
 	}
 
@@ -136,37 +136,36 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	 */
 
 	if (name == NULL) {
-		RTE_LOG(ERR, PMD, "Invalid name specified\n");
+		RTE_BOND_LOG(ERR, "Invalid name specified");
 		goto err;
 	}
 
 	if (socket_id >= number_of_sockets()) {
-		RTE_LOG(ERR, PMD,
-				"%s: invalid socket id specified to create bonded device on.\n",
-				__func__);
+		RTE_BOND_LOG(ERR,
+				"Invalid socket id specified to create bonded device on.");
 		goto err;
 	}
 
 	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
 	if (pci_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci dev on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci dev on socket");
 		goto err;
 	}
 
 	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
 	if (eth_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc eth_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
 		goto err;
 	}
 
 	pci_drv = rte_zmalloc_socket(name, sizeof(*pci_drv), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_drv on socket");
 		goto err;
 	}
 	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_id_table on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
 		goto err;
 	}
 
@@ -181,14 +180,14 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
 		goto err;
 	}
 
 	/* reserve an ethdev entry */
 	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to allocate rte_eth_dev\n");
+		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
 		goto err;
 	}
 
@@ -218,25 +217,31 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->pci_dev = pci_dev;
 
 	if (bond_ethdev_mode_set(eth_dev, mode)) {
-		RTE_LOG(ERR, PMD,
-				"%s: failed to set bonded device %d mode too %d\n",
-				__func__, eth_dev->data->port_id, mode);
+		RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
+				 eth_dev->data->port_id, mode);
 		goto err;
 	}
 
+	rte_spinlock_init(&internals->lock);
+
+	internals->port_id = eth_dev->data->port_id;
 	internals->current_primary_port = 0;
 	internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
 	internals->user_defined_mac = 0;
 	internals->link_props_set = 0;
+
+	internals->link_status_polling_enabled = 0;
+
+	internals->link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS;
+	internals->link_down_delay_ms = 0;
+	internals->link_up_delay_ms = 0;
+
 	internals->slave_count = 0;
 	internals->active_slave_count = 0;
 
 	memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
 	memset(internals->slaves, 0, sizeof(internals->slaves));
 
-	memset(internals->presisted_slaves_conf, 0,
-			sizeof(internals->presisted_slaves_conf));
-
 	return eth_dev->data->port_id;
 
 err:
@@ -253,8 +258,8 @@ err:
 	return -1;
 }
 
-int
-rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
+static int
+__eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
 	struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
 	struct bond_dev_private *internals;
@@ -263,56 +268,43 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	int i, j;
 
-	/* Verify that port id's are valid bonded and slave ports */
-	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_add;
-
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_add;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
 
-	/*
-	 * Verify that new slave device is not already a slave of another bonded
-	 * device */
+	/* Verify that new slave device is not already a slave of another
+	 * bonded device */
 	for (i = rte_eth_dev_count()-1; i >= 0; i--) {
 		if (valid_bonded_ethdev(&rte_eth_devices[i]) == 0) {
 			temp_internals = rte_eth_devices[i].data->dev_private;
+
 			for (j = 0; j < temp_internals->slave_count; j++) {
 				/* Device already a slave of a bonded device */
-				if (temp_internals->slaves[j] == slave_port_id)
-					goto err_add;
+				if (temp_internals->slaves[j].port_id == slave_port_id) {
+					RTE_BOND_LOG(ERR, "Slave port %d is already a slave",
+							slave_port_id);
+					return -1;
+				}
 			}
 		}
 	}
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
-
 	slave_eth_dev = &rte_eth_devices[slave_port_id];
 
-	if (internals->slave_count > 0) {
-		/* Check that new slave device is the same type as the other slaves
-		 * and not repetitive */
-		for (i = 0; i < internals->slave_count; i++) {
-			if (slave_eth_dev->pci_dev->driver->id_table->device_id !=
-					rte_eth_devices[internals->slaves[i]].pci_dev->driver->id_table->device_id ||
-				internals->slaves[i] == slave_port_id)
-				goto err_add;
-		}
-	}
-
 	/* Add slave details to bonded device */
-	internals->slaves[internals->slave_count] = slave_port_id;
-
-	slave_config_store(internals, slave_eth_dev);
+	slave_add(internals, slave_eth_dev);
 
 	if (internals->slave_count < 1) {
-		/* if MAC is not user defined then use MAC of first slave add to bonded
-		 * device */
+		/* if MAC is not user defined then use MAC of first slave add to
+		 * bonded device */
 		if (!internals->user_defined_mac)
 			mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs);
 
 		/* Inherit eth dev link properties from first slave */
-		link_properties_set(bonded_eth_dev, &(slave_eth_dev->data->dev_link));
+		link_properties_set(bonded_eth_dev,
+				&(slave_eth_dev->data->dev_link));
 
 		/* Make primary slave */
 		internals->primary_port = slave_port_id;
@@ -322,10 +314,10 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->link_props_set) {
 			if (link_properties_valid(&(bonded_eth_dev->data->dev_link),
 									  &(slave_eth_dev->data->dev_link))) {
-				RTE_LOG(ERR, PMD,
-						"%s: Slave port %d link speed/duplex not supported\n",
-						__func__, slave_port_id);
-				goto err_add;
+				RTE_BOND_LOG(ERR,
+						"Slave port %d link speed/duplex not supported",
+						slave_port_id);
+				return -1;
 			}
 		} else {
 			link_properties_set(bonded_eth_dev,
@@ -340,9 +332,9 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	if (bonded_eth_dev->data->dev_started) {
 		if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
-			RTE_LOG(ERR, PMD, "rte_bond_slaves_configure: port=%d\n",
+			RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
 					slave_port_id);
-			goto err_add;
+			return -1;
 		}
 	}
 
@@ -356,65 +348,79 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 	if (bonded_eth_dev->data->dev_started) {
 		rte_eth_link_get_nowait(slave_port_id, &link_props);
 
-		 if (link_props.link_status == 1) {
+		 if (link_props.link_status == 1)
 			internals->active_slaves[internals->active_slave_count++] =
 					slave_port_id;
-		}
 	}
-
 	return 0;
 
-err_add:
-	RTE_LOG(ERR, PMD, "Failed to add port %d as slave\n", slave_port_id);
-	return -1;
-
 }
 
+
 int
-rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
+	struct rte_eth_dev *bonded_eth_dev;
 	struct bond_dev_private *internals;
-	struct slave_conf *slave_conf;
 
-	int i;
-	int pos = -1;
+	int retval;
 
 	/* Verify that port id's are valid bonded and slave ports */
 	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_del;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
+
+	return retval;
+}
+
+
+static int
+__eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct bond_dev_private *internals;
+
+	int i, slave_idx = -1;
 
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_del;
+		return -1;
 
 	internals = rte_eth_devices[bonded_port_id].data->dev_private;
 
 	/* first remove from active slave list */
 	for (i = 0; i < internals->active_slave_count; i++) {
 		if (internals->active_slaves[i] == slave_port_id)
-			pos = i;
+			slave_idx = i;
 
 		/* shift active slaves up active array list */
-		if (pos >= 0 && i < (internals->active_slave_count - 1))
+		if (slave_idx >= 0 && i < (internals->active_slave_count - 1))
 			internals->active_slaves[i] = internals->active_slaves[i+1];
 	}
 
-	if (pos >= 0)
+	if (slave_idx >= 0)
 		internals->active_slave_count--;
 
-	pos = -1;
-	/* now remove from slave list */
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == slave_port_id)
-			pos = i;
+	slave_idx = -1;
+	/* now find in slave list */
+	for (i = 0; i < internals->slave_count; i++)
+		if (internals->slaves[i].port_id == slave_port_id) {
+			slave_idx = i;
+			break;
+		}
 
-		/* shift slaves up list */
-		if (pos >= 0 && i < internals->slave_count)
-			internals->slaves[i] = internals->slaves[i+1];
+	if (slave_idx < 0) {
+		RTE_BOND_LOG(ERR, "Couldn't find slave in port list, slave count %d",
+				internals->slave_count);
+		return -1;
 	}
 
-	if (pos < 0)
-		goto err_del;
-
 	/* Un-register link status change callback with bonded device pointer as
 	 * argument*/
 	rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
@@ -422,13 +428,10 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 			&rte_eth_devices[bonded_port_id].data->port_id);
 
 	/* Restore original MAC address of slave device */
-	slave_conf = slave_config_get(internals, slave_port_id);
+	mac_address_set(&rte_eth_devices[slave_port_id],
+			&(internals->slaves[slave_idx].persisted_mac_addr));
 
-	mac_address_set(&rte_eth_devices[slave_port_id], &(slave_conf->mac_addr));
-
-	slave_config_clear(internals, &rte_eth_devices[slave_port_id]);
-
-	internals->slave_count--;
+	slave_remove(internals, &rte_eth_devices[slave_port_id]);
 
 	/*  first slave in the active list will be the primary by default,
 	 *  otherwise use first device in list */
@@ -436,7 +439,7 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->active_slave_count > 0)
 			internals->current_primary_port = internals->active_slaves[0];
 		else if (internals->slave_count > 0)
-			internals->current_primary_port = internals->slaves[0];
+			internals->current_primary_port = internals->slaves[0].port_id;
 		else
 			internals->primary_port = 0;
 	}
@@ -454,12 +457,28 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 	}
 
 	return 0;
+}
 
-err_del:
-	RTE_LOG(ERR, PMD,
-			"Cannot remove slave device (not present in bonded device)\n");
-	return -1;
+int
+rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct rte_eth_dev *bonded_eth_dev;
+	struct bond_dev_private *internals;
+	int retval;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_remove_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
 
+	return retval;
 }
 
 int
@@ -524,6 +543,7 @@ int
 rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 {
 	struct bond_dev_private *internals;
+	int i;
 
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
@@ -536,10 +556,10 @@ rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 	if (internals->slave_count > len)
 		return -1;
 
-	memcpy(slaves, internals->slaves, internals->slave_count);
+	for (i = 0; i < internals->slave_count; i++)
+		slaves[i] = internals->slaves[i].port_id;
 
 	return internals->slave_count;
-
 }
 
 int
@@ -605,13 +625,13 @@ rte_eth_bond_mac_address_reset(uint8_t bonded_port_id)
 	internals->user_defined_mac = 0;
 
 	if (internals->slave_count > 0) {
-		struct slave_conf *conf;
-		conf = slave_config_get(internals, internals->primary_port);
-
 		/* Set MAC Address of Bonded Device */
-		if (mac_address_set(bonded_eth_dev, &conf->mac_addr) != 0)
+		if (mac_address_set(bonded_eth_dev,
+				&internals->slaves[internals->primary_port].persisted_mac_addr)
+				!= 0) {
+			RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
 			return -1;
-
+		}
 		/* Update all slave devices MAC addresses */
 		return mac_address_slaves_update(bonded_eth_dev);
 	}
@@ -654,3 +674,88 @@ rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id)
 
 	return internals->balance_xmit_policy;
 }
+
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_status_polling_interval_ms = internal_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_status_polling_interval_ms;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_down_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_down_delay_ms;
+}
+
+
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_up_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_up_delay_ms;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_args.c b/lib/librte_pmd_bond/rte_eth_bond_args.c
index 05a2b07..d8ce681 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_args.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_args.c
@@ -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;
 	}
@@ -174,6 +175,7 @@ bond_ethdev_parse_slave_mode_kvarg(const char *key __rte_unused,
 #endif
 		return 0;
 	default:
+		RTE_BOND_LOG(ERR, "Invalid slave mode value (%s) specified", value);
 		return -1;
 	}
 }
@@ -252,3 +254,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;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 2a86402..be87390 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -40,6 +40,7 @@
 #include <rte_devargs.h>
 #include <rte_kvargs.h>
 #include <rte_dev.h>
+#include <rte_alarm.h>
 
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
@@ -457,16 +458,16 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr)
 	mac_addr = eth_dev->data->mac_addrs;
 
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", __func__);
+		RTE_BOND_LOG(ERR,  "NULL pointer eth_dev specified");
 		return -1;
 	}
 
 	if (new_mac_addr == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer MAC specified\n", __func__);
+		RTE_BOND_LOG(ERR, "NULL pointer MAC specified");
 		return -1;
 	}
 
-	/* if new MAC is different to current MAC then update */
+	/* If new MAC is different to current MAC then update */
 	if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0)
 		memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr));
 
@@ -490,11 +491,10 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_BROADCAST:
 #endif
 		for (i = 0; i < internals->slave_count; i++) {
-			if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
+			if (mac_address_set(&rte_eth_devices[internals->slaves[i].port_id],
 					bonded_eth_dev->data->mac_addrs)) {
-				RTE_LOG(ERR, PMD,
-						"%s: Failed to update port Id %d MAC address\n",
-						__func__, internals->slaves[i]);
+				RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+						internals->slaves[i].port_id);
 				return -1;
 			}
 		}
@@ -502,23 +502,20 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_ACTIVE_BACKUP:
 	default:
 		for (i = 0; i < internals->slave_count; i++) {
-			if (internals->slaves[i] == internals->current_primary_port) {
+			if (internals->slaves[i].port_id ==
+					internals->current_primary_port) {
 				if (mac_address_set(&rte_eth_devices[internals->primary_port],
 						bonded_eth_dev->data->mac_addrs)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->current_primary_port);
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->current_primary_port);
+					return -1;
 				}
 			} else {
-				struct slave_conf *conf =
-						slave_config_get(internals, internals->slaves[i]);
-
-				if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
-						&conf->mac_addr)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->slaves[i]);
-
+				if (mac_address_set(
+						&rte_eth_devices[internals->slaves[i].port_id],
+						&internals->slaves[i].persisted_mac_addr)) {
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->slaves[i].port_id);
 					return -1;
 				}
 			}
@@ -570,34 +567,39 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	struct bond_rx_queue *bd_rx_q;
 	struct bond_tx_queue *bd_tx_q;
 
-	int q_id;
+	int errval, q_id;
 
 	/* Stop slave */
 	rte_eth_dev_stop(slave_eth_dev->data->port_id);
 
-	/* Enable interrupts on slave device */
-	slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
+	/* Enable interrupts on slave device if supported */
+	if (slave_eth_dev->driver->pci_drv.drv_flags & RTE_PCI_DRV_INTR_LSC)
+		slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
 
-	if (rte_eth_dev_configure(slave_eth_dev->data->port_id,
+	/* Configure device */
+	errval = rte_eth_dev_configure(slave_eth_dev->data->port_id,
 			bonded_eth_dev->data->nb_rx_queues,
 			bonded_eth_dev->data->nb_tx_queues,
-			&(slave_eth_dev->data->dev_conf)) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot configure slave device: port=%u\n",
-				slave_eth_dev->data->port_id);
-		return -1;
+			&(slave_eth_dev->data->dev_conf));
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "Cannot configure slave device: port %u , err (%d)",
+				slave_eth_dev->data->port_id, errval);
+		return errval;
 	}
 
 	/* Setup Rx Queues */
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
 		bd_rx_q = (struct bond_rx_queue *)bonded_eth_dev->data->rx_queues[q_id];
 
-		if (rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_rx_q->nb_rx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_rx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_rx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
@@ -605,69 +607,77 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
 		bd_tx_q = (struct bond_tx_queue *)bonded_eth_dev->data->tx_queues[q_id];
 
-		if (rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_tx_q->nb_tx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&bd_tx_q->tx_conf) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_tx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&bd_tx_q->tx_conf);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_tx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
 	/* Start device */
-	if (rte_eth_dev_start(slave_eth_dev->data->port_id) != 0) {
-		RTE_LOG(ERR, PMD, "rte_eth_dev_start: port=%u\n",
-				slave_eth_dev->data->port_id);
+	errval = rte_eth_dev_start(slave_eth_dev->data->port_id);
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "rte_eth_dev_start: port=%u, err (%d)",
+				slave_eth_dev->data->port_id, errval);
 		return -1;
 	}
 
 	return 0;
 }
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id)
-{
-	int i;
-
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id == slave_port_id)
-			return &internals->presisted_slaves_conf[i];
-	}
-	return NULL;
-}
-
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
 	int i, found = 0;
 
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id ==
-				slave_eth_dev->data->port_id) {
+		if (internals->slaves[i].port_id ==	slave_eth_dev->data->port_id)
 			found = 1;
-			memset(&internals->presisted_slaves_conf[i], 0,
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
-		if (found && i < (internals->slave_count - 1)) {
-			memcpy(&internals->presisted_slaves_conf[i],
-					&internals->presisted_slaves_conf[i+1],
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
+
+		if (found && i < (internals->slave_count - 1))
+			memcpy(&internals->slaves[i], &internals->slaves[i+1],
+					sizeof(internals->slaves[i]));
 	}
+
+	internals->slave_count--;
 }
 
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg);
+
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
-	struct slave_conf *presisted_slave_conf =
-			&internals->presisted_slaves_conf[internals->slave_count];
+	struct bond_slave_details *slave_details =
+			&internals->slaves[internals->slave_count];
+
+	slave_details->port_id = slave_eth_dev->data->port_id;
+	slave_details->last_link_status = 0;
+
+	/* If slave device doesn't support interrupts then we need to enabled
+	 * polling to monitor link status */
+	if (!(slave_eth_dev->pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
+		slave_details->link_status_poll_enabled = 1;
+
+		if (!internals->link_status_polling_enabled) {
+			internals->link_status_polling_enabled = 1;
 
-	presisted_slave_conf->port_id = slave_eth_dev->data->port_id;
+			rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+					bond_ethdev_slave_link_status_change_monitor,
+					(void *)&rte_eth_devices[internals->port_id]);
+		}
+	}
 
-	memcpy(&(presisted_slave_conf->mac_addr), slave_eth_dev->data->mac_addrs,
+	slave_details->link_status_wait_to_complete = 0;
+
+	memcpy(&(slave_details->persisted_mac_addr), slave_eth_dev->data->mac_addrs,
 			sizeof(struct ether_addr));
 }
 
@@ -698,31 +708,33 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* slave eth dev will be started by bonded device */
 	if (valid_bonded_ethdev(eth_dev)) {
-		RTE_LOG(ERR, PMD,
-				"%s: user tried to explicitly start a slave eth_dev (%d) of the bonded eth_dev\n",
-				__func__, eth_dev->data->port_id);
+		RTE_BOND_LOG(ERR, "User tried to explicitly start a slave eth_dev (%d)",
+				eth_dev->data->port_id);
 		return -1;
 	}
 
-	eth_dev->data->dev_link.link_status = 1;
+	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 1;
 
 	internals = eth_dev->data->dev_private;
 
 	if (internals->slave_count == 0) {
-		RTE_LOG(ERR, PMD,
-				"%s: Cannot start port since there are no slave devices\n",
-				__func__);
+		RTE_BOND_LOG(ERR, "Cannot start port since there are no slave devices");
 		return -1;
 	}
 
 	if (internals->user_defined_mac == 0) {
-		struct slave_conf *conf = slave_config_get(internals,
-				internals->primary_port);
+		struct ether_addr *new_mac_addr = NULL;
+
+		for (i = 0; i < internals->slave_count; i++)
+			if (internals->slaves[i].port_id == internals->primary_port)
+				new_mac_addr = &internals->slaves[i].persisted_mac_addr;
+
+		if (new_mac_addr == NULL)
+			return -1;
 
-		if (mac_address_set(eth_dev, &(conf->mac_addr)) != 0) {
-			RTE_LOG(ERR, PMD,
-					"bonded port (%d) failed to update mac address",
+		if (mac_address_set(eth_dev, new_mac_addr) != 0) {
+			RTE_BOND_LOG(ERR, "bonded port (%d) failed to update MAC address",
 					eth_dev->data->port_id);
 			return -1;
 		}
@@ -738,11 +750,11 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* Reconfigure each slave device if starting bonded device */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (slave_configure(eth_dev, &(rte_eth_devices[internals->slaves[i]]))
-				!= 0) {
-			RTE_LOG(ERR, PMD, "bonded port "
-					"(%d) failed to reconfigure slave device (%d)\n)",
-					eth_dev->data->port_id, internals->slaves[i]);
+		if (slave_configure(eth_dev,
+				&(rte_eth_devices[internals->slaves[i].port_id])) != 0) {
+			RTE_BOND_LOG(ERR,
+					"bonded port (%d) failed to reconfigure slave device (%d)",
+					eth_dev->data->port_id, internals->slaves[i].port_id);
 			return -1;
 		}
 	}
@@ -759,6 +771,7 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 	struct bond_dev_private *internals = eth_dev->data->dev_private;
 
 	internals->active_slave_count = 0;
+	internals->link_status_polling_enabled = 0;
 
 	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 0;
@@ -852,6 +865,65 @@ bond_ethdev_tx_queue_release(void *queue)
 	rte_free(queue);
 }
 
+
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
+{
+	struct rte_eth_dev *bonded_ethdev, *slave_ethdev;
+	struct bond_dev_private *internals;
+
+	/* Default value for polling slave found is true as we don't want to
+	 * disable the polling thread if we cannot get the lock */
+	int i, polling_slave_found = 1;
+
+	if (cb_arg == NULL)
+		return;
+
+	bonded_ethdev = (struct rte_eth_dev *)cb_arg;
+	internals = (struct bond_dev_private *)bonded_ethdev->data->dev_private;
+
+	if (!bonded_ethdev->data->dev_started ||
+		!internals->link_status_polling_enabled)
+		return;
+
+	/* If device is currently being configured then don't check slaves link
+	 * status, wait until next period */
+	if (rte_spinlock_trylock(&internals->lock)) {
+		if (internals->slave_count > 0)
+			polling_slave_found = 0;
+
+		for (i = 0; i < internals->slave_count; i++) {
+			if (!internals->slaves[i].link_status_poll_enabled)
+				continue;
+
+			slave_ethdev = &rte_eth_devices[internals->slaves[i].port_id];
+			polling_slave_found = 1;
+
+			/* Update slave link status */
+			(*slave_ethdev->dev_ops->link_update)(slave_ethdev,
+					internals->slaves[i].link_status_wait_to_complete);
+
+			/* if link status has changed since last checked then call lsc
+			 * event callback */
+			if (slave_ethdev->data->dev_link.link_status !=
+					internals->slaves[i].last_link_status) {
+				internals->slaves[i].last_link_status =
+						slave_ethdev->data->dev_link.link_status;
+
+				bond_ethdev_lsc_event_callback(internals->slaves[i].port_id,
+						RTE_ETH_EVENT_INTR_LSC,
+						&bonded_ethdev->data->port_id);
+			}
+		}
+		rte_spinlock_unlock(&internals->lock);
+	}
+
+	if (polling_slave_found)
+		/* Set alarm to continue monitoring link status of slave ethdev's */
+		rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+				bond_ethdev_slave_link_status_change_monitor, cb_arg);
+}
+
 static int
 bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev,
 		int wait_to_complete)
@@ -895,7 +967,7 @@ bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	memset(stats, 0, sizeof(*stats));
 
 	for (i = 0; i < internals->slave_count; i++) {
-		rte_eth_stats_get(internals->slaves[i], &slave_stats);
+		rte_eth_stats_get(internals->slaves[i].port_id, &slave_stats);
 
 		stats->ipackets += slave_stats.ipackets;
 		stats->opackets += slave_stats.opackets;
@@ -921,7 +993,7 @@ bond_ethdev_stats_reset(struct rte_eth_dev *dev)
 	int i;
 
 	for (i = 0; i < internals->slave_count; i++)
-		rte_eth_stats_reset(internals->slaves[i]);
+		rte_eth_stats_reset(internals->slaves[i].port_id);
 }
 
 static void
@@ -940,7 +1012,7 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)
 	case BONDING_MODE_BROADCAST:
 #endif
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_enable(internals->slaves[i]);
+			rte_eth_promiscuous_enable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -966,7 +1038,7 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	case BONDING_MODE_BROADCAST:
 #endif
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_disable(internals->slaves[i]);
+			rte_eth_promiscuous_disable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -975,6 +1047,16 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	}
 }
 
+static void
+bond_ethdev_delayed_lsc_propagation(void *arg)
+{
+	if (arg == NULL)
+		return;
+
+	_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
+			RTE_ETH_EVENT_INTR_LSC);
+}
+
 void
 bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		void *param)
@@ -1003,7 +1085,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 
 	/* verify that port_id is a valid slave of bonded port */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == port_id) {
+		if (internals->slaves[i].port_id == port_id) {
 			valid_slave = 1;
 			break;
 		}
@@ -1072,8 +1154,32 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		}
 	}
 
-	if (lsc_flag)
-		_rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
+	if (lsc_flag) {
+		/* Cancel any possible outstanding interrupts if delays are enabled */
+		if (internals->link_up_delay_ms > 0 ||
+			internals->link_down_delay_ms > 0)
+			rte_eal_alarm_cancel(bond_ethdev_delayed_lsc_propagation,
+					bonded_eth_dev);
+
+		if (bonded_eth_dev->data->dev_link.link_status) {
+			if (internals->link_up_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_up_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+
+		} else {
+			if (internals->link_down_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_down_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+		}
+	}
 }
 
 struct eth_dev_ops default_dev_ops = {
@@ -1223,8 +1329,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(ERR, EAL,
-				"Transmit policy can be specified only once for bonded device %s\n",
-				name);
+				"Transmit policy can be specified only once for bonded device"
+				" %s\n", name);
 		return -1;
 	}
 
@@ -1266,8 +1372,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				&bond_ethdev_parse_primary_slave_port_id_kvarg,
 				&primary_slave_port_id) < 0) {
 			RTE_LOG(INFO, EAL,
-					"Invalid primary slave port id specified for bonded device %s\n",
-					name);
+					"Invalid primary slave port id specified for bonded device"
+					" %s\n", name);
 			return -1;
 		}
 
@@ -1281,8 +1387,97 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(INFO, EAL,
-				"Primary slave can be specified only once for bonded device %s\n",
-				name);
+				"Primary slave can be specified only once for bonded device"
+				" %s\n", name);
+		return -1;
+	}
+
+	/* Parse link status monitor polling interval */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LSC_POLL_PERIOD_KVARG);
+	if (arg_count == 1) {
+		uint32_t lsc_poll_interval_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LSC_POLL_PERIOD_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&lsc_poll_interval_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid lsc polling interval value specified for bonded"
+					"device %s\n", name);
+			return -1;
+		}
+
+		if (rte_eth_bond_link_monitoring_set(port_id, lsc_poll_interval_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set lsc monitor polling interval (%u ms) on"
+					" bonded device %s\n", lsc_poll_interval_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"LSC polling interval can be specified only once for bonded"
+				"device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link up interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_UP_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_up_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_UP_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_up_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link up propagation delay value specified for "
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_up_prop_delay_set(port_id, link_up_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link up propagation delay (%u ms) on bonded"
+					"device %s\n", link_up_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link up propagation delay can be specified only once for "
+				"bonded device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link down interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_down_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_down_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link down propagation delay value specified for"
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_down_prop_delay_set(port_id, link_down_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link down propagation delay (%u ms) on"
+					" bonded device %s\n", link_down_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link down propagation delay can be specified only once for"
+				" bonded device %s\n", name);
 		return -1;
 	}
 
diff --git a/lib/librte_pmd_bond/rte_eth_bond_private.h b/lib/librte_pmd_bond/rte_eth_bond_private.h
index 1db6e4d..6254c84 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_private.h
+++ b/lib/librte_pmd_bond/rte_eth_bond_private.h
@@ -39,20 +39,27 @@ extern "C" {
 #endif
 
 #include <rte_ethdev.h>
+#include <rte_spinlock.h>
 
 #include "rte_eth_bond.h"
 
-#define PMD_BOND_SLAVE_PORT_KVARG		("slave")
-#define PMD_BOND_PRIMARY_SLAVE_KVARG	("primary")
-#define PMD_BOND_MODE_KVARG				("mode")
-#define PMD_BOND_XMIT_POLICY_KVARG		("xmit_policy")
-#define PMD_BOND_SOCKET_ID_KVARG		("socket_id")
-#define PMD_BOND_MAC_ADDR_KVARG			("mac")
+#define PMD_BOND_SLAVE_PORT_KVARG			("slave")
+#define PMD_BOND_PRIMARY_SLAVE_KVARG		("primary")
+#define PMD_BOND_MODE_KVARG					("mode")
+#define PMD_BOND_XMIT_POLICY_KVARG			("xmit_policy")
+#define PMD_BOND_SOCKET_ID_KVARG			("socket_id")
+#define PMD_BOND_MAC_ADDR_KVARG				("mac")
+#define PMD_BOND_LSC_POLL_PERIOD_KVARG		("lsc_poll_period_ms")
+#define PMD_BOND_LINK_UP_PROP_DELAY_KVARG	("up_delay")
+#define PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG	("down_delay")
 
 #define PMD_BOND_XMIT_POLICY_LAYER2_KVARG	("l2")
 #define PMD_BOND_XMIT_POLICY_LAYER23_KVARG	("l23")
 #define PMD_BOND_XMIT_POLICY_LAYER34_KVARG	("l34")
 
+#define RTE_BOND_LOG(lvl, msg, ...)		\
+	RTE_LOG(lvl, PMD, "%s(%d) - " msg "\n", __func__, __LINE__, ##__VA_ARGS__)
+
 extern const char *pmd_bond_init_valid_arguments[];
 
 extern const char *driver_name;
@@ -82,27 +89,36 @@ struct bond_tx_queue {
 	/**< Copy of TX configuration structure for queue */
 };
 
-/** Persisted Slave Configuration Structure */
-struct slave_conf {
-	uint8_t port_id;
-	/**< Port Id of slave eth_dev */
-	struct ether_addr mac_addr;
-	/**< Slave eth_dev original MAC address */
-};
+
 /** Bonded slave devices structure */
 struct bond_ethdev_slave_ports {
 	uint8_t slaves[RTE_MAX_ETHPORTS];	/**< Slave port id array */
 	uint8_t slave_count;				/**< Number of slaves */
 };
 
+struct bond_slave_details {
+	uint8_t port_id;
+
+	uint8_t link_status_poll_enabled;
+	uint8_t link_status_wait_to_complete;
+	uint8_t last_link_status;
+
+	/**< Port Id of slave eth_dev */
+	struct ether_addr persisted_mac_addr;
+};
+
 /** Link Bonding PMD device private configuration Structure */
 struct bond_dev_private {
+	uint8_t port_id;					/**< Port Id of Bonded Port */
 	uint8_t mode;						/**< Link Bonding Mode */
 
+	rte_spinlock_t lock;
+
 	uint8_t primary_port;				/**< Primary Slave Port */
 	uint8_t current_primary_port;		/**< Primary Slave Port */
 	uint8_t user_defined_primary_port;
 	/**< Flag for whether primary port is user defined or not */
+
 	uint8_t balance_xmit_policy;
 	/**< Transmit policy - l2 / l23 / l34 for operation in balance mode */
 	uint8_t user_defined_mac;
@@ -110,19 +126,23 @@ struct bond_dev_private {
 	uint8_t promiscuous_en;
 	/**< Enabled/disable promiscuous mode on slave devices */
 	uint8_t link_props_set;
-	/**< Bonded eth_dev link properties set */
+	/**< flag to denote if the link properties are set */
+
+	uint8_t link_status_polling_enabled;
+	uint32_t link_status_polling_interval_ms;
+
+	uint32_t link_down_delay_ms;
+	uint32_t link_up_delay_ms;
 
 	uint16_t nb_rx_queues;			/**< Total number of rx queues */
 	uint16_t nb_tx_queues;			/**< Total number of tx queues*/
 
-	uint8_t slave_count;			/**< Number of active slaves */
-	uint8_t active_slave_count;		/**< Number of slaves */
-
+	uint8_t active_slave_count;		/**< Number of active slaves */
 	uint8_t active_slaves[RTE_MAX_ETHPORTS];	/**< Active slave list */
-	uint8_t slaves[RTE_MAX_ETHPORTS];			/**< Slave list */
 
-	/** Persisted configuration of slaves */
-	struct slave_conf presisted_slaves_conf[RTE_MAX_ETHPORTS];
+	uint8_t slave_count;			/**< Number of bonded slaves */
+	struct bond_slave_details slaves[RTE_MAX_ETHPORTS];
+	/**< Arary of bonded slaves details */
 
 	struct rte_kvargs *kvlist;
 };
@@ -168,16 +188,13 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id);
-
 void
 bond_ethdev_primary_set(struct bond_dev_private *internals,
 		uint8_t slave_port_id);
@@ -210,6 +227,10 @@ int
 bond_ethdev_parse_bond_mac_addr_kvarg(const char *key __rte_unused,
 		const char *value, void *extra_args);
 
+int
+bond_ethdev_parse_time_ms_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 7/7] bond: unit test test macro refactor
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
                           ` (5 preceding siblings ...)
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 6/7] bond: lsc polling support Declan Doherty
@ 2014-11-24 12:27         ` Declan Doherty
  2014-11-24 15:35         ` [dpdk-dev] [PATCH v7 0/7] link bonding Thomas Monjalon
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 12:27 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/test_link_bonding.c | 2604 +++++++++++++++++-------------------------
 1 files changed, 1052 insertions(+), 1552 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index f428193..206b10a 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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,
@@ -784,56 +716,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();
@@ -847,36 +762,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
@@ -884,32 +787,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] =
@@ -917,56 +815,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;
 }
@@ -974,7 +860,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;
 
@@ -983,87 +869,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;
 }
 
@@ -1131,7 +992,7 @@ test_adding_slave_after_bonded_device_started(void)
 #define TEST_STATUS_INTERRUPT_SLAVE_COUNT	4
 #define TEST_LSC_WAIT_TIMEOUT_MS	500
 
-int test_lsc_interupt_count;
+int test_lsc_interrupt_count;
 
 
 static void
@@ -1139,7 +1000,7 @@ 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++;
+	test_lsc_interrupt_count++;
 
 	pthread_cond_signal(&cvar);
 	pthread_mutex_unlock(&mutex);
@@ -1161,12 +1022,12 @@ lsc_timeout(int wait_us)
 	ts.tv_nsec += wait_us * 1000;
 
 	pthread_mutex_lock(&mutex);
-	if (test_lsc_interupt_count < 1)
+	if (test_lsc_interrupt_count < 1)
 		retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
 
 	pthread_mutex_unlock(&mutex);
 
-	if (retval == 0 && test_lsc_interupt_count < 1)
+	if (retval == 0 && test_lsc_interrupt_count < 1)
 		return -1;
 
 	return retval;
@@ -1179,11 +1040,12 @@ 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;
+	test_lsc_interrupt_count = 0;
 
 	/* register link status change interrupt callback */
 	rte_eth_dev_callback_register(test_params->bonded_port_id,
@@ -1206,7 +1068,7 @@ test_status_interrupt(void)
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[2], 0);
 
-	TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+	TEST_ASSERT_EQUAL(test_lsc_interrupt_count, 0,
 			"Received a link status change interrupt unexpectedly");
 
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -1215,7 +1077,7 @@ test_status_interrupt(void)
 	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) == 0,
 			"timed out waiting for interrupt");
 
-	TEST_ASSERT(test_lsc_interupt_count > 0,
+	TEST_ASSERT(test_lsc_interrupt_count > 0,
 			"Did not receive link status change interrupt");
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
@@ -1226,7 +1088,7 @@ test_status_interrupt(void)
 			slave_count, 0);
 
 	/* bring one slave port up so link status will change */
-	test_lsc_interupt_count = 0;
+	test_lsc_interrupt_count = 0;
 
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[0], 1);
@@ -1235,12 +1097,12 @@ test_status_interrupt(void)
 			"timed out waiting for interrupt");
 
 	/* test that we have received another lsc interrupt */
-	TEST_ASSERT(test_lsc_interupt_count > 0,
+	TEST_ASSERT(test_lsc_interrupt_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;
+	test_lsc_interrupt_count = 0;
 
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[0], 1);
@@ -1248,7 +1110,7 @@ test_status_interrupt(void)
 	TEST_ASSERT(lsc_timeout(TEST_LSC_WAIT_TIMEOUT_MS) != 0,
 			"received unexpected interrupt");
 
-	TEST_ASSERT_EQUAL(test_lsc_interupt_count, 0,
+	TEST_ASSERT_EQUAL(test_lsc_interrupt_count, 0,
 			"Did not receive link status change interrupt");
 
 
@@ -1313,10 +1175,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;
 }
@@ -1326,51 +1186,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 */
@@ -1380,10 +1232,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();
@@ -1529,17 +1380,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 */
@@ -1548,21 +1399,18 @@ 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 */
@@ -1571,19 +1419,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 */
@@ -1620,17 +1464,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 */
@@ -1643,55 +1486,42 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 	/* 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("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++) {
@@ -1708,91 +1538,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 */
@@ -1805,44 +1621,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 */
@@ -1869,26 +1679,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(
@@ -1896,13 +1702,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;
 
@@ -1913,19 +1718,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,
@@ -1963,27 +1765,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++) {
@@ -2005,7 +1804,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 };
 
@@ -2039,7 +1837,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 */
@@ -2054,7 +1853,7 @@ test_roundrobin_verfiy_polling_slave_link_status_change(void)
 			&test_params->bonded_port_id);
 
 	/* link status change callback for first slave link up */
-	test_lsc_interupt_count = 0;
+	test_lsc_interrupt_count = 0;
 
 	virtual_ethdev_set_link_status(polling_test_slaves[0], 1);
 
@@ -2062,14 +1861,14 @@ test_roundrobin_verfiy_polling_slave_link_status_change(void)
 
 
 	/* no link status change callback for second slave link up */
-	test_lsc_interupt_count = 0;
+	test_lsc_interrupt_count = 0;
 
 	virtual_ethdev_set_link_status(polling_test_slaves[1], 1);
 
 	TEST_ASSERT_FAIL(lsc_timeout(15000), "unexpectedly succeeded");
 
 	/* link status change callback for both slave links down */
-	test_lsc_interupt_count = 0;
+	test_lsc_interrupt_count = 0;
 
 	virtual_ethdev_set_link_status(polling_test_slaves[0], 0);
 	virtual_ethdev_set_link_status(polling_test_slaves[1], 0);
@@ -2101,15 +1900,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);
@@ -2120,32 +1917,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);
 
@@ -2153,35 +1943,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();
@@ -2199,78 +1982,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);
 			}
 		}
 
@@ -2296,61 +2064,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 */
@@ -2366,117 +2121,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 address");
 
 	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();
@@ -2498,38 +2238,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(
@@ -2537,12 +2271,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);
@@ -2555,106 +2287,84 @@ 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 */
-
 	for (i = 0; i < TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT; i++) {
 		for (j = 0; j < MAX_PKT_BURST; j++) {
 			if (pkt_burst[i][j] != NULL) {
@@ -2664,7 +2374,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();
 }
@@ -2674,70 +2383,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();
@@ -2752,24 +2440,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);
@@ -2779,54 +2459,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++) {
@@ -2836,9 +2512,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();
@@ -2848,81 +2524,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++) {
@@ -2932,10 +2592,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();
@@ -2976,82 +2636,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++) {
@@ -3061,10 +2705,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();
@@ -3253,21 +2896,23 @@ 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],
@@ -3276,56 +2921,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++) {
@@ -3344,48 +2977,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 */
@@ -3401,115 +3023,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();
@@ -3531,32 +3140,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(
@@ -3564,106 +3168,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;
-	}
+	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);
 
 	/* Send to sets of packet burst and verify that they are balanced across
 	 *  slaves */
 	burst_size = 21;
 
-	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");
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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");
+
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, &pkt_burst[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][0],
-			burst_size) != burst_size) {
-		printf("rte_eth_tx_burst failed\n");
-		return -1;
-	}
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size);
 
 	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 (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[2], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[2], (int)port_stats.opackets,
+			burst_size);
 
 	/* verify that all packets get send on primary slave when no other slaves
 	 * are available */
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[2], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id, slaves,
-			RTE_MAX_ETHPORTS) != 1) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_active_slaves_get(
+			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS), 1,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 1);
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][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[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size +
-			burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)(burst_size + burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
-
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[0], 0);
@@ -3675,16 +3253,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 			test_params->slave_port_ids[3], 1);
 
 	for (i = 0; i < TEST_BALANCE_LINK_STATUS_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,
+				"Failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
-
-
 	/* Verify that pkts are not received on slaves with link status down */
 
 	rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
@@ -3692,12 +3268,10 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size * 3)) {
-		printf("(%d) port_stats.ipackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.ipackets,
-				burst_size * 3);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)(burst_size * 3),
+			"(%d) port_stats.ipackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.ipackets,
+			burst_size * 3);
 
 	/* free mbufs allocate for rx testing */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
@@ -3719,16 +3293,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 static int
 test_broadcast_tx_burst(void)
 {
-	int i, pktlen, retval, burst_size, generated_burst_size, nb_tx;
+	int i, pktlen, burst_size;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 
 	struct rte_eth_stats port_stats;
 
-	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;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 2, 1),
+			"Failed to intialise bonded device");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
@@ -3740,46 +3312,37 @@ test_broadcast_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,
+	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);
-	if (generated_burst_size != burst_size)
-		return -1;
+			1), burst_size, "Failed to generate packet burst");
 
 	/* 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) {
-		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);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+			pkts_burst, burst_size), burst_size,
+			"Bonded Port (%d) rx burst failed, packets transmitted value "
+			"not as expected (%d)",
+			test_params->bonded_port_id, burst_size);
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size *
-			test_params->bonded_slave_count) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
-				burst_size);
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)burst_size * test_params->bonded_slave_count,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			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) {
-			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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)\n",
+				test_params->bonded_port_id,
+				(unsigned int)port_stats.opackets, burst_size);
 	}
 
 	/* Put all slaves down and try and transmit */
@@ -3790,10 +3353,9 @@ 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 != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkts_burst, burst_size),  0,
+			"transmitted an unexpected number of packets");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -3929,20 +3491,20 @@ test_broadcast_rx_burst(void)
 	struct rte_eth_stats port_stats;
 
 	int burst_size[BROADCAST_RX_BURST_NUM_OF_SLAVES] = { 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_BROADCAST, 0, 3, 1) != 0)
-		return -1;
-
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 3, 1),
+			"Failed to intialise bonded device");
 
 	/* Generate test bursts of packets to transmit */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; 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 slave 0 */
@@ -3954,57 +3516,44 @@ test_broadcast_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("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[0] + burst_size[1] + burst_size[2],
+			"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[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[0], (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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; i++) {
@@ -4023,48 +3572,38 @@ test_broadcast_rx_burst(void)
 static int
 test_broadcast_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_BROADCAST, 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 */
@@ -4076,45 +3615,39 @@ test_broadcast_verify_mac_assignment(void)
 {
 	struct ether_addr read_mac_addr, expected_mac_addr_0, expected_mac_addr_1;
 
-	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_1);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 4, 1),
+			"Failed to intialise bonded device");
 
 	/* Verify that all MACs are the same as first slave added to bonded
 	 * device */
 	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
@@ -4122,45 +3655,41 @@ test_broadcast_verify_mac_assignment(void)
 
 	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 new primary"
-				" port\n", test_params->slave_port_ids[i]);
-		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 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_1, &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_1, &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 address");
 
 	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_params->slave_port_ids[i]);
-		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 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(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", test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -4182,26 +3711,22 @@ 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, 0,
-			BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+				BONDING_MODE_BROADCAST, 0, BROADCAST_LINK_STATUS_NUM_OF_SLAVES,
+				1), "Failed to intialise bonded device");
 
 	/* 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;
-	}
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+	TEST_ASSERT_EQUAL(slave_count, 4,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 4);
 
 	/* Set 2 slaves link status to down */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -4211,11 +3736,9 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != 2) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, 2,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 2);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++)
 		rte_eth_stats_reset(test_params->slave_port_ids[i]);
@@ -4223,80 +3746,62 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	/* Verify that pkts are not sent on slaves with link status down */
 	burst_size = 21;
 
-	if (generate_test_burst(&pkt_burst[0][0], burst_size, 0, 0, 1, 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, 0, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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\n");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size * slave_count)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size * slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size * slave_count),
+			"(%d) port_stats.opackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size * slave_count);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%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_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[1]);
-		return -1;
-	}
 
 	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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[2]);
-		return -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]);
+
 
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
-		if (generate_test_burst(&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0) !=
-				burst_size) {
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0),
+				burst_size, "failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
 	/* Verify that pkts are not received on slaves with link status down */
+	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");
 
-	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;
-	}
 
 	/* 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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
@@ -4319,19 +3824,14 @@ 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)  != 0) {
-		printf("failed to reconfigure bonded device");
-		return -1;
-	}
-
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device");
 
 	test_params->nb_rx_q = 2;
 	test_params->nb_tx_q = 2;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
-		printf("failed to reconfigure bonded device with less rx/tx queues");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device with less rx/tx queues");
 
 	return 0;
 }
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 0/7] link bonding
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
                           ` (6 preceding siblings ...)
  2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 7/7] bond: unit test test macro refactor Declan Doherty
@ 2014-11-24 15:35         ` Thomas Monjalon
  2014-11-24 16:24           ` Doherty, Declan
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
  8 siblings, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2014-11-24 15:35 UTC (permalink / raw)
  To: Declan Doherty; +Cc: dev

Hi Declan,

There are still 2 kind of errors reported by checkpatch:
- 14 occurrences of this typo:
WARNING:TYPO_SPELLING: 'interupt' may be misspelled - perhaps 'interrupt'?
- 6 occurences of missing space:
WARNING:MISSING_SPACE: break quoted strings at a space character

Example:
#2016: FILE: lib/librte_pmd_bond/rte_eth_bond_pmd.c:1420:
+                               "LSC polling interval can be specified only once for bonded"
+                               "device %s\n", name);
You should put a space between "bonded" and "device".

-- 
Thomas

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 0/7] link bonding
  2014-11-24 15:35         ` [dpdk-dev] [PATCH v7 0/7] link bonding Thomas Monjalon
@ 2014-11-24 16:24           ` Doherty, Declan
  2014-11-24 17:53             ` Thomas Monjalon
  0 siblings, 1 reply; 91+ messages in thread
From: Doherty, Declan @ 2014-11-24 16:24 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

Hey, sorry about that, I submitted the patchset without the typo fix. I'll resubmit the patchset now.
What version of checkpatch are you using, I don't get any warning for the missing spaces for the
version of the script with kernel 3.15 on Fedora

Thanks
Declan


> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Monday, November 24, 2014 3:36 PM
> To: Doherty, Declan
> Cc: dev@dpdk.org
> Subject: Re: [PATCH v7 0/7] link bonding
> 
> Hi Declan,
> 
> There are still 2 kind of errors reported by checkpatch:
> - 14 occurrences of this typo:
> WARNING:TYPO_SPELLING: 'interupt' may be misspelled - perhaps 'interrupt'?
> - 6 occurences of missing space:
> WARNING:MISSING_SPACE: break quoted strings at a space character
> 
> Example:
> #2016: FILE: lib/librte_pmd_bond/rte_eth_bond_pmd.c:1420:
> +                               "LSC polling interval can be specified only once for bonded"
> +                               "device %s\n", name);
> You should put a space between "bonded" and "device".
> 
> --
> Thomas

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 0/7] link bonding
  2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
                           ` (7 preceding siblings ...)
  2014-11-24 15:35         ` [dpdk-dev] [PATCH v7 0/7] link bonding Thomas Monjalon
@ 2014-11-24 16:33         ` Declan Doherty
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 1/7] bond: link status interrupt support Declan Doherty
                             ` (8 more replies)
  8 siblings, 9 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 16:33 UTC (permalink / raw)
  To: dev

v8:
- Missing typo fix
- Missing whitespace

v7:
- Fixes for checkpatch issues and typo fixes
- Removed patch "test app: adding support for generating variable sized" as this
  was already committed in commit aca4360340f169dcc11b1a9be955b44de8b9f6eb
  
v6:
- Re-based to dpdk.org addressing associated issues for MBUF_REFCNT
- Added details to testpmd user guide for new command to set link status polling interval.

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:
- Re-based 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.
- Re-based 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 (7):
  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
  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           |   11 +-
 app/test/packet_burst_generator.h           |   15 +-
 app/test/test.h                             |    7 +-
 app/test/test_link_bonding.c                | 3371 ++++++++++++++-------------
 app/test/virtual_pmd.c                      |   95 +-
 app/test/virtual_pmd.h                      |   53 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   19 +
 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     |   28 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c      |  553 ++++--
 lib/librte_pmd_bond/rte_eth_bond_private.h  |   71 +-
 15 files changed, 2719 insertions(+), 1973 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 1/7] bond: link status interrupt support
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
@ 2014-11-24 16:33           ` Declan Doherty
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 2/7] bond: removing switch statement from rx burst method Declan Doherty
                             ` (7 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 16:33 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index d407e4f..7ecb76e 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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);
 	}
 
@@ -1081,12 +1087,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);
 
@@ -1119,8 +1125,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 */
@@ -1144,6 +1150,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_interrupt_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_interrupt_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_interrupt_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_interrupt_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_interrupt_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_interrupt_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_interrupt_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_interrupt_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_interrupt_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_interrupt_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,
@@ -1215,7 +1359,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;
 
@@ -1285,7 +1429,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;
 
@@ -1375,7 +1519,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;
 
@@ -1467,7 +1611,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;
 
@@ -1558,7 +1702,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;
 
@@ -1622,7 +1766,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;
 
@@ -1763,7 +1907,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;
@@ -1863,7 +2007,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;
@@ -1957,7 +2101,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;
 
@@ -2027,7 +2171,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;
 
@@ -2166,7 +2310,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;
@@ -2337,7 +2481,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");
@@ -2417,7 +2561,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");
@@ -2519,7 +2663,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;
@@ -2647,7 +2791,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;
@@ -2785,7 +2929,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;
 
@@ -2874,7 +3018,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);
@@ -2928,7 +3072,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
@@ -3058,7 +3202,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;
 
@@ -3251,7 +3395,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;
@@ -3344,7 +3488,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;
 
 
@@ -3436,7 +3580,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);
@@ -3492,7 +3636,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
@@ -3592,7 +3736,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;
 
@@ -3729,7 +3873,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;
 	}
@@ -3738,7 +3882,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;
 	}
@@ -3786,6 +3930,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),
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index 75f5694..dd33119 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -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,
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 147028b..de0cd56 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -930,6 +930,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;
@@ -975,6 +976,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,
@@ -999,6 +1001,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);
@@ -1014,6 +1017,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.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 2/7] bond: removing switch statement from rx burst method
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 1/7] bond: link status interrupt support Declan Doherty
@ 2014-11-24 16:33           ` Declan Doherty
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 3/7] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
                             ` (6 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 16:33 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   65 +++++++++++++++++--------------
 1 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index de0cd56..f2fe930 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -59,35 +59,38 @@ 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:
-#ifdef RTE_MBUF_REFCNT
-	case BONDING_MODE_BROADCAST:
-#endif
-	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;
@@ -136,7 +139,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;
@@ -272,7 +275,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;
@@ -486,24 +490,27 @@ 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;
 #ifdef RTE_MBUF_REFCNT
 	case BONDING_MODE_BROADCAST:
 		eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+		eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 		break;
 #endif
 	default:
 		return -1;
 	}
 
-	eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
 	internals->mode = mode;
 
 	return 0;
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 3/7] bond: fix naming inconsistency in tx_burst_round_robin
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 1/7] bond: link status interrupt support Declan Doherty
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 2/7] bond: removing switch statement from rx burst method Declan Doherty
@ 2014-11-24 16:33           ` Declan Doherty
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 4/7] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
                             ` (5 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 16:33 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index f2fe930..6e770af 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -93,7 +93,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];
@@ -108,13 +108,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;
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 4/7] bond: free mbufs if transmission fails in bonding tx_burst functions
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
                             ` (2 preceding siblings ...)
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 3/7] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
@ 2014-11-24 16:33           ` Declan Doherty
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 5/7] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
                             ` (4 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 16:33 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/packet_burst_generator.c      |   11 +-
 app/test/packet_burst_generator.h      |   15 +-
 app/test/test_link_bonding.c           |  435 ++++++++++++++++++++++++++++++--
 app/test/virtual_pmd.c                 |   78 +++++--
 app/test/virtual_pmd.h                 |    7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   83 +++++--
 6 files changed, 551 insertions(+), 78 deletions(-)

diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c
index 017139b..b2824dc 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -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,12 +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. */
 
+
 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 pkt_len,
-		      uint8_t nb_pkt_segs)
+		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 pkt_len, uint8_t nb_pkt_segs)
 {
 	int i, nb_pkt = 0;
 	size_t eth_hdr_size;
diff --git a/app/test/packet_burst_generator.h b/app/test/packet_burst_generator.h
index fe992ac..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -47,13 +47,13 @@ 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
+#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,
-		      struct ether_addr *dst_mac, uint8_t vlan_enabled,
-		      uint16_t van_id);
+		struct ether_addr *dst_mac, uint8_t vlan_enabled, uint16_t van_id);
 
 uint16_t
 initialize_udp_header(struct udp_hdr *udp_hdr, uint16_t src_port,
@@ -70,10 +70,9 @@ 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 pkt_len,
-		      uint8_t nb_pkt_segs);
+		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 pkt_len, uint8_t nb_pkt_segs);
 
 #ifdef __cplusplus
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 7ecb76e..c11a0bc 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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);
 	}
@@ -1336,12 +1339,10 @@ 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,
-				      PACKET_BURST_GEN_PKT_LEN_128, 1);
+	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, PACKET_BURST_GEN_PKT_LEN_128,
+			1);
 	if (generated_burst_size != burst_size) {
 		printf("Failed to generate packet burst");
 		return -1;
@@ -1419,6 +1420,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 };
@@ -1928,12 +2058,9 @@ 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,
-				      PACKET_BURST_GEN_PKT_LEN, 1);
+	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;
 
@@ -2585,10 +2712,9 @@ 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],
-				  PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[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;
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
@@ -2596,10 +2722,9 @@ 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],
-				  PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1])
+			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;
 
 	/* Send burst 1 on bonded port */
@@ -2913,6 +3038,140 @@ 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
@@ -3417,19 +3676,17 @@ 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,
-				      PACKET_BURST_GEN_PKT_LEN, 1);
+	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;
 
 	/* 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);
@@ -3472,6 +3729,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
@@ -3784,7 +4160,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;
 	}
@@ -3933,6 +4309,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),
@@ -3956,12 +4333,14 @@ 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),
 #ifdef RTE_MBUF_REFCNT
 		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),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index e861c5b..81d4be3 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -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,65 @@ 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;
+		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->tx_burst_fail_count;
+
+		/* 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 +430,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)
 {
 	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
 
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 766b6ac..3b5c911 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -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
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 6e770af..2a86402 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -102,10 +102,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;
 	internals = bd_tx_q->dev_private;
@@ -121,19 +121,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
 	 * 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]);
+	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,
+					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;
+
+				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]));
+			}
+			num_tx_total += num_tx_slave;
+		}
+	}
 
 	return num_tx_total;
 }
@@ -284,7 +297,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;
 
@@ -316,11 +329,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;
 }
 
@@ -332,12 +357,13 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct rte_mbuf **bufs,
 	struct bond_dev_private *internals;
 	struct bond_tx_queue *bd_tx_q;
 
-	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_successful_tx_slave = -1;
 
 	bd_tx_q = (struct bond_tx_queue *)queue;
 	internals = bd_tx_q->dev_private;
@@ -356,11 +382,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
+		 * maximum number of packets */
+		if (slave_tx_total[i] > max_nb_of_tx_pkts) {
+			max_nb_of_tx_pkts = slave_tx_total[i];
+			most_successful_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
+	 * handle failures of all packets except those of the most successful slave
+	 */
+	if (unlikely(tx_failed_flag))
+		for (i = 0; i < num_of_slaves; i++)
+			if (i != most_successful_tx_slave)
+				while (slave_tx_total[i] < nb_pkts)
+					rte_pktmbuf_free(bufs[slave_tx_total[i]++]);
+
+	return max_nb_of_tx_pkts;
 }
 #endif
 
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 5/7] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
                             ` (3 preceding siblings ...)
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 4/7] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
@ 2014-11-24 16:33           ` Declan Doherty
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 6/7] bond: lsc polling support Declan Doherty
                             ` (3 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 16:33 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4c3fc76..be12c13 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3642,7 +3642,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);
 	}
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 12adafa..8a4190b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -630,7 +630,7 @@ init_config(void)
 
 
 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
 	struct rte_port *port;
 
@@ -649,6 +649,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();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 9cbfeac..5a3423c 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 6/7] bond: lsc polling support
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
                             ` (4 preceding siblings ...)
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 5/7] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
@ 2014-11-24 16:33           ` Declan Doherty
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 7/7] bond: unit test test macro refactor Declan Doherty
                             ` (2 subsequent siblings)
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 16:33 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test-pmd/cmdline.c                      |   63 +++++
 app/test/test.h                             |    7 +-
 app/test/test_link_bonding.c                |  265 ++++++++++++-------
 app/test/virtual_pmd.c                      |   17 +-
 app/test/virtual_pmd.h                      |   48 +++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   19 ++
 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     |   28 ++-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c      |  393 ++++++++++++++++++++-------
 lib/librte_pmd_bond/rte_eth_bond_private.h  |   71 +++--
 11 files changed, 958 insertions(+), 348 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index be12c13..af8f907 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -462,6 +462,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()
@@ -3733,6 +3736,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 *** */
@@ -7787,6 +7849,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,
diff --git a/app/test/test.h b/app/test/test.h
index bd44a7f..d5b6951 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -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;											\
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index c11a0bc..2411125 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -234,42 +234,34 @@ configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 	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;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_dev_configure(port_id, test_params->nb_rx_q,
+			test_params->nb_tx_q, &default_pmd_conf),
+			"rte_eth_dev_configure for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++) {
-		if (rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
+	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
 				rte_eth_dev_socket_id(port_id), &rx_conf_default,
-				test_params->mbuf_pool) < 0) {
-			goto error;
-		}
-	}
+				test_params->mbuf_pool) ,
+				"rte_eth_rx_queue_setup for port %d failed", port_id);
 
-	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++) {
-		if (rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
-				rte_eth_dev_socket_id(port_id), &tx_conf_default) < 0) {
-			printf("Failed to setup tx queue (%d).\n", q_id);
-			goto error;
-		}
-	}
+	for (q_id = 0; q_id < test_params->nb_tx_q; q_id++)
+		TEST_ASSERT_SUCCESS(rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
+				rte_eth_dev_socket_id(port_id), &tx_conf_default),
+				"rte_eth_tx_queue_setup for port %d failed", port_id);
 
-	if (start) {
-		if (rte_eth_dev_start(port_id) < 0) {
-			printf("Failed to start device (%d).\n", port_id);
-			goto error;
-		}
-	}
-	return 0;
+	if (start)
+		TEST_ASSERT_SUCCESS(rte_eth_dev_start(port_id),
+				"rte_eth_dev_start for port %d failed", port_id);
 
-error:
-	printf("Failed to configure ethdev %d\n", port_id);
-	return -1;
+	return 0;
 }
 
 static int slaves_initialized;
 
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
+
+
 static int
 test_setup(void)
 {
@@ -310,7 +302,7 @@ test_setup(void)
 			snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_%d", i);
 
 			test_params->slave_port_ids[i] = virtual_ethdev_create(pmd_name,
-					mac_addr, rte_socket_id());
+					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;
@@ -414,34 +406,27 @@ test_create_bonded_device_with_invalid_params(void)
 static int
 test_add_slave_to_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]);
-	if (retval != 0) {
-		printf("Failed to add slave (%d) to bonded port (%d).\n",
-				test_params->bonded_port_id,
-				test_params->slave_port_ids[test_params->bonded_slave_count]);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave (%d) to bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count],
+			test_params->bonded_port_id);
 
 	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 + 1) {
-		printf("Number of slaves (%d) is greater than expected (%d).\n",
-				current_slave_count, test_params->bonded_slave_count + 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count + 1,
+			"Number of slaves (%d) is greater than expected (%d).",
+			current_slave_count, test_params->bonded_slave_count + 1);
 
 	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 as expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(current_slave_count, 0,
+					"Number of active slaves (%d) is not as expected (%d).\n",
+					current_slave_count, 0);
 
 	test_params->bonded_slave_count++;
 
@@ -476,27 +461,23 @@ test_add_slave_to_invalid_bonded_device(void)
 static int
 test_remove_slave_from_bonded_device(void)
 {
-	int retval, current_slave_count;
+	int current_slave_count;
 	struct ether_addr read_mac_addr, *mac_addr;
 	uint8_t slaves[RTE_MAX_ETHPORTS];
 
-	retval = rte_eth_bond_slave_remove(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
-	if (retval != 0) {
-		printf("\t Failed to remove slave %d from bonded port (%d).\n",
-				test_params->slave_port_ids[test_params->bonded_slave_count-1],
-				test_params->bonded_port_id);
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_remove(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count-1]),
+			"Failed to remove slave %d from bonded port (%d).",
+			test_params->slave_port_ids[test_params->bonded_slave_count-1],
+			test_params->bonded_port_id);
 
 
 	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 - 1) {
-		printf("Number of slaves (%d) is great than expected (%d).\n",
-				current_slave_count, 0);
-		return -1;
-	}
+
+	TEST_ASSERT_EQUAL(current_slave_count, test_params->bonded_slave_count - 1,
+			"Number of slaves (%d) is great than expected (%d).\n",
+			current_slave_count, test_params->bonded_slave_count - 1);
 
 
 	mac_addr = (struct ether_addr *)slave_mac;
@@ -506,10 +487,8 @@ test_remove_slave_from_bonded_device(void)
 	rte_eth_macaddr_get(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1],
 			&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\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count-1]);
@@ -891,21 +870,20 @@ test_set_primary_slave(void)
 		return -1;
 	}
 
+	/* 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;
+	}
+
 	/* Set slave as primary
 	 * Verify slave it is now primary slave
 	 * Verify that MAC address of bonded device is that of primary slave
 	 * Verify that MAC address of all bonded slaves are that of primary slave
 	 */
 	for (i = 0; i < 4; i++) {
-
-		/* 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;
-		}
-
 		retval = rte_eth_bond_primary_set(test_params->bonded_port_id,
 				test_params->slave_port_ids[i]);
 		if (retval != 0) {
@@ -929,6 +907,7 @@ test_set_primary_slave(void)
 
 		/* 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;
 
@@ -1093,19 +1072,18 @@ static int
 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 */
+	/* Configure bonded device */
 	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);
 
-	while (number_of_slaves > test_params->bonded_slave_count) {
-		/* Add slaves to bonded device */
+	/* Add slaves to bonded device */
+	while (number_of_slaves > test_params->bonded_slave_count)
 		TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
 				"Failed to add slave (%d to  bonding port (%d).",
 				test_params->bonded_slave_count - 1,
 				test_params->bonded_port_id);
-	}
 
 	/* Set link bonding mode  */
 	TEST_ASSERT_SUCCESS(rte_eth_bond_mode_set(test_params->bonded_port_id,
@@ -1128,9 +1106,9 @@ test_adding_slave_after_bonded_device_started(void)
 {
 	int i;
 
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 4, 0)
-			!= 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_ROUND_ROBIN, 0, 4, 0),
+			"Failed to add slaves to bonded device");
 
 	/* Enabled slave devices */
 	for (i = 0; i < test_params->bonded_slave_count + 1; i++) {
@@ -1138,12 +1116,9 @@ test_adding_slave_after_bonded_device_started(void)
 				test_params->slave_port_ids[i], 1);
 	}
 
-	if (rte_eth_bond_slave_add(test_params->bonded_port_id,
-			test_params->slave_port_ids[test_params->bonded_slave_count]) !=
-					0) {
-		printf("\t Failed to add slave to bonded port.\n");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(test_params->bonded_port_id,
+			test_params->slave_port_ids[test_params->bonded_slave_count]),
+			"Failed to add slave to bonded port.\n");
 
 	rte_eth_stats_reset(
 			test_params->slave_port_ids[test_params->bonded_slave_count]);
@@ -1158,8 +1133,6 @@ test_adding_slave_after_bonded_device_started(void)
 
 int test_lsc_interrupt_count;
 
-static pthread_mutex_t mutex;
-static pthread_cond_t cvar;
 
 static void
 test_bonding_lsc_event_callback(uint8_t port_id __rte_unused,
@@ -1183,7 +1156,7 @@ lsc_timeout(int wait_us)
 	gettimeofday(&tp, NULL);
 
 	/* Convert from timeval to timespec */
-	ts.tv_sec  = tp.tv_sec;
+	ts.tv_sec = tp.tv_sec;
 	ts.tv_nsec = tp.tv_usec * 1000;
 	ts.tv_nsec += wait_us * 1000;
 
@@ -1193,6 +1166,9 @@ lsc_timeout(int wait_us)
 
 	pthread_mutex_unlock(&mutex);
 
+	if (retval == 0 && test_lsc_interrupt_count < 1)
+		return -1;
+
 	return retval;
 }
 
@@ -1202,9 +1178,6 @@ 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)
@@ -1284,9 +1257,6 @@ test_status_interrupt(void)
 				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();
 }
@@ -1419,6 +1389,7 @@ test_roundrobin_tx_burst(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#ifdef RTE_MBUF_REFCNT
 static int
 verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
 {
@@ -1432,6 +1403,7 @@ verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
 	}
 	return 0;
 }
+#endif
 
 
 static void
@@ -1537,11 +1509,12 @@ test_roundrobin_tx_burst_slave_tx_fail(void)
 				(unsigned int)port_stats.opackets, slave_expected_tx_count);
 	}
 
+#ifdef RTE_MBUF_REFCNT
 	/* 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");
-
+#endif
 	free_mbufs(&pkt_burst[tx_count], TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
 
 	/* Clean up and remove slaves from bonded device */
@@ -2028,6 +2001,101 @@ test_roundrobin_verify_slave_link_status_change_behaviour(void)
 	return remove_slaves_and_stop_bonded_device();
 }
 
+#define TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT (2)
+
+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 };
+
+static int
+test_roundrobin_verfiy_polling_slave_link_status_change(void)
+{
+	struct ether_addr *mac_addr = (struct ether_addr *)polling_slave_mac;
+	char slave_name[RTE_ETH_NAME_MAX_LEN];
+
+	int i;
+
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+		/* Generate slave name / MAC address */
+		snprintf(slave_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_poll_%d", i);
+		mac_addr->addr_bytes[ETHER_ADDR_LEN-1] = i;
+
+		/* Create slave devices with no ISR Support */
+		if (polling_test_slaves[i] == -1) {
+			polling_test_slaves[i] = virtual_ethdev_create(slave_name, mac_addr,
+					rte_socket_id(), 0);
+			TEST_ASSERT(polling_test_slaves[i] >= 0,
+					"Failed to create virtual virtual ethdev %s\n", slave_name);
+
+			/* Configure slave */
+			TEST_ASSERT_SUCCESS(configure_ethdev(polling_test_slaves[i], 0, 0),
+					"Failed to configure virtual ethdev %s(%d)", slave_name,
+					polling_test_slaves[i]);
+		}
+
+		/* Add slave to bonded device */
+		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);
+	}
+
+	/* Initialize bonded device */
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 1, 1),
+			"Failed to configure bonded device %d",
+			test_params->bonded_port_id);
+
+
+	/* 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);
+
+	/* link status change callback for first slave link up */
+	test_lsc_interrupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 1);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(15000), "timed out waiting for interrupt");
+
+
+	/* no link status change callback for second slave link up */
+	test_lsc_interrupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 1);
+
+	TEST_ASSERT_FAIL(lsc_timeout(15000), "unexpectedly succeeded");
+
+	/* link status change callback for both slave links down */
+	test_lsc_interrupt_count = 0;
+
+	virtual_ethdev_set_link_status(polling_test_slaves[0], 0);
+	virtual_ethdev_set_link_status(polling_test_slaves[1], 0);
+
+	TEST_ASSERT_SUCCESS(lsc_timeout(20000), "timed out waiting for interrupt");
+
+	/* Un-Register link status change interrupt callback */
+	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);
+
+
+	/* Clean up and remove slaves from bonded device */
+	for (i = 0; i < TEST_RR_POLLING_LINK_STATUS_SLAVE_COUNT; i++) {
+
+		TEST_ASSERT_SUCCESS(
+				rte_eth_bond_slave_remove(test_params->bonded_port_id,
+						polling_test_slaves[i]),
+				"Failed to remove slave %d from bonded port (%d)",
+				polling_test_slaves[i], test_params->bonded_port_id);
+	}
+
+	return remove_slaves_and_stop_bonded_device();
+}
+
+
 /** Active Backup Mode Tests */
 
 static int
@@ -3160,10 +3228,12 @@ test_balance_tx_burst_slave_tx_fail(void)
 				(unsigned int)port_stats.opackets,
 				TEST_BAL_SLAVE_TX_FAIL_BURST_SIZE_2);
 
+#ifdef RTE_MBUF_REFCNT
 	/* 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");
+#endif
 
 	free_mbufs(&pkts_burst_1[tx_count_1],
 			TEST_BAL_SLAVE_TX_FAIL_PACKETS_COUNT);
@@ -4315,6 +4385,7 @@ static struct unit_test_suite link_bonding_test_suite  = {
 		TEST_CASE(test_roundrobin_verify_promiscuous_enable_disable),
 		TEST_CASE(test_roundrobin_verify_mac_assignment),
 		TEST_CASE(test_roundrobin_verify_slave_link_status_change_behaviour),
+		TEST_CASE(test_roundrobin_verfiy_polling_slave_link_status_change),
 		TEST_CASE(test_activebackup_tx_burst),
 		TEST_CASE(test_activebackup_rx_burst),
 		TEST_CASE(test_activebackup_verify_promiscuous_enable_disable),
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 81d4be3..e7be98b 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -456,6 +456,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)
 {
@@ -503,7 +511,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;
@@ -553,7 +561,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;
diff --git a/app/test/virtual_pmd.h b/app/test/virtual_pmd.h
index 3b5c911..2462853 100644
--- a/app/test/virtual_pmd.h
+++ b/app/test/virtual_pmd.h
@@ -40,38 +40,58 @@ extern "C" {
 
 #include <rte_ether.h>
 
-int virtual_ethdev_init(void);
+int
+virtual_ethdev_init(void);
 
-int virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, uint8_t socket_id);
+int
+virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
+		uint8_t socket_id, uint8_t isr_support);
 
-void virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id, uint8_t link_status);
+void
+virtual_ethdev_set_link_status(uint8_t port_id, uint8_t link_status);
 
-void virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, struct rte_mbuf **pkts_burst, int burst_length);
+void
+virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id,
+		uint8_t link_status);
 
+void
+virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id,
+		struct rte_mbuf **pkts_burst, int burst_length);
 
-/** Control methods for the dev_ops functions pointer to control the behavior of the Virtual PMD */
 
-void virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
+/** Control methods for the dev_ops functions pointer to control the behavior
+ *  of the Virtual PMD */
 
-void virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_stop_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_link_update_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success);
 
-void virtual_ethdev_rx_burst_fn_set_success(uint8_t port_id, uint8_t success);
+void
+virtual_ethdev_link_update_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);
+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,
+void
+virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id,
 		uint8_t packet_fail_count);
 
 #ifdef __cplusplus
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index c0d0033..93fd3d4 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1479,6 +1479,25 @@ For example, set a Link Bonding device (port 10) to use a balance policy of laye
 
     testpmd> set bonding xmit_balance_policy 10 l34
 
+
+set bonding mon_period
+~~~~~~~~~~~~~~~~~~~~~~
+
+Set the link status monitoring polling period in milliseconds for a bonding devicie.
+
+This adds support for PMD slave devices which do not support link status interrupts.
+When the mon_period is set to a value greater than 0 then all PMD's which do not support
+link status ISR will be queried every polling interval to check if their link status has changed.
+
+set bonding mon_period (port_id) (value)
+
+For example, to set the link status monitoring polling period of bonded device (port 5) to 150ms
+
+.. code-block:: console
+
+    testpmd> set bonding mon_period 5 150
+
+
 show bonding config
 ~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/librte_pmd_bond/rte_eth_bond.h b/lib/librte_pmd_bond/rte_eth_bond.h
index 344ca1e..2ed4f7c 100644
--- a/lib/librte_pmd_bond/rte_eth_bond.h
+++ b/lib/librte_pmd_bond/rte_eth_bond.h
@@ -249,6 +249,86 @@ rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy);
 int
 rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id);
 
+/**
+ * Set the link monitoring frequency (in ms) for monitoring the link status of
+ * slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param internal_ms		Monitoring interval in milliseconds
+ *
+ * @return
+ *	0 on success, negative value otherwise.
+ */
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms);
+
+/**
+ * Get the current link monitoring frequency (in ms) for monitoring of the link
+ * status of slave devices
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ *
+ * @return
+ *	Monitoring interval on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id);
+
+
+/**
+ * Set the period in milliseconds for delaying the disabling of a bonded link
+ * when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the disabling of a bonded
+ * link when the link down status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id);
+
+/**
+ * Set the period in milliseconds for delaying the enabling of a bonded link
+ * when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms);
+
+/**
+ * Get the period in milliseconds set for delaying the enabling of a bonded
+ * link when the link up status has been detected
+ *
+ * @param bonded_port_id	Port ID of bonded device.
+ * @param delay_ms			Delay period in milliseconds.
+ *
+ * @return
+ *  Delay period on success, negative value otherwise.
+ */
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
index dd33119..f146bda 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -39,6 +39,8 @@
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
 
+#define DEFAULT_POLLING_INTERVAL_10_MS (10)
+
 int
 valid_bonded_ethdev(struct rte_eth_dev *eth_dev)
 {
@@ -63,9 +65,8 @@ valid_port_id(uint8_t port_id)
 	/* Verify that port id is valid */
 	int ethdev_count = rte_eth_dev_count();
 	if (port_id >= ethdev_count) {
-		RTE_LOG(ERR, PMD,
-				"%s: port Id %d is greater than rte_eth_dev_count %d\n",
-				__func__, port_id, ethdev_count);
+		RTE_BOND_LOG(ERR, "Port Id %d is greater than rte_eth_dev_count %d",
+				port_id, ethdev_count);
 		return -1;
 	}
 
@@ -81,9 +82,8 @@ valid_bonded_port_id(uint8_t port_id)
 
 	/* Verify that bonded_port_id refers to a bonded port */
 	if (valid_bonded_ethdev(&rte_eth_devices[port_id])) {
-		RTE_LOG(ERR, PMD,
-				"%s: Specified port Id %d is not a bonded eth_dev device\n",
-				__func__, port_id);
+		RTE_BOND_LOG(ERR, "Specified port Id %d is not a bonded eth_dev device",
+				port_id);
 		return -1;
 	}
 
@@ -136,37 +136,36 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	 */
 
 	if (name == NULL) {
-		RTE_LOG(ERR, PMD, "Invalid name specified\n");
+		RTE_BOND_LOG(ERR, "Invalid name specified");
 		goto err;
 	}
 
 	if (socket_id >= number_of_sockets()) {
-		RTE_LOG(ERR, PMD,
-				"%s: invalid socket id specified to create bonded device on.\n",
-				__func__);
+		RTE_BOND_LOG(ERR,
+				"Invalid socket id specified to create bonded device on.");
 		goto err;
 	}
 
 	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
 	if (pci_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci dev on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci dev on socket");
 		goto err;
 	}
 
 	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
 	if (eth_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc eth_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
 		goto err;
 	}
 
 	pci_drv = rte_zmalloc_socket(name, sizeof(*pci_drv), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_drv on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_drv on socket");
 		goto err;
 	}
 	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
 	if (pci_drv == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc pci_id_table on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
 		goto err;
 	}
 
@@ -181,14 +180,14 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to malloc internals on socket\n");
+		RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
 		goto err;
 	}
 
 	/* reserve an ethdev entry */
 	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "Unable to allocate rte_eth_dev\n");
+		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
 		goto err;
 	}
 
@@ -218,25 +217,31 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->pci_dev = pci_dev;
 
 	if (bond_ethdev_mode_set(eth_dev, mode)) {
-		RTE_LOG(ERR, PMD,
-				"%s: failed to set bonded device %d mode too %d\n",
-				__func__, eth_dev->data->port_id, mode);
+		RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
+				 eth_dev->data->port_id, mode);
 		goto err;
 	}
 
+	rte_spinlock_init(&internals->lock);
+
+	internals->port_id = eth_dev->data->port_id;
 	internals->current_primary_port = 0;
 	internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
 	internals->user_defined_mac = 0;
 	internals->link_props_set = 0;
+
+	internals->link_status_polling_enabled = 0;
+
+	internals->link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS;
+	internals->link_down_delay_ms = 0;
+	internals->link_up_delay_ms = 0;
+
 	internals->slave_count = 0;
 	internals->active_slave_count = 0;
 
 	memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
 	memset(internals->slaves, 0, sizeof(internals->slaves));
 
-	memset(internals->presisted_slaves_conf, 0,
-			sizeof(internals->presisted_slaves_conf));
-
 	return eth_dev->data->port_id;
 
 err:
@@ -253,8 +258,8 @@ err:
 	return -1;
 }
 
-int
-rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
+static int
+__eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
 	struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
 	struct bond_dev_private *internals;
@@ -263,56 +268,43 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	int i, j;
 
-	/* Verify that port id's are valid bonded and slave ports */
-	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_add;
-
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_add;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
 
-	/*
-	 * Verify that new slave device is not already a slave of another bonded
-	 * device */
+	/* Verify that new slave device is not already a slave of another
+	 * bonded device */
 	for (i = rte_eth_dev_count()-1; i >= 0; i--) {
 		if (valid_bonded_ethdev(&rte_eth_devices[i]) == 0) {
 			temp_internals = rte_eth_devices[i].data->dev_private;
+
 			for (j = 0; j < temp_internals->slave_count; j++) {
 				/* Device already a slave of a bonded device */
-				if (temp_internals->slaves[j] == slave_port_id)
-					goto err_add;
+				if (temp_internals->slaves[j].port_id == slave_port_id) {
+					RTE_BOND_LOG(ERR, "Slave port %d is already a slave",
+							slave_port_id);
+					return -1;
+				}
 			}
 		}
 	}
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
-
 	slave_eth_dev = &rte_eth_devices[slave_port_id];
 
-	if (internals->slave_count > 0) {
-		/* Check that new slave device is the same type as the other slaves
-		 * and not repetitive */
-		for (i = 0; i < internals->slave_count; i++) {
-			if (slave_eth_dev->pci_dev->driver->id_table->device_id !=
-					rte_eth_devices[internals->slaves[i]].pci_dev->driver->id_table->device_id ||
-				internals->slaves[i] == slave_port_id)
-				goto err_add;
-		}
-	}
-
 	/* Add slave details to bonded device */
-	internals->slaves[internals->slave_count] = slave_port_id;
-
-	slave_config_store(internals, slave_eth_dev);
+	slave_add(internals, slave_eth_dev);
 
 	if (internals->slave_count < 1) {
-		/* if MAC is not user defined then use MAC of first slave add to bonded
-		 * device */
+		/* if MAC is not user defined then use MAC of first slave add to
+		 * bonded device */
 		if (!internals->user_defined_mac)
 			mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs);
 
 		/* Inherit eth dev link properties from first slave */
-		link_properties_set(bonded_eth_dev, &(slave_eth_dev->data->dev_link));
+		link_properties_set(bonded_eth_dev,
+				&(slave_eth_dev->data->dev_link));
 
 		/* Make primary slave */
 		internals->primary_port = slave_port_id;
@@ -322,10 +314,10 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->link_props_set) {
 			if (link_properties_valid(&(bonded_eth_dev->data->dev_link),
 									  &(slave_eth_dev->data->dev_link))) {
-				RTE_LOG(ERR, PMD,
-						"%s: Slave port %d link speed/duplex not supported\n",
-						__func__, slave_port_id);
-				goto err_add;
+				RTE_BOND_LOG(ERR,
+						"Slave port %d link speed/duplex not supported",
+						slave_port_id);
+				return -1;
 			}
 		} else {
 			link_properties_set(bonded_eth_dev,
@@ -340,9 +332,9 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	if (bonded_eth_dev->data->dev_started) {
 		if (slave_configure(bonded_eth_dev, slave_eth_dev) != 0) {
-			RTE_LOG(ERR, PMD, "rte_bond_slaves_configure: port=%d\n",
+			RTE_BOND_LOG(ERR, "rte_bond_slaves_configure: port=%d",
 					slave_port_id);
-			goto err_add;
+			return -1;
 		}
 	}
 
@@ -356,65 +348,79 @@ rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 	if (bonded_eth_dev->data->dev_started) {
 		rte_eth_link_get_nowait(slave_port_id, &link_props);
 
-		 if (link_props.link_status == 1) {
+		 if (link_props.link_status == 1)
 			internals->active_slaves[internals->active_slave_count++] =
 					slave_port_id;
-		}
 	}
-
 	return 0;
 
-err_add:
-	RTE_LOG(ERR, PMD, "Failed to add port %d as slave\n", slave_port_id);
-	return -1;
-
 }
 
+
 int
-rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
+	struct rte_eth_dev *bonded_eth_dev;
 	struct bond_dev_private *internals;
-	struct slave_conf *slave_conf;
 
-	int i;
-	int pos = -1;
+	int retval;
 
 	/* Verify that port id's are valid bonded and slave ports */
 	if (valid_bonded_port_id(bonded_port_id) != 0)
-		goto err_del;
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
+
+	return retval;
+}
+
+
+static int
+__eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct bond_dev_private *internals;
+
+	int i, slave_idx = -1;
 
 	if (valid_slave_port_id(slave_port_id) != 0)
-		goto err_del;
+		return -1;
 
 	internals = rte_eth_devices[bonded_port_id].data->dev_private;
 
 	/* first remove from active slave list */
 	for (i = 0; i < internals->active_slave_count; i++) {
 		if (internals->active_slaves[i] == slave_port_id)
-			pos = i;
+			slave_idx = i;
 
 		/* shift active slaves up active array list */
-		if (pos >= 0 && i < (internals->active_slave_count - 1))
+		if (slave_idx >= 0 && i < (internals->active_slave_count - 1))
 			internals->active_slaves[i] = internals->active_slaves[i+1];
 	}
 
-	if (pos >= 0)
+	if (slave_idx >= 0)
 		internals->active_slave_count--;
 
-	pos = -1;
-	/* now remove from slave list */
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == slave_port_id)
-			pos = i;
+	slave_idx = -1;
+	/* now find in slave list */
+	for (i = 0; i < internals->slave_count; i++)
+		if (internals->slaves[i].port_id == slave_port_id) {
+			slave_idx = i;
+			break;
+		}
 
-		/* shift slaves up list */
-		if (pos >= 0 && i < internals->slave_count)
-			internals->slaves[i] = internals->slaves[i+1];
+	if (slave_idx < 0) {
+		RTE_BOND_LOG(ERR, "Couldn't find slave in port list, slave count %d",
+				internals->slave_count);
+		return -1;
 	}
 
-	if (pos < 0)
-		goto err_del;
-
 	/* Un-register link status change callback with bonded device pointer as
 	 * argument*/
 	rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
@@ -422,13 +428,10 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 			&rte_eth_devices[bonded_port_id].data->port_id);
 
 	/* Restore original MAC address of slave device */
-	slave_conf = slave_config_get(internals, slave_port_id);
+	mac_address_set(&rte_eth_devices[slave_port_id],
+			&(internals->slaves[slave_idx].persisted_mac_addr));
 
-	mac_address_set(&rte_eth_devices[slave_port_id], &(slave_conf->mac_addr));
-
-	slave_config_clear(internals, &rte_eth_devices[slave_port_id]);
-
-	internals->slave_count--;
+	slave_remove(internals, &rte_eth_devices[slave_port_id]);
 
 	/*  first slave in the active list will be the primary by default,
 	 *  otherwise use first device in list */
@@ -436,7 +439,7 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 		if (internals->active_slave_count > 0)
 			internals->current_primary_port = internals->active_slaves[0];
 		else if (internals->slave_count > 0)
-			internals->current_primary_port = internals->slaves[0];
+			internals->current_primary_port = internals->slaves[0].port_id;
 		else
 			internals->primary_port = 0;
 	}
@@ -454,12 +457,28 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 	}
 
 	return 0;
+}
 
-err_del:
-	RTE_LOG(ERR, PMD,
-			"Cannot remove slave device (not present in bonded device)\n");
-	return -1;
+int
+rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+	struct rte_eth_dev *bonded_eth_dev;
+	struct bond_dev_private *internals;
+	int retval;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	internals = bonded_eth_dev->data->dev_private;
+
+	rte_spinlock_lock(&internals->lock);
+
+	retval = __eth_bond_slave_remove_lock_free(bonded_port_id, slave_port_id);
+
+	rte_spinlock_unlock(&internals->lock);
 
+	return retval;
 }
 
 int
@@ -524,6 +543,7 @@ int
 rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 {
 	struct bond_dev_private *internals;
+	int i;
 
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
@@ -536,10 +556,10 @@ rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 	if (internals->slave_count > len)
 		return -1;
 
-	memcpy(slaves, internals->slaves, internals->slave_count);
+	for (i = 0; i < internals->slave_count; i++)
+		slaves[i] = internals->slaves[i].port_id;
 
 	return internals->slave_count;
-
 }
 
 int
@@ -605,13 +625,13 @@ rte_eth_bond_mac_address_reset(uint8_t bonded_port_id)
 	internals->user_defined_mac = 0;
 
 	if (internals->slave_count > 0) {
-		struct slave_conf *conf;
-		conf = slave_config_get(internals, internals->primary_port);
-
 		/* Set MAC Address of Bonded Device */
-		if (mac_address_set(bonded_eth_dev, &conf->mac_addr) != 0)
+		if (mac_address_set(bonded_eth_dev,
+				&internals->slaves[internals->primary_port].persisted_mac_addr)
+				!= 0) {
+			RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
 			return -1;
-
+		}
 		/* Update all slave devices MAC addresses */
 		return mac_address_slaves_update(bonded_eth_dev);
 	}
@@ -654,3 +674,88 @@ rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id)
 
 	return internals->balance_xmit_policy;
 }
+
+
+int
+rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_status_polling_interval_ms = internal_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_status_polling_interval_ms;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_down_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_down_delay_ms;
+}
+
+
+int
+rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
+
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals->link_up_delay_ms = delay_ms;
+
+	return 0;
+}
+
+int
+rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(bonded_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+
+	return internals->link_up_delay_ms;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_args.c b/lib/librte_pmd_bond/rte_eth_bond_args.c
index 05a2b07..d8ce681 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_args.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_args.c
@@ -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;
 	}
@@ -174,6 +175,7 @@ bond_ethdev_parse_slave_mode_kvarg(const char *key __rte_unused,
 #endif
 		return 0;
 	default:
+		RTE_BOND_LOG(ERR, "Invalid slave mode value (%s) specified", value);
 		return -1;
 	}
 }
@@ -252,3 +254,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;
+}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 2a86402..be87390 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -40,6 +40,7 @@
 #include <rte_devargs.h>
 #include <rte_kvargs.h>
 #include <rte_dev.h>
+#include <rte_alarm.h>
 
 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
@@ -457,16 +458,16 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr)
 	mac_addr = eth_dev->data->mac_addrs;
 
 	if (eth_dev == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", __func__);
+		RTE_BOND_LOG(ERR,  "NULL pointer eth_dev specified");
 		return -1;
 	}
 
 	if (new_mac_addr == NULL) {
-		RTE_LOG(ERR, PMD, "%s: NULL pointer MAC specified\n", __func__);
+		RTE_BOND_LOG(ERR, "NULL pointer MAC specified");
 		return -1;
 	}
 
-	/* if new MAC is different to current MAC then update */
+	/* If new MAC is different to current MAC then update */
 	if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0)
 		memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr));
 
@@ -490,11 +491,10 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_BROADCAST:
 #endif
 		for (i = 0; i < internals->slave_count; i++) {
-			if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
+			if (mac_address_set(&rte_eth_devices[internals->slaves[i].port_id],
 					bonded_eth_dev->data->mac_addrs)) {
-				RTE_LOG(ERR, PMD,
-						"%s: Failed to update port Id %d MAC address\n",
-						__func__, internals->slaves[i]);
+				RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+						internals->slaves[i].port_id);
 				return -1;
 			}
 		}
@@ -502,23 +502,20 @@ mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_ACTIVE_BACKUP:
 	default:
 		for (i = 0; i < internals->slave_count; i++) {
-			if (internals->slaves[i] == internals->current_primary_port) {
+			if (internals->slaves[i].port_id ==
+					internals->current_primary_port) {
 				if (mac_address_set(&rte_eth_devices[internals->primary_port],
 						bonded_eth_dev->data->mac_addrs)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->current_primary_port);
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->current_primary_port);
+					return -1;
 				}
 			} else {
-				struct slave_conf *conf =
-						slave_config_get(internals, internals->slaves[i]);
-
-				if (mac_address_set(&rte_eth_devices[internals->slaves[i]],
-						&conf->mac_addr)) {
-					RTE_LOG(ERR, PMD,
-							"%s: Failed to update port Id %d MAC address\n",
-							__func__, internals->slaves[i]);
-
+				if (mac_address_set(
+						&rte_eth_devices[internals->slaves[i].port_id],
+						&internals->slaves[i].persisted_mac_addr)) {
+					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
+							internals->slaves[i].port_id);
 					return -1;
 				}
 			}
@@ -570,34 +567,39 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	struct bond_rx_queue *bd_rx_q;
 	struct bond_tx_queue *bd_tx_q;
 
-	int q_id;
+	int errval, q_id;
 
 	/* Stop slave */
 	rte_eth_dev_stop(slave_eth_dev->data->port_id);
 
-	/* Enable interrupts on slave device */
-	slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
+	/* Enable interrupts on slave device if supported */
+	if (slave_eth_dev->driver->pci_drv.drv_flags & RTE_PCI_DRV_INTR_LSC)
+		slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
 
-	if (rte_eth_dev_configure(slave_eth_dev->data->port_id,
+	/* Configure device */
+	errval = rte_eth_dev_configure(slave_eth_dev->data->port_id,
 			bonded_eth_dev->data->nb_rx_queues,
 			bonded_eth_dev->data->nb_tx_queues,
-			&(slave_eth_dev->data->dev_conf)) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot configure slave device: port=%u\n",
-				slave_eth_dev->data->port_id);
-		return -1;
+			&(slave_eth_dev->data->dev_conf));
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "Cannot configure slave device: port %u , err (%d)",
+				slave_eth_dev->data->port_id, errval);
+		return errval;
 	}
 
 	/* Setup Rx Queues */
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
 		bd_rx_q = (struct bond_rx_queue *)bonded_eth_dev->data->rx_queues[q_id];
 
-		if (rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_rx_q->nb_rx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_rx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&(bd_rx_q->rx_conf), bd_rx_q->mb_pool);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_rx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
@@ -605,69 +607,77 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
 		bd_tx_q = (struct bond_tx_queue *)bonded_eth_dev->data->tx_queues[q_id];
 
-		if (rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
+		errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
 				bd_tx_q->nb_tx_desc,
 				rte_eth_dev_socket_id(slave_eth_dev->data->port_id),
-				&bd_tx_q->tx_conf) != 0) {
-			RTE_LOG(ERR, PMD, "rte_eth_tx_queue_setup: port=%d queue_id %d\n",
-					slave_eth_dev->data->port_id, q_id);
-			return -1;
+				&bd_tx_q->tx_conf);
+		if (errval != 0) {
+			RTE_BOND_LOG(ERR,
+					"rte_eth_tx_queue_setup: port=%d queue_id %d, err (%d)",
+					slave_eth_dev->data->port_id, q_id, errval);
+			return errval;
 		}
 	}
 
 	/* Start device */
-	if (rte_eth_dev_start(slave_eth_dev->data->port_id) != 0) {
-		RTE_LOG(ERR, PMD, "rte_eth_dev_start: port=%u\n",
-				slave_eth_dev->data->port_id);
+	errval = rte_eth_dev_start(slave_eth_dev->data->port_id);
+	if (errval != 0) {
+		RTE_BOND_LOG(ERR, "rte_eth_dev_start: port=%u, err (%d)",
+				slave_eth_dev->data->port_id, errval);
 		return -1;
 	}
 
 	return 0;
 }
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id)
-{
-	int i;
-
-	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id == slave_port_id)
-			return &internals->presisted_slaves_conf[i];
-	}
-	return NULL;
-}
-
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
 	int i, found = 0;
 
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->presisted_slaves_conf[i].port_id ==
-				slave_eth_dev->data->port_id) {
+		if (internals->slaves[i].port_id ==	slave_eth_dev->data->port_id)
 			found = 1;
-			memset(&internals->presisted_slaves_conf[i], 0,
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
-		if (found && i < (internals->slave_count - 1)) {
-			memcpy(&internals->presisted_slaves_conf[i],
-					&internals->presisted_slaves_conf[i+1],
-					sizeof(internals->presisted_slaves_conf[i]));
-		}
+
+		if (found && i < (internals->slave_count - 1))
+			memcpy(&internals->slaves[i], &internals->slaves[i+1],
+					sizeof(internals->slaves[i]));
 	}
+
+	internals->slave_count--;
 }
 
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg);
+
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev)
 {
-	struct slave_conf *presisted_slave_conf =
-			&internals->presisted_slaves_conf[internals->slave_count];
+	struct bond_slave_details *slave_details =
+			&internals->slaves[internals->slave_count];
+
+	slave_details->port_id = slave_eth_dev->data->port_id;
+	slave_details->last_link_status = 0;
+
+	/* If slave device doesn't support interrupts then we need to enabled
+	 * polling to monitor link status */
+	if (!(slave_eth_dev->pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
+		slave_details->link_status_poll_enabled = 1;
+
+		if (!internals->link_status_polling_enabled) {
+			internals->link_status_polling_enabled = 1;
 
-	presisted_slave_conf->port_id = slave_eth_dev->data->port_id;
+			rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+					bond_ethdev_slave_link_status_change_monitor,
+					(void *)&rte_eth_devices[internals->port_id]);
+		}
+	}
 
-	memcpy(&(presisted_slave_conf->mac_addr), slave_eth_dev->data->mac_addrs,
+	slave_details->link_status_wait_to_complete = 0;
+
+	memcpy(&(slave_details->persisted_mac_addr), slave_eth_dev->data->mac_addrs,
 			sizeof(struct ether_addr));
 }
 
@@ -698,31 +708,33 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* slave eth dev will be started by bonded device */
 	if (valid_bonded_ethdev(eth_dev)) {
-		RTE_LOG(ERR, PMD,
-				"%s: user tried to explicitly start a slave eth_dev (%d) of the bonded eth_dev\n",
-				__func__, eth_dev->data->port_id);
+		RTE_BOND_LOG(ERR, "User tried to explicitly start a slave eth_dev (%d)",
+				eth_dev->data->port_id);
 		return -1;
 	}
 
-	eth_dev->data->dev_link.link_status = 1;
+	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 1;
 
 	internals = eth_dev->data->dev_private;
 
 	if (internals->slave_count == 0) {
-		RTE_LOG(ERR, PMD,
-				"%s: Cannot start port since there are no slave devices\n",
-				__func__);
+		RTE_BOND_LOG(ERR, "Cannot start port since there are no slave devices");
 		return -1;
 	}
 
 	if (internals->user_defined_mac == 0) {
-		struct slave_conf *conf = slave_config_get(internals,
-				internals->primary_port);
+		struct ether_addr *new_mac_addr = NULL;
+
+		for (i = 0; i < internals->slave_count; i++)
+			if (internals->slaves[i].port_id == internals->primary_port)
+				new_mac_addr = &internals->slaves[i].persisted_mac_addr;
+
+		if (new_mac_addr == NULL)
+			return -1;
 
-		if (mac_address_set(eth_dev, &(conf->mac_addr)) != 0) {
-			RTE_LOG(ERR, PMD,
-					"bonded port (%d) failed to update mac address",
+		if (mac_address_set(eth_dev, new_mac_addr) != 0) {
+			RTE_BOND_LOG(ERR, "bonded port (%d) failed to update MAC address",
 					eth_dev->data->port_id);
 			return -1;
 		}
@@ -738,11 +750,11 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* Reconfigure each slave device if starting bonded device */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (slave_configure(eth_dev, &(rte_eth_devices[internals->slaves[i]]))
-				!= 0) {
-			RTE_LOG(ERR, PMD, "bonded port "
-					"(%d) failed to reconfigure slave device (%d)\n)",
-					eth_dev->data->port_id, internals->slaves[i]);
+		if (slave_configure(eth_dev,
+				&(rte_eth_devices[internals->slaves[i].port_id])) != 0) {
+			RTE_BOND_LOG(ERR,
+					"bonded port (%d) failed to reconfigure slave device (%d)",
+					eth_dev->data->port_id, internals->slaves[i].port_id);
 			return -1;
 		}
 	}
@@ -759,6 +771,7 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 	struct bond_dev_private *internals = eth_dev->data->dev_private;
 
 	internals->active_slave_count = 0;
+	internals->link_status_polling_enabled = 0;
 
 	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 0;
@@ -852,6 +865,65 @@ bond_ethdev_tx_queue_release(void *queue)
 	rte_free(queue);
 }
 
+
+static void
+bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
+{
+	struct rte_eth_dev *bonded_ethdev, *slave_ethdev;
+	struct bond_dev_private *internals;
+
+	/* Default value for polling slave found is true as we don't want to
+	 * disable the polling thread if we cannot get the lock */
+	int i, polling_slave_found = 1;
+
+	if (cb_arg == NULL)
+		return;
+
+	bonded_ethdev = (struct rte_eth_dev *)cb_arg;
+	internals = (struct bond_dev_private *)bonded_ethdev->data->dev_private;
+
+	if (!bonded_ethdev->data->dev_started ||
+		!internals->link_status_polling_enabled)
+		return;
+
+	/* If device is currently being configured then don't check slaves link
+	 * status, wait until next period */
+	if (rte_spinlock_trylock(&internals->lock)) {
+		if (internals->slave_count > 0)
+			polling_slave_found = 0;
+
+		for (i = 0; i < internals->slave_count; i++) {
+			if (!internals->slaves[i].link_status_poll_enabled)
+				continue;
+
+			slave_ethdev = &rte_eth_devices[internals->slaves[i].port_id];
+			polling_slave_found = 1;
+
+			/* Update slave link status */
+			(*slave_ethdev->dev_ops->link_update)(slave_ethdev,
+					internals->slaves[i].link_status_wait_to_complete);
+
+			/* if link status has changed since last checked then call lsc
+			 * event callback */
+			if (slave_ethdev->data->dev_link.link_status !=
+					internals->slaves[i].last_link_status) {
+				internals->slaves[i].last_link_status =
+						slave_ethdev->data->dev_link.link_status;
+
+				bond_ethdev_lsc_event_callback(internals->slaves[i].port_id,
+						RTE_ETH_EVENT_INTR_LSC,
+						&bonded_ethdev->data->port_id);
+			}
+		}
+		rte_spinlock_unlock(&internals->lock);
+	}
+
+	if (polling_slave_found)
+		/* Set alarm to continue monitoring link status of slave ethdev's */
+		rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
+				bond_ethdev_slave_link_status_change_monitor, cb_arg);
+}
+
 static int
 bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev,
 		int wait_to_complete)
@@ -895,7 +967,7 @@ bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	memset(stats, 0, sizeof(*stats));
 
 	for (i = 0; i < internals->slave_count; i++) {
-		rte_eth_stats_get(internals->slaves[i], &slave_stats);
+		rte_eth_stats_get(internals->slaves[i].port_id, &slave_stats);
 
 		stats->ipackets += slave_stats.ipackets;
 		stats->opackets += slave_stats.opackets;
@@ -921,7 +993,7 @@ bond_ethdev_stats_reset(struct rte_eth_dev *dev)
 	int i;
 
 	for (i = 0; i < internals->slave_count; i++)
-		rte_eth_stats_reset(internals->slaves[i]);
+		rte_eth_stats_reset(internals->slaves[i].port_id);
 }
 
 static void
@@ -940,7 +1012,7 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)
 	case BONDING_MODE_BROADCAST:
 #endif
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_enable(internals->slaves[i]);
+			rte_eth_promiscuous_enable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -966,7 +1038,7 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	case BONDING_MODE_BROADCAST:
 #endif
 		for (i = 0; i < internals->slave_count; i++)
-			rte_eth_promiscuous_disable(internals->slaves[i]);
+			rte_eth_promiscuous_disable(internals->slaves[i].port_id);
 		break;
 	/* Promiscuous mode is propagated only to primary slave */
 	case BONDING_MODE_ACTIVE_BACKUP:
@@ -975,6 +1047,16 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 	}
 }
 
+static void
+bond_ethdev_delayed_lsc_propagation(void *arg)
+{
+	if (arg == NULL)
+		return;
+
+	_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
+			RTE_ETH_EVENT_INTR_LSC);
+}
+
 void
 bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		void *param)
@@ -1003,7 +1085,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 
 	/* verify that port_id is a valid slave of bonded port */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (internals->slaves[i] == port_id) {
+		if (internals->slaves[i].port_id == port_id) {
 			valid_slave = 1;
 			break;
 		}
@@ -1072,8 +1154,32 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		}
 	}
 
-	if (lsc_flag)
-		_rte_eth_dev_callback_process(bonded_eth_dev, RTE_ETH_EVENT_INTR_LSC);
+	if (lsc_flag) {
+		/* Cancel any possible outstanding interrupts if delays are enabled */
+		if (internals->link_up_delay_ms > 0 ||
+			internals->link_down_delay_ms > 0)
+			rte_eal_alarm_cancel(bond_ethdev_delayed_lsc_propagation,
+					bonded_eth_dev);
+
+		if (bonded_eth_dev->data->dev_link.link_status) {
+			if (internals->link_up_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_up_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+
+		} else {
+			if (internals->link_down_delay_ms > 0)
+				rte_eal_alarm_set(internals->link_down_delay_ms * 1000,
+						bond_ethdev_delayed_lsc_propagation,
+						(void *)bonded_eth_dev);
+			else
+				_rte_eth_dev_callback_process(bonded_eth_dev,
+						RTE_ETH_EVENT_INTR_LSC);
+		}
+	}
 }
 
 struct eth_dev_ops default_dev_ops = {
@@ -1223,8 +1329,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(ERR, EAL,
-				"Transmit policy can be specified only once for bonded device %s\n",
-				name);
+				"Transmit policy can be specified only once for bonded device"
+				" %s\n", name);
 		return -1;
 	}
 
@@ -1266,8 +1372,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				&bond_ethdev_parse_primary_slave_port_id_kvarg,
 				&primary_slave_port_id) < 0) {
 			RTE_LOG(INFO, EAL,
-					"Invalid primary slave port id specified for bonded device %s\n",
-					name);
+					"Invalid primary slave port id specified for bonded device"
+					" %s\n", name);
 			return -1;
 		}
 
@@ -1281,8 +1387,97 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(INFO, EAL,
-				"Primary slave can be specified only once for bonded device %s\n",
-				name);
+				"Primary slave can be specified only once for bonded device"
+				" %s\n", name);
+		return -1;
+	}
+
+	/* Parse link status monitor polling interval */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LSC_POLL_PERIOD_KVARG);
+	if (arg_count == 1) {
+		uint32_t lsc_poll_interval_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LSC_POLL_PERIOD_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&lsc_poll_interval_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid lsc polling interval value specified for bonded"
+					"device %s\n", name);
+			return -1;
+		}
+
+		if (rte_eth_bond_link_monitoring_set(port_id, lsc_poll_interval_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set lsc monitor polling interval (%u ms) on"
+					" bonded device %s\n", lsc_poll_interval_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"LSC polling interval can be specified only once for bonded"
+				"device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link up interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_UP_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_up_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_UP_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_up_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link up propagation delay value specified for "
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_up_prop_delay_set(port_id, link_up_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link up propagation delay (%u ms) on bonded"
+					"device %s\n", link_up_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link up propagation delay can be specified only once for "
+				"bonded device %s\n", name);
+		return -1;
+	}
+
+	/* Parse link down interrupt propagation delay */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG);
+	if (arg_count == 1) {
+		uint32_t link_down_delay_ms;
+
+		if (rte_kvargs_process(kvlist,
+				PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG,
+				&bond_ethdev_parse_time_ms_kvarg,
+				&link_down_delay_ms) < 0) {
+			RTE_LOG(INFO, EAL,
+					"Invalid link down propagation delay value specified for"
+					"bonded device %s\n", name);
+			return -1;
+		}
+
+		/* Set balance mode transmit policy*/
+		if (rte_eth_bond_link_down_prop_delay_set(port_id, link_down_delay_ms)
+				!= 0) {
+			RTE_LOG(ERR, EAL,
+					"Failed to set link down propagation delay (%u ms) on"
+					" bonded device %s\n", link_down_delay_ms, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_LOG(INFO, EAL,
+				"Link down propagation delay can be specified only once for"
+				" bonded device %s\n", name);
 		return -1;
 	}
 
diff --git a/lib/librte_pmd_bond/rte_eth_bond_private.h b/lib/librte_pmd_bond/rte_eth_bond_private.h
index 1db6e4d..030d143 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_private.h
+++ b/lib/librte_pmd_bond/rte_eth_bond_private.h
@@ -39,20 +39,27 @@ extern "C" {
 #endif
 
 #include <rte_ethdev.h>
+#include <rte_spinlock.h>
 
 #include "rte_eth_bond.h"
 
-#define PMD_BOND_SLAVE_PORT_KVARG		("slave")
-#define PMD_BOND_PRIMARY_SLAVE_KVARG	("primary")
-#define PMD_BOND_MODE_KVARG				("mode")
-#define PMD_BOND_XMIT_POLICY_KVARG		("xmit_policy")
-#define PMD_BOND_SOCKET_ID_KVARG		("socket_id")
-#define PMD_BOND_MAC_ADDR_KVARG			("mac")
+#define PMD_BOND_SLAVE_PORT_KVARG			("slave")
+#define PMD_BOND_PRIMARY_SLAVE_KVARG		("primary")
+#define PMD_BOND_MODE_KVARG					("mode")
+#define PMD_BOND_XMIT_POLICY_KVARG			("xmit_policy")
+#define PMD_BOND_SOCKET_ID_KVARG			("socket_id")
+#define PMD_BOND_MAC_ADDR_KVARG				("mac")
+#define PMD_BOND_LSC_POLL_PERIOD_KVARG		("lsc_poll_period_ms")
+#define PMD_BOND_LINK_UP_PROP_DELAY_KVARG	("up_delay")
+#define PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG	("down_delay")
 
 #define PMD_BOND_XMIT_POLICY_LAYER2_KVARG	("l2")
 #define PMD_BOND_XMIT_POLICY_LAYER23_KVARG	("l23")
 #define PMD_BOND_XMIT_POLICY_LAYER34_KVARG	("l34")
 
+#define RTE_BOND_LOG(lvl, msg, ...)		\
+	RTE_LOG(lvl, PMD, "%s(%d) - " msg "\n", __func__, __LINE__, ##__VA_ARGS__);
+
 extern const char *pmd_bond_init_valid_arguments[];
 
 extern const char *driver_name;
@@ -82,27 +89,36 @@ struct bond_tx_queue {
 	/**< Copy of TX configuration structure for queue */
 };
 
-/** Persisted Slave Configuration Structure */
-struct slave_conf {
-	uint8_t port_id;
-	/**< Port Id of slave eth_dev */
-	struct ether_addr mac_addr;
-	/**< Slave eth_dev original MAC address */
-};
+
 /** Bonded slave devices structure */
 struct bond_ethdev_slave_ports {
 	uint8_t slaves[RTE_MAX_ETHPORTS];	/**< Slave port id array */
 	uint8_t slave_count;				/**< Number of slaves */
 };
 
+struct bond_slave_details {
+	uint8_t port_id;
+
+	uint8_t link_status_poll_enabled;
+	uint8_t link_status_wait_to_complete;
+	uint8_t last_link_status;
+
+	/**< Port Id of slave eth_dev */
+	struct ether_addr persisted_mac_addr;
+};
+
 /** Link Bonding PMD device private configuration Structure */
 struct bond_dev_private {
+	uint8_t port_id;					/**< Port Id of Bonded Port */
 	uint8_t mode;						/**< Link Bonding Mode */
 
+	rte_spinlock_t lock;
+
 	uint8_t primary_port;				/**< Primary Slave Port */
 	uint8_t current_primary_port;		/**< Primary Slave Port */
 	uint8_t user_defined_primary_port;
 	/**< Flag for whether primary port is user defined or not */
+
 	uint8_t balance_xmit_policy;
 	/**< Transmit policy - l2 / l23 / l34 for operation in balance mode */
 	uint8_t user_defined_mac;
@@ -110,19 +126,23 @@ struct bond_dev_private {
 	uint8_t promiscuous_en;
 	/**< Enabled/disable promiscuous mode on slave devices */
 	uint8_t link_props_set;
-	/**< Bonded eth_dev link properties set */
+	/**< flag to denote if the link properties are set */
+
+	uint8_t link_status_polling_enabled;
+	uint32_t link_status_polling_interval_ms;
+
+	uint32_t link_down_delay_ms;
+	uint32_t link_up_delay_ms;
 
 	uint16_t nb_rx_queues;			/**< Total number of rx queues */
 	uint16_t nb_tx_queues;			/**< Total number of tx queues*/
 
-	uint8_t slave_count;			/**< Number of active slaves */
-	uint8_t active_slave_count;		/**< Number of slaves */
-
+	uint8_t active_slave_count;		/**< Number of active slaves */
 	uint8_t active_slaves[RTE_MAX_ETHPORTS];	/**< Active slave list */
-	uint8_t slaves[RTE_MAX_ETHPORTS];			/**< Slave list */
 
-	/** Persisted configuration of slaves */
-	struct slave_conf presisted_slaves_conf[RTE_MAX_ETHPORTS];
+	uint8_t slave_count;			/**< Number of bonded slaves */
+	struct bond_slave_details slaves[RTE_MAX_ETHPORTS];
+	/**< Arary of bonded slaves details */
 
 	struct rte_kvargs *kvlist;
 };
@@ -168,16 +188,13 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_clear(struct bond_dev_private *internals,
+slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
 void
-slave_config_store(struct bond_dev_private *internals,
+slave_add(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
 
-struct slave_conf *
-slave_config_get(struct bond_dev_private *internals, uint8_t slave_port_id);
-
 void
 bond_ethdev_primary_set(struct bond_dev_private *internals,
 		uint8_t slave_port_id);
@@ -210,6 +227,10 @@ int
 bond_ethdev_parse_bond_mac_addr_kvarg(const char *key __rte_unused,
 		const char *value, void *extra_args);
 
+int
+bond_ethdev_parse_time_ms_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 7/7] bond: unit test test macro refactor
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
                             ` (5 preceding siblings ...)
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 6/7] bond: lsc polling support Declan Doherty
@ 2014-11-24 16:33           ` Declan Doherty
  2014-11-24 18:32           ` [dpdk-dev] [PATCH v8 0/7] link bonding Thomas Monjalon
  2014-11-24 20:54           ` Thomas Monjalon
  8 siblings, 0 replies; 91+ messages in thread
From: Declan Doherty @ 2014-11-24 16:33 UTC (permalink / raw)
  To: dev


Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 app/test/test_link_bonding.c           | 2576 +++++++++++++-------------------
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   16 +-
 2 files changed, 1046 insertions(+), 1546 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 2411125..c040be2 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -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,
@@ -784,56 +716,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();
@@ -847,36 +762,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
@@ -884,32 +787,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] =
@@ -917,56 +815,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;
 }
@@ -974,7 +860,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;
 
@@ -983,87 +869,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;
 }
 
@@ -1179,9 +1040,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_interrupt_count = 0;
 
@@ -1313,10 +1175,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;
 }
@@ -1326,51 +1186,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 */
@@ -1380,10 +1232,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();
@@ -1529,17 +1380,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 */
@@ -1548,21 +1399,18 @@ 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 */
@@ -1571,19 +1419,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 */
@@ -1620,17 +1464,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 */
@@ -1643,55 +1486,42 @@ test_roundrobin_rx_burst_on_multiple_slaves(void)
 	/* 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("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++) {
@@ -1708,91 +1538,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 */
@@ -1805,44 +1621,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 */
@@ -1869,26 +1679,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(
@@ -1896,13 +1702,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;
 
@@ -1913,19 +1718,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,
@@ -1963,27 +1765,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++) {
@@ -2005,7 +1804,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 };
 
@@ -2039,7 +1837,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 */
@@ -2101,15 +1900,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);
@@ -2120,32 +1917,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);
 
@@ -2153,35 +1943,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();
@@ -2199,78 +1982,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);
 			}
 		}
 
@@ -2296,61 +2064,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 */
@@ -2366,117 +2121,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 address");
 
 	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();
@@ -2498,38 +2238,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(
@@ -2537,12 +2271,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);
@@ -2555,106 +2287,84 @@ 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 */
-
 	for (i = 0; i < TEST_ACTIVE_BACKUP_RX_BURST_SLAVE_COUNT; i++) {
 		for (j = 0; j < MAX_PKT_BURST; j++) {
 			if (pkt_burst[i][j] != NULL) {
@@ -2664,7 +2374,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();
 }
@@ -2674,70 +2383,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();
@@ -2752,24 +2440,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);
@@ -2779,54 +2459,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++) {
@@ -2836,9 +2512,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();
@@ -2848,81 +2524,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++) {
@@ -2932,10 +2592,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();
@@ -2976,82 +2636,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++) {
@@ -3061,10 +2705,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();
@@ -3253,21 +2896,23 @@ 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],
@@ -3276,56 +2921,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++) {
@@ -3344,48 +2977,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 */
@@ -3401,115 +3023,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();
@@ -3531,32 +3140,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(
@@ -3564,106 +3168,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;
-	}
+	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);
 
 	/* Send to sets of packet burst and verify that they are balanced across
 	 *  slaves */
 	burst_size = 21;
 
-	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");
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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");
+
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, &pkt_burst[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][0],
-			burst_size) != burst_size) {
-		printf("rte_eth_tx_burst failed\n");
-		return -1;
-	}
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size);
 
 	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 (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[2], (int)port_stats.opackets,
-				burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[2], (int)port_stats.opackets,
+			burst_size);
 
 	/* verify that all packets get send on primary slave when no other slaves
 	 * are available */
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[2], 0);
 
-	if (rte_eth_bond_active_slaves_get(test_params->bonded_port_id, slaves,
-			RTE_MAX_ETHPORTS) != 1) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 1);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_bond_active_slaves_get(
+			test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS), 1,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 1);
 
-	if (generate_test_burst(&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0) !=
-			burst_size) {
-		printf("generate_test_burst failed\n");
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(generate_test_burst(
+			&pkt_burst[1][0], burst_size, 0, 1, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[1][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[1][0], burst_size),
+			burst_size, "rte_eth_tx_burst failed");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size +
-			burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size + burst_size + burst_size);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)(burst_size + burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size + burst_size + burst_size);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size + burst_size)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d).\n",
-				test_params->slave_port_ids[0], (int)port_stats.opackets,
-				burst_size + burst_size);
-		return -1;
-	}
-
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size + burst_size),
+			"(%d) port_stats.opackets (%d) not as expected (%d).",
+			test_params->slave_port_ids[0], (int)port_stats.opackets,
+			burst_size + burst_size);
 
 	virtual_ethdev_simulate_link_status_interrupt(
 			test_params->slave_port_ids[0], 0);
@@ -3675,16 +3253,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 			test_params->slave_port_ids[3], 1);
 
 	for (i = 0; i < TEST_BALANCE_LINK_STATUS_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,
+				"Failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
-
-
 	/* Verify that pkts are not received on slaves with link status down */
 
 	rte_eth_rx_burst(test_params->bonded_port_id, 0, rx_pkt_burst,
@@ -3692,12 +3268,10 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 
 	/* Verify bonded device rx count */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.ipackets != (uint64_t)(burst_size * 3)) {
-		printf("(%d) port_stats.ipackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.ipackets,
-				burst_size * 3);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)(burst_size * 3),
+			"(%d) port_stats.ipackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.ipackets,
+			burst_size * 3);
 
 	/* free mbufs allocate for rx testing */
 	for (i = 0; i < TEST_BALANCE_RX_BURST_SLAVE_COUNT; i++) {
@@ -3719,16 +3293,14 @@ test_balance_verify_slave_link_status_change_behaviour(void)
 static int
 test_broadcast_tx_burst(void)
 {
-	int i, pktlen, retval, burst_size, generated_burst_size, nb_tx;
+	int i, pktlen, burst_size;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 
 	struct rte_eth_stats port_stats;
 
-	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;
-	}
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 2, 1),
+			"Failed to intialise bonded device");
 
 	initialize_eth_header(test_params->pkt_eth_hdr,
 			(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
@@ -3740,46 +3312,37 @@ test_broadcast_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,
+	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);
-	if (generated_burst_size != burst_size)
-		return -1;
+			1), burst_size, "Failed to generate packet burst");
 
 	/* 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) {
-		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);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(test_params->bonded_port_id, 0,
+			pkts_burst, burst_size), burst_size,
+			"Bonded Port (%d) rx burst failed, packets transmitted value "
+			"not as expected (%d)",
+			test_params->bonded_port_id, burst_size);
 
 	/* Verify bonded port tx stats */
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size *
-			test_params->bonded_slave_count) {
-		printf("Bonded Port (%d) opackets value (%u) not as expected (%d)\n",
-				test_params->bonded_port_id, (unsigned int)port_stats.opackets,
-				burst_size);
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets,
+			(uint64_t)burst_size * test_params->bonded_slave_count,
+			"Bonded Port (%d) opackets value (%u) not as expected (%d)",
+			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) {
-			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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+				"Slave Port (%d) opackets value (%u) not as expected (%d)\n",
+				test_params->bonded_port_id,
+				(unsigned int)port_stats.opackets, burst_size);
 	}
 
 	/* Put all slaves down and try and transmit */
@@ -3790,10 +3353,9 @@ 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 != 0)
-		return -1;
+	TEST_ASSERT_EQUAL(rte_eth_tx_burst(
+			test_params->bonded_port_id, 0, pkts_burst, burst_size),  0,
+			"transmitted an unexpected number of packets");
 
 	/* Clean up and remove slaves from bonded device */
 	return remove_slaves_and_stop_bonded_device();
@@ -3929,20 +3491,20 @@ test_broadcast_rx_burst(void)
 	struct rte_eth_stats port_stats;
 
 	int burst_size[BROADCAST_RX_BURST_NUM_OF_SLAVES] = { 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_BROADCAST, 0, 3, 1) != 0)
-		return -1;
-
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 3, 1),
+			"Failed to intialise bonded device");
 
 	/* Generate test bursts of packets to transmit */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; 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 slave 0 */
@@ -3954,57 +3516,44 @@ test_broadcast_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("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[0] + burst_size[1] + burst_size[2],
+			"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[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[0], (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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_RX_BURST_NUM_OF_SLAVES; i++) {
@@ -4023,48 +3572,38 @@ test_broadcast_rx_burst(void)
 static int
 test_broadcast_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_BROADCAST, 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 */
@@ -4076,45 +3615,39 @@ test_broadcast_verify_mac_assignment(void)
 {
 	struct ether_addr read_mac_addr, expected_mac_addr_0, expected_mac_addr_1;
 
-	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_1);
 
 	/* Initialize bonded device with 4 slaves in round robin mode */
-	if (initialize_bonded_device_with_slaves(BONDING_MODE_BROADCAST, 0, 4, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+			BONDING_MODE_BROADCAST, 0, 4, 1),
+			"Failed to intialise bonded device");
 
 	/* Verify that all MACs are the same as first slave added to bonded
 	 * device */
 	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
@@ -4122,45 +3655,41 @@ test_broadcast_verify_mac_assignment(void)
 
 	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 new primary"
-				" port\n", test_params->slave_port_ids[i]);
-		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 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_1, &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_1, &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 address");
 
 	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_params->slave_port_ids[i]);
-		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 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(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", test_params->slave_port_ids[i]);
 	}
 
 	/* Clean up and remove slaves from bonded device */
@@ -4182,26 +3711,22 @@ 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, 0,
-			BROADCAST_LINK_STATUS_NUM_OF_SLAVES, 1) != 0)
-		return -1;
+	TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+				BONDING_MODE_BROADCAST, 0, BROADCAST_LINK_STATUS_NUM_OF_SLAVES,
+				1), "Failed to intialise bonded device");
 
 	/* 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;
-	}
+	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
+			slaves, RTE_MAX_ETHPORTS);
+	TEST_ASSERT_EQUAL(slave_count, 4,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 4);
 
 	/* Set 2 slaves link status to down */
 	virtual_ethdev_simulate_link_status_interrupt(
@@ -4211,11 +3736,9 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 
 	slave_count = rte_eth_bond_active_slaves_get(test_params->bonded_port_id,
 			slaves, RTE_MAX_ETHPORTS);
-	if (slave_count != 2) {
-		printf("Number of active slaves (%d) is not as expected (%d).\n",
-				slave_count, 2);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(slave_count, 2,
+			"Number of active slaves (%d) is not as expected (%d).",
+			slave_count, 2);
 
 	for (i = 0; i < test_params->bonded_slave_count; i++)
 		rte_eth_stats_reset(test_params->slave_port_ids[i]);
@@ -4223,80 +3746,62 @@ test_broadcast_verify_slave_link_status_change_behaviour(void)
 	/* Verify that pkts are not sent on slaves with link status down */
 	burst_size = 21;
 
-	if (generate_test_burst(&pkt_burst[0][0], burst_size, 0, 0, 1, 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, 0, 1, 0, 0), burst_size,
+			"generate_test_burst failed");
 
-	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\n");
 
 	rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
-	if (port_stats.opackets != (uint64_t)(burst_size * slave_count)) {
-		printf("(%d) port_stats.opackets (%d) not as expected (%d)\n",
-				test_params->bonded_port_id, (int)port_stats.opackets,
-				burst_size * slave_count);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)(burst_size * slave_count),
+			"(%d) port_stats.opackets (%d) not as expected (%d)\n",
+			test_params->bonded_port_id, (int)port_stats.opackets,
+			burst_size * slave_count);
 
 	rte_eth_stats_get(test_params->slave_port_ids[0], &port_stats);
-	if (port_stats.opackets != (uint64_t)burst_size) {
-		printf("(%d) port_stats.opackets not as expected\n",
-				test_params->slave_port_ids[0]);
-		return -1;
-	}
+	TEST_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%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_ASSERT_EQUAL(port_stats.opackets, 0,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[1]);
-		return -1;
-	}
 
 	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_ASSERT_EQUAL(port_stats.opackets, (uint64_t)burst_size,
+			"(%d) port_stats.opackets not as expected",
 				test_params->slave_port_ids[2]);
-		return -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]);
+
 
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
-		if (generate_test_burst(&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0) !=
-				burst_size) {
-			return -1;
-		}
+		TEST_ASSERT_EQUAL(generate_test_burst(
+				&pkt_burst[i][0], burst_size, 0, 0, 1, 0, 0),
+				burst_size, "failed to generate packet burst");
 
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->slave_port_ids[i],
 				&pkt_burst[i][0], burst_size);
 	}
 
 	/* Verify that pkts are not received on slaves with link status down */
+	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");
 
-	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;
-	}
 
 	/* 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 allocate for rx testing */
 	for (i = 0; i < BROADCAST_LINK_STATUS_NUM_OF_SLAVES; i++) {
@@ -4319,19 +3824,14 @@ 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)  != 0) {
-		printf("failed to reconfigure bonded device");
-		return -1;
-	}
-
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device");
 
 	test_params->nb_rx_q = 2;
 	test_params->nb_tx_q = 2;
 
-	if (configure_ethdev(test_params->bonded_port_id, 0, 0)  != 0) {
-		printf("failed to reconfigure bonded device with less rx/tx queues");
-		return -1;
-	}
+	TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
+			"failed to reconfigure bonded device with less rx/tx queues");
 
 	return 0;
 }
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index be87390..cf2fbab 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -1403,7 +1403,7 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				&lsc_poll_interval_ms) < 0) {
 			RTE_LOG(INFO, EAL,
 					"Invalid lsc polling interval value specified for bonded"
-					"device %s\n", name);
+					" device %s\n", name);
 			return -1;
 		}
 
@@ -1417,7 +1417,7 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 	} else if (arg_count > 1) {
 		RTE_LOG(INFO, EAL,
 				"LSC polling interval can be specified only once for bonded"
-				"device %s\n", name);
+				" device %s\n", name);
 		return -1;
 	}
 
@@ -1431,8 +1431,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				&bond_ethdev_parse_time_ms_kvarg,
 				&link_up_delay_ms) < 0) {
 			RTE_LOG(INFO, EAL,
-					"Invalid link up propagation delay value specified for "
-					"bonded device %s\n", name);
+					"Invalid link up propagation delay value specified for"
+					" bonded device %s\n", name);
 			return -1;
 		}
 
@@ -1441,13 +1441,13 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				!= 0) {
 			RTE_LOG(ERR, EAL,
 					"Failed to set link up propagation delay (%u ms) on bonded"
-					"device %s\n", link_up_delay_ms, name);
+					" device %s\n", link_up_delay_ms, name);
 			return -1;
 		}
 	} else if (arg_count > 1) {
 		RTE_LOG(INFO, EAL,
-				"Link up propagation delay can be specified only once for "
-				"bonded device %s\n", name);
+				"Link up propagation delay can be specified only once for"
+				" bonded device %s\n", name);
 		return -1;
 	}
 
@@ -1462,7 +1462,7 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				&link_down_delay_ms) < 0) {
 			RTE_LOG(INFO, EAL,
 					"Invalid link down propagation delay value specified for"
-					"bonded device %s\n", name);
+					" bonded device %s\n", name);
 			return -1;
 		}
 
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 0/7] link bonding
  2014-11-24 16:24           ` Doherty, Declan
@ 2014-11-24 17:53             ` Thomas Monjalon
  0 siblings, 0 replies; 91+ messages in thread
From: Thomas Monjalon @ 2014-11-24 17:53 UTC (permalink / raw)
  To: Doherty, Declan; +Cc: dev

2014-11-24 16:24, Doherty, Declan:
> Hey, sorry about that, I submitted the patchset without the typo fix. I'll resubmit the patchset now.
> What version of checkpatch are you using, I don't get any warning for the missing spaces for the
> version of the script with kernel 3.15 on Fedora

I use the last one (3.18-rc6).
There is now a check for common typos. It appears to be really convenient.

-- 
Thomas

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v8 0/7] link bonding
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
                             ` (6 preceding siblings ...)
  2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 7/7] bond: unit test test macro refactor Declan Doherty
@ 2014-11-24 18:32           ` Thomas Monjalon
  2014-11-24 18:51             ` Thomas Monjalon
  2014-11-24 20:54           ` Thomas Monjalon
  8 siblings, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2014-11-24 18:32 UTC (permalink / raw)
  To: Declan Doherty; +Cc: dev

Declan,
There are still some missing spaces:

WARNING:MISSING_SPACE: break quoted strings at a space character
#2002: FILE: lib/librte_pmd_bond/rte_eth_bond_pmd.c:1406:
+                                       "Invalid lsc polling interval value specified for bonded"
+                                       "device %s\n", name);
WARNING:MISSING_SPACE: break quoted strings at a space character
#2016: FILE: lib/librte_pmd_bond/rte_eth_bond_pmd.c:1420:
+                               "LSC polling interval can be specified only once for bonded"
+                               "device %s\n", name);
WARNING:MISSING_SPACE: break quoted strings at a space character
#2040: FILE: lib/librte_pmd_bond/rte_eth_bond_pmd.c:1444:
+                                       "Failed to set link up propagation delay (%u ms) on bonded"
+                                       "device %s\n", link_up_delay_ms, name);
WARNING:MISSING_SPACE: break quoted strings at a space character
#2061: FILE: lib/librte_pmd_bond/rte_eth_bond_pmd.c:1465:
+                                       "Invalid link down propagation delay value specified for"
+                                       "bonded device %s\n", name);
WARNING:MISSING_SPACE: break quoted strings at a space character
#3674: FILE: app/test/test_link_bonding.c:3672:
+                               "slave port (%d) mac address not set to that of new primary"
+                               "port", test_params->slave_port_ids[i]);

I'm fixing it for you because I'm losing confidence all bonding patches will
be ready on time.
Some i40e patches won't be applied today because I spend more time on bonding.
For next release cycle, I'll have to be more strict.

Please Declan, could you be the bonding maintainer and ensure other bonding
patches (mode 4, mode 5, fixes) to come are ready and nothing will delay
their integration?
Thanks
-- 
Thomas

2014-11-24 16:33, Declan Doherty:
> v8:
> - Missing typo fix
> - Missing whitespace
> 
> v7:
> - Fixes for checkpatch issues and typo fixes
> - Removed patch "test app: adding support for generating variable sized" as this
>   was already committed in commit aca4360340f169dcc11b1a9be955b44de8b9f6eb

> Declan Doherty (7):
>   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
>   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

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v8 0/7] link bonding
  2014-11-24 18:32           ` [dpdk-dev] [PATCH v8 0/7] link bonding Thomas Monjalon
@ 2014-11-24 18:51             ` Thomas Monjalon
  0 siblings, 0 replies; 91+ messages in thread
From: Thomas Monjalon @ 2014-11-24 18:51 UTC (permalink / raw)
  To: Declan Doherty; +Cc: dev

2014-11-24 19:32, Thomas Monjalon:
> I'm fixing it for you because I'm losing confidence all bonding patches will
> be ready on time.

I've just understood what happened.
I think it's a wrong git manipulation: the fixes were squashed in the last
commit, so the patch 6/7 was still having issues.

-- 
Thomas

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v8 0/7] link bonding
  2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
                             ` (7 preceding siblings ...)
  2014-11-24 18:32           ` [dpdk-dev] [PATCH v8 0/7] link bonding Thomas Monjalon
@ 2014-11-24 20:54           ` Thomas Monjalon
  2014-11-25 10:56             ` Jastrzebski, MichalX K
  8 siblings, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2014-11-24 20:54 UTC (permalink / raw)
  To: Declan Doherty; +Cc: dev

2014-11-24 16:33, Declan Doherty:
> v8:
> - Missing typo fix
> - Missing whitespace
> 
> v7:
> - Fixes for checkpatch issues and typo fixes
> - Removed patch "test app: adding support for generating variable sized" as this
>   was already committed in commit aca4360340f169dcc11b1a9be955b44de8b9f6eb
>   
> v6:
> - Re-based to dpdk.org addressing associated issues for MBUF_REFCNT
> - Added details to testpmd user guide for new command to set link status polling interval.
> 
> 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:
> - Re-based 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.
> - Re-based 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 (7):
>   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
>   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

Applied with some minor fixes.

Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v8 0/7] link bonding
  2014-11-24 20:54           ` Thomas Monjalon
@ 2014-11-25 10:56             ` Jastrzebski, MichalX K
  2014-11-25 11:20               ` Thomas Monjalon
  0 siblings, 1 reply; 91+ messages in thread
From: Jastrzebski, MichalX K @ 2014-11-25 10:56 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Monday, November 24, 2014 9:54 PM
> To: Doherty, Declan
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v8 0/7] link bonding
> 
> 2014-11-24 16:33, Declan Doherty:
> > v8:
> > - Missing typo fix
> > - Missing whitespace
> >
> > v7:
> > - Fixes for checkpatch issues and typo fixes
> > - Removed patch "test app: adding support for generating variable sized" as
> this
> >   was already committed in commit
> aca4360340f169dcc11b1a9be955b44de8b9f6eb
> >
> > v6:
> > - Re-based to dpdk.org addressing associated issues for MBUF_REFCNT
> > - Added details to testpmd user guide for new command to set link status
> polling interval.
> >
> > 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:
> > - Re-based 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.
> > - Re-based 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 (7):
> >   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
> >   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
> 
> Applied with some minor fixes.
> 
> Thanks
> --
> Thomas

Hi Thomas,
I noticed some problems with applying link bonding mode 4 patches after you applied Declan's patches. 
Link bonding mode 4 0001-bond-add-mode-4-support.patch won't apply because of this error:
Checking patch lib/librte_pmd_bond/rte_eth_bond_private.h...
error: while searching for:
#define RTE_BOND_LOG(lvl, msg, ...)             \
        RTE_LOG(lvl, PMD, "%s(%d) - " msg "\n", __func__, __LINE__, ##__VA_ARGS__);

extern const char *pmd_bond_init_valid_arguments[];

extern const char *driver_name;

error: patch failed: lib/librte_pmd_bond/rte_eth_bond_private.h:60
error: lib/librte_pmd_bond/rte_eth_bond_private.h: patch does not apply

This happens because originally in Declan's [PATCH v8 6/7] bond: lsc polling support there is a semicolon
at the end of RTE_LOG... line , and my patch is looking for this semicolon also. 
So do you want me to send a v6 patch fixing this issue?

The second issue is that Link bonding mode 4 0002-testpmd-add-mode-4-support.patch won't
apply also, because of this error;
error: while searching for:
                /* Update number of ports */
                nb_ports = rte_eth_dev_count();
                reconfig(port_id, res->socket);
                rte_eth_promiscuous_enable(port_id);
        }


error: patch failed: app/test-pmd/cmdline.c:3646
error: app/test-pmd/cmdline.c: patch does not apply

This is probably because you didn't apply Declan's patch:
[PATCH v8 5/7] testpmd: adding parameter to reconfig

This is a part of this patch:
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4c3fc76..be12c13 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3642,7 +3642,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);
 	}

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v8 0/7] link bonding
  2014-11-25 10:56             ` Jastrzebski, MichalX K
@ 2014-11-25 11:20               ` Thomas Monjalon
  0 siblings, 0 replies; 91+ messages in thread
From: Thomas Monjalon @ 2014-11-25 11:20 UTC (permalink / raw)
  To: Jastrzebski, MichalX K; +Cc: dev

2014-11-25 10:56, Jastrzebski, MichalX K:
> I noticed some problems with applying link bonding mode 4 patches after you applied Declan's patches. 
> Link bonding mode 4 0001-bond-add-mode-4-support.patch won't apply because of this error:
> Checking patch lib/librte_pmd_bond/rte_eth_bond_private.h...
> error: while searching for:
> #define RTE_BOND_LOG(lvl, msg, ...)             \
>         RTE_LOG(lvl, PMD, "%s(%d) - " msg "\n", __func__, __LINE__, ##__VA_ARGS__);
> 
> extern const char *pmd_bond_init_valid_arguments[];
> 
> extern const char *driver_name;
> 
> error: patch failed: lib/librte_pmd_bond/rte_eth_bond_private.h:60
> error: lib/librte_pmd_bond/rte_eth_bond_private.h: patch does not apply
> 
> This happens because originally in Declan's [PATCH v8 6/7] bond: lsc polling support there is a semicolon
> at the end of RTE_LOG... line , and my patch is looking for this semicolon also. 
> So do you want me to send a v6 patch fixing this issue?

I can fix this type of conflict by myself but I want you send a v6
because v5 had no commit log.
I want also a review from Declan. If it's already done, please add the acked-by
in your patch.

> The second issue is that Link bonding mode 4 0002-testpmd-add-mode-4-support.patch won't
> apply also, because of this error;
> error: while searching for:
>                 /* Update number of ports */
>                 nb_ports = rte_eth_dev_count();
>                 reconfig(port_id, res->socket);
>                 rte_eth_promiscuous_enable(port_id);
>         }
> 
> 
> error: patch failed: app/test-pmd/cmdline.c:3646
> error: app/test-pmd/cmdline.c: patch does not apply
> 
> This is probably because you didn't apply Declan's patch:
> [PATCH v8 5/7] testpmd: adding parameter to reconfig

Oh yes ! It's totally my fault. The patch has mysteriously disappeared.
It's fixed now.

Thanks for reporting
-- 
Thomas

^ permalink raw reply	[flat|nested] 91+ messages in thread

end of thread, other threads:[~2014-11-25 11:10 UTC | newest]

Thread overview: 91+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
2014-08-19 13:51 ` [dpdk-dev] [PATCH 1/6] bond: link status interrupt support Declan Doherty
2014-08-20 20:24   ` Sanford, Robert
2014-08-19 13:51 ` [dpdk-dev] [PATCH 2/6] bond: removing switch statement from rx burst method Declan Doherty
2014-08-20 20:25   ` Sanford, Robert
2014-08-19 13:51 ` [dpdk-dev] [PATCH 3/6] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-08-20 20:25   ` Sanford, Robert
2014-08-19 13:51 ` [dpdk-dev] [PATCH 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-08-19 13:51 ` [dpdk-dev] [PATCH 5/6] test app: adding support for generating variable sized packets Declan Doherty
2014-08-19 13:51 ` [dpdk-dev] [PATCH 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-08-22  7:41 ` [dpdk-dev] [PATCH 0/6] link bonding Jiajia, SunX
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 " Declan Doherty
2014-09-02 13:31   ` De Lara Guarch, Pablo
2014-09-02 18:15   ` Stephen Hemminger
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 1/6] bond: link status interrupt support Declan Doherty
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 2/6] bond: removing switch statement from rx burst method Declan Doherty
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 3/6] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-09-02  9:22   ` Doherty, Declan
2014-09-02  9:31     ` Thomas Monjalon
2014-09-23 13:18   ` [dpdk-dev] [PATCH v3 0/5] link bonding Declan Doherty
2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 1/5] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 2/5] test app: adding support for generating variable sized packet Declan Doherty
2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 3/5] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 4/5] bond: lsc polling support Declan Doherty
2014-09-24 13:16       ` Ananyev, Konstantin
2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 5/5] bond: unit test test macro refactor Declan Doherty
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 5/6] test app: adding support for generating variable sized packets Declan Doherty
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 1/8] bond: link status interrupt support Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 2/8] bond: removing switch statement from rx burst method Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-10-13 15:29     ` De Lara Guarch, Pablo
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 5/8] test app: adding support for generating variable sized packet bursts Declan Doherty
2014-10-24  3:22     ` Liang, Cunming
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 7/8] bond: lsc polling support Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 8/8] bond: unit test test macro refactor Declan Doherty
2014-10-08  8:49   ` [dpdk-dev] [PATCH v4 0/8] link bonding Jiajia, SunX
2014-10-09 19:20   ` De Lara Guarch, Pablo
2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 1/8] bond: link status interrupt support Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 2/8] bond: removing switch statement from rx burst method Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 5/8] test app: adding support for generating variable sized packet Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 7/8] bond: lsc polling support Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 8/8] bond: unit test test macro refactor Declan Doherty
2014-10-14 15:59     ` [dpdk-dev] [PATCH v5 0/8] link bonding De Lara Guarch, Pablo
2014-11-05  3:10     ` Jiajia, SunX
2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 1/8] bond: link status interrupt support Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 2/8] bond: removing switch statement from rx burst method Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 5/8] test app: adding support for generating variable sized packet Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 7/8] bond: lsc polling support Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 8/8] bond: unit test test macro refactor Declan Doherty
2014-11-07 16:40       ` [dpdk-dev] [PATCH v6 0/8] link bonding De Lara Guarch, Pablo
2014-11-21 17:07         ` Doherty, Declan
2014-11-21 18:36           ` Thomas Monjalon
2014-11-23 13:40             ` Thomas Monjalon
2014-11-21  8:59       ` Jiajia, SunX
2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 1/7] bond: link status interrupt support Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 2/7] bond: removing switch statement from rx burst method Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 3/7] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 4/7] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 5/7] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 6/7] bond: lsc polling support Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 7/7] bond: unit test test macro refactor Declan Doherty
2014-11-24 15:35         ` [dpdk-dev] [PATCH v7 0/7] link bonding Thomas Monjalon
2014-11-24 16:24           ` Doherty, Declan
2014-11-24 17:53             ` Thomas Monjalon
2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 1/7] bond: link status interrupt support Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 2/7] bond: removing switch statement from rx burst method Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 3/7] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 4/7] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 5/7] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 6/7] bond: lsc polling support Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 7/7] bond: unit test test macro refactor Declan Doherty
2014-11-24 18:32           ` [dpdk-dev] [PATCH v8 0/7] link bonding Thomas Monjalon
2014-11-24 18:51             ` Thomas Monjalon
2014-11-24 20:54           ` Thomas Monjalon
2014-11-25 10:56             ` Jastrzebski, MichalX K
2014-11-25 11:20               ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).