From patchwork Fri Oct 25 18:30:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 62028 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3C3531E4E2; Fri, 25 Oct 2019 20:31:09 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 4803F1DF95 for ; Fri, 25 Oct 2019 20:31:06 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 11:31:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,229,1569308400"; d="scan'208";a="201890969" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.223.78]) by orsmga003.jf.intel.com with ESMTP; 25 Oct 2019 11:31:03 -0700 From: Ferruh Yigit To: Ferruh Yigit Cc: dev@dpdk.org, David Marchand , Igor Ryzhov Date: Fri, 25 Oct 2019 19:30:58 +0100 Message-Id: <20191025183058.43054-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190919112257.85337-1-iryzhov@nfware.com> References: <20190919112257.85337-1-iryzhov@nfware.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2] kni: add ability to set min/max MTU X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Igor Ryzhov 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 Acked-by: Ferruh Yigit --- examples/kni/main.c | 3 +++ kernel/linux/kni/kni_misc.c | 6 ++++++ lib/librte_eal/linux/eal/include/rte_kni_common.h | 2 ++ lib/librte_kni/rte_kni.c | 2 ++ lib/librte_kni/rte_kni.h | 2 ++ 5 files changed, 15 insertions(+) diff --git a/examples/kni/main.c b/examples/kni/main.c index c576fc767..5f713e6b2 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -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; diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c index 2b75502a8..84ef03b5f 100644 --- a/kernel/linux/kni/kni_misc.c +++ b/kernel/linux/kni/kni_misc.c @@ -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); diff --git a/lib/librte_eal/linux/eal/include/rte_kni_common.h b/lib/librte_eal/linux/eal/include/rte_kni_common.h index b51fe27bd..46f75a710 100644 --- a/lib/librte_eal/linux/eal/include/rte_kni_common.h +++ b/lib/librte_eal/linux/eal/include/rte_kni_common.h @@ -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]; }; diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index 0f3648508..7fbcf2201 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -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); diff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h index f6b66c33d..f1bb782c6 100644 --- a/lib/librte_kni/rte_kni.h +++ b/lib/librte_kni/rte_kni.h @@ -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; }; /**