[dpdk-dev,v2] testpmd: fix a bug in tx_vlan set command support

Message ID 1450784205-10880-2-git-send-email-xiao.w.wang@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Xiao Wang Dec. 22, 2015, 11:36 a.m. UTC
  Now in cmd_tx_vlan_set_parsed function, we check the vlan_offload
capability first, if it's an invalid port_id we'll get a strange
prompt saying "Error, as QinQ has been enabled.". We should always
make sure that we get a valid port_id first before we check other
information. It's the same problem for cmd_tx_vlan_set_qinq_parsed.

Signed-off-by: Wang Xiao W <xiao.w.wang@intel.com>
---
 app/test-pmd/cmdline.c | 12 ------------
 app/test-pmd/config.c  | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 12 deletions(-)
  

Comments

Xiao Wang Feb. 4, 2016, 8:27 a.m. UTC | #1
v3:
* Reworded the patch subject and commit message, added detail for reproducing
  the bug.

* Reordered the definitions of cmd_tx_vlan_set_portid and cmd_tx_vlan_set_vlanid
  to keep in consistency with cmd_tx_vlan_set.tokens.

v2:
* Removed the bug fix unrelated code change to make this patch a pure bug fix
  patch.

* Fixed the "PATCH 1/2" mistake in the patch title, rewrote the subject.

Wang Xiao W (1):
  testpmd: fix wrong prompt in tx_vlan set command handler

 app/test-pmd/cmdline.c | 18 +++---------------
 app/test-pmd/config.c  | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 15 deletions(-)
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 73298c9..2adf6ca 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -2952,12 +2952,6 @@  cmd_tx_vlan_set_parsed(void *parsed_result,
 		       __attribute__((unused)) void *data)
 {
 	struct cmd_tx_vlan_set_result *res = parsed_result;
-	int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
-
-	if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) {
-		printf("Error, as QinQ has been enabled.\n");
-		return;
-	}
 
 	tx_vlan_set(res->port_id, res->vlan_id);
 }
@@ -3004,12 +2998,6 @@  cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
 			    __attribute__((unused)) void *data)
 {
 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
-	int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
-
-	if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) {
-		printf("Error, as QinQ hasn't been enabled.\n");
-		return;
-	}
 
 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
 }
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 7088f6f..956d29c 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1839,10 +1839,18 @@  vlan_tpid_set(portid_t port_id, uint16_t tp_id)
 void
 tx_vlan_set(portid_t port_id, uint16_t vlan_id)
 {
+	int vlan_offload;
 	if (port_id_is_invalid(port_id, ENABLED_WARN))
 		return;
 	if (vlan_id_is_invalid(vlan_id))
 		return;
+
+	vlan_offload = rte_eth_dev_get_vlan_offload(port_id);
+	if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) {
+		printf("Error, as QinQ has been enabled.\n");
+		return;
+	}
+
 	tx_vlan_reset(port_id);
 	ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_INSERT_VLAN;
 	ports[port_id].tx_vlan_id = vlan_id;
@@ -1851,12 +1859,20 @@  tx_vlan_set(portid_t port_id, uint16_t vlan_id)
 void
 tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer)
 {
+	int vlan_offload;
 	if (port_id_is_invalid(port_id, ENABLED_WARN))
 		return;
 	if (vlan_id_is_invalid(vlan_id))
 		return;
 	if (vlan_id_is_invalid(vlan_id_outer))
 		return;
+
+	vlan_offload = rte_eth_dev_get_vlan_offload(port_id);
+	if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) {
+		printf("Error, as QinQ hasn't been enabled.\n");
+		return;
+	}
+
 	tx_vlan_reset(port_id);
 	ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_INSERT_QINQ;
 	ports[port_id].tx_vlan_id = vlan_id;