From patchwork Wed Mar 8 13:59:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 13165890 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29B37C74A44 for ; Wed, 8 Mar 2023 14:01:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232034AbjCHOBh (ORCPT ); Wed, 8 Mar 2023 09:01:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231875AbjCHOBM (ORCPT ); Wed, 8 Mar 2023 09:01:12 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18EE3166D0; Wed, 8 Mar 2023 05:59:54 -0800 (PST) Received: (Authenticated sender: kory.maincent@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 2B1511C0006; Wed, 8 Mar 2023 13:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678283993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=//XnOC4QFhmJ7i1YYoN/2+RccvSoeB5H6nk0zPIwbOo=; b=CD8TZsQkdconduXri9+46hCujVR/OH/NPwGYUO9sGkz81XFhOy82Za/uXVewjZNB76rs2o RYsR0pJHDWMhQb+S1fSFyhsQOnZz+S7pybsSdCVvc6yfI+x1iGESW2fR0lLnmf6P+zVkkP hYN+m8+VURe/SlOl0Xc0KUEjWDrxkO4FQMp3SGgApPQaU/DRtuck2eT4GsVi1VsbiHNJ9N ekaOCUkaJY/qPW+ALYiKNtiFhSctJHEDmknroTTo3QdVcnfvYArULCwCDeJcZhFhuzGNl2 QN3EUeIHCvEVo+B6HdT2SXULM5SgxFZ8CRhQYmu0JS+d3joHUsuOzkXTlLjAkQ== From: =?utf-8?q?K=C3=B6ry_Maincent?= To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-omap@vger.kernel.org Cc: Michael Walle , Maxime Chevallier , Richard Cochran , Kory Maincent , thomas.petazzoni@bootlin.com, Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , Joakim Zhang , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Grygorii Strashko , Minghao Chi , Guangbin Huang , Jie Wang , Oleksij Rempel , "Gustavo A. R. Silva" , Sean Anderson , Wolfram Sang , Alexandru Tachici , Marco Bonelli Subject: [PATCH v3 1/5] net: ethtool: Refactor identical get_ts_info implementations. Date: Wed, 8 Mar 2023 14:59:25 +0100 Message-Id: <20230308135936.761794-2-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230308135936.761794-1-kory.maincent@bootlin.com> References: <20230308135936.761794-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Richard Cochran The vlan, macvlan and the bonding drivers call their "real" device driver in order to report the time stamping capabilities. Provide a core ethtool helper function to avoid copy/paste in the stack. Signed-off-by: Richard Cochran Signed-off-by: Kory Maincent --- Notes: Changes in V2: - Refactor also macvlan driver drivers/net/bonding/bond_main.c | 14 ++------------ drivers/net/macvlan.c | 14 +------------- include/linux/ethtool.h | 8 ++++++++ net/8021q/vlan_dev.c | 15 +-------------- net/ethtool/common.c | 6 ++++++ 5 files changed, 18 insertions(+), 39 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index fce9301c8ebb..11e025074594 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -5683,9 +5683,7 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev, struct ethtool_ts_info *info) { struct bonding *bond = netdev_priv(bond_dev); - const struct ethtool_ops *ops; struct net_device *real_dev; - struct phy_device *phydev; int ret = 0; rcu_read_lock(); @@ -5694,16 +5692,8 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev, rcu_read_unlock(); if (real_dev) { - ops = real_dev->ethtool_ops; - phydev = real_dev->phydev; - - if (phy_has_tsinfo(phydev)) { - ret = phy_ts_info(phydev, info); - goto out; - } else if (ops->get_ts_info) { - ret = ops->get_ts_info(real_dev, info); - goto out; - } + ret = ethtool_get_ts_info_by_layer(real_dev, info); + goto out; } info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index b8cc55b2d721..7e923d27196f 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1059,20 +1059,8 @@ static int macvlan_ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) { struct net_device *real_dev = macvlan_dev_real_dev(dev); - const struct ethtool_ops *ops = real_dev->ethtool_ops; - struct phy_device *phydev = real_dev->phydev; - if (phy_has_tsinfo(phydev)) { - return phy_ts_info(phydev, info); - } else if (ops->get_ts_info) { - return ops->get_ts_info(real_dev, info); - } else { - info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | - SOF_TIMESTAMPING_SOFTWARE; - info->phc_index = -1; - } - - return 0; + return ethtool_get_ts_info_by_layer(real_dev, info); } static netdev_features_t macvlan_fix_features(struct net_device *dev, diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 99dc7bfbcd3c..fa20abec4b93 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -834,6 +834,14 @@ ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings, */ int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index); +/** + * ethtool_get_ts_info_by_layer - Obtains time stamping capabilities from the MAC or PHY layer. + * @dev: pointer to net_device structure + * @info: buffer to hold the result + * Returns zero on sauces, non-zero otherwise. + */ +int ethtool_get_ts_info_by_layer(struct net_device *dev, struct ethtool_ts_info *info); + /** * ethtool_sprintf - Write formatted string to ethtool string data * @data: Pointer to start of string to update diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index e1bb41a443c4..3e475feae543 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -683,20 +683,7 @@ static int vlan_ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) { const struct vlan_dev_priv *vlan = vlan_dev_priv(dev); - const struct ethtool_ops *ops = vlan->real_dev->ethtool_ops; - struct phy_device *phydev = vlan->real_dev->phydev; - - if (phy_has_tsinfo(phydev)) { - return phy_ts_info(phydev, info); - } else if (ops->get_ts_info) { - return ops->get_ts_info(vlan->real_dev, info); - } else { - info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | - SOF_TIMESTAMPING_SOFTWARE; - info->phc_index = -1; - } - - return 0; + return ethtool_get_ts_info_by_layer(vlan->real_dev, info); } static void vlan_dev_get_stats64(struct net_device *dev, diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 566adf85e658..64a7e05cf2c2 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -572,6 +572,12 @@ int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index) } EXPORT_SYMBOL(ethtool_get_phc_vclocks); +int ethtool_get_ts_info_by_layer(struct net_device *dev, struct ethtool_ts_info *info) +{ + return __ethtool_get_ts_info(dev, info); +} +EXPORT_SYMBOL(ethtool_get_ts_info_by_layer); + const struct ethtool_phy_ops *ethtool_phy_ops; void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops) From patchwork Wed Mar 8 13:59:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 13165891 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D12C0C742A7 for ; Wed, 8 Mar 2023 14:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232052AbjCHOCP (ORCPT ); Wed, 8 Mar 2023 09:02:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231929AbjCHOBS (ORCPT ); Wed, 8 Mar 2023 09:01:18 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31A16EC68; Wed, 8 Mar 2023 06:00:14 -0800 (PST) Received: (Authenticated sender: kory.maincent@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id F28CF1C000E; Wed, 8 Mar 2023 14:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678284013; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=czGjNh4cWwRAo6F0QrE2kkelI5xt05bawsUna3HuQGY=; b=f6KmTlzeblr45vlPCuhdDXzwumIUHqVM5zW3ZhhHQkz4m6xZ6w4XUZkGofI4NJ1eSK3Eky C82M0vJSU7AXRex6doe1WSYdMVWM6iysuLxpA7YhaTK5z0D1gZWfdanV5cnlDJh1KcGA/e 43GJBI8m4GkSmlvziWIagMfN+7NQ5vfaVCuK51hxNr/Aqeb07vUIrEN/LMgwOq/30DhKvW TlfqL9507WL/Ql9LtjMyNjoxaCkgjuQRGMi07hHSSoWoEyTexyVIXabySO8IL6XTP26YNz w7Vq6p9R7zYJlnbF1RWcbhvLApEj2FFXfDKu5O63915H27ZFCIN8590wr2+3xw== From: =?utf-8?q?K=C3=B6ry_Maincent?= To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-omap@vger.kernel.org Cc: Michael Walle , Maxime Chevallier , Kory Maincent , Richard Cochran , thomas.petazzoni@bootlin.com, Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , Joakim Zhang , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Grygorii Strashko , Minghao Chi , Guangbin Huang , Jie Wang , Oleksij Rempel , Alexandru Tachici , "Gustavo A. R. Silva" , Sean Anderson , Wolfram Sang , Alexander Lobakin , Maxim Korotkov , Marco Bonelli Subject: [PATCH v3 2/5] net: Expose available time stamping layers to user space. Date: Wed, 8 Mar 2023 14:59:26 +0100 Message-Id: <20230308135936.761794-3-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230308135936.761794-1-kory.maincent@bootlin.com> References: <20230308135936.761794-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Kory Maincent Time stamping on network packets may happen either in the MAC or in the PHY, but not both. In preparation for making the choice selectable, expose both the current and available layers via ethtool. In accordance with the kernel implementation as it stands, the current layer will always read as "phy" when a PHY time stamping device is present. Future patches will allow changing the current layer administratively. Signed-off-by: Richard Cochran Signed-off-by: Kory Maincent --- Notes: Changes in v2: - Move the introduction of selected_timestamping_layer variable in next patch. Changes in v3: - Move on to ethtool instead of syfs Documentation/networking/ethtool-netlink.rst | 2 + include/uapi/linux/ethtool.h | 2 + include/uapi/linux/net_tstamp.h | 6 +++ net/ethtool/ioctl.c | 50 ++++++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index d578b8bcd8a4..ca8e1182bc8e 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -1787,4 +1787,6 @@ are netlink only. n/a ``ETHTOOL_MSG_PHC_VCLOCKS_GET`` n/a ``ETHTOOL_MSG_MODULE_GET`` n/a ``ETHTOOL_MSG_MODULE_SET`` + ``ETHTOOL_LIST_PTP`` n/a + ``ETHTOOL_GET_PTP`` n/a =================================== ===================================== diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index dc2aa3d75b39..56cf24388290 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1629,6 +1629,8 @@ enum ethtool_fec_config_bits { #define ETHTOOL_PHY_STUNABLE 0x0000004f /* Set PHY tunable configuration */ #define ETHTOOL_GFECPARAM 0x00000050 /* Get FEC settings */ #define ETHTOOL_SFECPARAM 0x00000051 /* Set FEC settings */ +#define ETHTOOL_LIST_PTP 0x00000052 /* List PTP providers */ +#define ETHTOOL_GET_PTP 0x00000053 /* Get current PTP provider */ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h index 55501e5e7ac8..1ec489e18f97 100644 --- a/include/uapi/linux/net_tstamp.h +++ b/include/uapi/linux/net_tstamp.h @@ -13,6 +13,12 @@ #include #include /* for SO_TIMESTAMPING */ +/* Hardware layer of the SO_TIMESTAMPING provider */ +enum timestamping_layer { + MAC_TIMESTAMPING = (1<<0), + PHY_TIMESTAMPING = (1<<1), +}; + /* SO_TIMESTAMPING flags */ enum { SOF_TIMESTAMPING_TX_HARDWARE = (1<<0), diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 81fe2422fe58..d8a0a5d991e0 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2319,6 +2319,48 @@ static int ethtool_get_ts_info(struct net_device *dev, void __user *useraddr) return 0; } +static int ethtool_list_ptp(struct net_device *dev, void __user *useraddr) +{ + struct ethtool_value edata = { + .cmd = ETHTOOL_LIST_PTP, + .data = 0, + }; + struct phy_device *phydev = dev->phydev; + const struct ethtool_ops *ops = dev->ethtool_ops; + + if (phy_has_tsinfo(phydev)) + edata.data = PHY_TIMESTAMPING; + if (ops->get_ts_info) + edata.data |= MAC_TIMESTAMPING; + + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + + return 0; +} + +static int ethtool_get_ptp(struct net_device *dev, void __user *useraddr) +{ + struct ethtool_value edata = { + .cmd = ETHTOOL_GET_PTP, + .data = 0, + }; + struct phy_device *phydev = dev->phydev; + const struct ethtool_ops *ops = dev->ethtool_ops; + + if (phy_has_tsinfo(phydev)) + edata.data = PHY_TIMESTAMPING; + else if (ops->get_ts_info) + edata.data = MAC_TIMESTAMPING; + else + return -EOPNOTSUPP; + + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + + return 0; +} + int ethtool_get_module_info_call(struct net_device *dev, struct ethtool_modinfo *modinfo) { @@ -2770,6 +2812,8 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr, case ETHTOOL_PHY_GTUNABLE: case ETHTOOL_GLINKSETTINGS: case ETHTOOL_GFECPARAM: + case ETHTOOL_LIST_PTP: + case ETHTOOL_GET_PTP: break; default: if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) @@ -2997,6 +3041,12 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr, case ETHTOOL_SFECPARAM: rc = ethtool_set_fecparam(dev, useraddr); break; + case ETHTOOL_LIST_PTP: + rc = ethtool_list_ptp(dev, useraddr); + break; + case ETHTOOL_GET_PTP: + rc = ethtool_get_ptp(dev, useraddr); + break; default: rc = -EOPNOTSUPP; } From patchwork Wed Mar 8 13:59:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 13165892 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 761B0C742A7 for ; Wed, 8 Mar 2023 14:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231949AbjCHOC3 (ORCPT ); Wed, 8 Mar 2023 09:02:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231946AbjCHOBV (ORCPT ); Wed, 8 Mar 2023 09:01:21 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1EEF3D09F; Wed, 8 Mar 2023 06:00:26 -0800 (PST) Received: (Authenticated sender: kory.maincent@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 0CF0D1C0002; Wed, 8 Mar 2023 14:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678284025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6lf6IjatvOcyoWSFI3/mxSXIMBx/zkHwZGUcOEydNR8=; b=AJF3cSBf4TaQaO2LV/YVHEbq7u++t/Ey4WmwvhT2pIC5jTUuxrjqyyVCqiUIHi2XNzj3nE Ha5ukFCiiArhYR2cdlqftJ4ChfXdo/4saBayG0AYmqNlb5u1MTEsWLmMc96OlOV/iiPqB1 1O79SckAfDBmU/4arZd1aJBvn/tDuArCkTqhydNliZv5Vu6D3a079xm/rjiN+ZvdcILRCN qM8w0vvZ3TLaqS/HJPBl1/0bW4PC/OJRGVvcF3zvbAj4ggQFlsV/lRAE5k5gC/nB/dGlUU Vc0p8W1Xq9GE5hGxEUFwn9uW3Jo/uKMPGGB+OnPqzi6Wi7HCS0XtA1e8aYBiJA== From: =?utf-8?q?K=C3=B6ry_Maincent?= To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-omap@vger.kernel.org Cc: Michael Walle , Maxime Chevallier , Richard Cochran , Kory Maincent , thomas.petazzoni@bootlin.com, Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , Joakim Zhang , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Grygorii Strashko , Minghao Chi , Guangbin Huang , Jie Wang , Oleksij Rempel , Sean Anderson , Alexandru Tachici , "Gustavo A. R. Silva" , Wolfram Sang , Alexander Lobakin , Marco Bonelli Subject: [PATCH v3 3/5] net: Let the active time stamping layer be selectable. Date: Wed, 8 Mar 2023 14:59:27 +0100 Message-Id: <20230308135936.761794-4-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230308135936.761794-1-kory.maincent@bootlin.com> References: <20230308135936.761794-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Richard Cochran Add the ETHTOOL_SET_PTP ethtool ioctl, and add checks in the ioctl and time stamping paths to respect the currently selected time stamping layer. Add a preferred-timestamp devicetree binding to select the preferred hardware timestamp layer between PHY and MAC. The choice of using devicetree binding has been made as the PTP precision and quality depends of external things, like adjustable clock, or the lack of a temperature compensated crystal or specific features. Even if the preferred timestamp is a configuration it is hardly related to the design oh the board. Signed-off-by: Richard Cochran Signed-off-by: Kory Maincent --- Notes: Changes in v2: - Move selected_timestamping_layer introduction in this patch. - Replace strmcmp by sysfs_streq. - Use the PHY timestamp only if available. Changes in v3: - Added a devicetree binding to select the preferred timestamp - Replace the way to select timestamp through ethtool instead of sysfs You can test it with the ethtool source on branch feature_ptp of: https://github.com/kmaincent/ethtool Documentation/networking/ethtool-netlink.rst | 1 + drivers/net/phy/phy_device.c | 34 ++++++++++++++++ include/linux/netdevice.h | 6 +++ include/uapi/linux/ethtool.h | 1 + net/core/dev_ioctl.c | 43 ++++++++++++++++++-- net/core/timestamping.c | 6 +++ net/ethtool/common.c | 16 ++++++-- net/ethtool/ioctl.c | 41 ++++++++++++++----- 8 files changed, 131 insertions(+), 17 deletions(-) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index ca8e1182bc8e..4a1153dd4859 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -1789,4 +1789,5 @@ are netlink only. n/a ``ETHTOOL_MSG_MODULE_SET`` ``ETHTOOL_LIST_PTP`` n/a ``ETHTOOL_GET_PTP`` n/a + ``ETHTOOL_SET_PTP`` n/a =================================== ===================================== diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 8cff61dbc4b5..5e120452a358 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -34,6 +34,9 @@ #include #include #include +#include +#include + MODULE_DESCRIPTION("PHY library"); MODULE_AUTHOR("Andy Fleming"); @@ -1378,6 +1381,34 @@ int phy_sfp_probe(struct phy_device *phydev, } EXPORT_SYMBOL(phy_sfp_probe); +void of_set_timestamp(struct net_device *netdev, struct phy_device *phydev) +{ + struct device_node *node = phydev->mdio.dev.of_node; + const struct ethtool_ops *ops = netdev->ethtool_ops; + const char *s; + enum timestamping_layer ts_layer = 0; + + if (phy_has_hwtstamp(phydev)) + ts_layer = PHY_TIMESTAMPING; + else if (ops->get_ts_info) + ts_layer = MAC_TIMESTAMPING; + + if (of_property_read_string(node, "preferred-timestamp", &s)) + goto out; + + if (!s) + goto out; + + if (phy_has_hwtstamp(phydev) && !strcmp(s, "phy")) + ts_layer = PHY_TIMESTAMPING; + + if (ops->get_ts_info && !strcmp(s, "mac")) + ts_layer = MAC_TIMESTAMPING; + +out: + netdev->selected_timestamping_layer = ts_layer; +} + /** * phy_attach_direct - attach a network device to a given PHY device pointer * @dev: network device to attach @@ -1451,6 +1482,8 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, phydev->phy_link_change = phy_link_change; if (dev) { + of_set_timestamp(dev, phydev); + phydev->attached_dev = dev; dev->phydev = phydev; @@ -1762,6 +1795,7 @@ void phy_detach(struct phy_device *phydev) phy_suspend(phydev); if (dev) { + dev->selected_timestamping_layer = MAC_TIMESTAMPING; phydev->attached_dev->phydev = NULL; phydev->attached_dev = NULL; } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ba2bd604359d..d9a1c12fc43c 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -1981,6 +1982,9 @@ enum netdev_ml_priv_type { * * @threaded: napi threaded mode is enabled * + * @selected_timestamping_layer: Tracks whether the MAC or the PHY + * performs packet time stamping. + * * @net_notifier_list: List of per-net netdev notifier block * that follow this device when it is moved * to another network namespace. @@ -2339,6 +2343,8 @@ struct net_device { unsigned wol_enabled:1; unsigned threaded:1; + enum timestamping_layer selected_timestamping_layer; + struct list_head net_notifier_list; #if IS_ENABLED(CONFIG_MACSEC) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 56cf24388290..d3a41b6e9eb0 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1631,6 +1631,7 @@ enum ethtool_fec_config_bits { #define ETHTOOL_SFECPARAM 0x00000051 /* Set FEC settings */ #define ETHTOOL_LIST_PTP 0x00000052 /* List PTP providers */ #define ETHTOOL_GET_PTP 0x00000053 /* Get current PTP provider */ +#define ETHTOOL_SET_PTP 0x00000054 /* Set PTP provider */ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index 7674bb9f3076..a75cff331495 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -262,6 +262,42 @@ static int dev_eth_ioctl(struct net_device *dev, return err; } +static int dev_hwtstamp_ioctl(struct net_device *dev, + struct ifreq *ifr, unsigned int cmd) +{ + const struct net_device_ops *ops = dev->netdev_ops; + int err; + + err = dsa_ndo_eth_ioctl(dev, ifr, cmd); + if (err == 0 || err != -EOPNOTSUPP) + return err; + + if (!netif_device_present(dev)) + return -ENODEV; + + switch (dev->selected_timestamping_layer) { + case MAC_TIMESTAMPING: + if (ops->ndo_do_ioctl == phy_do_ioctl) { + /* Some drivers set .ndo_do_ioctl to phy_do_ioctl. */ + err = -EOPNOTSUPP; + } else { + err = ops->ndo_eth_ioctl(dev, ifr, cmd); + } + break; + + case PHY_TIMESTAMPING: + if (phy_has_hwtstamp(dev->phydev)) { + err = phy_mii_ioctl(dev->phydev, ifr, cmd); + } else { + err = -ENODEV; + WARN_ON(1); + } + break; + } + + return err; +} + static int dev_siocbond(struct net_device *dev, struct ifreq *ifr, unsigned int cmd) { @@ -397,6 +433,9 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, void __user *data, return err; fallthrough; + case SIOCGHWTSTAMP: + return dev_hwtstamp_ioctl(dev, ifr, cmd); + /* * Unknown or private ioctl */ @@ -407,9 +446,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, void __user *data, if (cmd == SIOCGMIIPHY || cmd == SIOCGMIIREG || - cmd == SIOCSMIIREG || - cmd == SIOCSHWTSTAMP || - cmd == SIOCGHWTSTAMP) { + cmd == SIOCSMIIREG) { err = dev_eth_ioctl(dev, ifr, cmd); } else if (cmd == SIOCBONDENSLAVE || cmd == SIOCBONDRELEASE || diff --git a/net/core/timestamping.c b/net/core/timestamping.c index 04840697fe79..31c3142787b7 100644 --- a/net/core/timestamping.c +++ b/net/core/timestamping.c @@ -28,6 +28,9 @@ void skb_clone_tx_timestamp(struct sk_buff *skb) if (!skb->sk) return; + if (skb->dev->selected_timestamping_layer != PHY_TIMESTAMPING) + return; + type = classify(skb); if (type == PTP_CLASS_NONE) return; @@ -50,6 +53,9 @@ bool skb_defer_rx_timestamp(struct sk_buff *skb) if (!skb->dev || !skb->dev->phydev || !skb->dev->phydev->mii_ts) return false; + if (skb->dev->selected_timestamping_layer != PHY_TIMESTAMPING) + return false; + if (skb_headroom(skb) < ETH_HLEN) return false; diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 64a7e05cf2c2..e55e70bdbb3c 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -548,10 +548,18 @@ int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) memset(info, 0, sizeof(*info)); info->cmd = ETHTOOL_GET_TS_INFO; - if (phy_has_tsinfo(phydev)) - return phy_ts_info(phydev, info); - if (ops->get_ts_info) - return ops->get_ts_info(dev, info); + switch (dev->selected_timestamping_layer) { + case MAC_TIMESTAMPING: + if (ops->get_ts_info) + return ops->get_ts_info(dev, info); + break; + + case PHY_TIMESTAMPING: + if (phy_has_tsinfo(phydev)) + return phy_ts_info(phydev, info); + WARN_ON(1); + return -ENODEV; + } info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_SOFTWARE; diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index d8a0a5d991e0..85a074bef17d 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2343,17 +2343,8 @@ static int ethtool_get_ptp(struct net_device *dev, void __user *useraddr) { struct ethtool_value edata = { .cmd = ETHTOOL_GET_PTP, - .data = 0, + .data = dev->selected_timestamping_layer, }; - struct phy_device *phydev = dev->phydev; - const struct ethtool_ops *ops = dev->ethtool_ops; - - if (phy_has_tsinfo(phydev)) - edata.data = PHY_TIMESTAMPING; - else if (ops->get_ts_info) - edata.data = MAC_TIMESTAMPING; - else - return -EOPNOTSUPP; if (copy_to_user(useraddr, &edata, sizeof(edata))) return -EFAULT; @@ -2361,6 +2352,33 @@ static int ethtool_get_ptp(struct net_device *dev, void __user *useraddr) return 0; } +static int ethtool_set_ptp(struct net_device *dev, void __user *useraddr) +{ + struct ethtool_value edata; + enum timestamping_layer flavor; + + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + + flavor = edata.data; + + if (!dev->phydev) + return 0; + + if (dev->selected_timestamping_layer != flavor) { + const struct net_device_ops *ops = dev->netdev_ops; + struct ifreq ifr = {0}; + + /* Disable time stamping in the current layer. */ + if (netif_device_present(dev) && ops->ndo_eth_ioctl) + ops->ndo_eth_ioctl(dev, &ifr, SIOCSHWTSTAMP); + + dev->selected_timestamping_layer = flavor; + } + + return 0; +} + int ethtool_get_module_info_call(struct net_device *dev, struct ethtool_modinfo *modinfo) { @@ -3047,6 +3065,9 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr, case ETHTOOL_GET_PTP: rc = ethtool_get_ptp(dev, useraddr); break; + case ETHTOOL_SET_PTP: + rc = ethtool_set_ptp(dev, useraddr); + break; default: rc = -EOPNOTSUPP; } From patchwork Wed Mar 8 13:59:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 13165893 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73B6CC74A44 for ; Wed, 8 Mar 2023 14:02:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232076AbjCHOCt (ORCPT ); Wed, 8 Mar 2023 09:02:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231788AbjCHOBa (ORCPT ); Wed, 8 Mar 2023 09:01:30 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38106567B7; Wed, 8 Mar 2023 06:00:38 -0800 (PST) Received: (Authenticated sender: kory.maincent@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id A7E7F1C001B; Wed, 8 Mar 2023 14:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678284037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZkezqfSVIqRLfpbJoE+hx/1UCsqNMqn17crrczW4LZM=; b=ezkxuiPBuWOkKdMV246ocix4cgUAQsSe0VCnFpEBVOcTPDD+D5RBWSCiKA9c2jhFmR0CuQ 4lIOtbRhPRDjgQcBQWY1RlZLp4KQe3coboAQPbYr7OPYSmP0eXtkLotqFFXdXCtPTJ11Gq g638NyRU1N0ZB+hQf6WqYlX7WWjywhNQwErAIkU8LbWIwWAy1JX5NHTAMLF4CgDbP7DcG3 9zl/cDeZ8psiVWJgcBPbAxXebPj8XpZFxtwQw1tkb8MGDJp2ldm6cL/OFiIOqoERMMCSDm BOacQQiWrmHA8rJlTUQ9Img7ycltXvxSDAjn2+wBfaLRBrbbMkz6IY07RbmLSA== From: =?utf-8?q?K=C3=B6ry_Maincent?= To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-omap@vger.kernel.org Cc: Michael Walle , Maxime Chevallier , Richard Cochran , Kory Maincent , thomas.petazzoni@bootlin.com, Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , Joakim Zhang , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Grygorii Strashko , Minghao Chi , Jie Wang , Guangbin Huang , Oleksij Rempel , "Gustavo A. R. Silva" , Sean Anderson , Wolfram Sang , Alexandru Tachici , Marco Bonelli , Maxim Korotkov Subject: [PATCH v3 4/5] net: fix up drivers WRT phy time stamping Date: Wed, 8 Mar 2023 14:59:28 +0100 Message-Id: <20230308135936.761794-5-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230308135936.761794-1-kory.maincent@bootlin.com> References: <20230308135936.761794-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Richard Cochran For "git bisect" correctness, this patch should be squashed in to the previous one, but it is broken out here for the purpose of review. Signed-off-by: Richard Cochran Signed-off-by: Kory Maincent --- drivers/net/ethernet/freescale/fec_main.c | 23 +++++++++----------- drivers/net/ethernet/mscc/ocelot_net.c | 21 +++++++++--------- drivers/net/ethernet/ti/cpsw_priv.c | 12 +++++------ drivers/net/ethernet/ti/netcp_ethss.c | 26 +++++------------------ 4 files changed, 31 insertions(+), 51 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index f250b0df27fb..b98119551e6a 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3058,22 +3058,19 @@ static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) if (!netif_running(ndev)) return -EINVAL; + switch (cmd) { + case SIOCSHWTSTAMP: + return fep->bufdesc_ex ? fec_ptp_set(ndev, rq) : + -EOPNOTSUPP; + + case SIOCGHWTSTAMP: + return fep->bufdesc_ex ? fec_ptp_get(ndev, rq) : + -EOPNOTSUPP; + } + if (!phydev) return -ENODEV; - if (fep->bufdesc_ex) { - bool use_fec_hwts = !phy_has_hwtstamp(phydev); - - if (cmd == SIOCSHWTSTAMP) { - if (use_fec_hwts) - return fec_ptp_set(ndev, rq); - fec_ptp_disable_hwts(ndev); - } else if (cmd == SIOCGHWTSTAMP) { - if (use_fec_hwts) - return fec_ptp_get(ndev, rq); - } - } - return phy_mii_ioctl(phydev, rq, cmd); } diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 50858cc10fef..8c37db28a93d 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -882,18 +882,19 @@ static int ocelot_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) struct ocelot *ocelot = priv->port.ocelot; int port = priv->port.index; - /* If the attached PHY device isn't capable of timestamping operations, - * use our own (when possible). - */ - if (!phy_has_hwtstamp(dev->phydev) && ocelot->ptp) { - switch (cmd) { - case SIOCSHWTSTAMP: - return ocelot_hwstamp_set(ocelot, port, ifr); - case SIOCGHWTSTAMP: - return ocelot_hwstamp_get(ocelot, port, ifr); - } + switch (cmd) { + case SIOCSHWTSTAMP: + return ocelot->ptp ? ocelot_hwstamp_set(ocelot, port, ifr) : + -EOPNOTSUPP; + + case SIOCGHWTSTAMP: + return ocelot->ptp ? ocelot_hwstamp_get(ocelot, port, ifr) : + -EOPNOTSUPP; } + if (!dev->phydev) + return -ENODEV; + return phy_mii_ioctl(dev->phydev, ifr, cmd); } diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c index 758295c898ac..b15b83bb269a 100644 --- a/drivers/net/ethernet/ti/cpsw_priv.c +++ b/drivers/net/ethernet/ti/cpsw_priv.c @@ -714,13 +714,11 @@ int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) phy = cpsw->slaves[slave_no].phy; - if (!phy_has_hwtstamp(phy)) { - switch (cmd) { - case SIOCSHWTSTAMP: - return cpsw_hwtstamp_set(dev, req); - case SIOCGHWTSTAMP: - return cpsw_hwtstamp_get(dev, req); - } + switch (cmd) { + case SIOCSHWTSTAMP: + return cpsw_hwtstamp_set(dev, req); + case SIOCGHWTSTAMP: + return cpsw_hwtstamp_get(dev, req); } if (phy) diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c index 751fb0bc65c5..36ce80f8bd6b 100644 --- a/drivers/net/ethernet/ti/netcp_ethss.c +++ b/drivers/net/ethernet/ti/netcp_ethss.c @@ -2557,15 +2557,6 @@ static int gbe_txtstamp_mark_pkt(struct gbe_intf *gbe_intf, !gbe_dev->tx_ts_enabled) return 0; - /* If phy has the txtstamp api, assume it will do it. - * We mark it here because skb_tx_timestamp() is called - * after all the txhooks are called. - */ - if (phy_has_txtstamp(phydev)) { - skb_shinfo(p_info->skb)->tx_flags |= SKBTX_IN_PROGRESS; - return 0; - } - if (gbe_need_txtstamp(gbe_intf, p_info)) { p_info->txtstamp = gbe_txtstamp; p_info->ts_context = (void *)gbe_intf; @@ -2583,11 +2574,6 @@ static int gbe_rxtstamp(struct gbe_intf *gbe_intf, struct netcp_packet *p_info) if (p_info->rxtstamp_complete) return 0; - if (phy_has_rxtstamp(phydev)) { - p_info->rxtstamp_complete = true; - return 0; - } - if (gbe_dev->rx_ts_enabled) cpts_rx_timestamp(gbe_dev->cpts, p_info->skb); @@ -2821,13 +2807,11 @@ static int gbe_ioctl(void *intf_priv, struct ifreq *req, int cmd) struct gbe_intf *gbe_intf = intf_priv; struct phy_device *phy = gbe_intf->slave->phy; - if (!phy_has_hwtstamp(phy)) { - switch (cmd) { - case SIOCGHWTSTAMP: - return gbe_hwtstamp_get(gbe_intf, req); - case SIOCSHWTSTAMP: - return gbe_hwtstamp_set(gbe_intf, req); - } + switch (cmd) { + case SIOCGHWTSTAMP: + return gbe_hwtstamp_get(gbe_intf, req); + case SIOCSHWTSTAMP: + return gbe_hwtstamp_set(gbe_intf, req); } if (phy) From patchwork Wed Mar 8 13:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 13165894 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DDADC742A7 for ; Wed, 8 Mar 2023 14:03:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232043AbjCHODE (ORCPT ); Wed, 8 Mar 2023 09:03:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231927AbjCHOCO (ORCPT ); Wed, 8 Mar 2023 09:02:14 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 751132917A; Wed, 8 Mar 2023 06:00:50 -0800 (PST) Received: (Authenticated sender: kory.maincent@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 800A21C0004; Wed, 8 Mar 2023 14:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678284048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FucVkdzUMOd65SVJGkH7EDy0k/VJGGY+7Sjp+ByagLo=; b=l2Hy8sxwSbOagOh4qXqiDmXElZB7HrqKG7ChK5wn2lLJc18LegiOwOKou6GV21eLMkr8Ol Vez+EdMLarTZmVFVBsohRf5uzi9gpQMKulobXbOUPiHJGoHvPTe83KqpQiMOOF/plHiG9T 0LdUM1uckTop2CP/6tYlBCzJU2p/9QK4RimTYOMp6TrVBWIr5e8igbC+3mqQLw9fTkT9RA fDmVz3+HLFvCYm/AP4W+jTNggr3yf23PmJZ/s3EXu25+MxLT1eg1pTgwEB8VMlw6tiDEf6 DSo/GrQhraOTQOcJrN6OmPTZB/JEd7Id9uv/i+xDcwHZSTQbbC3+HD0yWw50IQ== From: =?utf-8?q?K=C3=B6ry_Maincent?= To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-omap@vger.kernel.org Cc: Michael Walle , Maxime Chevallier , Kory Maincent , thomas.petazzoni@bootlin.com, Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , Joakim Zhang , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Grygorii Strashko , Richard Cochran , Minghao Chi , Guangbin Huang , Jie Wang , Oleksij Rempel , Alexandru Tachici , Sean Anderson , "Gustavo A. R. Silva" , Wolfram Sang , Maxim Korotkov , Marco Bonelli Subject: [PATCH v3 5/5] dt-bindings: net: phy: add timestamp preferred choice property Date: Wed, 8 Mar 2023 14:59:29 +0100 Message-Id: <20230308135936.761794-6-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230308135936.761794-1-kory.maincent@bootlin.com> References: <20230308135936.761794-1-kory.maincent@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Kory Maincent Add property to select the preferred hardware timestamp layer. The choice of using devicetree binding has been made as the PTP precision and quality depends of external things, like adjustable clock, or the lack of a temperature compensated crystal or specific features. Even if the preferred timestamp is a configuration it is hardly related to the design of the board. Signed-off-by: Kory Maincent --- Documentation/devicetree/bindings/net/ethernet-phy.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml index ad808e9ce5b9..3ea6d2a59ff7 100644 --- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml @@ -144,6 +144,13 @@ properties: Mark the corresponding energy efficient ethernet mode as broken and request the ethernet to stop advertising it. + preferred-timestamp: + enum: + - phy + - mac + description: + Specifies the preferred hardware timestamp layer. + pses: $ref: /schemas/types.yaml#/definitions/phandle-array maxItems: 1