* [dpdk-dev] [PATCH 1/2] testpmd: optimize tx_vlan_set and tx_qinq_set function @ 2015-12-21 11:13 Wang Xiao W 2015-12-22 11:36 ` [dpdk-dev] [PATCH v2] testpmd: fix a bug in tx_vlan set command support Wang Xiao W 0 siblings, 1 reply; 6+ messages in thread From: Wang Xiao W @ 2015-12-21 11:13 UTC (permalink / raw) To: jing.d.chen, pablo.de.lara.guarch; +Cc: dev Now in cmd_tx_vlan_set_parsed function, we check the vlan_offload capability first, if it's a invalid port we'll get a prompt saying "Error, as QinQ has been enabled.". So 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. Meanwhile, tx_vlan reset operation is simple enough to be put directly into tx_vlan_set and tx_qinq_set function. Signed-off-by: Wang Xiao W <xiao.w.wang@intel.com> --- app/test-pmd/cmdline.c | 12 ------------ app/test-pmd/config.c | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 14 deletions(-) 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..7572b3e 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1839,25 +1839,42 @@ 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; - tx_vlan_reset(port_id); + + 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; + } + + ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_INSERT_QINQ; ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_INSERT_VLAN; ports[port_id].tx_vlan_id = vlan_id; + ports[port_id].tx_vlan_id_outer = 0; } 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; - tx_vlan_reset(port_id); + + 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; + } + + ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_INSERT_VLAN; ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_INSERT_QINQ; ports[port_id].tx_vlan_id = vlan_id; ports[port_id].tx_vlan_id_outer = vlan_id_outer; -- 1.9.3 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] testpmd: fix a bug in tx_vlan set command support 2015-12-21 11:13 [dpdk-dev] [PATCH 1/2] testpmd: optimize tx_vlan_set and tx_qinq_set function Wang Xiao W @ 2015-12-22 11:36 ` Wang Xiao W 2015-12-22 11:36 ` Wang Xiao W 0 siblings, 1 reply; 6+ messages in thread From: Wang Xiao W @ 2015-12-22 11:36 UTC (permalink / raw) To: jing.d.chen, pablo.de.lara.guarch; +Cc: dev 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. v1: * Initial version for tx_vlan set command support bug fix. Wang Xiao W (1): testpmd: fix a bug in tx_vlan set command support app/test-pmd/cmdline.c | 12 ------------ app/test-pmd/config.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 12 deletions(-) -- 1.9.3 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] testpmd: fix a bug in tx_vlan set command support 2015-12-22 11:36 ` [dpdk-dev] [PATCH v2] testpmd: fix a bug in tx_vlan set command support Wang Xiao W @ 2015-12-22 11:36 ` Wang Xiao W 2016-02-04 8:27 ` [dpdk-dev] [PATCH v3] testpmd: fix wrong prompt in tx_vlan set command handler Wang Xiao W 0 siblings, 1 reply; 6+ messages in thread From: Wang Xiao W @ 2015-12-22 11:36 UTC (permalink / raw) To: jing.d.chen, pablo.de.lara.guarch; +Cc: dev 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(-) 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; -- 1.9.3 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v3] testpmd: fix wrong prompt in tx_vlan set command handler 2015-12-22 11:36 ` Wang Xiao W @ 2016-02-04 8:27 ` Wang Xiao W 2016-02-04 8:27 ` Wang Xiao W 0 siblings, 1 reply; 6+ messages in thread From: Wang Xiao W @ 2016-02-04 8:27 UTC (permalink / raw) To: jing.d.chen; +Cc: dev 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(-) -- 1.9.3 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v3] testpmd: fix wrong prompt in tx_vlan set command handler 2016-02-04 8:27 ` [dpdk-dev] [PATCH v3] testpmd: fix wrong prompt in tx_vlan set command handler Wang Xiao W @ 2016-02-04 8:27 ` Wang Xiao W 2016-02-04 9:52 ` Bruce Richardson 0 siblings, 1 reply; 6+ messages in thread From: Wang Xiao W @ 2016-02-04 8:27 UTC (permalink / raw) To: jing.d.chen; +Cc: dev When using testpmd, sometimes we forget the right order of port_id and vid in "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" command, and input "tx_vlan set 51 0", we'll get a strange prompt saying "Error, as QinQ has been enabled.". In cmd_tx_vlan_set_parsed function, the first thing we do is checking the port's vlan_offload capability, rather than checking validity of the port_id, therefore if it's an invalid port_id we'll get the above wrong message. We should always make sure that we get a valid port_id before we do other things. It's the similar issue for cmd_tx_vlan_set_qinq_parsed function. Signed-off-by: Wang Xiao W <xiao.w.wang@intel.com> --- app/test-pmd/cmdline.c | 18 +++--------------- app/test-pmd/config.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 6d28c1b..52179e6 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2954,12 +2954,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); } @@ -2970,12 +2964,12 @@ cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = cmdline_parse_token_string_t cmd_tx_vlan_set_set = TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, set, "set"); -cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = - TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, - vlan_id, UINT16); cmdline_parse_token_num_t cmd_tx_vlan_set_portid = TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, port_id, UINT8); +cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = + TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, + vlan_id, UINT16); cmdline_parse_inst_t cmd_tx_vlan_set = { .f = cmd_tx_vlan_set_parsed, @@ -3006,12 +3000,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; -- 1.9.3 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v3] testpmd: fix wrong prompt in tx_vlan set command handler 2016-02-04 8:27 ` Wang Xiao W @ 2016-02-04 9:52 ` Bruce Richardson 0 siblings, 0 replies; 6+ messages in thread From: Bruce Richardson @ 2016-02-04 9:52 UTC (permalink / raw) To: Wang Xiao W; +Cc: dev On Thu, Feb 04, 2016 at 04:27:32PM +0800, Wang Xiao W wrote: > When using testpmd, sometimes we forget the right order of port_id and > vid in "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" command, and > input "tx_vlan set 51 0", we'll get a strange prompt saying "Error, as > QinQ has been enabled.". > > In cmd_tx_vlan_set_parsed function, the first thing we do is checking > the port's vlan_offload capability, rather than checking validity of the > port_id, therefore if it's an invalid port_id we'll get the above wrong > message. We should always make sure that we get a valid port_id before > we do other things. > > It's the similar issue for cmd_tx_vlan_set_qinq_parsed function. > > Signed-off-by: Wang Xiao W <xiao.w.wang@intel.com> Please include a fixes line, in patches fixing problems. thanks, /Bruce ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-02-04 9:52 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-12-21 11:13 [dpdk-dev] [PATCH 1/2] testpmd: optimize tx_vlan_set and tx_qinq_set function Wang Xiao W 2015-12-22 11:36 ` [dpdk-dev] [PATCH v2] testpmd: fix a bug in tx_vlan set command support Wang Xiao W 2015-12-22 11:36 ` Wang Xiao W 2016-02-04 8:27 ` [dpdk-dev] [PATCH v3] testpmd: fix wrong prompt in tx_vlan set command handler Wang Xiao W 2016-02-04 8:27 ` Wang Xiao W 2016-02-04 9:52 ` Bruce Richardson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).