From patchwork Fri Mar 29 17:52:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 51940 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 87B714F93; Fri, 29 Mar 2019 18:52:51 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 325154CA6 for ; Fri, 29 Mar 2019 18:52:37 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2019 10:52:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,285,1549958400"; d="scan'208";a="138397051" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.212]) by orsmga003.jf.intel.com with ESMTP; 29 Mar 2019 10:52:35 -0700 From: Ferruh Yigit To: Wenzhuo Lu , Jingjing Wu , Bernard Iremonger Cc: dev@dpdk.org, Ian Stokes Date: Fri, 29 Mar 2019 17:52:19 +0000 Message-Id: <20190329175219.23831-7-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190329175219.23831-1-ferruh.yigit@intel.com> References: <1553259678-4515-1-git-send-email-ian.stokes@intel.com> <20190329175219.23831-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 7/7] app/testpmd: verify MTU with device provided limits X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ian Stokes This commit uses the mtu fields populated in rte_eth_dev_info_get() to validate the mtu value being passed in port_mtu_set(). Signed-off-by: Ian Stokes --- app/test-pmd/config.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b9e5dd923..cadcb512f 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1063,9 +1063,16 @@ void port_mtu_set(portid_t port_id, uint16_t mtu) { int diag; + struct rte_eth_dev_info dev_info; if (port_id_is_invalid(port_id, ENABLED_WARN)) return; + rte_eth_dev_info_get(port_id, &dev_info); + if (mtu > dev_info.max_mtu || mtu < dev_info.min_mtu) { + printf("Set MTU failed. MTU:%u is not in valid range, min:%u - max:%u\n", + mtu, dev_info.min_mtu, dev_info.max_mtu); + return; + } diag = rte_eth_dev_set_mtu(port_id, mtu); if (diag == 0) return;