[dpdk-dev] [PATCH v2] net/kni: calc mbuf&mtu according to given mb_pool

Liron Himi lironh at marvell.com
Sun Mar 10 15:27:11 CET 2019


Adding Alan.

-----Original Message-----
From: Liron Himi 
Sent: Monday, February 25, 2019 13:30
To: ferruh.yigit at intel.com
Cc: dev at dpdk.org; Liron Himi <lironh at marvell.com>; Liron Himi <lironh at marvell.com>
Subject: RE: [PATCH v2] net/kni: calc mbuf&mtu according to given mb_pool

Hi,

Kind reminder

Regards,
Liron

-----Original Message-----
From: lironh at marvell.com <lironh at marvell.com>
Sent: Saturday, February 23, 2019 22:15
To: ferruh.yigit at intel.com
Cc: dev at dpdk.org; Liron Himi <lironh at marvell.com>
Subject: [PATCH v2] net/kni: calc mbuf&mtu according to given mb_pool

From: Liron Himi <lironh at marvell.com>

- mbuf_size and mtu are now being calculated according to the given mb-pool.

- max_mtu is now being set according to the given mtu

the above two changes provide the ability to work with jumbo frames

Signed-off-by: Liron Himi <lironh at marvell.com>
---
 drivers/net/kni/rte_eth_kni.c | 10 +++++++---
 kernel/linux/kni/compat.h     |  4 ++++
 kernel/linux/kni/kni_misc.c   |  3 +++
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index a1e9970..5e02224 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -16,9 +16,11 @@
 /* Only single queue supported */
 #define KNI_MAX_QUEUE_PER_PORT 1
 
-#define MAX_PACKET_SZ 2048
 #define MAX_KNI_PORTS 8
 
+#define KNI_ETHER_MTU(mbuf_size)       \
+	((mbuf_size) - ETHER_HDR_LEN) /**< Ethernet MTU. */
+
 #define ETH_KNI_NO_REQUEST_THREAD_ARG	"no_request_thread"
 static const char * const valid_arguments[] = {
 	ETH_KNI_NO_REQUEST_THREAD_ARG,
@@ -123,11 +125,13 @@ eth_kni_start(struct rte_eth_dev *dev)
 	struct rte_kni_conf conf;
 	const char *name = dev->device->name + 4; /* remove net_ */
 
+	mb_pool = internals->rx_queues[0].mb_pool;
 	snprintf(conf.name, RTE_KNI_NAMESIZE, "%s", name);
 	conf.force_bind = 0;
 	conf.group_id = port_id;
-	conf.mbuf_size = MAX_PACKET_SZ;
-	mb_pool = internals->rx_queues[0].mb_pool;
+	conf.mbuf_size =
+		rte_pktmbuf_data_room_size(mb_pool) - RTE_PKTMBUF_HEADROOM;
+	conf.mtu = KNI_ETHER_MTU(conf.mbuf_size);
 
 	internals->kni = rte_kni_alloc(mb_pool, &conf, NULL);
 	if (internals->kni == NULL) {
diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h index 3c575c7..b9f9a6f 100644
--- a/kernel/linux/kni/compat.h
+++ b/kernel/linux/kni/compat.h
@@ -117,3 +117,7 @@
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)  #define HAVE_SIGNAL_FUNCTIONS_OWN_HEADER  #endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) #define 
+HAVE_MAX_MTU_PARAM #endif
diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c index 522ae23..04c78eb 100644
--- a/kernel/linux/kni/kni_misc.c
+++ b/kernel/linux/kni/kni_misc.c
@@ -459,6 +459,9 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,
 
 	if (dev_info.mtu)
 		net_dev->mtu = dev_info.mtu;
+#ifdef HAVE_MAX_MTU_PARAM
+	net_dev->max_mtu = net_dev->mtu;
+#endif
 
 	ret = register_netdev(net_dev);
 	if (ret) {
--
2.7.4



More information about the dev mailing list