Skip to contentSkip to conversation

testpmd: Fix action of operationg invalid port

PATCH Applied Michael Qiu 3 participants 3 messages Mar 9, 2015 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 testpmd: Fix action of operationg invalid port

Currently, if try to start/stop/close one invalid prot, no error shows in testpmd.
This is a bug, need check the port number.

---
 app/test-pmd/config.c  |  3 +++
 app/test-pmd/testpmd.c | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
app/test-pmd/config.c +3 -0
index 49be819..ec53923 100644
@@ -384,6 +384,9 @@ port_infos_display(portid_t port_id)
 int
 port_id_is_invalid(portid_t port_id, enum print_warning warning)
 {
+	if (port_id == (portid_t)RTE_PORT_ALL)
+		return 0;
+
 	if (ports[port_id].enabled)
 		return 0;
 
app/test-pmd/testpmd.c +12 -2
index e556b4c..1c4c651 100644
@@ -1326,6 +1326,9 @@ start_port(portid_t pid)
 		return -1;
 	}
 
+	if (port_id_is_invalid(pid, ENABLED_WARN))
+		return 0;
+
 	if (init_fwd_streams() < 0) {
 		printf("Fail from init_fwd_streams()\n");
 		return -1;
@@ -1482,10 +1485,14 @@ stop_port(portid_t pid)
 		dcb_test = 0;
 		dcb_config = 0;
 	}
+
+	if (port_id_is_invalid(pid, ENABLED_WARN))
+		return;
+
 	printf("Stopping ports...\n");
 
 	FOREACH_PORT(pi, ports) {
-		if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi)
+		if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
 			continue;
 
 		port = &ports[pi];
@@ -1517,10 +1524,13 @@ close_port(portid_t pid)
 		return;
 	}
 
+	if (port_id_is_invalid(pid, ENABLED_WARN))
+                return;
+
 	printf("Closing ports...\n");
 
 	FOREACH_PORT(pi, ports) {
-		if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi)
+		if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
 			continue;
 
 		port = &ports[pi];
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1425881147-27600-1-git-send-email-michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 59 lines · Michael Qiu

Currently, if try to start/stop/close one invalid prot, no error shows in testpmd.
This is a bug, need check the port number.

---
 app/test-pmd/config.c  |  3 +++
 app/test-pmd/testpmd.c | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
app/test-pmd/config.c +3 -0
index 49be819..ec53923 100644
@@ -384,6 +384,9 @@ port_infos_display(portid_t port_id)
 int
 port_id_is_invalid(portid_t port_id, enum print_warning warning)
 {
+	if (port_id == (portid_t)RTE_PORT_ALL)
+		return 0;
+
 	if (ports[port_id].enabled)
 		return 0;
 
app/test-pmd/testpmd.c +9 -1
index e556b4c..1c4c651 100644
@@ -1326,6 +1326,9 @@ start_port(portid_t pid)
 		return -1;
 	}
 
+	if (port_id_is_invalid(pid, ENABLED_WARN))
+		return 0;
+
 	if (init_fwd_streams() < 0) {
 		printf("Fail from init_fwd_streams()\n");
 		return -1;
@@ -1482,10 +1485,14 @@ stop_port(portid_t pid)
 		dcb_test = 0;
 		dcb_config = 0;
 	}
+
+	if (port_id_is_invalid(pid, ENABLED_WARN))
+		return;
+
 	printf("Stopping ports...\n");
 
 	FOREACH_PORT(pi, ports) {
-		if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi)
+		if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
 			continue;
 
 		port = &ports[pi];
@@ -1517,10 +1524,13 @@ close_port(portid_t pid)
 		return;
 	}
 
+	if (port_id_is_invalid(pid, ENABLED_WARN))

app/test-pmd/testpmd.c close_port(portid_t pid) · line 1536

Quoted 10 lines
app/test-pmd/testpmd.c +3 -1
+                return;
+
 	printf("Closing ports...\n");
 
 	FOREACH_PORT(pi, ports) {
-		if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi)
+		if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
 			continue;
 
 		port = &ports[pi];

A message that is not in the archive (sent off-list or not yet received): 54FD397B.9010707-AlSX/UN32fvPDbFq/[email protected]