[v3,7/7] app/testpmd: verify MTU with device provided limits

Message ID 20190329175219.23831-7-ferruh.yigit@intel.com
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • [v3,1/7] ethdev: add min/max MTU to device info
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ferruh Yigit March 29, 2019, 5:52 p.m.
From: Ian Stokes <ian.stokes@intel.com>

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 <ian.stokes@intel.com>
---
 app/test-pmd/config.c | 7 +++++++
 1 file changed, 7 insertions(+)

Patch

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;