Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp542515pxh; Wed, 10 Nov 2021 05:49:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPdnuALtfyiizwO9v5NjYAD4AAuy9lakN5NvVNCpgc4PdDxD02cBvLdLYO/ixnqurWX3+9 X-Received: by 2002:a17:907:3f8a:: with SMTP id hr10mr20175344ejc.527.1636552183415; Wed, 10 Nov 2021 05:49:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636552183; cv=none; d=google.com; s=arc-20160816; b=X+H2m80Vzn10qWbh4s0rZQoqJQUQmsqF+4s5tYXKImKtpXefZPijycDwJtCUPtBlZp HbKJT5ktonEAy/dFrh3pgZxIEUahwni5mv93NmGt4/7GVlWThGEHS5SepQggywPhZySp Ohouudx0VDppy+DaETnMy7T1d4zIJAHjptuuo2y1PiARB4AW45BZsoCN68EyZY78VUQF 9FkrRFc2/r/zpLKr/cm41DOjJHlX/d7IChzc/LDW6SKBKGMNn2eTvL7F+3ooRGFMK9nG fideuNzEOD/RTVN0KD8S1VzBLgc7bmZNtXjs63n4lSRPzzihajFzLvoVhsg+omq/JK7d LQrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=/MciXaiM/IuTmIk/zMIlZFbpG5qOYdi18BE9VZB246g=; b=HZfQXwHRdYflWJ3silxAPawDu+bcAEKBX5yvpilHeZVdG2QYnbibqkEAyErRYKNRPH ev1G4jFCxqZ5vCDXXMyFDBF9a4B00KdE1+y34fK1wZeFAZO0J8wcW1jG0MPSTBT74ST6 LnXuO9NhIlLlOzRDR6S4Lsvzpzy2rMw58zjda2jutbf6nzwomrJHpb4xQDDFkIr5xyLi hwH8nzXoUFS/3Q+kR/cmx2RdTbZjlA1g6isZB+51Sy9Ds3/YepPxJjq9UjsDHtdCN4mR PjY75QAcI2tPunLwrkoPbGfPySmBJwbn4Dw8pH9GtWs7Qh6EOgUUDTYABhIV6r8jkHim cPGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="QdH2wN/O"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p20si36564381eds.482.2021.11.10.05.49.18; Wed, 10 Nov 2021 05:49:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="QdH2wN/O"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231991AbhKJNuM (ORCPT + 99 others); Wed, 10 Nov 2021 08:50:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231526AbhKJNuL (ORCPT ); Wed, 10 Nov 2021 08:50:11 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01539C061764; Wed, 10 Nov 2021 05:47:23 -0800 (PST) From: Kurt Kanzenbach DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1636552041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/MciXaiM/IuTmIk/zMIlZFbpG5qOYdi18BE9VZB246g=; b=QdH2wN/OUfJa1D4UUw9Z158yvc9J6KaiHGOpk0xV/c0tqp7CrqRK9r8STCXWwofz9sGvGM 5zG/+sxajESDEe/WEMSfNV+cVysXCwXZv4BVfd4GYZsEHHLmaufib+Tg10nzB1o2ksabIC 9+p6Xw/KmvvEn4zGHvQ35pAgdcDu7XIPEpjf4FL7T9roN+GStDZaJOpjpJQ+SEuTgrHG+j uqMnQFcLnQtSBO5v+FKeMoW/3j6aW3eOjbXEs0ABZylnGhFt38O0EACE9vjDhbUgckx8mf UPDHWShhreB0mNFiB/lyUawGu9BC/d+1MNnazJgF0y5g6fdFlgGpBFq7rFuYow== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1636552041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/MciXaiM/IuTmIk/zMIlZFbpG5qOYdi18BE9VZB246g=; b=r8RlS/AQgTnYBJ8q5P3IWsoiij24JoTCzTmVCbkZ9VsEFMn/04rNTxuegKnAY5pnMA2cgA vB8Aszd6wQxvuxAA== To: Vladimir Oltean Cc: Martin Kaistra , Florian Fainelli , Andrew Lunn , Vivien Didelot , Richard Cochran , "David S. Miller" , Jakub Kicinski , John Stultz , Thomas Gleixner , Stephen Boyd , Russell King , Marc Kleine-Budde , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v2 6/7] net: dsa: b53: Add logic for TX timestamping In-Reply-To: <20211110130545.ga7ajracz2vvzotg@skbuf> References: <20211109095013.27829-1-martin.kaistra@linutronix.de> <20211109095013.27829-7-martin.kaistra@linutronix.de> <20211109111213.6vo5swdhxjvgmyjt@skbuf> <87ee7o8otj.fsf@kurt> <20211110130545.ga7ajracz2vvzotg@skbuf> Date: Wed, 10 Nov 2021 14:47:19 +0100 Message-ID: <8735o486mw.fsf@kurt> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed Nov 10 2021, Vladimir Oltean wrote: > Hi Kurt, > > On Wed, Nov 10, 2021 at 08:14:32AM +0100, Kurt Kanzenbach wrote: >> Hi Vladimir, >>=20 >> On Tue Nov 09 2021, Vladimir Oltean wrote: >> >> +void b53_port_txtstamp(struct dsa_switch *ds, int port, struct sk_bu= ff *skb) >> >> +{ >> >> + struct b53_device *dev =3D ds->priv; >> >> + struct b53_port_hwtstamp *ps =3D &dev->ports[port].port_hwtstamp; >> >> + struct sk_buff *clone; >> >> + unsigned int type; >> >> + >> >> + type =3D ptp_classify_raw(skb); >> >> + >> >> + if (type !=3D PTP_CLASS_V2_L2) >> >> + return; >> >> + >> >> + if (!test_bit(B53_HWTSTAMP_ENABLED, &ps->state)) >> >> + return; >> >> + >> >> + clone =3D skb_clone_sk(skb); >> >> + if (!clone) >> >> + return; >> >> + >> >> + if (test_and_set_bit_lock(B53_HWTSTAMP_TX_IN_PROGRESS, &ps->state))= { >> > >> > Is it ok if you simply don't timestamp a second skb which may be sent >> > while the first one is in flight, I wonder? What PTP profiles have you >> > tested with? At just one PTP packet at a time, the switch isn't giving >> > you a lot. >>=20 >> PTP only generates a couple of messages per second which need to be >> timestamped. Therefore, this behavior shouldn't be a problem. >>=20 >> hellcreek (and mv88e6xxx) do the same thing, simply because the device >> can only hold only one Tx timestamp. If we'd allow more than one PTP >> packet in flight, there will be correlation problems. I've tested with >> default and gPTP profile without any problems. What PTP profiles do have >> in mind? > > First of all, let's separate "more than one packet in flight" at the > hardware/driver level vs user space level. Even if there is any hardware > requirement to not request TX timestamping for the 2nd frame until the > 1st has been acked, that shouldn't necessarily have an implication upon > what user space sees. After all, we don't tell user space anything about > the realities of the hardware it's running on. Fair enough. > > So it is true that ptp4l is single threaded and always polls > synchronously for the reception of a TX timestamp on the error queue > before proceeding to do anything else. But writing a kernel driver to > the specification of a single user space program is questionable. > Especially with the SOF_TIMESTAMPING_OPT_ID flag of the SO_TIMESTAMPING > socket option, it is quite possible to write a different PTP stack that > handles TX timestamps differently. It sends event messages on their > respective timer expiry (sync, peer delay request, whatever), and > processes TX timestamps as they come, asynchronously instead of blocking. > That other PTP stack would not work reliably with this driver (or with > mv88e6xxx, or with hellcreek). Yeah, a PTP stack which e.g. runs delay measurements independently from the other tasks (sync, announce, ...) may run into trouble with such as an implementation. I'm wondering how would you solve that problem for hardware such as hellcreek? If a packet for timestamping is "in-flight" the Tx path for a concurrent frame would have to be delayed. That might be a surprise to the user as well. Thanks, Kurt --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCgAxFiEEooWgvezyxHPhdEojeSpbgcuY8KYFAmGLzWcTHGt1cnRAbGlu dXRyb25peC5kZQAKCRB5KluBy5jwphxXD/9AAZtvg6YJic2fjwwmSNV2WUUBMVmO ztwGA8AvA5luVfVRNBZFWViU1+2F81GfyqZa3311B7lMVWoMcT02ZTsSOiRKVXpM Xx8ut3iXN/2D+mfklMYHU5K8qLd/fqk2n7PLJkXN5B0YCV9+l5KRVbIKMnzwbemX x3Pkm1D0Nk3+/I81TW22/NmejIde9DJQ+YasgsaxAkWVe1j2ZMGstYkowDUjjjq+ IGQqzpXxsmK4rLCe0d9wNElbaykiPNA93o+B2uN3nOhwuRo5odhY0QwJ06OjrZto C4IyID15l2B8EyLVw7ap4U0jwTmR3HugM/fzWZMgbNiPeiYJsNgxxFN5txu3z+qx fzQ0AB11w49qYcIRZCG4G8oC8vWJTHWP1/O02c5yKf5fQjztMynhnHOFtWkIYJUw N9gwO9KYVtDS7axyDxwTCkDNc/ncST9nXiajqxxtrcBQHJc24nsqV/YBDN9xMikI OThlrPhnh986mXaK7SFfmnyw4172wHc8zcKm/WDgVCcRAB+8MQVa/dCKSKg2tFjP rlrhMs9Veo9wkmF17yqSMNgUUHgfcl6nmkIRWk0fKmVfSKzBfWlHHVcOocuyOMvG JV9n3yJGpQSRYNbsBQQroEiYiD0h9ZEtJMDPPph4suAF+zbbBHNeyFBJGWTXVqlv nadUgwMvQI2XFQ== =Uu/4 -----END PGP SIGNATURE----- --=-=-=--