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 C0DE6A0032; Wed, 11 May 2022 03:16:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5C1F8406B4; Wed, 11 May 2022 03:16:22 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2118.outbound.protection.outlook.com [40.107.244.118]) by mails.dpdk.org (Postfix) with ESMTP id 3D8CF4067E; Wed, 11 May 2022 03:16:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ga/NBO/RTESVHyKsGrLje82fJ2seLZCEbU2EbZrMSNfyUsixYonq3Z/zJRz1r4tbuIbQ84lzy43INyNRP8ZM7mCYtjSa8b/en2Sq9grCPLO+G7G0H+Av7EEEvaQoaEv14gj6pAa//nekOGPgC8TlJz4hsTnkJgIWMRwm3sCu753+nN8gld+v3Ki6U4Op3STMiNoIUQkGy/Pizcj712DVp4m4Z2+2tIa/rZhj3WJJeJPCJV/cbi7TGhU5lByE1ztU+xjzM/hoUefDDQpTwdJjwHUSfKo0IUj0QUUpamFB9LI0Ve8S/T/QSDopEBaOxJ0krrvaPo3bpIqFrkaoZGxWuA== 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=MQRqiL2/UI5EafJYGVgph9Hphbh2/56nBPKb9TNiEkY=; b=kH5ReqVVw1rnqw8u0gQoLIUSigCxhepYf6YWqFNu0oaX2nfepcDW45KVXWEyjL9EI86ZUTje+Du8x8YJ/aXyqfi9d7YWpV+Gc6CLoEQhXL8tjmlqGRXI/Qv8qsIbkc8Ziwns+9pvyBEQH804bjnn7pFR4Cbgxt/3guq5/weZnFpSJqVuTtMVMRIu32Fv2zgfCQc8gZy7CpvIxAFiS//zPqqlskHqcZkKC6UCftXtC6AL17S+/86vbAZGfA2wR0CSJ7gZO1iYxxr0XUzre1eNu/TTPiFFUuDuCqHfF/lY6uDNepkSnNd5qkIpmBDdXUrNuFucbyVbHcHJVi+MZ6MQlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MQRqiL2/UI5EafJYGVgph9Hphbh2/56nBPKb9TNiEkY=; b=V4G8UblLXDQfa+jvymZvhtjheTG90Urt7yWcLjA8UJmG4RbY28fKVR4vlMPUwN+vJoG4dJ8GGVUIBgyZBCPzW+JkYm/D40RfEmyv7H1DKf8H8VymDCDWpLAH/Isg7klSVci5xgMhpsteTvnMwL1STt+2rZkCeKY0WbrDDyaNMCI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM5PR1301MB1994.namprd13.prod.outlook.com (2603:10b6:4:2d::36) by PH7PR13MB5933.namprd13.prod.outlook.com (2603:10b6:510:152::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.12; Wed, 11 May 2022 01:16:16 +0000 Received: from DM5PR1301MB1994.namprd13.prod.outlook.com ([fe80::ecb7:bb70:9e83:d660]) by DM5PR1301MB1994.namprd13.prod.outlook.com ([fe80::ecb7:bb70:9e83:d660%5]) with mapi id 15.20.5250.012; Wed, 11 May 2022 01:16:16 +0000 From: Peng Zhang To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Peng Zhang , stable@dpdk.org, Chaoyong He , Louis Peens , Walter Heymans Subject: [PATCH v4] net/nfp: make sure MTU is never larger than mbufsize Date: Wed, 11 May 2022 03:15:53 +0200 Message-Id: <20220511011553.2905582-1-peng.zhang@corigine.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220330031751.119830-1-peng.zhang@corigine.com> References: <20220330031751.119830-1-peng.zhang@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0092.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:191::7) To DM5PR1301MB1994.namprd13.prod.outlook.com (2603:10b6:4:2d::36) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 16c8709d-f65e-4ff5-4a88-08da32ebd87f X-MS-TrafficTypeDiagnostic: PH7PR13MB5933: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: tXtiLE+a/gs7xlkNEWZ6ZCLsSMtxqWNJFnffOhoKTWCUydXh9+67UcV/IPQFEKZaeeN0QPa6D98biGxsquGaSfxkPW9PZSp8BRluXnWPbKkKVGQv29CyqfRXe4FYff4JAmBOsQ7Isyucqol/uZt4+6OXLDk1TKYEHwkXe1OXNSon2Gx3fnZFdEMCYtp0CPfn5ReFqYM2A/5dLlp4Vt85L+BlA8y0NLJh1w6HOBHo0juWgGIl2AdUh0E/8AL9eTBAlLqqFCiOzgFQX47CqDVnTxpNeYRj0z8ZTeTR5r3Xofn0W6pMR0tT28MnRthciIZemK5kotwRU7DOckACSnNQ6pXgnJJUUB+CimEUKmTUej2e+gb/+dzXuVOcXuCSIhpheQm7FPzz4vO59tQpB4O+GVccocxTgGtAIdsSVPii6o5EN+IC5NUyXRMxY1YDTMqHU79XXr4PGRcl+um4XBs8yyg3xrb5vz5Y93NO61HQdP12vMq1FEtiW9ZGvUIJZOfDEhIJPnPebgaeNnig2PgmxJ1iLgT0UcH7hibXDam5AiGgcc92OaJklZO4M8G/tClbH8QxvUTV+fK6cbmUNyX3yEsad83RUyI6QMkRPwI2/nfETnc1XyeJrhUcsMoaChnLmx4PpSjVkK+bU+dJyizo6IlQhLxOH2vATWBkKDG5LyF56LeWblyat5289JfIoFb486KYAZZeW5RpYQzmEUc5ZlATzorZ7oRCWexPNK8vARw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR1301MB1994.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(346002)(39840400004)(366004)(136003)(376002)(396003)(66946007)(186003)(66574015)(38100700002)(36756003)(450100002)(66476007)(44832011)(8936002)(66556008)(6512007)(26005)(83380400001)(5660300002)(2616005)(4326008)(8676002)(1076003)(107886003)(6506007)(54906003)(6916009)(38350700002)(86362001)(508600001)(52116002)(6486002)(2906002)(6666004)(316002)(168963002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NnJhRTNIUWNMTlpKVUhzb2FvMCtLMDk3U2N6WUFPVjlCN3k1RTU2akZNNE1k?= =?utf-8?B?M3RFZENCT2NoU1BIS3htUG93OWtjdVFnQUp2ekNlbEpuM1ZIWUVEVDFQY1Za?= =?utf-8?B?aCtCdnVKVndXbkpjVW9YN2hPMU51MjhZRCtBTHZXeU1ab0Q2VzF6WHR5UXI2?= =?utf-8?B?NzNNQmZrSmp5ZlM3MmJjTlgyUG4yK3lEckQxRHU1YmwvOU9HZVFZSXZBaHBh?= =?utf-8?B?OXhuNFdqTFQzYjNPRk5iNFNqdXlBSkR3dGpUcTJhRWExb1dXazRFS3VleWs0?= =?utf-8?B?YytrNkdQeWlhdFBvczhnRm5EMVcwcklRMFFrcTI3V2oxYWh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aNFpZaGlEcFlnM2M1bURoL1pveXg1b3RB?= =?utf-8?B?TkNTSHFZOE1hd05zMldKRjBwcEFmYXpqRG1hWXR1blFxTFdtUW8yeWx6SXR1?= =?utf-8?B?SjNTVVZIVkdvdloyMjdJV25oM2p0MTZJdWs0Z0J4aWlRVVNtSklDOFd0YVhz?= =?utf-8?B?Y3pWUzY2OTQ5SmRRZTY1a2J5b2pIZDNxS2RRZ0lEcXVPNnNCeE9ZcHlvdE0y?= =?utf-8?Q?hAH0iWVlaSwkR+LQ=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16c8709d-f65e-4ff5-4a88-08da32ebd87f X-MS-Exchange-CrossTenant-AuthSource: DM5PR1301MB1994.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 01:16:16.4145 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0eR61hNuOfjJERPnR3LbqWG+6z+tG2Ac8Vn3a6G9tk7i5zlxNtG3gpevIrh1veviE477B3p3HY6+1TdFT2Otkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5933 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 Setting a MTU larger than mbufsize is not supported by the device but not prohibited by the driver. This change adds a restriction to the driver to prevent setting an MTU that is too large. While at it define the minimum MTU in the device information to describe the complete supported MTU range. Fixes: d4a27a3 ("nfp: add basic features") Cc: stable@dpdk.org Signed-off-by: Peng Zhang Signed-off-by: Chaoyong He Signed-off-by: Louis Peens Signed-off-by: Niklas Söderlund Reviewed-by: Walter Heymans ------ Depends-on: patch-109914 ("net/nfp: update how MAX MTU is read") --- drivers/net/nfp/nfp_common.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index 52fbda1a79..be68c25fb8 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -176,6 +176,13 @@ nfp_net_configure(struct rte_eth_dev *dev) return -EINVAL; } + /* Checking MTU set */ + if (rxmode->mtu > hw->flbufsz) { + PMD_INIT_LOG(INFO, "MTU (%u) larger then current mbufsize (%u) not supported", + rxmode->mtu, hw->flbufsz); + return -ERANGE; + } + return 0; } @@ -702,6 +709,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) */ dev_info->max_rx_pktlen = NFP_FRAME_SIZE_MAX; dev_info->max_mtu = hw->max_mtu; + dev_info->min_mtu = RTE_ETHER_MIN_MTU; /* Next should change when PF support is implemented */ dev_info->max_mac_addrs = 1; @@ -961,6 +969,13 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EBUSY; } + /* MTU larger then current mbufsize not supported */ + if (mtu > hw->flbufsz) { + PMD_DRV_LOG(ERR, "MTU (%u) larger then current mbufsize (%u) not supported", + mtu, hw->flbufsz); + return -ERANGE; + } + /* writing to configuration space */ nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu); -- 2.27.0