Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2479845rdb; Mon, 20 Nov 2023 11:59:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8S9y8ykfUfw/I/QGPKwlSjaCHqeq+wYxbVVV7HyAaKckF3X9+vc95n4plZsMNPLvU7fR+ X-Received: by 2002:a17:90b:1c12:b0:27d:6937:db89 with SMTP id oc18-20020a17090b1c1200b0027d6937db89mr8427473pjb.43.1700510357513; Mon, 20 Nov 2023 11:59:17 -0800 (PST) Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o21-20020a17090ac71500b002850ee93251si5598176pjt.47.2023.11.20.11.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 11:59:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nxp.com header.s=selector2 header.b="bZy+jpU/"; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id ECB74801C087; Mon, 20 Nov 2023 11:59:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233785AbjKTT7L (ORCPT + 99 others); Mon, 20 Nov 2023 14:59:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229721AbjKTT7K (ORCPT ); Mon, 20 Nov 2023 14:59:10 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2050.outbound.protection.outlook.com [40.107.14.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE584BE; Mon, 20 Nov 2023 11:59:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L2XAM0uo55y7AU+Nv0SXsaDhyj3gj3xpT92Mwy+9MWrNHGV6qWB6nmAeMHzjfagjjX2aniNnX0FnOygnRh8t/pD8L5+iATt9uIurqg18a9vsLG4Uh6zHWoS+VI0HEaOyaZCrA/2ORFOlFkM2Uo8hd4R0wwxEsLPaUmGrDm0GComYhethaeTTYYAJtYMXhj7PGs4S077pVSvAwrGoRTb47MPvSZ/Ue74OKuubnSN6viYsoACypbxnruUCGriiJ8s3oFyGLihcr+QDTAzS6KfZphjdk3XVRtsMYw/QgSGe+n8EmlacHNIgAgw5uG4R3Wr9Pc45EUSOqTMaYT5wN5Lr8g== 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=QsYqAMvGo09QcEuvDMkpnIdd7dwwLh2yhzNYU6abE8s=; b=c/2QjZmQO/Q0/FA6qJfmJzxqZ10pjeczYxn8BJnHwAquR5aKYajCqX8iScmpAySW4TqjzlcYT9WaTncjHzAIQ9f4bSnImkbJI3RuN1YxRERhTO/tvCxVlf1vAry4tdfynsKil1n8fj1uRZ+cgH00ANAall3z5tepk0biAVBfKKp79vdHs0BM6nKA5CH4wTkfXEX3Xe8Xt9d6MsxYeOaocpmJuVv3equFYD2ml81d/Y7pc86SwAMLG0g50/gXJ4EsrzHwOJcSoVP3kqD7rSkEsJOacSWAWBg07SMTNUGsmxKzBSp/DQAF7jgBu2/FnrbkFe0UNzuHN4r58mJZzKjnKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QsYqAMvGo09QcEuvDMkpnIdd7dwwLh2yhzNYU6abE8s=; b=bZy+jpU/Sg4yJI4CGsgorOgU+AQgWjG1bnuXeO143zUQ0VCRznCPJX1qxHKMIENSu3PK3HfqcIgrsB2w2SKblNfgPp7AlOZLZCo7Tb2Mh0c1qlORbk2L+GI4wMdv1sMtlQVXyBVWAsiswH5z/Av8p4R2anUEtxyCdkJjEY3RXK8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AM7PR04MB7061.eurprd04.prod.outlook.com (2603:10a6:20b:114::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Mon, 20 Nov 2023 19:59:03 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dd33:f07:7cfd:afa4]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dd33:f07:7cfd:afa4%7]) with mapi id 15.20.7025.015; Mon, 20 Nov 2023 19:59:02 +0000 Date: Mon, 20 Nov 2023 21:58:58 +0200 From: Vladimir Oltean To: Jakub Kicinski Cc: Andrew Lunn , =?utf-8?B?S8O2cnk=?= Maincent , Florian Fainelli , Broadcom internal kernel review list , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , 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 , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier Subject: Re: [PATCH net-next v7 15/16] net: ethtool: ts: Let the active time stamping layer be selectable Message-ID: <20231120195858.wpaymolv6ws4hntp@skbuf> References: <20231118183433.30ca1d1a@kernel.org> <20231120104439.15bfdd09@kmaincent-XPS-13-7390> <20231120105255.cgbart5amkg4efaz@skbuf> <20231120121440.3274d44c@kmaincent-XPS-13-7390> <20231120120601.ondrhbkqpnaozl2q@skbuf> <20231120144929.3375317e@kmaincent-XPS-13-7390> <20231120142316.d2emoaqeej2pg4s3@skbuf> <20231120093723.4d88fb2a@kernel.org> <157c68b0-687e-4333-9d59-fad3f5032345@lunn.ch> <20231120105148.064dc4bd@kernel.org> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231120105148.064dc4bd@kernel.org> X-ClientProxiedBy: AM0P190CA0002.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::12) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AM7PR04MB7061:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c7ce2ee-ae7c-41e7-d8de-08dbea0324d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WF3oHowYaO422F4SdHozFoD8n2ER86braizv5bvfR6bPsgSZl11JUpYV86YMRtR8fN1DX9KKJiybqdbZ1fLR4X34eHMrGd8WQIUA2MketzplRobaZhbRhB2yIlPlh4EzLIwJaHM2Q4dSsr3ozTICKjLwh2xOzrk/Nd3hMwxMBC7dQHo1OClYv6k6Hi6iz0kYzZxL1MgIL/6wRZDBMlOfT9lNwyeXzzRnErBF+1WxvYEXDk95fph15ssDOGaT+lgZz1m1zfjg4MVujlnjSy06G4SDsDyKJ5XV1GbwYY8TJT7MfGBgPYxVH2HOLqlC0tRuYtfYiqxe156jh89Mh5kXST8nGcaAASrZq2x+V5x4NeyogRqLkgAyAbvS831hPo8nTPfzz9nDxhl6mVnGZfF0WxvKMiqvCaGHbvFQ2pGUaQp8T/CvmmxkIAOLOLXSnyGt9FCEsTpqJgF1JkEU/PF76xVSlwrvFnhkFJkIYPc/WWVOb2fJSXcjsMrzltOSWD0eae9XWWAtf5t/5CxqMSI1nQNTgPFUSJ3ZA3UyEb944tw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7916004)(366004)(396003)(376002)(136003)(39860400002)(346002)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(41300700001)(66899024)(5660300002)(86362001)(7416002)(44832011)(2906002)(33716001)(66574015)(9686003)(6506007)(6512007)(1076003)(26005)(83380400001)(6486002)(966005)(478600001)(6666004)(4326008)(8676002)(8936002)(38100700002)(316002)(6916009)(66946007)(54906003)(66476007)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?PpiRQkNWo1+w3XjjF6YLyNcmn0cJSmC9DdLZTyfWdtGqIlI8Dkxlp8Ks3/?= =?iso-8859-1?Q?oHkuNxF8SCwOak/GNp8zXjaVuHd/OnLpZoPzYhm4moT8G4DEZ1/X+1ribr?= =?iso-8859-1?Q?5AUwttvE2MKvdIFMHE4UsAQfo7+PT8rBBAGkOQAXWXCfu+c0NXjGuPM5j/?= =?iso-8859-1?Q?3127AhRnm2RO6MFbiXvCzsI3nfRFzDfoAkre3cQ8uYX0TEHvIlw6ES5FNp?= =?iso-8859-1?Q?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UWULtEz8HBcZbQ?= =?iso-8859-1?Q?hzhh0NeJHiMzGB4i33JpnAoUCSDYPLyOL1MT6qUEccH+BlDFkYbWYYNzBt?= =?iso-8859-1?Q?j3EwhRP/vEFTQKL2GEMReYGvzyyUewe5mAJd/yHIJyCF1Lcfj7U4Wvwt5C?= =?iso-8859-1?Q?hvwNLaXvDwgvutIrncqvD7xl27HtHFNYcolo95XLw5BjHGN7z5HuK3jbYc?= =?iso-8859-1?Q?2ANCtRm4oedXSu18zWJuEr9wM7n8oBmj+LWEYTcnMMkcmvO7Jas8NIoxdz?= =?iso-8859-1?Q?05fCImrKenX5+5qiDAesjX1VGubBjHKzGrw3jnoGN2GyPfzIct4iRToltm?= =?iso-8859-1?Q?OOZJ33MS9kkcaMmvcoIelWNnUyKYmTyWO12wAqvmaZA1/xaXphSQ8xc7gN?= =?iso-8859-1?Q?P6dkdKnvWOBnTw2mSijHKE+xMh8aETfyNYedWnGYydCuMzzumtSdZhQlEj?= =?iso-8859-1?Q?p6tKL6y1t8sOihZC5YfUy0Lbehbdi937URhGmyHHkwueqp1hzUuqPhlVwv?= =?iso-8859-1?Q?0Mnxkk2iIUNxYx5aeGUrr2bLdN0cd0IYvriL6kRJQx+Br9RriqXx8Okw?= =?iso-8859-1?Q?=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c7ce2ee-ae7c-41e7-d8de-08dbea0324d9 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2023 19:59:02.8942 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: w17UQ76k4xJUhEBfAPmiAi5+ZLlehiD0otZuvqwq3CBwhIG7HYq/xQkLzUp+VJKOhKqpl6wFXkWTKFkfV2K+cw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7061 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 11:59:13 -0800 (PST) On Mon, Nov 20, 2023 at 10:51:48AM -0800, Jakub Kicinski wrote: > On Mon, 20 Nov 2023 19:39:35 +0100 Andrew Lunn wrote: > > Do you know of real hardware with a MAC and a PHY sharing a PHC? > > mlx5 for sure, but other designs, too. PHY, NIC pipeline and PCIe PTM > may all need to time stamp from a single time counter. I'm still waiting for you to fully clarify the "per socket vs global" aspect, but independently of that, at least I understand why this is a counter-argument to my proposal. I need to tune it a bit (ASSUMING that we want DMA timestamps to "look like" hwtimestamps, and not like their own thing, to user space), because the PHC index would no longer fully identify a hwtstamp provider, so we need something more. I imagine both ETHTOOL_MSG_TSINFO_GET and ETHTOOL_MSG_TSINFO_SET to support a new (nest) nlattr called ETHTOOL_A_TSINFO_HWSTAMP_PROVIDER. This would contain (u32) ETHTOOL_A_TSINFO_HWSTAMP_PROVIDER_PHC_INDEX and (u32) ETHTOOL_A_TSINFO_HWSTAMP_PROVIDER_QUALIFIER. It could be extensible in the future, but this is the baseline and forms the key. The latter takes values from an: enum ethtool_hwstamp_provider_qualifier { ETHTOOL_HWSTAMP_PROVIDER_QUALIFIER_MAC, ETHTOOL_HWSTAMP_PROVIDER_QUALIFIER_PHY, ETHTOOL_HWSTAMP_PROVIDER_QUALIFIER_DMA, }; with Jakub's comments about the various types providing various qualities of timestamps, given here: https://lore.kernel.org/netdev/20230511150902.57d9a437@kernel.org/ - PHY - per spec, at the RS layer - MAC - "close to the wire" in the MAC, specifically the pipeline delay (PHY stamp vs MAC stamp) should be constant for all packets; there must be no variable-time buffering and (for Tx) the time stamping must be past the stage of the pipeline affected by pause frames - DMA - worst quality, variable delay timestamp, usually taken when packets DMA descriptors (Rx or completion) are being written It _sounds_ like we've all been talking about the same thing for ages, but we weren't. So, a PHC could offer multiple hwtstamp providers, as many as there are qualifiers to uniquely describe them. Each hwstamp provider is represented by a single ETHTOOL_A_TSINFO_HWSTAMP_PROVIDER nested nlattr. In TSINFO_GET requests, there are as many ETHTOOL_A_TSINFO_HWSTAMP_PROVIDER nests as there are hwtstamp providers for the NIC. In the "normal" case of one single hwtstamp provider per PHC, it would be the responsibility of the driver to set its qualifier to the right thing: phylib to ETHTOOL_HWSTAMP_PROVIDER_QUALIFIER_PHY, and "normal" MAC drivers to ETHTOOL_HWSTAMP_PROVIDER_QUALIFIER_MAC. Here, the qualifier isn't more than an extra (partially redundant) mechanism for user space to know what it's juggling with. As opposed to K?ry's proposal (where "dev->ts_layer == PHY_TIMESTAMPING" means actual phylib), ETHTOOL_HWSTAMP_PROVIDER_QUALIFIER_PHY describes the PHY-like timestamp quality of any hwtstamp provider, be it provided by a phylib PHY or a firmware-based PHY. It doesn't describe "the layer" itself. Does this tick all boxes?