From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shahaf Shuler Subject: Re: [RFC] ethdev: add min/max MTU to device info Date: Thu, 6 Sep 2018 05:51:39 +0000 Message-ID: References: <20180905164157.844-1-stephen@networkplumber.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable To: Stephen Hemminger , "dev@dpdk.org" Return-path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60079.outbound.protection.outlook.com [40.107.6.79]) by dpdk.org (Postfix) with ESMTP id DABB8326C for ; Thu, 6 Sep 2018 07:51:40 +0200 (CEST) In-Reply-To: <20180905164157.844-1-stephen@networkplumber.org> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Wednesday, September 5, 2018 7:42 PM, Stephen Hemminger: > Subject: [dpdk-dev] [RFC] ethdev: add min/max MTU to device info >=20 > 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 s= ave > space, it fits in a hole in existing structure. >=20 > The initial version sets max mtu to normal Ethernet, it is up to PMD to s= et > larger value if it supports Jumbo frames. >=20 > Fixing the drivers to use this is trivial and can be done by 18.11. > Already have some of the patches done. >=20 > Signed-off-by: Stephen Hemminger Makes sense. Acked-by: Shahaf Shuler > --- > lib/librte_ethdev/rte_ethdev.c | 7 +++++++ lib/librte_ethdev/rte_ethdev= .h > | 2 ++ > 2 files changed, 9 insertions(+) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.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 =3D lim; > dev_info->tx_desc_lim =3D lim; > dev_info->device =3D dev->device; > + dev_info->min_mtu =3D ETHER_MIN_MTU; > + dev_info->max_mtu =3D ETHER_MTU; >=20 > 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; >=20 > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > dev =3D &rte_eth_devices[port_id]; > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mtu_set, - > ENOTSUP); >=20 > + rte_eth_dev_info_get(port_id, &dev_info); > + if (mtu < dev_info.min_mtu || mtu > dev_info.max_mtu) > + return -EINVAL; > + > ret =3D (*dev->dev_ops->mtu_set)(dev, mtu); > if (!ret) > dev->data->mtu =3D mtu; > diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethde= v.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. */ > -- > 2.17.1