From patchwork Wed Feb 20 15:57:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Stokes X-Patchwork-Id: 50388 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 E392629D2; Wed, 20 Feb 2019 16:58:29 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 5E54620BD for ; Wed, 20 Feb 2019 16:58:28 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2019 07:58:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,391,1544515200"; d="scan'208";a="123906801" Received: from sivswdev08.ir.intel.com (HELO localhost.localdomain) ([10.237.217.47]) by fmsmga007.fm.intel.com with ESMTP; 20 Feb 2019 07:58:25 -0800 From: Ian Stokes To: dev@dpdk.org Cc: stephen@networkplumber.org, Ian Stokes Date: Wed, 20 Feb 2019 15:57:50 +0000 Message-Id: <1550678275-4959-2-git-send-email-ian.stokes@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1550678275-4959-1-git-send-email-ian.stokes@intel.com> References: <1550678275-4959-1-git-send-email-ian.stokes@intel.com> Subject: [dpdk-dev] [RFC 1/6] ethdev: add min/max MTU to device info 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: Stephen Hemminger This addresses the usability issue raised by OVS at DPDK Userspace summit. It adds general min/max mtu into device info. For compatiablity, and to save space, it fits in a hole in existing structure. The initial version sets max mtu to normal Ethernet, it is up to PMD to set larger value if it supports Jumbo frames. Also remove the deprecation notice introduced in 18.11 regarding this change. Signed-off-by: Stephen Hemminger Signed-off-by: Ian Stokes Acked-by: Andrew Rybchenko --- doc/guides/rel_notes/deprecation.rst | 12 ------------ lib/librte_ethdev/rte_ethdev.c | 7 +++++++ lib/librte_ethdev/rte_ethdev.h | 2 ++ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 1b4fcb7e6..0e85c47f3 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -56,18 +56,6 @@ Deprecation Notices Target release for removal of the legacy API will be defined once most PMDs have switched to rte_flow. -* ethdev: Maximum and minimum MTU values vary between hardware devices. In - hardware agnostic DPDK applications access to such information would allow - a more accurate way of validating and setting supported MTU values on a per - device basis rather than using a defined default for all devices. To - resolve this, the following members will be added to ``rte_eth_dev_info``. - Note: these can be added to fit a hole in the existing structure for amd64 - but not for 32-bit, as such ABI change will occur as size of the structure - will increase. - - - Member ``uint16_t min_mtu`` the minimum MTU allowed. - - Member ``uint16_t max_mtu`` the maximum MTU allowed. - * meter: New ``rte_color`` definition will be added in 19.02 and that will replace ``enum rte_meter_color`` in meter library in 19.05. This will help to consolidate color definition, which is currently replicated in many places, diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 0d192a24b..f089af94d 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -2527,6 +2527,8 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info) dev_info->rx_desc_lim = lim; dev_info->tx_desc_lim = lim; dev_info->device = dev->device; + dev_info->min_mtu = ETHER_MIN_MTU; + dev_info->max_mtu = ETHER_MTU; RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get); (*dev->dev_ops->dev_infos_get)(dev, dev_info); @@ -2590,12 +2592,17 @@ int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu) { int ret; + struct rte_eth_dev_info dev_info; struct rte_eth_dev *dev; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP); + rte_eth_dev_info_get(port_id, &dev_info); + if (mtu < dev_info.min_mtu || mtu > dev_info.max_mtu) + return -EINVAL; + ret = (*dev->dev_ops->mtu_set)(dev, mtu); if (!ret) dev->data->mtu = mtu; diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index a3c864a13..9fe51b2bd 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1086,6 +1086,8 @@ struct rte_eth_dev_info { const char *driver_name; /**< Device Driver name. */ unsigned int if_index; /**< Index to bound host interface, or 0 if none. Use if_indextoname() to translate into an interface name. */ + uint16_t min_mtu; /**< Minimum MTU allowed */ + uint16_t max_mtu; /**< Maximum MTU allowed */ const uint32_t *dev_flags; /**< Device flags */ uint32_t min_rx_bufsize; /**< Minimum size of RX buffer. */ uint32_t max_rx_pktlen; /**< Maximum configurable length of RX pkt. */