[dpdk-dev,v3,03/10] app/testpmd: support check of single port stop

Message ID b203ca6c37b89cb814618923f11e2b69910ccf2a.1514281260.git.shahafs@mellanox.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Shahaf Shuler Dec. 26, 2017, 9:44 a.m. UTC
  This patch adds supports for checking if a single port is stopped.
currently there is a function to check only for all ports.

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
---
 app/test-pmd/testpmd.c | 16 ++++++++++++----
 app/test-pmd/testpmd.h |  1 +
 2 files changed, 13 insertions(+), 4 deletions(-)
  

Comments

Wenzhuo Lu Jan. 9, 2018, 3:20 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Shahaf Shuler
> Sent: Tuesday, December 26, 2017 5:44 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v3 03/10] app/testpmd: support check of single
> port stop
> 
> This patch adds supports for checking if a single port is stopped.
> currently there is a function to check only for all ports.
> 
> Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 6785b095f..77154ef3b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1394,15 +1394,23 @@  all_ports_started(void)
 }
 
 int
+port_is_stopped(portid_t port_id)
+{
+	struct rte_port *port = &ports[port_id];
+
+	if ((port->port_status != RTE_PORT_STOPPED) &&
+	    (port->slave_flag == 0))
+		return 0;
+	return 1;
+}
+
+int
 all_ports_stopped(void)
 {
 	portid_t pi;
-	struct rte_port *port;
 
 	RTE_ETH_FOREACH_DEV(pi) {
-		port = &ports[pi];
-		if ((port->port_status != RTE_PORT_STOPPED) &&
-			(port->slave_flag == 0))
+		if (!port_is_stopped(pi))
 			return 0;
 	}
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 1639d27e7..ab74d39ce 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -682,6 +682,7 @@  void reset_port(portid_t pid);
 void attach_port(char *identifier);
 void detach_port(portid_t port_id);
 int all_ports_stopped(void);
+int port_is_stopped(portid_t port_id);
 int port_is_started(portid_t port_id);
 void pmd_test_exit(void);
 void fdir_get_infos(portid_t port_id);