kni: set initial value for MTU
authorHemant Agrawal <hemant.agrawal@nxp.com>
Thu, 18 Jan 2018 06:13:00 +0000 (11:43 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 1 Feb 2018 00:03:26 +0000 (01:03 +0100)
Configure initial application provided  mtu on the KNI interface.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
examples/kni/main.c
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
lib/librte_eal/linuxapp/kni/kni_misc.c
lib/librte_kni/rte_kni.c
lib/librte_kni/rte_kni.h

index bd3b329..0d9980e 100644 (file)
@@ -846,6 +846,8 @@ kni_alloc(uint16_t port_id)
                        rte_eth_macaddr_get(port_id,
                                        (struct ether_addr *)&conf.mac_addr);
 
+                       rte_eth_dev_get_mtu(port_id, &conf.mtu);
+
                        memset(&ops, 0, sizeof(ops));
                        ops.port_id = port_id;
                        ops.change_mtu = kni_change_mtu;
index b186417..cfa9448 100644 (file)
@@ -120,6 +120,7 @@ struct rte_kni_device_info {
 
        /* mbuf size */
        unsigned mbuf_size;
+       unsigned int mtu;
        char mac_addr[6];
 };
 
index 83649ce..01574ec 100644 (file)
@@ -451,6 +451,9 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,
                        random_ether_addr(net_dev->dev_addr);
        }
 
+       if (dev_info.mtu)
+               net_dev->mtu = dev_info.mtu;
+
        ret = register_netdev(net_dev);
        if (ret) {
                pr_err("error %i registering device \"%s\"\n",
index c089a49..2867411 100644 (file)
@@ -340,6 +340,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
        dev_info.force_bind = conf->force_bind;
        dev_info.group_id = conf->group_id;
        dev_info.mbuf_size = conf->mbuf_size;
+       dev_info.mtu = conf->mtu;
 
        memcpy(dev_info.mac_addr, conf->mac_addr, ETHER_ADDR_LEN);
 
index 711c2a9..99055e2 100644 (file)
@@ -69,6 +69,7 @@ struct rte_kni_conf {
        __extension__
        uint8_t force_bind : 1; /* Flag to bind kernel thread */
        char mac_addr[ETHER_ADDR_LEN]; /* MAC address assigned to KNI */
+       uint16_t mtu;
 };
 
 /**