DPDK patches and discussions
 help / color / mirror / Atom feed
From: Igor Ryzhov <iryzhov@nfware.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] kni: add ability to set min/max MTU
Date: Thu, 19 Sep 2019 14:22:57 +0300	[thread overview]
Message-ID: <20190919112257.85337-1-iryzhov@nfware.com> (raw)

Starting with kernel version 4.10, there are new min/max MTU values in
net_device structure, which are set to ETH_MIN_MTU and ETH_DATA_LEN by
default. We should be able to change these values to allow MTU more than
1500 to be set on KNI.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
---
 examples/kni/main.c                               | 3 +++
 kernel/linux/kni/compat.h                         | 4 ++++
 kernel/linux/kni/kni_misc.c                       | 8 ++++++++
 lib/librte_eal/linux/eal/include/rte_kni_common.h | 2 ++
 lib/librte_kni/rte_kni.c                          | 2 ++
 lib/librte_kni/rte_kni.h                          | 2 ++
 6 files changed, 21 insertions(+)

diff --git a/examples/kni/main.c b/examples/kni/main.c
index 4710d7176..c22a7c18d 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -907,6 +907,9 @@ kni_alloc(uint16_t port_id)
 
 			rte_eth_dev_get_mtu(port_id, &conf.mtu);
 
+			conf.min_mtu = dev_info.min_mtu;
+			conf.max_mtu = dev_info.max_mtu;
+
 			memset(&ops, 0, sizeof(ops));
 			ops.port_id = port_id;
 			ops.change_mtu = kni_change_mtu;
diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h
index 562d8bf94..fe0ee55e7 100644
--- a/kernel/linux/kni/compat.h
+++ b/kernel/linux/kni/compat.h
@@ -89,6 +89,10 @@
 #define HAVE_TRANS_START_HELPER
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
+#define HAVE_MIN_MAX_MTU
+#endif
+
 /*
  * KNI uses NET_NAME_UNKNOWN macro to select correct version of alloc_netdev()
  * For old kernels just backported the commit that enables the macro
diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c
index 2b75502a8..aeb275329 100644
--- a/kernel/linux/kni/kni_misc.c
+++ b/kernel/linux/kni/kni_misc.c
@@ -390,6 +390,14 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,
 	net_dev->max_mtu = net_dev->mtu;
 #endif
 
+#ifdef HAVE_MIN_MAX_MTU
+	if (dev_info.min_mtu)
+		net_dev->min_mtu = dev_info.min_mtu;
+
+	if (dev_info.max_mtu)
+		net_dev->max_mtu = dev_info.max_mtu;
+#endif
+
 	ret = register_netdev(net_dev);
 	if (ret) {
 		pr_err("error %i registering device \"%s\"\n",
diff --git a/lib/librte_eal/linux/eal/include/rte_kni_common.h b/lib/librte_eal/linux/eal/include/rte_kni_common.h
index 37d9ee8f0..70992d835 100644
--- a/lib/librte_eal/linux/eal/include/rte_kni_common.h
+++ b/lib/librte_eal/linux/eal/include/rte_kni_common.h
@@ -120,6 +120,8 @@ struct rte_kni_device_info {
 	/* mbuf size */
 	unsigned mbuf_size;
 	unsigned int mtu;
+	unsigned int min_mtu;
+	unsigned int max_mtu;
 	uint8_t mac_addr[6];
 };
 
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 4b51fb4fe..521db27c4 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -252,6 +252,8 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 	dev_info.group_id = conf->group_id;
 	dev_info.mbuf_size = conf->mbuf_size;
 	dev_info.mtu = conf->mtu;
+	dev_info.min_mtu = conf->min_mtu;
+	dev_info.max_mtu = conf->max_mtu;
 
 	memcpy(dev_info.mac_addr, conf->mac_addr, RTE_ETHER_ADDR_LEN);
 
diff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h
index 5699a6443..b22446fa7 100644
--- a/lib/librte_kni/rte_kni.h
+++ b/lib/librte_kni/rte_kni.h
@@ -70,6 +70,8 @@ struct rte_kni_conf {
 	uint8_t force_bind : 1; /* Flag to bind kernel thread */
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; /* MAC address assigned to KNI */
 	uint16_t mtu;
+	uint16_t min_mtu;
+	uint16_t max_mtu;
 };
 
 /**
-- 
2.23.0


             reply	other threads:[~2019-09-19 11:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 11:22 Igor Ryzhov [this message]
2019-10-11 16:16 ` Ferruh Yigit
2019-10-16  6:40   ` David Marchand
2019-10-16 10:43     ` Ferruh Yigit
2019-10-16 10:55       ` David Marchand
2019-10-16 14:47         ` David Marchand
2019-10-16 14:59           ` Ferruh Yigit
2019-10-25 18:30 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2019-10-25 18:32   ` Ferruh Yigit
2019-10-27 10:12   ` David Marchand
2019-10-27 19:56     ` Igor Ryzhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190919112257.85337-1-iryzhov@nfware.com \
    --to=iryzhov@nfware.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).