From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 5E7191B73C for ; Sat, 27 Apr 2019 00:30:42 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3QMBTHQ004178; Fri, 26 Apr 2019 15:30:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=FxRy1+H5j3p7sl5DX5Sc1K7Fw+JrAs9ml4wwe+iLij8=; b=JM9Q7cpcTQLYDHYe3SDn3QGgMagj5Qjwm3L+ltLuTUFVGO7WtwMPEfR3pmsErCVvqRgM 9DDOu+kAw9BjUecsEey9smcCVNSM/W1VyrY8RIuGQuaBk1ZKUL+5rpKXG5mZ2vM/FbNU 9KfRYHmvir/tc2Q7HlQKdVRWrWY8EJE6cVnzWcIxcuCR7roMxTDRls6YwUprtrG40euy BgM4T8qZV6CpalQzNFFCUmEoMtom/zXcklC0MBvyIOAFBnmclVWzMMd76oPJiNj3klhC wCc9SJtHkgsMqh5xEDsCCqKPbd17eREPKuaZqLFT0CkRxzPF8EiHczD/CUChcexeReSz PQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2s3g4kne1n-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 26 Apr 2019 15:30:41 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 26 Apr 2019 15:30:38 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 26 Apr 2019 15:30:38 -0700 Received: from kk-box-0.marvell.com (unknown [10.95.131.77]) by maili.marvell.com (Postfix) with ESMTP id 216DF3F703F; Fri, 26 Apr 2019 15:30:36 -0700 (PDT) From: To: CC: Krzysztof Kanas , Date: Sat, 27 Apr 2019 00:30:29 +0200 Message-ID: <20190426223029.23677-1-kkanas@marvell.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-26_15:, , signatures=0 Subject: [dpdk-dev] [PATCH] net/bonding: fix test bonding MAC assignment X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 22:30:42 -0000 From: Krzysztof Kanas Fix test_set_bonded_port_initialization_mac_assignment so that it works after 're run' test_link_bonding. Fixes: f2ef6f21ee2e ("bond: fix mac assignment to slaves") Cc: declan.doherty@intel.com Signed-off-by: Krzysztof Kanas --- app/test/test_link_bonding.c | 53 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c index 0fe1d78eb0f5..c00ec6c445bd 100644 --- a/app/test/test_link_bonding.c +++ b/app/test/test_link_bonding.c @@ -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, -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 71560A05D3 for ; Sat, 27 Apr 2019 00:30:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 62DC91B73E; Sat, 27 Apr 2019 00:30:44 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 5E7191B73C for ; Sat, 27 Apr 2019 00:30:42 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3QMBTHQ004178; Fri, 26 Apr 2019 15:30:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=FxRy1+H5j3p7sl5DX5Sc1K7Fw+JrAs9ml4wwe+iLij8=; b=JM9Q7cpcTQLYDHYe3SDn3QGgMagj5Qjwm3L+ltLuTUFVGO7WtwMPEfR3pmsErCVvqRgM 9DDOu+kAw9BjUecsEey9smcCVNSM/W1VyrY8RIuGQuaBk1ZKUL+5rpKXG5mZ2vM/FbNU 9KfRYHmvir/tc2Q7HlQKdVRWrWY8EJE6cVnzWcIxcuCR7roMxTDRls6YwUprtrG40euy BgM4T8qZV6CpalQzNFFCUmEoMtom/zXcklC0MBvyIOAFBnmclVWzMMd76oPJiNj3klhC wCc9SJtHkgsMqh5xEDsCCqKPbd17eREPKuaZqLFT0CkRxzPF8EiHczD/CUChcexeReSz PQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2s3g4kne1n-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 26 Apr 2019 15:30:41 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 26 Apr 2019 15:30:38 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 26 Apr 2019 15:30:38 -0700 Received: from kk-box-0.marvell.com (unknown [10.95.131.77]) by maili.marvell.com (Postfix) with ESMTP id 216DF3F703F; Fri, 26 Apr 2019 15:30:36 -0700 (PDT) From: To: CC: Krzysztof Kanas , Date: Sat, 27 Apr 2019 00:30:29 +0200 Message-ID: <20190426223029.23677-1-kkanas@marvell.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="UTF-8" X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-26_15:, , signatures=0 Subject: [dpdk-dev] [PATCH] net/bonding: fix test bonding MAC assignment X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190426223029.VsE0yK54xIbA7J99Jmiu8yNK9hO0hk5lytXycYy1TZQ@z> From: Krzysztof Kanas Fix test_set_bonded_port_initialization_mac_assignment so that it works after 're run' test_link_bonding. Fixes: f2ef6f21ee2e ("bond: fix mac assignment to slaves") Cc: declan.doherty@intel.com Signed-off-by: Krzysztof Kanas --- app/test/test_link_bonding.c | 53 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c index 0fe1d78eb0f5..c00ec6c445bd 100644 --- a/app/test/test_link_bonding.c +++ b/app/test/test_link_bonding.c @@ -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, -- 2.20.1