From patchwork Tue Dec 22 11:36:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Wang X-Patchwork-Id: 9625 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D561E5A24; Tue, 22 Dec 2015 12:36:58 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id EB0B2593A for ; Tue, 22 Dec 2015 12:36:57 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 22 Dec 2015 03:36:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,464,1444719600"; d="scan'208";a="876703469" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 22 Dec 2015 03:36:57 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id tBMBas0j019188; Tue, 22 Dec 2015 19:36:54 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id tBMBapoh010923; Tue, 22 Dec 2015 19:36:53 +0800 Received: (from xiaowan1@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id tBMBapWY010919; Tue, 22 Dec 2015 19:36:51 +0800 From: Wang Xiao W To: jing.d.chen@intel.com, pablo.de.lara.guarch@intel.com Date: Tue, 22 Dec 2015 19:36:45 +0800 Message-Id: <1450784205-10880-2-git-send-email-xiao.w.wang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1450784205-10880-1-git-send-email-xiao.w.wang@intel.com> References: <1450696402-14847-1-git-send-email-xiao.w.wang@intel.com> <1450784205-10880-1-git-send-email-xiao.w.wang@intel.com> Cc: dev@dpdk.org Subject: [dpdk-dev] [PATCH v2] testpmd: fix a bug in tx_vlan set command support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "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 --- 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;