DPDK patches and discussions
 help / color / mirror / Atom feed
From: <lironh@marvell.com>
To: <ferruh.yigit@intel.com>
Cc: <dev@dpdk.org>, <walan@marvell.com>, Liron Himi <lironh@marvell.com>
Subject: [dpdk-dev] [PATCH v4] net/kni: calc mbuf&mtu according to given mb_pool
Date: Sun, 24 Mar 2019 14:15:45 +0200	[thread overview]
Message-ID: <1553429745-10169-1-git-send-email-lironh@marvell.com> (raw)
Message-ID: <20190324121545.IFOHs22_bgDh7URMqScl0YnffZSCpGnuTkNuwlGsIU4@z> (raw)
In-Reply-To: <1553278337-12558-1-git-send-email-lironh@marvell.com>

From: Liron Himi <lironh@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@marvell.com>
---
 doc/guides/nics/kni.rst                        |  3 ++-
 doc/guides/prog_guide/kernel_nic_interface.rst |  1 +
 doc/guides/rel_notes/release_19_05.rst         |  9 +++++++++
 drivers/net/kni/rte_eth_kni.c                  | 10 +++++++---
 examples/kni/main.c                            |  3 ++-
 kernel/linux/kni/compat.h                      |  4 ++++
 kernel/linux/kni/kni_misc.c                    |  3 +++
 7 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/doc/guides/nics/kni.rst b/doc/guides/nics/kni.rst
index 204fbd5..a66c595 100644
--- a/doc/guides/nics/kni.rst
+++ b/doc/guides/nics/kni.rst
@@ -55,7 +55,8 @@ configuration:
 
         Interface name: kni#
         force bind kernel thread to a core : NO
-        mbuf size: MAX_PACKET_SZ
+        mbuf size: (rte_pktmbuf_data_room_size(pktmbuf_pool) - RTE_PKTMBUF_HEADROOM)
+        mtu: (conf.mbuf_size - ETHER_HDR_LEN)
 
 KNI control path is not supported with the PMD, since there is no physical
 backend device by default.
diff --git a/doc/guides/prog_guide/kernel_nic_interface.rst b/doc/guides/prog_guide/kernel_nic_interface.rst
index 33ea980..412769f 100644
--- a/doc/guides/prog_guide/kernel_nic_interface.rst
+++ b/doc/guides/prog_guide/kernel_nic_interface.rst
@@ -187,6 +187,7 @@ The ``struct rte_kni_conf`` structure contains fields which allow the
 user to specify the interface name, set the MTU size, set an explicit or
 random MAC address and control the affinity of the kernel Rx thread(s)
 (both single and multi-threaded modes).
+By default the mtu is derived from the mbuf buffer length.
 
 The ``struct rte_kni_ops`` structure contains pointers to functions to
 handle requests from the ``rte_kni`` kernel module.  These functions
diff --git a/doc/guides/rel_notes/release_19_05.rst b/doc/guides/rel_notes/release_19_05.rst
index 61a2c73..74a838b 100644
--- a/doc/guides/rel_notes/release_19_05.rst
+++ b/doc/guides/rel_notes/release_19_05.rst
@@ -91,6 +91,15 @@ New Features
 
   * Added promiscuous mode support.
 
+* **Updated KNI kernel module, KNI PMD driver.**
+
+  Updated the KNI kernel module to set the max_mtu according to the given
+  initial mtu size. Without it, the maximum mtu was 1500.
+
+  Updated the KNI PMD driver to set the mbuf_size and mtu based on
+  the given mb-pool. This provide the ability to pass jumbo frames
+  if the mb-pool contains suitable buffers' size.
+
 
 Removed Items
 -------------
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/examples/kni/main.c b/examples/kni/main.c
index a58774a..50cb771 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -888,7 +888,8 @@ kni_alloc(uint16_t port_id)
 			snprintf(conf.name, RTE_KNI_NAMESIZE,
 						"vEth%u", port_id);
 		conf.group_id = port_id;
-		conf.mbuf_size = MAX_PACKET_SZ;
+		conf.mbuf_size = rte_pktmbuf_data_room_size(pktmbuf_pool) -
+			RTE_PKTMBUF_HEADROOM;
 		/*
 		 * The first KNI device associated to a port
 		 * is the master, for multiple kernel thread
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


  parent reply	other threads:[~2019-03-24 10:05 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21  8:47 [dpdk-dev] [PATCH] " lironh
2019-02-23 20:14 ` [dpdk-dev] [PATCH v2] " lironh
2019-02-25 11:29   ` Liron Himi
2019-03-10 14:27     ` Liron Himi
2019-03-13 16:57       ` Ferruh Yigit
2019-03-14  6:37         ` Liron Himi
2019-03-14  6:37           ` Liron Himi
2019-03-14  9:28           ` Ferruh Yigit
2019-03-14  9:28             ` Ferruh Yigit
2019-03-15 17:02             ` Liron Himi
2019-03-15 17:02               ` Liron Himi
2019-03-15 17:59               ` Ferruh Yigit
2019-03-15 17:59                 ` Ferruh Yigit
2019-03-17  9:43                 ` Liron Himi
2019-03-17  9:43                   ` Liron Himi
2019-03-20 19:48                   ` Ferruh Yigit
2019-03-20 19:48                     ` Ferruh Yigit
2019-03-22 18:12   ` [dpdk-dev] [PATCH v3] " lironh
2019-03-22 18:12     ` lironh
2019-03-23 21:48     ` Rami Rosen
2019-03-23 21:48       ` Rami Rosen
2019-03-24 10:05       ` [dpdk-dev] [EXT] " Liron Himi
2019-03-24 10:05         ` Liron Himi
2019-03-24 12:15     ` lironh [this message]
2019-03-24 12:15       ` [dpdk-dev] [PATCH v4] " lironh
2019-03-25 15:44       ` Ferruh Yigit
2019-03-25 15:44         ` Ferruh Yigit
2019-03-25 20:48       ` [dpdk-dev] [PATCH v5] " lironh
2019-03-25 20:48         ` lironh
2019-03-25 21:11         ` Ferruh Yigit
2019-03-25 21:11           ` Ferruh Yigit
2019-03-26 18:40         ` [dpdk-dev] [PATCH v6] " lironh
2019-03-26 17:59           ` Ferruh Yigit
2019-03-26 17:59             ` Ferruh Yigit
2019-03-30  0:00             ` Thomas Monjalon
2019-03-30  0:00               ` Thomas Monjalon
2019-03-26 18:40           ` lironh

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=1553429745-10169-1-git-send-email-lironh@marvell.com \
    --to=lironh@marvell.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=walan@marvell.com \
    /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).