All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Kurt Kanzenbach <kurt@linutronix.de>
Cc: Martin Kaistra <martin.kaistra@linutronix.de>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Richard Cochran <richardcochran@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	John Stultz <john.stultz@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v2 6/7] net: dsa: b53: Add logic for TX timestamping
Date: Wed, 10 Nov 2021 15:05:45 +0200	[thread overview]
Message-ID: <20211110130545.ga7ajracz2vvzotg@skbuf> (raw)
In-Reply-To: <87ee7o8otj.fsf@kurt>

Hi Kurt,

On Wed, Nov 10, 2021 at 08:14:32AM +0100, Kurt Kanzenbach wrote:
> Hi Vladimir,
> 
> On Tue Nov 09 2021, Vladimir Oltean wrote:
> >> +void b53_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
> >> +{
> >> +	struct b53_device *dev = ds->priv;
> >> +	struct b53_port_hwtstamp *ps = &dev->ports[port].port_hwtstamp;
> >> +	struct sk_buff *clone;
> >> +	unsigned int type;
> >> +
> >> +	type = ptp_classify_raw(skb);
> >> +
> >> +	if (type != PTP_CLASS_V2_L2)
> >> +		return;
> >> +
> >> +	if (!test_bit(B53_HWTSTAMP_ENABLED, &ps->state))
> >> +		return;
> >> +
> >> +	clone = 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.
> 
> PTP only generates a couple of messages per second which need to be
> timestamped. Therefore, this behavior shouldn't be a problem.
> 
> 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.

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).

> > Is it a hardware limitation?
> 
> Not for the b53. It will generate status frames for each to be
> timestamped packet. However, I don't see the need to allow more than one
> Tx packet per port to be timestamped at the moment.
> 
> Thanks,
> Kurt



  reply	other threads:[~2021-11-10 13:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09  9:50 [PATCH v2 0/7] Add PTP support for BCM53128 switch Martin Kaistra
2021-11-09  9:50 ` [PATCH v2 1/7] net: dsa: b53: Add BroadSync HD register definitions Martin Kaistra
2021-11-09 10:10   ` Kurt Kanzenbach
2021-11-09 18:04   ` Florian Fainelli
2021-11-10  8:19     ` Martin Kaistra
2021-11-09  9:50 ` [PATCH v2 2/7] net: dsa: b53: Move struct b53_device to include/linux/dsa/b53.h Martin Kaistra
2021-11-09 18:05   ` Florian Fainelli
2021-11-09 18:11     ` Florian Fainelli
2021-11-09 18:15       ` Vladimir Oltean
2021-11-09 18:20         ` Florian Fainelli
2021-11-09 18:49           ` Vladimir Oltean
2021-11-09  9:50 ` [PATCH v2 3/7] timecounter: allow for non-power of two overflow Martin Kaistra
2021-11-24 20:55   ` Thomas Gleixner
2021-11-09  9:50 ` [PATCH v2 4/7] net: dsa: b53: Add PHC clock support Martin Kaistra
2021-11-09 18:08   ` Florian Fainelli
2021-11-09  9:50 ` [PATCH v2 5/7] net: dsa: b53: Add logic for RX timestamping Martin Kaistra
2021-11-09 18:07   ` Florian Fainelli
2021-11-10  8:43     ` Martin Kaistra
2021-11-09  9:50 ` [PATCH v2 6/7] net: dsa: b53: Add logic for TX timestamping Martin Kaistra
2021-11-09 11:12   ` Vladimir Oltean
2021-11-10  7:14     ` Kurt Kanzenbach
2021-11-10 13:05       ` Vladimir Oltean [this message]
2021-11-10 13:30         ` Vladimir Oltean
2021-11-10 13:47         ` Kurt Kanzenbach
2021-11-10 14:00           ` Vladimir Oltean
2021-11-10 15:08         ` Richard Cochran
2021-11-10 15:23           ` Vladimir Oltean
2021-11-10 12:57   ` Vladimir Oltean
2021-11-09  9:50 ` [PATCH v2 7/7] net: dsa: b53: Expose PTP timestamping ioctls to userspace Martin Kaistra
2021-11-09 10:39 ` [PATCH v2 0/7] Add PTP support for BCM53128 switch Vladimir Oltean
2021-11-09 11:13   ` Martin Kaistra
2021-11-09 18:13     ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211110130545.ga7ajracz2vvzotg@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=john.stultz@linaro.org \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=martin.kaistra@linutronix.de \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.