From patchwork Thu Mar 25 01:11:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 12162615 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20E53C433E2 for ; Thu, 25 Mar 2021 01:13:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD9CD61A24 for ; Thu, 25 Mar 2021 01:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239569AbhCYBMa (ORCPT ); Wed, 24 Mar 2021 21:12:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:52304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239546AbhCYBMH (ORCPT ); Wed, 24 Mar 2021 21:12:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BC3F61A18; Thu, 25 Mar 2021 01:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616634727; bh=5Qgbif0kiDvbA9CA4CjJ/BGxTnwNb4TNSg6d5fPIxsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r/BEgMxeVtXsi+dSevkFOTZRSwrmZvi1RoO3+pxSjaChFGclxQf+B9HBIY9sr2WqU mFvfMQf67zB/Fpg0a2WlvRXKk05S/VkEDqGqX4+vhc2FY9Z53xX4/XHLjzVtQQiBwS G9wHDgYK6IDqKKxvOfl7Wk3aJzCz+tB6xnlsXvQJ1uRwkTH+hCpGRPyRaulM/AIbCE wsss5RYOeIa/svN4oAW0+bVZ2ekoDoeKwoKEJvjxirp2/qdNquBEUr7g/2TDdRajXf uor5bNr08R/EyQveCAbYna03TQ4ZT48CtkURC1zOwpcG0FyMdjuYrckiFHkcBqOnKt HUbrUBpuHsKGw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, ecree.xilinx@gmail.com, michael.chan@broadcom.com, damian.dybek@intel.com, paul.greenwalt@intel.com, rajur@chelsio.com, jaroslawx.gawin@intel.com, vkochan@marvell.com, alobakin@pm.me, snelson@pensando.io, shayagr@amazon.com, ayal@nvidia.com, shenjian15@huawei.com, saeedm@nvidia.com, mkubecek@suse.cz, andrew@lunn.ch, roopa@nvidia.com, Jakub Kicinski Subject: [PATCH net-next 1/6] ethtool: fec: fix typo in kdoc Date: Wed, 24 Mar 2021 18:11:55 -0700 Message-Id: <20210325011200.145818-2-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210325011200.145818-1-kuba@kernel.org> References: <20210325011200.145818-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org s/porte/the port/ Signed-off-by: Jakub Kicinski Reviewed-by: Andrew Lunn --- include/uapi/linux/ethtool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index cde753bb2093..1433d6278018 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1374,15 +1374,15 @@ struct ethtool_per_queue_op { __u32 queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)]; char data[]; }; /** * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM - * @active_fec: FEC mode which is active on porte + * @active_fec: FEC mode which is active on the port * @fec: Bitmask of supported/configured FEC modes * @rsvd: Reserved for future extensions. i.e FEC bypass feature. * * Drivers should reject a non-zero setting of @autoneg when * autoneogotiation is disabled (or not supported) for the link. * */ From patchwork Thu Mar 25 01:11:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 12162617 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43500C433E3 for ; Thu, 25 Mar 2021 01:13:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0121561A2A for ; Thu, 25 Mar 2021 01:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239573AbhCYBMb (ORCPT ); Wed, 24 Mar 2021 21:12:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:52334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239547AbhCYBMI (ORCPT ); Wed, 24 Mar 2021 21:12:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6894961A1D; Thu, 25 Mar 2021 01:12:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616634728; bh=lfQTIsxGgK/T6nkf25phdKN+2C5QT/CByloOAt4tPUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GVlhJmp6gPBhUHC4eBk7FF4zGQcs6fq8IPLvP8LWsBh5ZE9sWGNxQjteNcHZJPTiI C+VSXPgjOC3IMaCIequJHjxswQa1HUWK65R9tRtlg/XJWybvVbmJp6U1cdGZrWc0r5 uXWatURUXvStjLE172rniTwm5BrrtDRxvgTG97O5O1yrHkaQkAHFVHVF/D/ZXMGbnL 8mNj85cTDoKzWswCpN+i4SXiPSIX1YyJu8xZl3ZCd84Hb3+A9LHMj+4nxAtAtN8xdZ R1j4M+T0FX8Laq27jG9Sc/FRX0mRA31rZmt7047buH8UHxYNKx0aOwES0viuEzSsmv drj3YuQE+CAnA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, ecree.xilinx@gmail.com, michael.chan@broadcom.com, damian.dybek@intel.com, paul.greenwalt@intel.com, rajur@chelsio.com, jaroslawx.gawin@intel.com, vkochan@marvell.com, alobakin@pm.me, snelson@pensando.io, shayagr@amazon.com, ayal@nvidia.com, shenjian15@huawei.com, saeedm@nvidia.com, mkubecek@suse.cz, andrew@lunn.ch, roopa@nvidia.com, Jakub Kicinski Subject: [PATCH net-next 2/6] ethtool: fec: remove long structure description Date: Wed, 24 Mar 2021 18:11:56 -0700 Message-Id: <20210325011200.145818-3-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210325011200.145818-1-kuba@kernel.org> References: <20210325011200.145818-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Digging through the mailing list archive @autoneg was part of the first version of the RFC, this left over comment was pointed out twice in review but wasn't removed. The sentence is an exact copy-paste from pauseparam. Signed-off-by: Jakub Kicinski Reviewed-by: Andrew Lunn --- include/uapi/linux/ethtool.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 1433d6278018..36bf435d232c 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1377,18 +1377,14 @@ struct ethtool_per_queue_op { /** * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM * @active_fec: FEC mode which is active on the port * @fec: Bitmask of supported/configured FEC modes * @rsvd: Reserved for future extensions. i.e FEC bypass feature. - * - * Drivers should reject a non-zero setting of @autoneg when - * autoneogotiation is disabled (or not supported) for the link. - * */ struct ethtool_fecparam { __u32 cmd; /* bitmask of FEC modes */ __u32 active_fec; __u32 fec; __u32 reserved; From patchwork Thu Mar 25 01:11:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 12162621 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F2E7C433E4 for ; Thu, 25 Mar 2021 01:13:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DCE161A18 for ; Thu, 25 Mar 2021 01:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239577AbhCYBMc (ORCPT ); Wed, 24 Mar 2021 21:12:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:52372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239548AbhCYBMJ (ORCPT ); Wed, 24 Mar 2021 21:12:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 34B5D61A23; Thu, 25 Mar 2021 01:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616634729; bh=LwjQ3fWWVDGxr02YqLA6dfhtrvstH3EUV5Luh6ZVRGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lNxpk2kPbX0TgOf1jGAnJv5973NNLvvdJDulq6+TNI8E78Hs964z7hD1SNFOASjoI nLxp6/paMRtOypNyP/CmoLAepO9qQX4K0QG+09m+xTi1GBasQaWBAxUpQwWSzAx0Vu RxGW+koelyVYenmfieEV0jHberfCGVTHpYHoVMVLxz3rvDn62gQDTf5sGlwjrsNXXy KwgI3uXFX+pX/MRfPLFioH9olChDsSAeigqkKtsPX5tcgzbmp3tjI2SLH7N+nVTStG FdcoUZxjIBh5pLV5yYKYdBTEwrMGEgDcBq8XZTEOY0+i25YeWF24dCy6sOCOs7ixji ZVeAYamItQtCw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, ecree.xilinx@gmail.com, michael.chan@broadcom.com, damian.dybek@intel.com, paul.greenwalt@intel.com, rajur@chelsio.com, jaroslawx.gawin@intel.com, vkochan@marvell.com, alobakin@pm.me, snelson@pensando.io, shayagr@amazon.com, ayal@nvidia.com, shenjian15@huawei.com, saeedm@nvidia.com, mkubecek@suse.cz, andrew@lunn.ch, roopa@nvidia.com, Jakub Kicinski Subject: [PATCH net-next 3/6] ethtool: fec: sanitize ethtool_fecparam->reserved Date: Wed, 24 Mar 2021 18:11:57 -0700 Message-Id: <20210325011200.145818-4-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210325011200.145818-1-kuba@kernel.org> References: <20210325011200.145818-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org struct ethtool_fecparam::reserved is never looked at by the core. Make sure it's actually 0. Unfortunately we can't return an error because old ethtool doesn't zero-initialize the structure for SET. On GET we can be more verbose, there are no in tree (ab)users. Fix up the kdoc on the structure. Remove the mention of FEC bypass. Seems like a niche thing to configure in the first place. Signed-off-by: Jakub Kicinski --- include/uapi/linux/ethtool.h | 2 +- net/ethtool/ioctl.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 36bf435d232c..9e2682a67460 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1376,15 +1376,15 @@ struct ethtool_per_queue_op { }; /** * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM * @active_fec: FEC mode which is active on the port * @fec: Bitmask of supported/configured FEC modes - * @rsvd: Reserved for future extensions. i.e FEC bypass feature. + * @reserved: Reserved for future extensions, ignore on GET, write 0 for SET. */ struct ethtool_fecparam { __u32 cmd; /* bitmask of FEC modes */ __u32 active_fec; __u32 fec; __u32 reserved; diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 0788cc3b3114..be3549023d89 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2564,14 +2564,17 @@ static int ethtool_get_fecparam(struct net_device *dev, void __user *useraddr) if (!dev->ethtool_ops->get_fecparam) return -EOPNOTSUPP; rc = dev->ethtool_ops->get_fecparam(dev, &fecparam); if (rc) return rc; + if (WARN_ON_ONCE(fecparam.reserved)) + fecparam.reserved = 0; + if (copy_to_user(useraddr, &fecparam, sizeof(fecparam))) return -EFAULT; return 0; } static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr) { @@ -2579,14 +2582,16 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr) if (!dev->ethtool_ops->set_fecparam) return -EOPNOTSUPP; if (copy_from_user(&fecparam, useraddr, sizeof(fecparam))) return -EFAULT; + fecparam.reserved = 0; + return dev->ethtool_ops->set_fecparam(dev, &fecparam); } /* The main entry point in this file. Called from net/core/dev_ioctl.c */ int dev_ethtool(struct net *net, struct ifreq *ifr) { From patchwork Thu Mar 25 01:11:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 12162619 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D038C433E8 for ; Thu, 25 Mar 2021 01:13:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BEE961A19 for ; Thu, 25 Mar 2021 01:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239514AbhCYBMd (ORCPT ); Wed, 24 Mar 2021 21:12:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:52396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239549AbhCYBMK (ORCPT ); Wed, 24 Mar 2021 21:12:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 52A7261A0A; Thu, 25 Mar 2021 01:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616634730; bh=vjHHuOcIYUWeM7cgt0LJMNjhI8c6YLJazfEC6WJooJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UsDp4EoOT1ay8CnyjL1GGTBjo2t+RHx5auA2WRWYB9Gz5jYHK0Sb5wFU7+z9YNCNX m2O7+nb68AO2ovuf+o8mn92WpyHWDgLV5VdtSqsqMjx9xUVP8ce3YckWpHeAtilhuK Q/R+VUYq0UPT1k4SUFilSb0TZS1BxUnjrI2s0qgK7sIBeaybyvagftQ8BXatNHroDp AThfba9Ztg9aoFgvQG2By1OPlpO52DX/b3dTxTBsc5wH6eT/stYvxgU6MwByIH+9Q9 R3HtCaGU8A53UuUKVgwswHa6pYf/+/Wjuejxe/RaHLK+7y0ksRZvJO/N1GyEPwnZhq VWC5d0ZKGHmAA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, ecree.xilinx@gmail.com, michael.chan@broadcom.com, damian.dybek@intel.com, paul.greenwalt@intel.com, rajur@chelsio.com, jaroslawx.gawin@intel.com, vkochan@marvell.com, alobakin@pm.me, snelson@pensando.io, shayagr@amazon.com, ayal@nvidia.com, shenjian15@huawei.com, saeedm@nvidia.com, mkubecek@suse.cz, andrew@lunn.ch, roopa@nvidia.com, Jakub Kicinski Subject: [PATCH net-next 4/6] ethtool: fec: sanitize ethtool_fecparam->active_fec Date: Wed, 24 Mar 2021 18:11:58 -0700 Message-Id: <20210325011200.145818-5-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210325011200.145818-1-kuba@kernel.org> References: <20210325011200.145818-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org struct ethtool_fecparam::active_fec is a GET-only field, all in-tree drivers correctly ignore it on SET. Clear the field on SET to avoid any confusion. Again, we can't reject non-zero now since ethtool user space does not zero-init the param correctly. Signed-off-by: Jakub Kicinski Reviewed-by: Andrew Lunn --- include/uapi/linux/ethtool.h | 2 +- net/ethtool/ioctl.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 9e2682a67460..517b68c5fcec 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1374,15 +1374,15 @@ struct ethtool_per_queue_op { __u32 queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)]; char data[]; }; /** * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM - * @active_fec: FEC mode which is active on the port + * @active_fec: FEC mode which is active on the port, GET only. * @fec: Bitmask of supported/configured FEC modes * @reserved: Reserved for future extensions, ignore on GET, write 0 for SET. */ struct ethtool_fecparam { __u32 cmd; /* bitmask of FEC modes */ __u32 active_fec; diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index be3549023d89..237ffe5440ef 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2582,14 +2582,15 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr) if (!dev->ethtool_ops->set_fecparam) return -EOPNOTSUPP; if (copy_from_user(&fecparam, useraddr, sizeof(fecparam))) return -EFAULT; + fecparam.active_fec = 0; fecparam.reserved = 0; return dev->ethtool_ops->set_fecparam(dev, &fecparam); } /* The main entry point in this file. Called from net/core/dev_ioctl.c */ From patchwork Thu Mar 25 01:11:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 12162625 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F7B3C433E9 for ; Thu, 25 Mar 2021 01:13:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88FBB61A2C for ; Thu, 25 Mar 2021 01:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239542AbhCYBMd (ORCPT ); Wed, 24 Mar 2021 21:12:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:52428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239550AbhCYBML (ORCPT ); Wed, 24 Mar 2021 21:12:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4D3A261A1F; Thu, 25 Mar 2021 01:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616634730; bh=G7JCaY0dsYnbcF4Pf8DRquwTxCW+RvwNRBkdNGQHqoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C0hLikrXNV4qZr8CkhZLyD4T7vJS2DciqJ7JNi38DH7yxOBEd4D0tpYvibJCDhpIU 8aIYvVMPJ8H2y0ajJUZayuMdOrZGVZDWFS6Te65PiHvVCkm5tL6dT7xEKpPQ8k3I64 l9BaOZHpSjg1Xg9dZl18edtm1i9a3aWyTews1RqZBhyw/XEgbkfy6f8l4F8COS7djB xt6X1tBV9UZMP2m3LA1Nje2Iv2+o2TxnSGpsWq3DGFegRaC7s253GAaNdJ8VZ/uI04 Pd2cihn4z0TZ+khNgXgoov6YlxUOZMadycU9/RTgZLjY7vIX0Oj+VjtFh2QYWudCeY S0a8aHoiqHFWw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, ecree.xilinx@gmail.com, michael.chan@broadcom.com, damian.dybek@intel.com, paul.greenwalt@intel.com, rajur@chelsio.com, jaroslawx.gawin@intel.com, vkochan@marvell.com, alobakin@pm.me, snelson@pensando.io, shayagr@amazon.com, ayal@nvidia.com, shenjian15@huawei.com, saeedm@nvidia.com, mkubecek@suse.cz, andrew@lunn.ch, roopa@nvidia.com, Jakub Kicinski Subject: [PATCH net-next 5/6] ethtool: fec: sanitize ethtool_fecparam->fec Date: Wed, 24 Mar 2021 18:11:59 -0700 Message-Id: <20210325011200.145818-6-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210325011200.145818-1-kuba@kernel.org> References: <20210325011200.145818-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Reject NONE on set, this mode means device does not support FEC so it's a little out of place in the set interface. This should be safe to do - user space ethtool does not allow the use of NONE on set. A few drivers treat it the same as OFF, but none use it instead of OFF. Similarly reject an empty FEC mask. The common user space tool will not send such requests and most drivers correctly reject it already. Signed-off-by: Jakub Kicinski Reported-by: kernel test robot Reported-by: Dan Carpenter --- net/ethtool/ioctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 237ffe5440ef..8797533ddc4b 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2582,14 +2582,17 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr) if (!dev->ethtool_ops->set_fecparam) return -EOPNOTSUPP; if (copy_from_user(&fecparam, useraddr, sizeof(fecparam))) return -EFAULT; + if (!fecparam.fec || fecparam.fec & ETHTOOL_FEC_NONE_BIT) + return -EINVAL; + fecparam.active_fec = 0; fecparam.reserved = 0; return dev->ethtool_ops->set_fecparam(dev, &fecparam); } /* The main entry point in this file. Called from net/core/dev_ioctl.c */ From patchwork Thu Mar 25 01:12:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 12162623 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DD04C433E6 for ; Thu, 25 Mar 2021 01:13:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7402B61A18 for ; Thu, 25 Mar 2021 01:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239582AbhCYBMe (ORCPT ); Wed, 24 Mar 2021 21:12:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:52454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239551AbhCYBMM (ORCPT ); Wed, 24 Mar 2021 21:12:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1757161A29; Thu, 25 Mar 2021 01:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616634732; bh=VW1f9o/6lWkZzQO7qx0eu6Q6tMeCokEFqcxcMqwoE5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FDWdmOzkSIN3IrH4G7hQr2aXLniVD2sZjSR+dt3RVDxDOZPVxNqXdxAeOWtnRcM0f /MLnvJM1XQ63cN1v32iPfWrlvqDperyoG4W+rg9L50t/pHBmJdw/bKoQ0tybaOK4G5 oVFwJOXwgtOm+wAya/Yexhzo8O5ZffnIlgtaoszOJVo5QGm3Ov7QFa3MvhHD/050X8 Kujp0AtO2N/WgBw5iRWhpjlIDDS3CyxVICCoirb0maxNcf9kxkOl73UHszLjfRpF+e Fbybf0tAnm/PLNydnLK306uIdA5qHYLSsU/gG57gLtOJoBQo0nuV//y80hR6vvveNn Qvp43S3Ic8ALQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, ecree.xilinx@gmail.com, michael.chan@broadcom.com, damian.dybek@intel.com, paul.greenwalt@intel.com, rajur@chelsio.com, jaroslawx.gawin@intel.com, vkochan@marvell.com, alobakin@pm.me, snelson@pensando.io, shayagr@amazon.com, ayal@nvidia.com, shenjian15@huawei.com, saeedm@nvidia.com, mkubecek@suse.cz, andrew@lunn.ch, roopa@nvidia.com, Jakub Kicinski Subject: [PATCH net-next 6/6] ethtool: clarify the ethtool FEC interface Date: Wed, 24 Mar 2021 18:12:00 -0700 Message-Id: <20210325011200.145818-7-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210325011200.145818-1-kuba@kernel.org> References: <20210325011200.145818-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The definition of the FEC driver interface is quite unclear. Improve the documentation. This is based on current driver and user space code, as well as the discussions about the interface: RFC v1 (24 Oct 2016): https://lore.kernel.org/netdev/1477363849-36517-1-git-send-email-vidya@cumulusnetworks.com/ - this version has the autoneg field - no active_fec field - none vs off confusion is already present RFC v2 (10 Feb 2017): https://lore.kernel.org/netdev/1486727004-11316-1-git-send-email-vidya@cumulusnetworks.com/ - autoneg removed - active_fec added v1 (10 Feb 2017): https://lore.kernel.org/netdev/1486751311-42019-1-git-send-email-vidya@cumulusnetworks.com/ - no changes in the code v1 (24 Jun 2017): https://lore.kernel.org/netdev/1498331985-8525-1-git-send-email-roopa@cumulusnetworks.com/ - include in tree user v2 (27 Jul 2017): https://lore.kernel.org/netdev/1501199248-24695-1-git-send-email-roopa@cumulusnetworks.com/ Signed-off-by: Jakub Kicinski --- include/uapi/linux/ethtool.h | 37 +++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 517b68c5fcec..f6ef7d42c7a1 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1372,35 +1372,58 @@ struct ethtool_per_queue_op { __u32 cmd; __u32 sub_command; __u32 queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)]; char data[]; }; /** - * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters + * struct ethtool_fecparam - Ethernet Forward Error Correction parameters * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM - * @active_fec: FEC mode which is active on the port, GET only. - * @fec: Bitmask of supported/configured FEC modes + * @active_fec: FEC mode which is active on the port, single bit set, GET only. + * @fec: Bitmask of configured FEC modes. * @reserved: Reserved for future extensions, ignore on GET, write 0 for SET. + * + * FEC modes supported by the device can be read via %ETHTOOL_GLINKSETTINGS. + * FEC settings are configured by link autonegotiation whenever it's enabled. + * With autoneg on %ETHTOOL_GFECPARAM can be used to read the current mode. + * + * When autoneg is disabled %ETHTOOL_SFECPARAM controls the FEC settings. + * It is recommended that drivers only accept a single bit set in @fec. + * When multiple bits are set in @fec drivers may pick mode in an implementation + * dependent way. Drivers should reject mixing %ETHTOOL_FEC_AUTO_BIT with other + * FEC modes, because it's unclear whether in this case other modes constrain + * AUTO or are independent choices. + * Drivers must reject SET requests if they support none of the requested modes. + * + * If device does not support FEC drivers may use %ETHTOOL_FEC_NONE instead + * of returning %EOPNOTSUPP from %ETHTOOL_GFECPARAM. + * + * See enum ethtool_fec_config_bits for definition of valid bits for both + * @fec and @active_fec. */ struct ethtool_fecparam { __u32 cmd; /* bitmask of FEC modes */ __u32 active_fec; __u32 fec; __u32 reserved; }; /** * enum ethtool_fec_config_bits - flags definition of ethtool_fec_configuration - * @ETHTOOL_FEC_NONE: FEC mode configuration is not supported - * @ETHTOOL_FEC_AUTO: Default/Best FEC mode provided by driver + * @ETHTOOL_FEC_NONE: FEC mode configuration is not supported. Should not + * be used together with other bits. GET only. + * @ETHTOOL_FEC_AUTO: Select default/best FEC mode automatically, usually based + * link mode and SFP parameters read from module's EEPROM. + * This bit does _not_ mean autonegotiation. * @ETHTOOL_FEC_OFF: No FEC Mode - * @ETHTOOL_FEC_RS: Reed-Solomon Forward Error Detection mode - * @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon Forward Error Detection mode + * @ETHTOOL_FEC_RS: Reed-Solomon FEC Mode + * @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon FEC Mode + * @ETHTOOL_FEC_LLRS: Low Latency Reed Solomon FEC Mode (25G/50G Ethernet + * Consortium) */ enum ethtool_fec_config_bits { ETHTOOL_FEC_NONE_BIT, ETHTOOL_FEC_AUTO_BIT, ETHTOOL_FEC_OFF_BIT, ETHTOOL_FEC_RS_BIT, ETHTOOL_FEC_BASER_BIT,