From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ECBF7A09DE; Fri, 13 Nov 2020 11:37:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BE7F0C868; Fri, 13 Nov 2020 11:37:29 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 391454CA6 for ; Fri, 13 Nov 2020 11:37:27 +0100 (CET) IronPort-SDR: TEfciv0QvizmUUWaobkqDDV4/uyGEJ5A8yi9dHWqW+kaJf69RoBSqI4LZXBmz6CS4H0bgvzWh/ u5eIsoCtdlPQ== X-IronPort-AV: E=McAfee;i="6000,8403,9803"; a="166946566" X-IronPort-AV: E=Sophos;i="5.77,475,1596524400"; d="scan'208";a="166946566" 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/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 02:37:24 -0800 IronPort-SDR: LTi75RO93+FWRk1rmdLykCLmV1NqIoKx3Hg62DkaxenI4iXjYnTRLALcv8z9QQaRclGTKdB9dC qdOh/DqMxzgg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,475,1596524400"; d="scan'208";a="323955547" Received: from irsmsx606.ger.corp.intel.com ([163.33.146.139]) by orsmga003.jf.intel.com with ESMTP; 13 Nov 2020 02:37:23 -0800 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by IRSMSX606.ger.corp.intel.com (163.33.146.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 13 Nov 2020 10:37:19 +0000 Received: from shsmsx601.ccr.corp.intel.com ([10.109.6.141]) by SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.1713.004; Fri, 13 Nov 2020 18:37:17 +0800 From: "Zhang, Qi Z" To: "Yigit, Ferruh" , "Lu, Wenzhuo" , "Xing, Beilei" , "Iremonger, Bernard" CC: "Yigit, Ferruh" , "dev@dpdk.org" , "Yang, SteveX" , Thomas Monjalon , Andrew Rybchenko , "Ananyev, Konstantin" , Olivier Matz , Lance Richardson Thread-Topic: [dpdk-dev] [RFC] app/testpmd: fix MTU after device configure Thread-Index: AQHWs57vdwTem6YH60efuRn9lKpPbanF6oJg Date: Fri, 13 Nov 2020 10:37:17 +0000 Message-ID: <4b285aaef3bd4a5b9382a9138871f7c7@intel.com> References: <20201105180942.2938152-1-ferruh.yigit@intel.com> In-Reply-To: <20201105180942.2938152-1-ferruh.yigit@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows x-originating-ip: [10.108.32.68] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC] app/testpmd: fix MTU after device configure 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" > -----Original Message----- > From: dev On Behalf Of Ferruh Yigit > Sent: Friday, November 6, 2020 2:10 AM > To: Lu, Wenzhuo ; Xing, Beilei > ; Iremonger, Bernard > Cc: Yigit, Ferruh ; dev@dpdk.org; Yang, SteveX > ; Thomas Monjalon ; > Andrew Rybchenko ; Ananyev, Konstantin > ; Olivier Matz ; > Lance Richardson > Subject: [dpdk-dev] [RFC] app/testpmd: fix MTU after device configure >=20 > In 'rte_eth_dev_configure()', if 'DEV_RX_OFFLOAD_JUMBO_FRAME' is not set > the max frame size is limited to 'RTE_ETHER_MAX_LEN' (1518). > This is mistake because for the PMDs that has frame size bigger than > "RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN" (18 bytes), the MTU becomes > less than 1500, causing a valid frame with 1500 bytes payload to be dropp= ed. >=20 > Since 'rte_eth_dev_set_mtu()' works as expected, it is called after > 'rte_eth_dev_configure()' to fix the MTU. > It may look redundant to set MTU after 'rte_eth_dev_configure()', both wi= th > default values, but it is not, the resulting MTU config can be different = in the > device based on frame overhead of the PMD. >=20 > And instead of setting the MTU to default value, it is first get via > 'rte_eth_dev_get_mtu()' and set again, this is to cover cases MTU changed > from testpmd command line. >=20 > 'rte_eth_dev_set_mtu()', '-ENOTSUP' error is ignored to prevent irrelevan= t > warning messages for the virtual PMDs. >=20 > Signed-off-by: Ferruh Yigit Reviewed-by: Qi Zhang > --- > Cc: Steve Yang > Cc: Thomas Monjalon > Cc: Andrew Rybchenko > Cc: Konstantin Ananyev > Cc: Olivier Matz > Cc: Lance Richardson > --- > app/test-pmd/testpmd.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) >=20 > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index > 33fc0fddf5..48e9647fc7 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -2537,6 +2537,8 @@ start_port(portid_t pid) > } >=20 > if (port->need_reconfig > 0) { > + uint16_t mtu =3D RTE_ETHER_MTU; > + > port->need_reconfig =3D 0; >=20 > if (flow_isolate_all) { > @@ -2570,6 +2572,23 @@ start_port(portid_t pid) > port->need_reconfig =3D 1; > return -1; > } > + > + /* > + * Workaround for rte_eth_dev_configure(), max_rx_pkt_len > + * set MTU wrong for the PMDs that have frame overhead > + * bigger than RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN. > + * For a PMD that has 26 bytes overhead, > rte_eth_dev_configure() > + * can set MTU to max 1492, not to expected 1500 bytes. > + * Using rte_eth_dev_set_mtu() to be able to set MTU > correctly, > + * default MTU value is 1500. > + */ > + diag =3D rte_eth_dev_get_mtu(pi, &mtu); > + if (diag) > + printf("Failed to get MTU for port %d\n", pi); > + diag =3D rte_eth_dev_set_mtu(pi, mtu); > + if (diag !=3D 0 && diag !=3D -ENOTSUP) > + printf("Failed to set MTU to %u for port %d\n", > + mtu, pi); > } > if (port->need_reconfig_queues > 0) { > port->need_reconfig_queues =3D 0; > -- > 2.26.2