From patchwork Wed Sep 5 16:41:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 44312 X-Patchwork-Delegate: thomas@monjalon.net 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 EA69828FD; Wed, 5 Sep 2018 18:42:02 +0200 (CEST) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id 556511559 for ; Wed, 5 Sep 2018 18:42:01 +0200 (CEST) Received: by mail-wr1-f68.google.com with SMTP id k5-v6so8353746wre.10 for ; Wed, 05 Sep 2018 09:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=ZRawbZCjftw/N3VxCnMtlrCdK25giCcIOQwJ4cFYSNQ=; b=pQBnz/AsCUpsfQd26NPazO7o9HcFbKFTtELqae6sornsD1WcHl3l/VUvDF5ViNt954 VDGBDeD789B2nWvLti1wOR+WakDrIkyAnFmgT0U7XfiA3T8AtcMBTKz0XfK1bE49TfLl pMWoJkJbbIzIzHMkIk3ViGZHAx2hEtugigSylwBw0pMb/kEN90u/qqFO38JahD8z8KGR P9AdY2eKeAgndT0AxEjAmpUQxciZ1Zn+KNP6lPcXQGmqes+iCzVTcyetyEJkQxmR2C5Z lvM5/UDMUqaPy7oCvSi6CcdyqdOHa7oUOfvuxAwXYyqQb1/bHgyEEZTsde2ModFmUdUD brKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZRawbZCjftw/N3VxCnMtlrCdK25giCcIOQwJ4cFYSNQ=; b=ewOM20LWVoV1yhYbh1Y01vL+vG+T2Dux1JI/oe2hf4egYhQC5JOZ27lK/db7pDR/CG oXTOfOrdsqmwTcXzGil/Zgy3LSGlOmNyrjowpZjuGSTyvZyih3E7TRfHP+wFcUZivo0Q Byw9+u2igw9T5LHSAO6BNRJb5cRebrMsORnPuBaDYAQuxgqY4mZJL1aq+ixUKTc5ZuHy JEJ9udMCpHIKd7uSHCzt3P/y0LRMHCZeSqvcNBo08URrw3rN0iOE8PmRNapjMs+aRaiW RnrgiLBDDyUBAIC67pAbUqh2gnUBNC2O7i3zf+0+apeR4rZ685fnuXaSOrl0/fYfFpLA VdKA== X-Gm-Message-State: APzg51ADJtU1kHXNElbxKUZdSGLeu+TgpTf63BcAFW7w85G+WP+73idG +YhBZcpI01ZEWv4vPCIusH6C7g0kQslf+nFR X-Google-Smtp-Source: ANB0VdZ6OHCUIXaxknJADXO42DTIQlJrsen9+2SccW8DeanXFve5zLstgAWDTFjcqRlsLnFy4u6Zeg== X-Received: by 2002:adf:f7c4:: with SMTP id a4-v6mr28070494wrq.86.1536165720283; Wed, 05 Sep 2018 09:42:00 -0700 (PDT) Received: from shemminger-XPS-13-9360.access.network ([31.216.236.195]) by smtp.gmail.com with ESMTPSA id q200-v6sm29494331wmd.2.2018.09.05.09.41.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Sep 2018 09:41:59 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 5 Sep 2018 17:41:57 +0100 Message-Id: <20180905164157.844-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [RFC] 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" 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. Fixing the drivers to use this is trivial and can be done by 18.11. Already have some of the patches done. Signed-off-by: Stephen Hemminger Acked-by: Shahaf Shuler --- lib/librte_ethdev/rte_ethdev.c | 7 +++++++ lib/librte_ethdev/rte_ethdev.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 4c320250589a..df0c7536a7c4 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -2408,6 +2408,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); @@ -2471,12 +2473,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 7070e9ab408f..5171a9083288 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1015,6 +1015,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. */