]> git.droids-corp.org - dpdk.git/commitdiff
kni: add ability to set min/max MTU
authorIgor Ryzhov <iryzhov@nfware.com>
Fri, 25 Oct 2019 18:30:58 +0000 (19:30 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Sun, 27 Oct 2019 10:07:43 +0000 (11:07 +0100)
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>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
examples/kni/main.c
kernel/linux/kni/kni_misc.c
lib/librte_eal/linux/eal/include/rte_kni_common.h
lib/librte_kni/rte_kni.c
lib/librte_kni/rte_kni.h

index c576fc767e150e031f5ee5f3f1e4d1b4ea274100..5f713e6b228f885c0ac83a0b6b8b13054e84fe3c 100644 (file)
@@ -949,6 +949,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;
index 2b75502a8b0e8cb04ce86b46610a5022f62724cf..84ef03b5f8b06cfa49ed40f9476194dba4c4ab56 100644 (file)
@@ -388,6 +388,12 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,
                net_dev->mtu = dev_info.mtu;
 #ifdef HAVE_MAX_MTU_PARAM
        net_dev->max_mtu = net_dev->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);
index b51fe27bd77ec30e74efcaf871ed28badd125c2c..46f75a71039a2e5000fa4cd473f34320b60f633d 100644 (file)
@@ -122,6 +122,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];
 };
 
index 0f36485089af5b44eb6ef0746d36d6da7e5f51a9..7fbcf2201035a8dc52fa45ec6687a6295a4d6d9e 100644 (file)
@@ -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);
 
index f6b66c33de1754d80b092303bb2875e1a2af7bb6..f1bb782c68eaefd70088bf12908459b6e6faa2d7 100644 (file)
@@ -73,6 +73,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;
 };
 
 /**