From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1FDA4A0C41; Wed, 17 Nov 2021 09:23:23 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 64B2141150; Wed, 17 Nov 2021 09:22:55 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id D8D0741150 for ; Wed, 17 Nov 2021 09:22:53 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6C1526D; Wed, 17 Nov 2021 00:22:53 -0800 (PST) Received: from net-arm-n1amp-02.shanghai.arm.com (net-arm-n1amp-02.shanghai.arm.com [10.169.210.110]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4EDAE3F5A1; Wed, 17 Nov 2021 00:22:51 -0800 (PST) From: Joyce Kong To: Xiaoyun Li Cc: dev@dpdk.org, honnappa.nagarahalli@arm.com, nd@arm.com, Joyce Kong , Ruifeng Wang Subject: [PATCH v3 10/12] app/testpmd: remove atomic operations for port status Date: Wed, 17 Nov 2021 08:21:58 +0000 Message-Id: <20211117082200.1029621-11-joyce.kong@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117082200.1029621-1-joyce.kong@arm.com> References: <20211116094205.750359-1-joyce.kong@arm.com> <20211117082200.1029621-1-joyce.kong@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The port_status changes do not need to be handled atomically, as they are modified during initialization or through the testpmd prompt instead of multiple threads. Signed-off-by: Joyce Kong Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli --- app/test-pmd/testpmd.c | 58 ++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index a66dfb297c..ed472cacd2 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -2521,9 +2520,9 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi) continue; /* Fail to setup rx queue, return */ - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_HANDLING, - RTE_PORT_STOPPED) == 0) + if (port->port_status == RTE_PORT_HANDLING) + port->port_status = RTE_PORT_STOPPED; + else fprintf(stderr, "Port %d can not be set back to stopped\n", pi); fprintf(stderr, "Fail to configure port %d hairpin queues\n", @@ -2544,9 +2543,9 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi) continue; /* Fail to setup rx queue, return */ - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_HANDLING, - RTE_PORT_STOPPED) == 0) + if (port->port_status == RTE_PORT_HANDLING) + port->port_status = RTE_PORT_STOPPED; + else fprintf(stderr, "Port %d can not be set back to stopped\n", pi); fprintf(stderr, "Fail to configure port %d hairpin queues\n", @@ -2729,8 +2728,9 @@ start_port(portid_t pid) need_check_link_status = 0; port = &ports[pi]; - if (rte_atomic16_cmpset(&(port->port_status), RTE_PORT_STOPPED, - RTE_PORT_HANDLING) == 0) { + if (port->port_status == RTE_PORT_STOPPED) + port->port_status = RTE_PORT_HANDLING; + else { fprintf(stderr, "Port %d is now not stopped\n", pi); continue; } @@ -2766,8 +2766,9 @@ start_port(portid_t pid) nb_txq + nb_hairpinq, &(port->dev_conf)); if (diag != 0) { - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0) + if (port->port_status == RTE_PORT_HANDLING) + port->port_status = RTE_PORT_STOPPED; + else fprintf(stderr, "Port %d can not be set back to stopped\n", pi); @@ -2828,9 +2829,9 @@ start_port(portid_t pid) continue; /* Fail to setup tx queue, return */ - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_HANDLING, - RTE_PORT_STOPPED) == 0) + if (port->port_status == RTE_PORT_HANDLING) + port->port_status = RTE_PORT_STOPPED; + else fprintf(stderr, "Port %d can not be set back to stopped\n", pi); @@ -2880,9 +2881,9 @@ start_port(portid_t pid) continue; /* Fail to setup rx queue, return */ - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_HANDLING, - RTE_PORT_STOPPED) == 0) + if (port->port_status == RTE_PORT_HANDLING) + port->port_status = RTE_PORT_STOPPED; + else fprintf(stderr, "Port %d can not be set back to stopped\n", pi); @@ -2917,16 +2918,18 @@ start_port(portid_t pid) pi, rte_strerror(-diag)); /* Fail to setup rx queue, return */ - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0) + if (port->port_status == RTE_PORT_HANDLING) + port->port_status = RTE_PORT_STOPPED; + else fprintf(stderr, "Port %d can not be set back to stopped\n", pi); continue; } - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_HANDLING, RTE_PORT_STARTED) == 0) + if (port->port_status == RTE_PORT_HANDLING) + port->port_status = RTE_PORT_STARTED; + else fprintf(stderr, "Port %d can not be set into started\n", pi); @@ -3028,8 +3031,9 @@ stop_port(portid_t pid) } port = &ports[pi]; - if (rte_atomic16_cmpset(&(port->port_status), RTE_PORT_STARTED, - RTE_PORT_HANDLING) == 0) + if (port->port_status == RTE_PORT_STARTED) + port->port_status = RTE_PORT_HANDLING; + else continue; if (hairpin_mode & 0xf) { @@ -3055,8 +3059,9 @@ stop_port(portid_t pid) RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", pi); - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0) + if (port->port_status == RTE_PORT_HANDLING) + port->port_status = RTE_PORT_STOPPED; + else fprintf(stderr, "Port %d can not be set into stopped\n", pi); need_check_link_status = 1; @@ -3119,8 +3124,7 @@ close_port(portid_t pid) } port = &ports[pi]; - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_CLOSED, RTE_PORT_CLOSED) == 1) { + if (port->port_status == RTE_PORT_CLOSED) { fprintf(stderr, "Port %d is already closed\n", pi); continue; } -- 2.25.1