ethdev: add min/max MTU to device info
cover ethdev: add min/max MTU to device info
Building upon the discussion around [1], this series introduces MTU min and MTU max variables. It also provides updates to PMD implementations for ixgbe, i40e and IGB devices so that these variables are populated for use when retrieving device info.
This series was tested with OVS DPDK and functions as expected for the drivers listed below. But a wider selection of PMD drivers would have to adopt this to ensure jumbo frames functionality remains for drivers not modified in the series.
There is also ongoing discussion in [2] regarding overhead to be considered with MTU and how this may change from device to device, this series uses existing overhead assumptions.
There are also some tasks missing such as updating ethdev version and documentation that can be implemented in non RFC series if the approach is acceptable.
[1] http://mails.dpdk.org/archives/dev/2018-September/110959.html
[2] http://mails.dpdk.org/archives/dev/2019-February/124457.html
Ian Stokes (5):
net/i40e: set min and max MTU for i40e devices net/i40e: set min and max MTU for i40e VF devices net/ixgbe: set min and max MTU for ixgbe devices net/ixgbe: set min and max MTU for ixgbe VF devices net/e1000: set min and max MTU for igb devices
Stephen Hemminger (1):
ethdev: add min/max MTU to device info
doc/guides/rel_notes/deprecation.rst | 12 ------------ drivers/net/e1000/e1000_ethdev.h | 6 ++++++ drivers/net/e1000/igb_ethdev.c | 7 +++++-- drivers/net/i40e/i40e_ethdev.c | 2 ++ drivers/net/i40e/i40e_ethdev_vf.c | 2 ++ drivers/net/ixgbe/ixgbe_ethdev.c | 7 +++++-- drivers/net/ixgbe/ixgbe_ethdev.h | 3 +++ lib/librte_ethdev/rte_ethdev.c | 7 +++++++ lib/librte_ethdev/rte_ethdev.h | 2 ++ 9 files changed, 32 insertions(+), 16 deletions(-)
Signature · 1 line
2.13.6
RFC 1/6 ethdev: add min/max MTU to device info
From: Stephen Hemminger <[email protected]>
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.
--- 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(-)
doc/guides/rel_notes/deprecation.rst +0 -12
@@ -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,
lib/librte_ethdev/rte_ethdev.c +7 -0
@@ -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;
lib/librte_ethdev/rte_ethdev.h +2 -0
@@ -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. */
Signature · 1 line
2.13.6
Quoted 15 lines · Ian Stokes
From: Stephen Hemminger <[email protected]>
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 <[email protected]>Signed-off-by Ian Stokes <[email protected]>---
[...]
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info) · line 2531
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -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 ;
I think it should be set to UINT16_MAX to avoid breakage of jumbo frame support just after the patch. When all in tree drivers are updated, it can be set to ETHER_MTU, but it should in with UINT16_MAX value.
with above issue fixed
Quoted 34 lines · Andrew Rybchenko
Quoted 15 lines · Ian Stokes
From: Stephen Hemminger<[email protected]>
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<[email protected]>Signed-off-by Ian Stokes<[email protected]>---
[...]
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info) · line 2531
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -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 ;I think it should be set to
UINT16_MAXto avoid breakage of jumbo frame support just after the patch. When all in tree drivers are updated, it can be set toETHER_MTU, but it should in withUINT16_MAXvalue.
Quoted 3 lines
with above issue fixed
Acked-by Andrew Rybchenko <[email protected]>
Thanks for the feedback Andrew, I've made the change and submitted a v1 of the series (link below), I've added your ack to this patch specifically in the series also if that's ok.
http://mails.dpdk.org/archives/dev/2019-February/125319.html
Thanks
Ian
RFC 2/6 net/i40e: set min and max MTU for i40e devices
In reply to Ian StokesThis commit sets the min and max supported MTU values for i40e devices via the i40e_dev_info_get() function. Min MTU supported is set to ETHER_MIN_MTU and max mtu is calculated as the max packet length supported minus the transport overhead.
--- drivers/net/i40e/i40e_ethdev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/i40e/i40e_ethdev.c +2 -0
@@ -3499,6 +3499,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_rx_pktlen =I40E_FRAME_SIZE_MAX ; dev_info->max_mac_addrs = vsi->max_macaddrs; dev_info->max_vfs = pci_dev->max_vfs; + dev_info->max_mtu = dev_info->max_rx_pktlen -I40E_ETH_OVERHEAD ; + dev_info->min_mtu =ETHER_MIN_MTU ; dev_info->rx_queue_offload_capa =0 ; dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
Signature · 1 line
2.13.6
RFC 3/6 net/i40e: set min and max MTU for i40e VF devices
In reply to Ian StokesThis commit sets the min and max supported MTU values for i40e VF devices via the i40evf_dev_info_get() function. Min MTU supported is set to ETHER_MIN_MTU and max mtu is calculated as the max packet length supported minus the transport overhead.
--- drivers/net/i40e/i40e_ethdev_vf.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/i40e/i40e_ethdev_vf.c +2 -0
@@ -2216,6 +2216,8 @@ i40evf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_tx_queues =I40E_MAX_QP_NUM_PER_VF ; dev_info->min_rx_bufsize =I40E_BUF_SIZE_MIN ; dev_info->max_rx_pktlen =I40E_FRAME_SIZE_MAX ; + dev_info->max_mtu = dev_info->max_rx_pktlen -I40E_ETH_OVERHEAD ; + dev_info->min_mtu =ETHER_MIN_MTU ; dev_info->hash_key_size = (I40E_VFQF_HKEY_MAX_INDEX +1 ) *sizeof (uint32_t ); dev_info->reta_size =ETH_RSS_RETA_SIZE_64 ; dev_info->flow_type_rss_offloads = vf->adapter->flow_types_mask;
Signature · 1 line
2.13.6
RFC 4/6 net/ixgbe: set min and max MTU for ixgbe devices
In reply to Ian StokesThis commit sets the min and max supported MTU values for ixgbe devices via the ixgbe_dev_info_get() function. Min MTU supported is set to ETHER_MIN_MTU and max mtu is calculated as the max packet length supported minus the transport overhead. To aid in these calculations a new MACRO 'IXGBE_ETH_OVERHEAD' has been introduced to consolidate overhead calculation and avoid duplication.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 4 +++- drivers/net/ixgbe/ixgbe_ethdev.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +3 -1
@@ -3734,6 +3734,8 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_vmdq_pools =ETH_16_POOLS ; else dev_info->max_vmdq_pools = ETH_64_POOLS; + dev_info->max_mtu = dev_info->max_rx_pktlen -IXGBE_ETH_OVERHEAD ; + dev_info->min_mtu =ETHER_MIN_MTU ; dev_info->vmdq_queue_num = dev_info->max_rx_queues; dev_info->rx_queue_offload_capa =ixgbe_get_rx_queue_offloads (dev); dev_info->rx_offload_capa = (ixgbe_get_rx_port_offloads(dev) |
@@ -4925,7 +4927,7 @@ ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)uint32_t maxfrs;struct ixgbe_hw *hw;struct rte_eth_dev_info dev_info; -uint32_t frame_size = mtu +ETHER_HDR_LEN +ETHER_CRC_LEN ; +uint32_t frame_size = mtu +IXGBE_ETH_OVERHEAD ;struct rte_eth_dev_data *dev_data = dev->data;ixgbe_dev_info_get (dev, &dev_info);
drivers/net/ixgbe/ixgbe_ethdev.h +3 -0
@@ -100,6 +100,9 @@#define IXGBE_5TUPLE_MAX_PRI 7#define IXGBE_5TUPLE_MIN_PRI 1 +/* The overhead from MTU to max frame size. */ +#define IXGBE_ETH_OVERHEAD (ETHER_HDR_LEN + ETHER_CRC_LEN) +/* bit of VXLAN tunnel type | 7 bits of zeros | 8 bits of zeros*/ #define IXGBE_FDIR_VXLAN_TUNNEL_TYPE 0x8000/* bit of NVGRE tunnel type | 7 bits of zeros | 8 bits of zeros*/
Signature · 1 line
2.13.6
RFC 5/6 net/ixgbe: set min and max MTU for ixgbe VF devices
In reply to Ian StokesThis commit sets the min and max supported MTU values for ixgbe VF devices via the ixgbevf_dev_set_mtu() function. Min MTU supported is set to ETHER_MIN_MTU and max mtu is calculated as the max packet length supported minus the transport overhead. As transport overhead is the same for VF and PF ixgbe devices, reuse MACRO 'IXGBE_ETH_OVERHEAD' to avoid duplication.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
@@ -3843,6 +3843,7 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev, dev_info->max_tx_queues = (uint16_t )hw->mac.max_tx_queues; dev_info->min_rx_bufsize =1024 ;/* cf BSIZEPACKET in SRRCTL reg */ dev_info->max_rx_pktlen =9728 ;/* includes CRC, cf MAXFRS reg */ + dev_info->max_mtu = dev_info->max_rx_pktlen -IXGBE_ETH_OVERHEAD ; dev_info->max_mac_addrs = hw->mac.num_rar_entries; dev_info->max_hash_mac_addrs =IXGBE_VMDQ_NUM_UC_MAC ; dev_info->max_vfs = pci_dev->max_vfs;
@@ -6330,7 +6331,7 @@ static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) {struct ixgbe_hw *hw; -uint32_t max_frame = mtu +ETHER_HDR_LEN +ETHER_CRC_LEN ; +uint32_t max_frame = mtu +IXGBE_ETH_OVERHEAD ;struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode; hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);
Signature · 1 line
2.13.6
RFC 6/6 net/e1000: set min and max MTU for igb devices
In reply to Ian StokesThis commit sets the min and max supported MTU values for igb devices via the eth_igb_info_get() function. Min MTU supported is set to ETHER_MIN_MTU and max mtu is calculated as the max packet length supported minus the transport overhead. To aid in these calculations a new MACRO 'E1000_ETH_OVERHEAD' has been introduced to consolidate overhead calculation and avoid duplication.
--- drivers/net/e1000/e1000_ethdev.h | 6 ++++++ drivers/net/e1000/igb_ethdev.c | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/net/e1000/e1000_ethdev.h +6 -0
@@ -89,6 +89,12 @@ ETH_RSS_IPV6_UDP_EX)/* +* The overhead from MTU to max frame size. +* Considering VLAN so a tag needs to be counted. +*/ +#define E1000_ETH_OVERHEAD (ETHER_HDR_LEN + ETHER_CRC_LEN + VLAN_TAG_SIZE) + +/* * Maximum number of Ring Descriptors. * * Since RDLEN/TDLEN should be multiple of 128 bytes, the number of ring
drivers/net/e1000/igb_ethdev.c +5 -2
@@ -2283,6 +2283,10 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->speed_capa =ETH_LINK_SPEED_10M_HD |ETH_LINK_SPEED_10M |ETH_LINK_SPEED_100M_HD |ETH_LINK_SPEED_100M |ETH_LINK_SPEED_1G ; + + dev_info->max_mtu = dev_info->max_rx_pktlen -E1000_ETH_OVERHEAD ; + dev_info->min_mtu =ETHER_MIN_MTU ; + } static const uint32_t *
@@ -4466,8 +4470,7 @@ eth_igb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)uint32_t rctl;struct e1000_hw *hw;struct rte_eth_dev_info dev_info; -uint32_t frame_size = mtu + (ETHER_HDR_LEN +ETHER_CRC_LEN + -VLAN_TAG_SIZE ); +uint32_t frame_size = mtu +E1000_ETH_OVERHEAD ; hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);
Signature · 1 line
2.13.6