From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2BFD3A0548; Thu, 4 Nov 2021 06:27:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B2DC340E5A; Thu, 4 Nov 2021 06:27:02 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 84ED340DFD for ; Thu, 4 Nov 2021 06:27:00 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10157"; a="230368285" X-IronPort-AV: E=Sophos;i="5.87,208,1631602800"; d="scan'208";a="230368285" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2021 22:26:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,208,1631602800"; d="scan'208";a="489826345" Received: from npg-dpdk-virtio-xiachenbo-nw.sh.intel.com ([10.67.119.253]) by orsmga007.jf.intel.com with ESMTP; 03 Nov 2021 22:26:58 -0700 From: Chenbo Xia To: dev@dpdk.org Cc: maxime.coquelin@redhat.com Date: Thu, 4 Nov 2021 13:11:02 +0800 Message-Id: <20211104051102.7155-1-chenbo.xia@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] examples/vhost: fix port init failure in mergeable mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" When the example starts in mergeable mode with an i40e port, it fails to launch because the examples use default mtu MAX_MTU to configure ethdev. The root cause is some devices have Ethernet frame overhead and then MAX_MTU will be larger than device's max mtu, so the ethdev configure will fail. This patch checks the device's max mtu before setting the ethdev configuration. If the device has a max mtu, use that value to configure. Fixes: 1bb4a528c41f ("ethdev: fix max Rx packet length") Signed-off-by: Chenbo Xia Reported-by: Xingguang He --- examples/vhost/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 58e12aa710..09fb2382bf 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -273,6 +273,13 @@ port_init(uint16_t port) tx_rings = (uint16_t)rte_lcore_count(); + if (mergeable) { + if (dev_info.max_mtu != UINT16_MAX && dev_info.max_rx_pktlen > dev_info.max_mtu) + vmdq_conf_default.rxmode.mtu = dev_info.max_mtu; + else + vmdq_conf_default.rxmode.mtu = MAX_MTU; + } + /* Get port configuration. */ retval = get_eth_conf(&port_conf, num_devices); if (retval < 0) @@ -631,8 +638,6 @@ us_vhost_parse_args(int argc, char **argv) return -1; } mergeable = !!ret; - if (ret) - vmdq_conf_default.rxmode.mtu = MAX_MTU; break; case OPT_STATS_NUM: -- 2.17.1