]> git.droids-corp.org - dpdk.git/commitdiff
kni: calculate MTU from mbuf size
authorLiron Himi <lironh@marvell.com>
Tue, 26 Mar 2019 18:40:10 +0000 (20:40 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 29 Mar 2019 23:59:59 +0000 (00:59 +0100)
- 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>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
doc/guides/nics/kni.rst
doc/guides/prog_guide/kernel_nic_interface.rst
doc/guides/rel_notes/release_19_05.rst
drivers/net/kni/rte_eth_kni.c
kernel/linux/kni/compat.h
kernel/linux/kni/kni_misc.c

index 204fbd563aad61549fe72c2a357690f289b2d97b..a66c59531e184636166ed7d1bd6c215189d847ce 100644 (file)
@@ -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.
index 33ea980e55dc3fa065614d2461645b3eeccb70d1..7fcbd936f9a11a278f22ffe489581821fc34ca5e 100644 (file)
@@ -187,6 +187,8 @@ 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 KNI sample example gets the MTU from the matching device,
+and in case of KNI PMD it is derived from mbuf buffer length.
 
 The ``struct rte_kni_ops`` structure contains pointers to functions to
 handle requests from the ``rte_kni`` kernel module.  These functions
index aae8ff6029aaed640d57715db886e4c2f4c0d1cc..4e991180ed615224b0111889e9287aa4986f1f35 100644 (file)
@@ -54,6 +54,15 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Updated KNI module and PMD.**
+
+  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.
+
 * **Updated Solarflare network PMD.**
 
   Updated the sfc_efx driver including the following changes:
index a1e9970dfa232eb4bc2cd0830598f0c90f7ff92d..5e022242360e165ee32ef1e4037e0161c6722a16 100644 (file)
 /* 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) {
index 3c575c70a27c667062768237d264dba914f8d78d..562d8bf94a6ee5a43d24311529993851c2f73df9 100644 (file)
 #define ndo_change_mtu ndo_change_mtu_rh74
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
+#define HAVE_MAX_MTU_PARAM
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
 #define HAVE_SIGNAL_FUNCTIONS_OWN_HEADER
 #endif
index 522ae23b95b1d5718ed4ae4c696f89b0767c2804..04c78eb8745c64d0137598863b5a1ca503613500 100644 (file)
@@ -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) {