From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <bernard.iremonger@intel.com>
Received: from mga14.intel.com (mga14.intel.com [192.55.52.115])
 by dpdk.org (Postfix) with ESMTP id 7414F5424
 for <dev@dpdk.org>; Wed, 25 Jan 2017 15:36:19 +0100 (CET)
Received: from fmsmga004.fm.intel.com ([10.253.24.48])
 by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 25 Jan 2017 06:36:19 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.33,284,1477983600"; d="scan'208";a="217494258"
Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain)
 ([10.237.217.45])
 by fmsmga004.fm.intel.com with ESMTP; 25 Jan 2017 06:36:17 -0800
From: Bernard Iremonger <bernard.iremonger@intel.com>
To: dev@dpdk.org,
	wenzhuo.lu@intel.com,
	jingjing.wu@intel.com
Cc: Bernard Iremonger <bernard.iremonger@intel.com>
Date: Wed, 25 Jan 2017 14:36:03 +0000
Message-Id: <1485354963-17326-4-git-send-email-bernard.iremonger@intel.com>
X-Mailer: git-send-email 1.7.0.7
In-Reply-To: <1484671162-18493-1-git-send-email-bernard.iremonger@intel.com>
References: <1484671162-18493-1-git-send-email-bernard.iremonger@intel.com>
Subject: [dpdk-dev] [PATCH v5 3/3] app/testpmd: fix port stop
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 25 Jan 2017 14:36:19 -0000

The rte_eth_dev_stop function is not called if the port_status is
not RTE_PORT_STARTED. This can happen if the rte_eth_dev_start
function is called directly, ie not through the start_port function.

Make sure rte_eth_dev_stop is always called in stop_port function.

Fixes: ce8d561418d4 ("app/testpmd: add port configuration settings")
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/testpmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index ed7d83c..2d0ca3f 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1490,13 +1490,13 @@ stop_port(portid_t pid)
 			continue;
 		}
 
+		rte_eth_dev_stop(pi);
+
 		port = &ports[pi];
 		if (rte_atomic16_cmpset(&(port->port_status), RTE_PORT_STARTED,
 						RTE_PORT_HANDLING) == 0)
 			continue;
 
-		rte_eth_dev_stop(pi);
-
 		if (rte_atomic16_cmpset(&(port->port_status),
 			RTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0)
 			printf("Port %d can not be set into stopped\n", pi);
-- 
2.10.1