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 61F34A0093; Mon, 25 Apr 2022 18:25:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2CAA41109; Mon, 25 Apr 2022 18:25:27 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id E1CE040E78 for ; Mon, 25 Apr 2022 18:25:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650903927; x=1682439927; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=9ioYNJwGRGXciE07pIhJGku1OCl4hHU/EOXqIcRyBxY=; b=i53R2JkL6ZoeJJQqwIKzmDaqjxU0gjwZZ5KN2Ol4bHGDi/j3u5Rtutgi Oe4IFLHXBjnJIPWaZms/entgup+NYQialFlqL23oMTQ+Cv+xwg6obSwNW GxwL4wDSvFOVeJF1YMZFusygiqU9BspbfAXNw5OhtnOJY9Qj62dtvgjOh rDkBT+JmpvqzmbytOVmczC6GKW8hgG1RXWRFRE0x1WsDL9PoMvZiv/SJ0 U9iZdo87NK+s+fPt7WfNqOh8YF26XIBFeeLF7KQ8yt4dUgsqBZMVKQegt ptUBYh/V2aVurDXdv4n+LJwnE223jiUmw69dJeIqBFkZYww8z9uCkA55w g==; X-IronPort-AV: E=McAfee;i="6400,9594,10328"; a="247225707" X-IronPort-AV: E=Sophos;i="5.90,288,1643702400"; d="scan'208";a="247225707" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 09:25:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,288,1643702400"; d="scan'208";a="557808013" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga007.jf.intel.com with ESMTP; 25 Apr 2022 09:25:24 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 25 Apr 2022 09:25:24 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Mon, 25 Apr 2022 09:25:24 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.175) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Mon, 25 Apr 2022 09:25:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SmYgddlnJQJKUNCWPhG0elP8mwlgkHq3T8kh0WI8mDY6pXSMOw+UwcPpd7GdZHetvLoetIHLEjdo+Sznv9la0J/HztHKJ49RgZ9MUXnNieOwCeJZOT1gpycDpH+jJn4xiOOq2Xb9V0XrwGoMtVIw09yoBV/47v9hdm9dqQxCue8NTzYE7TU69oZZ3c8pJbkqjv+q76Ui5xBWy6uOXLlVY3rdp6LrrkBPsuOVN5bUQnHj0iWulvZzXH8rxdItvbNRsAQz1DQzftMlb+d5pJXIUB9Q1qWHKP6be1jD2cYngGemP+PBZkJVmgxtW/GikKaNQVWd4tHg/ZbOimQSyv4pkA== 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=pyCxVkUiMLjBbkYG1wMOaLapNL6WgsIt49ErqVs0Wpo=; b=UhtQkb73Ueh8DzDDIdvMe8jhcJE/xadWzSFfHndtmMdSToqu3e4dA4Tsqrw8eFtadxuJyUsNqY9hQq2Wq03JdW51FBDP+DJCvdlp/OgJFw27PSpurZfNi2qViZ8lvvz/EfPNmoiWjT9JN8hglwTlvikZk2pxz5A3eJ0hL1FxZG2Hi8F4obtw27j6w40WrbmYZrjmLJrjdOcJ99sKWQj+m6NSOu8Eqq1VGbEUqgax4wtOktHUm8D5APpBCEjgkllIKiG9SifL2Aq0o9G57zn/M+SR6Czy2I7Ri6Z2Vv6WHwO4emJgHSiU/bclzv0ISJMrGZpPWtJ6GkfhYBsT/6aGbA== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MWHPR11MB0062.namprd11.prod.outlook.com (2603:10b6:301:67::34) by DM5PR11MB1242.namprd11.prod.outlook.com (2603:10b6:3:14::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Mon, 25 Apr 2022 16:25:22 +0000 Received: from MWHPR11MB0062.namprd11.prod.outlook.com ([fe80::c3c:359:d9c4:3a54]) by MWHPR11MB0062.namprd11.prod.outlook.com ([fe80::c3c:359:d9c4:3a54%4]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 16:25:22 +0000 Message-ID: Date: Mon, 25 Apr 2022 21:55:13 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH 2/2] app/testpmd: fix incorrect MTU verification Content-Language: en-US To: "Min Hu (Connor)" , CC: , , , References: <20220406084537.16799-1-humin29@huawei.com> <20220406084537.16799-3-humin29@huawei.com> From: "Singh, Aman Deep" In-Reply-To: <20220406084537.16799-3-humin29@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PN0PR01CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:4f::11) To MWHPR11MB0062.namprd11.prod.outlook.com (2603:10b6:301:67::34) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3414626d-5ee8-477f-a344-08da26d831cf X-MS-TrafficTypeDiagnostic: DM5PR11MB1242:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9lCVmn+5ohcWjxWJRK65UFBIpjn5XO9dib1v2a1np3n2xNTDS1QJ4oK++B+Zo2QXLIcPt63pEawKCyEuOZ1503vTwTP9T4Ow/KhFiEFUu9YW11Q/wcGckhNTXLArX0oCB/Rri6ovjbgsrN5tHO6mllKqJgbQGzpHLzChFR7/cYdt0hvLat5mZy5r5lc1GwpErkYIokXZ2/4W+JHr86D+gAnNC6qHwbhie85vyihlglPluGQW0tFN0yTgOqjjKzvmp6fd3tiFP6x6kBMwHax5YrptYVR3FNtSp4WNQMuFoVziaV86eUKZgrFA2bv4jxsM9YYDXFXsxYqUdBcwnDKqs+w5gd7aaqpdLmPKUvwUmgt6mXFae/Cn/DhDIwD1OVo0a7mkQwcy+/SawcTKm/0+5GjBw3eSwhH2onrNXOdgF90cQ5M3z9Z//LvsZ3vCsE3Ay7BSS7mi4TLjFPOeOcKhx/PLVijKArszed4EGQtqPfpluiVEi7nUptbLxZ6TxDVRSZml2fdmhNLwYAGhD7PK1H6rC/Qy4ZqQR+EoDLBp45Mr2gktd/w5cJ5/XEn5jCvpTBw+0zwDCraL3kdyGiVJIothDUw0JNLZRsZL9Ya+PjAkSEJmLqHTJap1AAu8KCSHUjdi5HFDGRcUZI9EuEwqYQ8JMBO3qwYg6/aW+AorP5O61DCshu69T6DLlj7N6OWSMHO4qnsHk+354gNSg6K9kR4LnDybXdyRRXS3NAg8KvY= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB0062.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(4326008)(66476007)(8676002)(2616005)(31686004)(186003)(86362001)(316002)(66946007)(66556008)(36756003)(5660300002)(8936002)(6512007)(26005)(31696002)(83380400001)(6486002)(508600001)(53546011)(6506007)(107886003)(38100700002)(6666004)(82960400001)(2906002)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bzFjUzNYdDdoMzZJaldPSzN1K2FLcm4wMmhyOFB6K3NYM1YrTmJpWmlXSVM5?= =?utf-8?B?V0VCTmppWFF4S1pjaGVXVFZFWU9iT3BnR0JWMmhZUy95Nm44WHk3eWhWVXpP?= =?utf-8?B?UHB2UmN4WUhuQys4bm1MVCtyWkNIS2U1NkZhZkRFeGw3WkdKZXRMQmI5c1R0?= =?utf-8?B?OXdOakZIYWJIU3RrV3RrcTYyRUJwNmcraTE4TXc1bDNiclM5MXUyVXA5emkr?= =?utf-8?B?UXExSlFCVVNzYWx0bjhqYkR5RGFXWWdSeEsxZ253cUx4bWFtNUQxSkhSRVBl?= =?utf-8?B?QU1pOE9JcTlHd1lMeXo0dUc2dVlqRTAySDA3WGxVbHV1VGd5RDFOS3RwY3pL?= =?utf-8?B?Skxta1ZLTmZQdzUwam5Ib2pIRGtTR0ZoUVZZM0ZzUkZONDRHZ29CNm5QRUw1?= =?utf-8?B?TUdQN0QzdnV3YVU1WHRYSHZLU3BlbGFlM25ETW5DNkJXTlA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VGxH?= =?utf-8?B?UW8zQ045L0M0K0lSbllzS1k4RzRjZG1IWk5GSFpUb0tvaW1UdVhTREJjNlYy?= =?utf-8?B?RTRCaFQwbURobVZFSXMvcWk1SWQ2emVzczdpa3dvS3N3bGZqY0VRMTFLeFdh?= =?utf-8?Q?8HHkbrNoVnZcfxyQ=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 3414626d-5ee8-477f-a344-08da26d831cf X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB0062.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 16:25:22.2922 (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: LryzDPmEDax1D8C3+TnLhg6PFDX5EYQjZ82ueA/F9Tlp3R+H87ArPkLka8/UqBtjSw0GN/H0P8YyHEubX9NxZcKKB4WcVqyHGOjh4jXno/I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1242 X-OriginatorOrg: intel.com 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 On 4/6/2022 2:15 PM, Min Hu (Connor) wrote: > From: Huisong Li > > The macro RTE_ETHER_MIN_LEN isn't the minimum value of MTU. But testpmd > used it when execute 'port config mtu 0 xx' cmd. This patch fix it. > > Fixes: 1bb4a528c41f ("ethdev: fix max Rx packet length") > Cc: stable@dpdk.org > > Signed-off-by: Huisong Li > Signed-off-by: Min Hu (Connor) > --- > app/test-pmd/cmdline.c | 4 --- > app/test-pmd/config.c | 55 ++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 55 insertions(+), 4 deletions(-) > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index 6ffea8e21a..91e4090582 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -2050,10 +2050,6 @@ cmd_config_mtu_parsed(void *parsed_result, > { > struct cmd_config_mtu_result *res = parsed_result; > > - if (res->value < RTE_ETHER_MIN_LEN) { > - fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); > - return; > - } > port_mtu_set(res->port_id, res->value); > } > > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index bd689f9f86..1b1e738f83 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1254,6 +1254,57 @@ port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t reg_v) > display_port_reg_value(port_id, reg_off, reg_v); > } > > +static uint32_t > +eth_dev_get_overhead_len(uint32_t max_rx_pktlen, uint16_t max_mtu) > +{ > + uint32_t overhead_len; > + > + if (max_mtu != UINT16_MAX && max_rx_pktlen > max_mtu) > + overhead_len = max_rx_pktlen - max_mtu; > + else > + overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; > + > + return overhead_len; > +} > + > +static int > +eth_dev_validate_mtu(uint16_t port_id, uint16_t mtu) > +{ > + struct rte_eth_dev_info dev_info; > + uint32_t overhead_len; > + uint32_t frame_size; > + int ret; > + > + ret = rte_eth_dev_info_get(port_id, &dev_info); > + if (ret != 0) > + return ret; > + > + if (mtu < dev_info.min_mtu) { > + fprintf(stderr, > + "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) { > + fprintf(stderr, > + "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 > dev_info.max_rx_pktlen) { > + fprintf(stderr, > + "Frame size (%u) > device max frame size (%u) for port_id %u\n", > + frame_size, dev_info.max_rx_pktlen, port_id); > + return -EINVAL; > + } > + > + return 0; > +} > + > void > port_mtu_set(portid_t port_id, uint16_t mtu) > { > @@ -1263,6 +1314,10 @@ port_mtu_set(portid_t port_id, uint16_t mtu) > if (port_id_is_invalid(port_id, ENABLED_WARN)) > return; > > + diag = eth_dev_validate_mtu(port_id, mtu); > + if (diag != 0) > + return; > + > if (port->need_reconfig == 0) { > diag = rte_eth_dev_set_mtu(port_id, mtu); > if (diag != 0) { I just wanted to know if these added functions eth_dev_validate_mtu() &  eth_dev_get_overhead_len() are copy of ethdev library API's in file "rte_ethdev.c", which get called by rte_eth_dev_set_mtu. Is our intent, is to call these twice ?