From abdf63d11b0917bde76fa5a73c16363bc497085b Mon Sep 17 00:00:00 2001 From: Hemant Agrawal Date: Thu, 18 Jan 2018 11:43:00 +0530 Subject: [PATCH] kni: set initial value for MTU Configure initial application provided mtu on the KNI interface. Signed-off-by: Hemant Agrawal Acked-by: Ferruh Yigit --- examples/kni/main.c | 2 ++ lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 1 + lib/librte_eal/linuxapp/kni/kni_misc.c | 3 +++ lib/librte_kni/rte_kni.c | 1 + lib/librte_kni/rte_kni.h | 1 + 5 files changed, 8 insertions(+) diff --git a/examples/kni/main.c b/examples/kni/main.c index bd3b329f8e..0d9980ee1e 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -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; diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h index b186417cd4..cfa9448bd0 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h @@ -120,6 +120,7 @@ struct rte_kni_device_info { /* mbuf size */ unsigned mbuf_size; + unsigned int mtu; char mac_addr[6]; }; diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 83649ce49d..01574ecf74 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -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", diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index c089a49a26..28674115ff 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -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); diff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h index 711c2a980a..99055e2c25 100644 --- a/lib/librte_kni/rte_kni.h +++ b/lib/librte_kni/rte_kni.h @@ -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; }; /** -- 2.20.1