public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Felix Maurer <fmaurer@redhat.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Simon Horman <horms@kernel.org>,
	Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Subject: Re: [PATCH RFC net-next 0/2] hsr: Add additional info to send/ receive skbs
Date: Mon, 16 Feb 2026 17:10:38 +0100	[thread overview]
Message-ID: <aZNBfh81p1zBvbi2@thinkpad> (raw)
In-Reply-To: <20260204-hsr_ptp-v1-0-b421c69a77da@linutronix.de>

Hi Sebastian,

I had to read quite a bit about PTP and how it's supposed to be handled
in HSR rings. I've got no experience with PTP in the real world, but
here we go.

On Wed, Feb 04, 2026 at 12:24:02PM +0100, Sebastian Andrzej Siewior wrote:
> I am trying to extend linuxptp to support PTP over a HSR network. The
> user space for linuxptp are still under discussion, the thread starts at
> 	https://lists.nwtime.org/sympa/arc/linuxptp-devel/2025-11/msg00013.html
>
> the posted patches are also available at git repository for convenience
> 	https://git.kernel.org/pub/scm/linux/kernel/git/bigeasy/linuxptp-hsr.git hsr_v2
>
> This is the kernel side of the changes. In short PTP over HSR sends its
> packets to multicast address and every node needs to forward the PTP
> packet (SYNC and FOLLOW-UP for instance) within the HSR ring.
> In order to achieve this, the HSR stack must not duplicate and forward
> the PTP packets as it would with other packets. The delay caused by the
> duplication and forwarding adds overhead which in turn makes the timing
> information within the PTP packet inaccurate.
>
> My current approach is to open the hsr0 device from userland and send
> and receive the PTP packets individually on both slave interfaces. I
> added additional hints to the af_packet interface, which is used by
> linuxptp, to be able send a packet on a specific interface (A or B) and
> also to have the information recorded for received packets.
> Additionally, the PTP-timestamps which arrive on the slave interface are
> forwarded to the hsr interface.

I agree with Willem that the changes are pretty invasive in core parts
of the stack for a pretty narrow use case. It got me thinking what would
already be supported at the moment without any changes in the kernel or
pretty small changes. For that, I see three parts:

1. Userspace needs to get the full HSR+PTP frames including the headers
   and including the rx port information.
     a) Userspace should have a way to _only_ receive HSR+PTP frames
        instead of all traffic on one of the ports.
2. We should not forward HSR+PTP frames in HSR interface to prevent
   creating inaccurate timing information.
3. Userspace needs a way to send packets a) over just port A or B of an
   HSR interface, that b) already include an HSR header and should
   therefore go mostly unmodified.

Is that about a correct summary?

If I understand your patch 2 correctly, you will be maintaining two
sockets in userspace (one bound to each of the ports A and B through the
HSR interface using PACKET_HSR_BIND_PORT). Binding through the HSR
interface to port A/B has the very special meaning of making a socket
only receive a very small subset of the packets, that is PTP traffic at
the moment. This seems like a somewhat hidden property of the bound
sockets and should at least be very explicit.

Is there a reason not to create and bind one socket directly to each of
the underlying slave interfaces, with a socket filter attached to only
receive the HSR+PTP packets you want? The rx port information is
inherent to the socket this way. I'm not sure if sending over the
sockets works out of the box, but if something is needed for that, I'd
assume it's less invasive and more generally usable.

We'd still need to address 2. for this to work, but blocking forwarding
for PTP could be done in hsr_forward and friends with a much simpler
patch.

The other thing that came to my mind: this sounds like XDP with AF_XDP
could be a solution that could be used already today; not so much
because of their speed but because you can program what goes to the
stack and what ends up in userspace. It fulfills 1) + a) directly, 2)
implicitly by not letting these frames enter the stack, and 3) directly.
But I also see that handling AF_XDP sockets in userspace is quite some
work to do if all you really need is to separate out some traffic.

Thanks,
   Felix


  parent reply	other threads:[~2026-02-16 16:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04 11:24 [PATCH RFC net-next 0/2] hsr: Add additional info to send/ receive skbs Sebastian Andrzej Siewior
2026-02-04 11:24 ` [PATCH RFC net-next 1/2] hsr: Allow to send a specific port and with HSR header Sebastian Andrzej Siewior
2026-02-04 17:30   ` Willem de Bruijn
2026-02-17 15:36     ` Sebastian Andrzej Siewior
2026-03-04 14:58     ` Sebastian Andrzej Siewior
2026-03-04 15:56       ` Willem de Bruijn
2026-03-04 16:12         ` Sebastian Andrzej Siewior
2026-03-04 23:48           ` Willem de Bruijn
2026-03-05  8:07             ` Sebastian Andrzej Siewior
2026-03-05 14:41               ` Jakub Kicinski
2026-03-05 15:05                 ` Sebastian Andrzej Siewior
2026-02-04 11:24 ` [PATCH RFC net-next 2/2] af_packet: Add port specific handling for HSR Sebastian Andrzej Siewior
2026-02-04 17:36   ` Willem de Bruijn
2026-02-17 15:51     ` Sebastian Andrzej Siewior
2026-02-16 16:10 ` Felix Maurer [this message]
2026-02-16 16:19   ` [PATCH RFC net-next 0/2] hsr: Add additional info to send/ receive skbs Sebastian Andrzej Siewior
2026-02-16 16:25   ` Andrew Lunn
2026-02-17 16:14     ` Sebastian Andrzej Siewior
2026-02-17 16:10   ` Sebastian Andrzej Siewior
2026-02-18 19:28     ` Felix Maurer
2026-02-18 21:53       ` Willem de Bruijn
2026-02-24 11:48         ` Sebastian Andrzej Siewior
2026-02-24 11:24       ` Sebastian Andrzej Siewior

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=aZNBfh81p1zBvbi2@thinkpad \
    --to=fmaurer@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=willemdebruijn.kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox