net/bonding: fix test bonding MAC assignment
PATCH 1/1 net/bonding: fix test bonding MAC assignment
From: Krzysztof Kanas <[email protected]>
Fix test_set_bonded_port_initialization_mac_assignment so that it works after 're run' test_link_bonding.
--- app/test/test_link_bonding.c | 53 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-)
app/test/test_link_bonding.c +31 -22
@@ -201,6 +201,7 @@ configure_ethdev(uint16_t port_id, uint8_t start, uint8_t en_isr) }static int slaves_initialized; +static int mac_slaves_initialized;static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;static pthread_cond_t cvar =PTHREAD_COND_INITIALIZER ;
@@ -873,10 +874,11 @@ test_set_explicit_bonded_mac(void)static int test_set_bonded_port_initialization_mac_assignment (void ) { -int i, slave_count, bonded_port_id; +int i, slave_count;uint16_t slaves[RTE_MAX_ETHPORTS ]; -int slave_port_ids[BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ]; +static int bonded_port_id =-1 ; +static int slave_port_ids[BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ];struct ether_addr slave_mac_addr, bonded_mac_addr, read_mac_addr;
@@ -887,42 +889,49 @@ test_set_bonded_port_initialization_mac_assignment(void)/* * 1. a - Create / configure bonded / slave ethdevs */ - bonded_port_id =rte_eth_bond_create ("net_bonding_mac_ass_test" , -BONDING_MODE_ACTIVE_BACKUP ,rte_socket_id ()); -TEST_ASSERT (bonded_port_id >0 ,"failed to create bonded device" ); +if (bonded_port_id ==-1 ) { + bonded_port_id =rte_eth_bond_create ("net_bonding_mac_ass_test" , +BONDING_MODE_ACTIVE_BACKUP ,rte_socket_id ()); +TEST_ASSERT (bonded_port_id >0 ,"failed to create bonded device" ); -TEST_ASSERT_SUCCESS (configure_ethdev (bonded_port_id,0 ,0 ), -"Failed to configure bonded ethdev" ); +TEST_ASSERT_SUCCESS (configure_ethdev (bonded_port_id,0 ,0 ), +"Failed to configure bonded ethdev" ); + } -for (i =0 ; i <BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ; i++) { -char pmd_name[RTE_ETH_NAME_MAX_LEN ]; +if (!mac_slaves_initialized) { - slave_mac_addr.addr_bytes[ETHER_ADDR_LEN -1 ] = i +100 ; +for (i =0 ; i <BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ; i++) { +char pmd_name[RTE_ETH_NAME_MAX_LEN ]; -snprintf (pmd_name,RTE_ETH_NAME_MAX_LEN ,"eth_slave_%d" , i); + slave_mac_addr.addr_bytes[ETHER_ADDR_LEN -1 ] = i +100 ; - slave_port_ids[i] =virtual_ethdev_create (pmd_name, - &slave_mac_addr,rte_socket_id (),1 ); +snprintf (pmd_name,RTE_ETH_NAME_MAX_LEN , +"eth_slave_%d" , i); -TEST_ASSERT (slave_port_ids[i] >=0 , -"Failed to create slave ethdev %s" , pmd_name); + slave_port_ids[i] =virtual_ethdev_create (pmd_name, + &slave_mac_addr,rte_socket_id (),1 ); -TEST_ASSERT_SUCCESS (configure_ethdev (slave_port_ids[i],1 ,0 ), -"Failed to configure virtual ethdev %s" , - pmd_name); - } +TEST_ASSERT (slave_port_ids[i] >=0 , +"Failed to create slave ethdev %s" , + pmd_name); +TEST_ASSERT_SUCCESS (configure_ethdev ( + slave_port_ids[i],1 ,0 ), +"Failed to configure virtual ethdev %s" , + pmd_name); + } + mac_slaves_initialized =1 ; + }/* -* 2. Add slave ethdevs to bonded device -*/ +* 2. Add slave ethdevs to bonded device +*/ for (i =0 ; i <BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ; i++) {TEST_ASSERT_SUCCESS (rte_eth_bond_slave_add (bonded_port_id, slave_port_ids[i]),"Failed to add slave (%d) to bonded port (%d)." , slave_port_ids[i], bonded_port_id); } - slave_count =rte_eth_bond_slaves_get (bonded_port_id, slaves,RTE_MAX_ETHPORTS ); TEST_ASSERT_EQUAL(BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT, slave_count,
Signature · 1 line
2.20.1
Quoted 9 lines · On 4/26/2019 11:30 PM, [email protected] wrote:
From: Krzysztof Kanas <[email protected]>
Fix
test_set_bonded_port_initialization_mac_assignmentso that it works after 're run'test_link_bonding.Fixes f2ef6f21ee2e ("bond: fix mac assignment to slaves")Signed-off-by Krzysztof Kanas <[email protected]>
cc'ed maintainer, Chas.
Quoted 101 lines
--- app/test/test_link_bonding.c | 53 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-)app/test/test_link_bonding.c +31
-22@@ -201,6 +201,7 @@ configure_ethdev(uint16_t port_id, uint8_t start, uint8_t en_isr) }static int slaves_initialized; +static int mac_slaves_initialized;static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;static pthread_cond_t cvar =PTHREAD_COND_INITIALIZER ;@@ -873,10 +874,11 @@ test_set_explicit_bonded_mac(void)static int test_set_bonded_port_initialization_mac_assignment (void ) { -int i, slave_count, bonded_port_id; +int i, slave_count;uint16_t slaves[RTE_MAX_ETHPORTS ]; -int slave_port_ids[BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ]; +static int bonded_port_id =-1 ; +static int slave_port_ids[BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ];struct ether_addr slave_mac_addr, bonded_mac_addr, read_mac_addr;@@ -887,42 +889,49 @@ test_set_bonded_port_initialization_mac_assignment(void)/* * 1. a - Create / configure bonded / slave ethdevs */ - bonded_port_id =rte_eth_bond_create ("net_bonding_mac_ass_test" , -BONDING_MODE_ACTIVE_BACKUP ,rte_socket_id ()); -TEST_ASSERT (bonded_port_id >0 ,"failed to create bonded device" ); +if (bonded_port_id ==-1 ) { + bonded_port_id =rte_eth_bond_create ("net_bonding_mac_ass_test" , +BONDING_MODE_ACTIVE_BACKUP ,rte_socket_id ()); +TEST_ASSERT (bonded_port_id >0 ,"failed to create bonded device" ); -TEST_ASSERT_SUCCESS (configure_ethdev (bonded_port_id,0 ,0 ), -"Failed to configure bonded ethdev" ); +TEST_ASSERT_SUCCESS (configure_ethdev (bonded_port_id,0 ,0 ), +"Failed to configure bonded ethdev" ); + } -for (i =0 ; i <BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ; i++) { -char pmd_name[RTE_ETH_NAME_MAX_LEN ]; +if (!mac_slaves_initialized) { - slave_mac_addr.addr_bytes[ETHER_ADDR_LEN -1 ] = i +100 ; +for (i =0 ; i <BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ; i++) { +char pmd_name[RTE_ETH_NAME_MAX_LEN ]; -snprintf (pmd_name,RTE_ETH_NAME_MAX_LEN ,"eth_slave_%d" , i); + slave_mac_addr.addr_bytes[ETHER_ADDR_LEN -1 ] = i +100 ; - slave_port_ids[i] =virtual_ethdev_create (pmd_name, - &slave_mac_addr,rte_socket_id (),1 ); +snprintf (pmd_name,RTE_ETH_NAME_MAX_LEN , +"eth_slave_%d" , i); -TEST_ASSERT (slave_port_ids[i] >=0 , -"Failed to create slave ethdev %s" , pmd_name); + slave_port_ids[i] =virtual_ethdev_create (pmd_name, + &slave_mac_addr,rte_socket_id (),1 ); -TEST_ASSERT_SUCCESS (configure_ethdev (slave_port_ids[i],1 ,0 ), -"Failed to configure virtual ethdev %s" , - pmd_name); - } +TEST_ASSERT (slave_port_ids[i] >=0 , +"Failed to create slave ethdev %s" , + pmd_name); +TEST_ASSERT_SUCCESS (configure_ethdev ( + slave_port_ids[i],1 ,0 ), +"Failed to configure virtual ethdev %s" , + pmd_name); + } + mac_slaves_initialized =1 ; + }/* -* 2. Add slave ethdevs to bonded device -*/ +* 2. Add slave ethdevs to bonded device +*/ for (i =0 ; i <BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ; i++) {TEST_ASSERT_SUCCESS (rte_eth_bond_slave_add (bonded_port_id, slave_port_ids[i]),"Failed to add slave (%d) to bonded port (%d)." , slave_port_ids[i], bonded_port_id); } - slave_count =rte_eth_bond_slaves_get (bonded_port_id, slaves,RTE_MAX_ETHPORTS ); TEST_ASSERT_EQUAL(BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT, slave_count,
Chas Williams
Acked-bySeems fine.
Quoted 115 lines · Ferruh Yigit
Quoted 9 lines · On 4/26/2019 11:30 PM, [email protected] wrote:
From: Krzysztof Kanas <[email protected]>
Fix
test_set_bonded_port_initialization_mac_assignmentso that it works after 're run'test_link_bonding.Fixes f2ef6f21ee2e ("bond: fix mac assignment to slaves")Signed-off-by Krzysztof Kanas <[email protected]>cc'ed maintainer, Chas.
Quoted 101 lines
--- app/test/test_link_bonding.c | 53 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-)app/test/test_link_bonding.c +31
-22@@ -201,6 +201,7 @@ configure_ethdev(uint16_t port_id, uint8_t start, uint8_t en_isr) }static int slaves_initialized; +static int mac_slaves_initialized;static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;static pthread_cond_t cvar =PTHREAD_COND_INITIALIZER ;@@ -873,10 +874,11 @@ test_set_explicit_bonded_mac(void)static int test_set_bonded_port_initialization_mac_assignment (void ) { -int i, slave_count, bonded_port_id; +int i, slave_count;uint16_t slaves[RTE_MAX_ETHPORTS ]; -int slave_port_ids[BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ]; +static int bonded_port_id =-1 ; +static int slave_port_ids[BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ];struct ether_addr slave_mac_addr, bonded_mac_addr, read_mac_addr;@@ -887,42 +889,49 @@ test_set_bonded_port_initialization_mac_assignment(void)/* * 1. a - Create / configure bonded / slave ethdevs */ - bonded_port_id =rte_eth_bond_create ("net_bonding_mac_ass_test" , -BONDING_MODE_ACTIVE_BACKUP ,rte_socket_id ()); -TEST_ASSERT (bonded_port_id >0 ,"failed to create bonded device" ); +if (bonded_port_id ==-1 ) { + bonded_port_id =rte_eth_bond_create ("net_bonding_mac_ass_test" , +BONDING_MODE_ACTIVE_BACKUP ,rte_socket_id ()); +TEST_ASSERT (bonded_port_id >0 ,"failed to create bonded device" ); -TEST_ASSERT_SUCCESS (configure_ethdev (bonded_port_id,0 ,0 ), -"Failed to configure bonded ethdev" ); +TEST_ASSERT_SUCCESS (configure_ethdev (bonded_port_id,0 ,0 ), +"Failed to configure bonded ethdev" ); + } -for (i =0 ; i <BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ; i++) { -char pmd_name[RTE_ETH_NAME_MAX_LEN ]; +if (!mac_slaves_initialized) { - slave_mac_addr.addr_bytes[ETHER_ADDR_LEN -1 ] = i +100 ; +for (i =0 ; i <BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ; i++) { +char pmd_name[RTE_ETH_NAME_MAX_LEN ]; -snprintf (pmd_name,RTE_ETH_NAME_MAX_LEN ,"eth_slave_%d" , i); + slave_mac_addr.addr_bytes[ETHER_ADDR_LEN -1 ] = i +100 ; - slave_port_ids[i] =virtual_ethdev_create (pmd_name, - &slave_mac_addr,rte_socket_id (),1 ); +snprintf (pmd_name,RTE_ETH_NAME_MAX_LEN , +"eth_slave_%d" , i); -TEST_ASSERT (slave_port_ids[i] >=0 , -"Failed to create slave ethdev %s" , pmd_name); + slave_port_ids[i] =virtual_ethdev_create (pmd_name, + &slave_mac_addr,rte_socket_id (),1 ); -TEST_ASSERT_SUCCESS (configure_ethdev (slave_port_ids[i],1 ,0 ), -"Failed to configure virtual ethdev %s" , - pmd_name); - } +TEST_ASSERT (slave_port_ids[i] >=0 , +"Failed to create slave ethdev %s" , + pmd_name); +TEST_ASSERT_SUCCESS (configure_ethdev ( + slave_port_ids[i],1 ,0 ), +"Failed to configure virtual ethdev %s" , + pmd_name); + } + mac_slaves_initialized =1 ; + }/* -* 2. Add slave ethdevs to bonded device -*/ +* 2. Add slave ethdevs to bonded device +*/ for (i =0 ; i <BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ; i++) {TEST_ASSERT_SUCCESS (rte_eth_bond_slave_add (bonded_port_id, slave_port_ids[i]),"Failed to add slave (%d) to bonded port (%d)." , slave_port_ids[i], bonded_port_id); } - slave_count =rte_eth_bond_slaves_get (bonded_port_id, slaves,RTE_MAX_ETHPORTS ); TEST_ASSERT_EQUAL(BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT, slave_count,
Ferruh Yigit
AppliedQuoted 3 lines · Chas Williams
Seems fine.
Acked-by Chas Williams <[email protected]>
Applied to dpdk-next-net/master, thanks.
Quoted 12 lines · Ferruh Yigit
Quoted 10 lines · On 4/26/2019 11:30 PM, [email protected] wrote:
Quoted 9 lines
From: Krzysztof Kanas <[email protected]>
Fix
test_set_bonded_port_initialization_mac_assignmentso that it works after 're run'test_link_bonding.Fixes f2ef6f21ee2e ("bond: fix mac assignment to slaves")Signed-off-by Krzysztof Kanas <[email protected]>
Changed patch title as: "app/test: fix test bonding MAC assignment"
<...>
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
/*
app/test/test_link_bonding.c +2
-2-* 2. Add slave ethdevs to bonded device -*/ +* 2. Add slave ethdevs to bonded device +*/ for (i =0 ; i <BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT ; i++) {
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(bonded_port_id,
slave_port_ids[i]),
"Failed to add slave (%d) to bonded port (%d).", slave_port_ids[i],bonded_port_id);
}
-
slave_count= rte_eth_bond_slaves_get(bonded_port_id, slaves,
RTE_MAX_ETHPORTS);
Removed these unrelated whitespace changes and did a few syntax update while merging.