Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1293410rdb; Fri, 16 Feb 2024 10:53:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUXYmAlDMIb0ymN25GfgJWH0xSFuhNB9XN0pNAyteLRHWoCimTvMpG3pJCkwrVKNoRWN0ISXFwTvbVXAQg+ABd05awLr2yCCV/Ay1oPMw== X-Google-Smtp-Source: AGHT+IEc/fZEILXcBJgzJutHUgTSXqRllYowsCysB6K0iNe7hYjJH9gevD2ES8KpKjpeHDCAHFvB X-Received: by 2002:a19:9106:0:b0:511:6d75:f114 with SMTP id t6-20020a199106000000b005116d75f114mr4050123lfd.65.1708109591163; Fri, 16 Feb 2024 10:53:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708109591; cv=pass; d=google.com; s=arc-20160816; b=JrUx7kq/LZVRHckDxrsnH+b0WpP8/1dutmGCUcKU/i21ETWTC33NCHXu2qO8DO0wYg oSArJBzJ221qhOXnvMkj52fXPWBmkiGiqkgOvxG6+gVDEOYhUlyNMtowZam3ypP8RFqX QOqXGMNjgryK1b+tkWVlV8KkPtUsejV4ze9rDm81XFk6WcInMTWy7m39JQRbkf6kVCtv y/ujVQRM2HMfieMv5pcdC+RTubXRkwD9qbK46vhcuwU4UQJcI4/m4m6qVOZhzwW00GX2 TxTh1q7VRE8a7Jhy71ylGIg3j/pC45xLoheQjSjPDKWdH/hLRfPYDvGdNdRc7O3OK399 gi5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=w66qiBcuO517k0fIfzU2tv5eomSTAcruHYKVEIiNz7U=; fh=gPysi+5RP6D06HTvcNsmwT/8ai5RTHqbxxHkk6g1XmE=; b=K8WrpRgFlhwEtaJY+Agvv0MSNJJybn7bxRIODGWksdpUYmVl+aJkYtuziov9VQ90Q5 zkGewe6PWnOe9Oyx0rlM5CUWtgE4yofV8AbnXiuEUnspPGwYl8OOU0wnsCt3cB9QxIwO VaTLtuXtkhdEy9rxk2/J5c+PcKov3N3SNuIZ5TJw2SrlGbTlUr8xNa8OX14yFdDWYt9R C4XOxKML7VIbLnDcCoVH7repi2QkTBoEY94mZ0lMkT15eQA9tkNSlbXYiiwCgfUjWej0 Fte3nTceh3VJff0pFHY+7SlxB3SY7Xs9iSB/OIwo8U1yASgO+RC5qgAc3dqT84SXXHLS 5fAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ck+WO+AD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-69213-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69213-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t23-20020a05640203d700b00561a61e68e0si193685edw.482.2024.02.16.10.53.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:53:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69213-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ck+WO+AD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-69213-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69213-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 706D61F23BFE for ; Fri, 16 Feb 2024 18:53:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0AC6135A49; Fri, 16 Feb 2024 18:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ck+WO+AD" Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FE351353F0; Fri, 16 Feb 2024 18:52:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708109577; cv=none; b=LR/zSg2JUUM1XyOjYzc++ILT/OsMVo2dcFAs7iTbn0oJ2mGUlTXEw+9IZENWD/+EJRGSgLpbJfezkH/eY+8mz7yLubiTaSZKKuqZjQLpKaiexrlCV/KrDcYbakqA+QzNBD2XP/C9YafJeWQ89X4+vV4LbR/G4xW9oBE4EpPQ5fU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708109577; c=relaxed/simple; bh=3WkD8y+Hm2LbxjUUEU7dK0+hHpLtVVkdwRsfFhX61YI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=a3wGLgyi4pKe838gzeFYXeka5PNy30fDqvB6wh6L7USV43gAfRHkX/HMz2t+kijZnnXvvrZpyKZfHTLwyzoYgmjwShu+YqmpE93gxwZTjCNMb1OMIbpGGeZ5QZ0+Te2OHCTz+wFfzYKI2DT1uW/kFAnMCSk251LZgW/WYY7ZoAE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ck+WO+AD; arc=none smtp.client-ip=209.85.160.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-42dc7ccabbaso8516851cf.0; Fri, 16 Feb 2024 10:52:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708109575; x=1708714375; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=w66qiBcuO517k0fIfzU2tv5eomSTAcruHYKVEIiNz7U=; b=ck+WO+ADeEfG2y4BG7FocgevHgRR7k15rEZb9UQeOEMToSgNJplPszgHE4y691I2S5 RxjQbK4Jjk8/icHfUJAfhxzPMzmDIzZ3Lwa0yZZYnk59UIe31BgpmIGW/tzPGrttTkGG oxxVX9iiAtmbIJOHJe+tEWKv5Gwl1poUhaf26Hdjb6gmTIpT2eA3I4M1bP+FASkuW4gg zRO1BxjPIGXFosXNaKOLzmpfxLd3Wv0Hhr4WLpprvMlUw14ajsZYbL/y30orxzqFORsg N5gULBcfbJPYR/Ccckx5QLvvqN+QMhq1BargarvnR4qvAfcP0HL6qUSe4E3vlSFspkXa pFvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708109575; x=1708714375; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w66qiBcuO517k0fIfzU2tv5eomSTAcruHYKVEIiNz7U=; b=ExF6rrxbjW2LA2bce1A23XjMZYyKYEVhyKfqcjPViT6WJSMNTsaNRd7mGV4KNN/LUZ xAfjEY7r8APMoTGv9StSKUP7f9xOojsFphySLa8OnSdjezcJscm4Z4l+6lV1akd+joFA pvhRfkI+iTw/QI17SFRf4JxLm4/EaVYsr1ETreAsuC8UFRW38S2ELu2DdX4BBLk+w4bH OyzieW/Y/YCJ8qJS7ckJSK6LHpPfUqAQ/H5R7Pt5gZfgA1SwJ7KvNOuc+Me3zPDGx5AX e/S4DyKGbpaJysksr1z3455qg6OiE4rJOfpvsFaSfOwxpFgCf3RFaufAwHX2Q5u0I+bf wMaA== X-Forwarded-Encrypted: i=1; AJvYcCUpzWZyDZBHwPfWr7Fb96pe6EnZRZoo47ATuNcq/xS39PbvwpxGMN2Lo/zIQ5cde8Eel/4556Gf0JOb3OzgAh5w8bfc38S6fKeMM9Hjce/WGPn1lo9r0xGpuFnTCASe6S1aEFu2nha85lHqtaPL5bMF52CKlzYzEggnThr0gdbq X-Gm-Message-State: AOJu0Yx8aVLf4lETrlj7SzeG+UNqtFO0eFOfxrvgqN/7fhilzXDsMrG5 IEnX4uEkC+smtNfyrKYTmMJU2RPKgnuwaHgKJVA58xT+CpgqCPhT X-Received: by 2002:ac8:5acb:0:b0:42c:74ef:8f82 with SMTP id d11-20020ac85acb000000b0042c74ef8f82mr6389156qtd.67.1708109574675; Fri, 16 Feb 2024 10:52:54 -0800 (PST) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.googlemail.com with ESMTPSA id e18-20020ac86712000000b0042c61b99f42sm183180qtp.46.2024.02.16.10.52.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Feb 2024 10:52:54 -0800 (PST) Message-ID: <57a8160e-7f56-40b1-a69a-1fc56d8a79df@gmail.com> Date: Fri, 16 Feb 2024 10:52:50 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC net-next v8 04/13] net: Change the API of PHY default timestamp to MAC Content-Language: en-US To: Kory Maincent , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Simon Horman , Vladimir Oltean Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Rahul Rameshbabu References: <20240216-feature_ptp_netnext-v8-0-510f42f444fb@bootlin.com> <20240216-feature_ptp_netnext-v8-4-510f42f444fb@bootlin.com> From: Florian Fainelli Autocrypt: addr=florian.fainelli@broadcom.com; keydata= xsBNBFPAG8ABCAC3EO02urEwipgbUNJ1r6oI2Vr/+uE389lSEShN2PmL3MVnzhViSAtrYxeT M0Txqn1tOWoIc4QUl6Ggqf5KP6FoRkCrgMMTnUAINsINYXK+3OLe7HjP10h2jDRX4Ajs4Ghs JrZOBru6rH0YrgAhr6O5gG7NE1jhly+EsOa2MpwOiXO4DE/YKZGuVe6Bh87WqmILs9KvnNrQ PcycQnYKTVpqE95d4M824M5cuRB6D1GrYovCsjA9uxo22kPdOoQRAu5gBBn3AdtALFyQj9DQ KQuc39/i/Kt6XLZ/RsBc6qLs+p+JnEuPJngTSfWvzGjpx0nkwCMi4yBb+xk7Hki4kEslABEB AAHNMEZsb3JpYW4gRmFpbmVsbGkgPGZsb3JpYW4uZmFpbmVsbGlAYnJv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QgABgUCU8AbwQAKCRCTYAaomC8PVQ0VCACWk3n+ obFABEp5Rg6Qvspi9kWXcwCcfZV41OIYWhXMoc57ssjCand5noZi8bKg0bxw4qsg+9cNgZ3P N/DFWcNKcAT3Z2/4fTnJqdJS//YcEhlr8uGs+ZWFcqAPbteFCM4dGDRruo69IrHfyyQGx16s CcFlrN8vD066RKevFepb/ml7eYEdN5SRALyEdQMKeCSf3mectdoECEqdF/MWpfWIYQ1hEfdm C2Kztm+h3Nkt9ZQLqc3wsPJZmbD9T0c9Rphfypgw/SfTf2/CHoYVkKqwUIzI59itl5Lze+R5 wDByhWHx2Ud2R7SudmT9XK1e0x7W7a5z11Q6vrzuED5nQvkhAAoJEIExtcQpvGagugcIAJd5 EYe6KM6Y6RvI6TvHp+QgbU5dxvjqSiSvam0Ms3QrLidCtantcGT2Wz/2PlbZqkoJxMQc40rb fXa4xQSvJYj0GWpadrDJUvUu3LEsunDCxdWrmbmwGRKqZraV2oG7YEddmDqOe0Xm/NxeSobc MIlnaE6V0U8f5zNHB7Y46yJjjYT/Ds1TJo3pvwevDWPvv6rdBeV07D9s43frUS6xYd1uFxHC 7dZYWJjZmyUf5evr1W1gCgwLXG0PEi9n3qmz1lelQ8lSocmvxBKtMbX/OKhAfuP/iIwnTsww 95A2SaPiQZA51NywV8OFgsN0ITl2PlZ4Tp9hHERDe6nQCsNI/Us= In-Reply-To: <20240216-feature_ptp_netnext-v8-4-510f42f444fb@bootlin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/16/24 07:52, Kory Maincent wrote: > Change the API to select MAC default time stamping instead of the PHY. > Indeed the PHY is closer to the wire therefore theoretically it has less > delay than the MAC timestamping but the reality is different. Due to lower > time stamping clock frequency, latency in the MDIO bus and no PHC hardware > synchronization between different PHY, the PHY PTP is often less precise > than the MAC. The exception is for PHY designed specially for PTP case but > these devices are not very widespread. For not breaking the compatibility > default_timestamp flag has been introduced in phy_device that is set by > the phy driver to know we are using the old API behavior. > > Signed-off-by: Kory Maincent > --- > > Changes in v5: > - Extract the API change in this patch. > - Rename whitelist to allowlist. > - Set NETDEV_TIMESTAMPING in register_netdevice function. > - Add software timestamping case description in ts_info. > > Change in v6: > - Replace the allowlist phy with a default_timestamp flag to know which > phy is using old API behavior. > - Fix dereferenced of a possible null pointer. > - Follow timestamping layer naming update. > - Update timestamp default set between MAC and software. > - Update ts_info returned in case of software timestamping. > > Change in v8: > - Reform the implementation to use a simple phy_is_default_hwtstamp helper > instead of saving the hwtstamp in the net_device struct. > --- > drivers/net/phy/bcm-phy-ptp.c | 3 +++ > drivers/net/phy/dp83640.c | 3 +++ > drivers/net/phy/micrel.c | 6 ++++++ > drivers/net/phy/mscc/mscc_ptp.c | 3 +++ > drivers/net/phy/nxp-c45-tja11xx.c | 3 +++ > include/linux/phy.h | 17 +++++++++++++++++ > net/core/dev_ioctl.c | 8 +++----- > net/core/timestamping.c | 10 ++++++++-- > net/ethtool/common.c | 2 +- > 9 files changed, 47 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/phy/bcm-phy-ptp.c b/drivers/net/phy/bcm-phy-ptp.c > index 617d384d4551..d3e825c951ee 100644 > --- a/drivers/net/phy/bcm-phy-ptp.c > +++ b/drivers/net/phy/bcm-phy-ptp.c > @@ -931,6 +931,9 @@ struct bcm_ptp_private *bcm_ptp_probe(struct phy_device *phydev) > return ERR_CAST(clock); > priv->ptp_clock = clock; > > + /* Timestamp selected by default to keep legacy API */ > + phydev->default_timestamp = true; > + > priv->phydev = phydev; > bcm_ptp_init(priv); > > diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c > index 5c42c47dc564..64fd1a109c0f 100644 > --- a/drivers/net/phy/dp83640.c > +++ b/drivers/net/phy/dp83640.c > @@ -1450,6 +1450,9 @@ static int dp83640_probe(struct phy_device *phydev) > phydev->mii_ts = &dp83640->mii_ts; > phydev->priv = dp83640; > > + /* Timestamp selected by default to keep legacy API */ > + phydev->default_timestamp = true; > + This probably does not matter too much given that the mii_ts is not visible until we fully probed the PHY, though for consistency and to be on the safe side, it would be more prudent to set default_timestamp before finishing the mii_ts assignment, in case we ever become more aggressive at exposing objects to user-space/kernel-space. Probably over thinking this. More comments below: [snip] > > - if (!skb->dev || !skb->dev->phydev || !skb->dev->phydev->mii_ts) > + if (!skb->dev) > + return false; > + > + if (!phy_is_default_hwtstamp(skb->dev->phydev)) Was not obvious that we could remove the phydev NULL check, but it's fine because phy_is_default_hwtstamp() calls phy_has_hwtstamp() first, and that function has that check. Seems a bit brittle, but fair enough. -- Florian