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 0BEF8A034F; Mon, 11 Oct 2021 22:15:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D397C4111C; Mon, 11 Oct 2021 22:15:36 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 5FD24410FA for ; Mon, 11 Oct 2021 22:15:35 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10134"; a="213908459" X-IronPort-AV: E=Sophos;i="5.85,365,1624345200"; d="scan'208";a="213908459" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2021 13:15:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,365,1624345200"; d="scan'208";a="441562503" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga003.jf.intel.com with ESMTP; 11 Oct 2021 13:15:28 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Mon, 11 Oct 2021 13:15:28 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Mon, 11 Oct 2021 13:15:27 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Mon, 11 Oct 2021 13:15:27 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.43) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Mon, 11 Oct 2021 13:15:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mdtx7yI7DXsz7eFznzyHUbO+dSbMIJy3hwWjKEI0P7wloxFlX0jIQ0SWCY+dNdEtnoffIIK1TUBDhchBgLwAMlcDAwBI4zwF6msfpco5dbEX93j7OVXmfHvRv/1XHLFbtm9SyEDrEr5ZXU3DA0H9NQtiL5zq/XFiqbCA5yNYlZQKENjxXIMzJwuc4CCwXxtKLxz1HczCs9+QP97SUmfpEusySr46t5/l4nnfaC0z81sH3L2yeU4s9xa+asR55+ORrVQHBJRJmO24AO07LtobnPCKeLjRp91X51JzRskq+y+uMw5XCI8Lw9wQ6Dy78k5Eh1u1pTwUJRNHCx/8qx7RXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H+JhjJlrAAWHSIrzbOdYnad2zOdGQDGmrdQ0Wt4kvwc=; b=VtrW+P2NFQIYzurKBzYjEy5exswj58R98MXQTqUKjcfQHZq+WdvoAmTgxxlVJm0x11mTGLav5R9m/ZHZOBrEfoZiH2telRAl8/saUyHumxTebYMAA+rBBxri0JQKaYx33kd2MVvj3eLT605nrtGELd7laUOaoowLiAID5XXicrtondmCFfhqvwqcoHj32C3L37G8wJ3HWiFJTFNliGMczOjGZOEI2LPHryzKU/WtVUHIDWhyzWcrU7l9rB4w6tdz7cuCEGi3sCIU9DBBtJmBVow5el+no9W9a2dn2MqVsa+29g4OEUIDJq0b9HqTkD284ZTApvBk6PO0f3d+HM6cUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H+JhjJlrAAWHSIrzbOdYnad2zOdGQDGmrdQ0Wt4kvwc=; b=D3DLPKrlMA5kAzfH8UK4DfHdKRrG5Wx7ExC1EMxC+vDf97d7HvAY0+kZxXX41d74v8KFsKSHvw6Kh5mPX79WlJLZo/oAh+5uHaQjTHK59RRSG2CtA+Q4GGRoRowZplqcPQLNbGO3stCfqd7vZ8yLCtzj62zWrNXjC0VeRkH0nlI= Authentication-Results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by PH0PR11MB4951.namprd11.prod.outlook.com (2603:10b6:510:43::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Mon, 11 Oct 2021 20:15:26 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd7d:29be:3342:632c]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd7d:29be:3342:632c%5]) with mapi id 15.20.4587.026; Mon, 11 Oct 2021 20:15:26 +0000 Message-ID: <8afc3490-84b1-37e8-6261-ec535cf98e80@intel.com> Date: Mon, 11 Oct 2021 21:15:20 +0100 Content-Language: en-US To: "lihuisong (C)" CC: , Thomas Monjalon , Andrew Rybchenko References: <20211001143624.3744505-1-ferruh.yigit@intel.com> <20211007165626.2941995-1-ferruh.yigit@intel.com> <20211007165626.2941995-5-ferruh.yigit@intel.com> <5f1104a7-2e57-d95d-447d-81616f5dc8ea@huawei.com> From: Ferruh Yigit X-User: ferruhy In-Reply-To: <5f1104a7-2e57-d95d-447d-81616f5dc8ea@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: DB7PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:10:36::18) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 Received: from [192.168.0.206] (37.228.236.146) by DB7PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:10:36::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Mon, 11 Oct 2021 20:15:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba713f6a-c337-4ba3-c933-08d98cf3dcf7 X-MS-TrafficTypeDiagnostic: PH0PR11MB4951: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1060; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1Pi1CSFTinrHjq9GGONGJCAJMfHPT4ngzyT9c5cITNzCdABuqAJn5nJS0K6yLuxIDxQEbcAOkoXIc72XUtna6BLPANehFj+Z8Jc65DeVQn7EYaWDxqbGL0kk4p5jeRqXYsR9OjHDqmhR6URGQlYX3nBTwfS4iKcuTg94b5rzYt8/a+06tWQQi7+zoTjKHq0YZiEPs1g9F7mMiB9xjcMVG6RU3cMotZBonRz/1tA8jtfiAniTALxG1dGTi82VOQDQ7XSk4llrQA7wPgM50XmVfyEQMxI58NgpgnEf6XAucMHS5aiGSBlnUlNP1eKFU/NtOqzoj9mm9vz7GZb8AgldwCLs+B11dsLcRKsfrOmlxyWm1yZyuZFe/EeyovpNcGEH29+MKXCaCScGWXwwCRiTNp9XbFf2wgqf64eaBeN0SyxMxmZP9luezUbsEI1fe7Y6fljlOVQ1cDR5qqzXmbx76As1jJZormzEO0vn6kYOnOKtY8qEWvAqwcsMATE3mfJl49pvsF7a4LjAoz+ttYeW1zHiHw4CNlfDUKzrFGQr69ExmC5RPe+GBeW0/NfmVIR4iVp0wlgHsXeGfpmotOOFdzTKbn3jKCd0Lkr9idJF4ae+PWnn2N1qkQRZGxq4jRXYSfYPMZWRTW1j/xSrEcsLJZwce8kVNDNDtg8/C3t6B+b+JmCBhc8XBwumDiCj2CULDa/fZw1DeIrtQN47EzPLlQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(31696002)(66476007)(2906002)(66556008)(508600001)(16576012)(316002)(44832011)(6916009)(4326008)(31686004)(2616005)(956004)(54906003)(86362001)(83380400001)(26005)(186003)(66946007)(6666004)(8936002)(53546011)(6486002)(36756003)(38100700002)(8676002)(5660300002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aE5qTk95akxkTUlBbldBbG1vVmxPSS9oUHlxbkg4TW8vWENJbGVzaGlRZng4?= =?utf-8?B?cWIvbVFKTmhLanZ1SmFvRUdxMlRVWTZmUjFocENWNk9BSkFveGwxS1BLaFFO?= =?utf-8?B?VnhLUSs0Q0FzVUtWWnpOaktnNnZOV09XTTdiY2JwSnNoUXA4elcxZmNVMHlT?= =?utf-8?B?TFczVHJLSjV6K0cwQkxWWVA0ZnVDMDBYa3ZGTGE4Q1ltNGVnYk8yMnQwd29h?= =?utf-8?B?bWgyeUpvYkN1cnJYTzNwMGNRT1ZUQzR5aFFwcEhCcDluR3dzMU1Ic2hTcmJB?= =?utf-8?B?VkhTYnRwdU9uQWlGdWJad3l1UUNVU1RlaVUwNStObG9HV0NUejdBK2oxc25I?= =?utf-8?B?OEJ5YUhwTTZSSzJ1di9uMXNPOS80ZHdkRjFyRkl5Wk5IUFFYb1NQeElvTHZV?= =?utf-8?B?dFpwbVZTV3VtQjUwYTlOVWlMOU83QU1MUEc4NDFZN2E5YVFIOEtUMVR3eTM0?= =?utf-8?B?T3A2b2UyUFNCQ1gyTkR6bXY4cVFWbjcwc0pQZnRnL2hCam9TZDBaTjZDVEUw?= =?utf-8?B?RXdZZzJHclpTcnFqclJ0ZlZlOUpnVWdpMG42dm01dFhmcHl6d3R6em95U1hu?= =?utf-8?B?UzBML0wycGJzanhwTEFDZFRvS1ZaYjh6YmRPL2VhcXVpQjgwYmlBWXBlZysv?= =?utf-8?B?dm50clFuTXJCaVZ2Zi9LbnlOTERBZ0ljbGJ2Z3I5ZnM1Y2pza283NEZLTU9i?= =?utf-8?B?dlREaG5CTEIrdWpUT1NGeDdYamtkSk5FU2lmS3RUSG5xTzZIbmZMSGdOMjJR?= =?utf-8?B?V2tDbUdvZWVBNE1aQ2psZGRnUTdCMzZGYmNOZkZ0UURIcmd4YkNPQUVlb3lr?= =?utf-8?B?bFJmaTFNWFBpTkVoQm53WkQ4cGtTN2EvSWN6YUdNVUwwN2s0cmxKSFJRN1Uy?= =?utf-8?B?aXFvNmNIWEVGRzZsQjFncitKRjcyQWRncUJxZGtGUUZiRklXZzlRaXJ0VmlP?= =?utf-8?B?YU55QWpUdFdZMHFrS3BHNnhYSW43dGlLWlJ0QnQxbGVHcC9wdTlzSmtzai9s?= =?utf-8?B?bGhIVHg5YzRFeTVOTXAyU1FYYkVGT0NxOTQzTU5lSEFRTXdCNGt6Mk9IWTh3?= =?utf-8?B?ZEJWMDR5bXlmRExKLzQxMlFpQWx6VktxMHErMzRMdTNQdW5CMG1WYUJDLzZh?= =?utf-8?B?Nk9aVTFMcVdvbDZQQ2trOUxDV1NpMG9GUERHLytJcW1mUGk2cGNRdVpXT0pW?= =?utf-8?B?c0R0NlRzRENpRXNBbitHNHl5ekpYVWx4enYvek82ZEZmbE1yWlFENEVueURo?= =?utf-8?B?S1c5NE1sYW81UXZlNFVxZ0NDKzIraWh6THpPbk9yMTNCTXpaY0dwSUphYkdi?= =?utf-8?B?WGVwSzdtMGJyeUpoeks5bFpqSEFsZWZ5Y0FSMXJuQTRiZEZYRldFZndVMWR3?= =?utf-8?B?emJtUkNMdzlDRmFuU1IyMjhXUTRHbXVmdGxaMm5uQmZhamRXZUIrOXRlNnJT?= =?utf-8?B?TndlblhjYUdUcmJxY2REUyt3Ykl0MWxrWnNacEFxWThDUStRYW4vSEE5MUdn?= =?utf-8?B?ME9WL1lSTkp3WUtFSm1KNEtHOE1QOGk5VE5JMTh3dVFzWkgxQ05rUmVlbEdl?= =?utf-8?B?cHFZRU5xcXQ3dW04N0lDYkxxa3U1cnJ2ZVFMV2RockxNVnZWaEZuMzZlU2hv?= =?utf-8?B?cnBWS09XbFNibUJVWWJQVStMRlBGcHROZHNrcTBiUXVWK1NSUkloQlFWbldu?= =?utf-8?B?UG1waWc0bXNWamEzYVUveS9qMkxjem11WWJiVDZuQ2tGRHZGTXhqUWJaM3d2?= =?utf-8?Q?15L+jDwbnNxDWikUM8z+K9QlemHtMjYZ/zUniNc?= X-MS-Exchange-CrossTenant-Network-Message-Id: ba713f6a-c337-4ba3-c933-08d98cf3dcf7 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2021 20:15:26.4521 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WYM0S3pfLSepYSW0r8fwDZZjv23dcbB4AKLiOzVo/+i6m2KNBu3dnTz/aAWZ5GjM4HgBkXV1fK4rQDCkb8/o7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4951 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v5 5/6] ethdev: unify MTU checks 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" On 10/9/2021 12:43 PM, lihuisong (C) wrote: > Hi, Ferruh > > 在 2021/10/8 0:56, Ferruh Yigit 写道: >> Both 'rte_eth_dev_configure()' & 'rte_eth_dev_set_mtu()' sets MTU but >> have slightly different checks. Like one checks min MTU against >> RTE_ETHER_MIN_MTU and other RTE_ETHER_MIN_LEN. >> >> Checks moved into common function to unify the checks. Also this has >> benefit to have common error logs. >> >> Suggested-by: Huisong Li >> Signed-off-by: Ferruh Yigit >> --- >>   lib/ethdev/rte_ethdev.c | 82 ++++++++++++++++++++++++++--------------- >>   lib/ethdev/rte_ethdev.h |  2 +- >>   2 files changed, 54 insertions(+), 30 deletions(-) >> >> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c >> index c2b624aba1a0..0a6e952722ae 100644 >> --- a/lib/ethdev/rte_ethdev.c >> +++ b/lib/ethdev/rte_ethdev.c >> @@ -1336,6 +1336,47 @@ eth_dev_get_overhead_len(uint32_t max_rx_pktlen, uint16_t max_mtu) >>       return overhead_len; >>   } >> +/* rte_eth_dev_info_get() should be called prior to this function */ >> +static int >> +eth_dev_validate_mtu(uint16_t port_id, struct rte_eth_dev_info *dev_info, >> +        uint16_t mtu) >> +{ >> +    uint16_t overhead_len; >> +    uint32_t frame_size; >> + >> +    if (mtu < dev_info->min_mtu) { >> +        RTE_ETHDEV_LOG(ERR, >> +            "MTU (%u) < device min MTU (%u) for port_id %u\n", >> +            mtu, dev_info->min_mtu, port_id); >> +        return -EINVAL; >> +    } >> +    if (mtu > dev_info->max_mtu) { >> +        RTE_ETHDEV_LOG(ERR, >> +            "MTU (%u) > device max MTU (%u) for port_id %u\n", >> +            mtu, dev_info->max_mtu, port_id); >> +        return -EINVAL; >> +    } >> + >> +    overhead_len = eth_dev_get_overhead_len(dev_info->max_rx_pktlen, >> +            dev_info->max_mtu); >> +    frame_size = mtu + overhead_len; >> +    if (frame_size < RTE_ETHER_MIN_LEN) { >> +        RTE_ETHDEV_LOG(ERR, >> +            "Frame size (%u) < min frame size (%u) for port_id %u\n", >> +            frame_size, RTE_ETHER_MIN_LEN, port_id); >> +        return -EINVAL; >> +    } >> + >> +    if (frame_size > dev_info->max_rx_pktlen) { >> +        RTE_ETHDEV_LOG(ERR, >> +            "Frame size (%u) > device max frame size (%u) for port_id %u\n", >> +            frame_size, dev_info->max_rx_pktlen, port_id); >> +        return -EINVAL; >> +    } > > This function is used to verify the MTU. So "frame_size" is redundant. > Yes it is redundant for the drivers that both announce 'max_rx_pktlen' & 'max_mtu', but stil some drivers doesn't announce the 'max_mtu' values and default value 'UINT16_MAX' is set by ethdev, specially virtual drivers. That is why I kept both to be in safe side. > As modified by this patch, dev_info->min_mtu is calculated based on RTE_ETHER_MIN_LEN. > And for the min check, for the default 'min_mtu' check is redundant, but for the cases driver sets "min_mtu < (RTE_ETHER_MIN_LEN - overhead_len)" second check becomes different limit. I don't know if this happens at all in practice but I think it doesn't hurt to have both checks to be on safe side. >> + >> +    return 0; >> +} >> + >>   int >>   rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, >>                 const struct rte_eth_conf *dev_conf) >> @@ -1463,26 +1504,13 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, >>           goto rollback; >>       } >> -    /* >> -     * Check that the maximum RX packet length is supported by the >> -     * configured device. >> -     */ >>       if (dev_conf->rxmode.mtu == 0) >>           dev->data->dev_conf.rxmode.mtu = RTE_ETHER_MTU; >> -    max_rx_pktlen = dev->data->dev_conf.rxmode.mtu + overhead_len; >> -    if (max_rx_pktlen > dev_info.max_rx_pktlen) { >> -        RTE_ETHDEV_LOG(ERR, >> -            "Ethdev port_id=%u max_rx_pktlen %u > max valid value %u\n", >> -            port_id, max_rx_pktlen, dev_info.max_rx_pktlen); >> -        ret = -EINVAL; >> -        goto rollback; >> -    } else if (max_rx_pktlen < RTE_ETHER_MIN_LEN) { >> -        RTE_ETHDEV_LOG(ERR, >> -            "Ethdev port_id=%u max_rx_pktlen %u < min valid value %u\n", >> -            port_id, max_rx_pktlen, RTE_ETHER_MIN_LEN); >> -        ret = -EINVAL; >> + >> +    ret = eth_dev_validate_mtu(port_id, &dev_info, >> +            dev->data->dev_conf.rxmode.mtu); >> +    if (ret != 0) >>           goto rollback; >> -    } >>       dev->data->mtu = dev->data->dev_conf.rxmode.mtu; >> @@ -1491,6 +1519,9 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, >>        * size is supported by the configured device. >>        */ >>       if (dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_TCP_LRO) { >> +        overhead_len = eth_dev_get_overhead_len(dev_info.max_rx_pktlen, >> +                dev_info.max_mtu); >> +        max_rx_pktlen = dev->data->dev_conf.rxmode.mtu + overhead_len; >>           if (dev_conf->rxmode.max_lro_pkt_size == 0) >>               dev->data->dev_conf.rxmode.max_lro_pkt_size = max_rx_pktlen; >>           ret = eth_dev_check_lro_pkt_size(port_id, >> @@ -3437,7 +3468,8 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info) >>       dev_info->rx_desc_lim = lim; >>       dev_info->tx_desc_lim = lim; >>       dev_info->device = dev->device; >> -    dev_info->min_mtu = RTE_ETHER_MIN_MTU; >> +    dev_info->min_mtu = RTE_ETHER_MIN_LEN - RTE_ETHER_HDR_LEN - >> +        RTE_ETHER_CRC_LEN; > I suggest that the adjustment to the minimum mtu size is also explicitly reflected in the commit log. ack, I will >>       dev_info->max_mtu = UINT16_MAX; >>       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP); >> @@ -3643,21 +3675,13 @@ rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu) >>        * which relies on dev->dev_ops->dev_infos_get. >>        */ >>       if (*dev->dev_ops->dev_infos_get != NULL) { >> -        uint16_t overhead_len; >> -        uint32_t frame_size; >> - >>           ret = rte_eth_dev_info_get(port_id, &dev_info); >>           if (ret != 0) >>               return ret; >> -        if (mtu < dev_info.min_mtu || mtu > dev_info.max_mtu) >> -            return -EINVAL; >> - >> -        overhead_len = eth_dev_get_overhead_len(dev_info.max_rx_pktlen, >> -                dev_info.max_mtu); >> -        frame_size = mtu + overhead_len; >> -        if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) >> -            return -EINVAL; >> +        ret = eth_dev_validate_mtu(port_id, &dev_info, mtu); >> +        if (ret != 0) >> +            return ret; >>       } >>       ret = (*dev->dev_ops->mtu_set)(dev, mtu); >> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h >> index 4d0f956a4b28..50e124ff631f 100644 >> --- a/lib/ethdev/rte_ethdev.h >> +++ b/lib/ethdev/rte_ethdev.h >> @@ -3056,7 +3056,7 @@ int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr); >>    *  }; >>    * >>    * device = dev->device >> - * min_mtu = RTE_ETHER_MIN_MTU >> + * min_mtu = RTE_ETHER_MIN_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN >>    * max_mtu = UINT16_MAX >>    * >>    * The following fields will be populated if support for dev_infos_get()