}
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;
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;
/*
* 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) {
+ for (i = 0; i < BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT; i++) {
+ char pmd_name[RTE_ETH_NAME_MAX_LEN];
- slave_mac_addr.addr_bytes[ETHER_ADDR_LEN-1] = i + 100;
+ slave_mac_addr.addr_bytes[ETHER_ADDR_LEN-1] = i + 100;
- snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_slave_%d", i);
+ snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN,
+ "eth_slave_%d", i);
- slave_port_ids[i] = virtual_ethdev_create(pmd_name,
- &slave_mac_addr, rte_socket_id(), 1);
+ slave_port_ids[i] = virtual_ethdev_create(pmd_name,
+ &slave_mac_addr, rte_socket_id(), 1);
- TEST_ASSERT(slave_port_ids[i] >= 0,
- "Failed to create slave 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);
+ TEST_ASSERT_SUCCESS(configure_ethdev(slave_port_ids[i], 1, 0),
+ "Failed to configure virtual ethdev %s",
+ pmd_name);
+ }
+ mac_slaves_initialized = 1;
}