public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC net-next v2 0/2] hsr: Add additional info to send/ receive skbs
@ 2026-03-09 15:52 Sebastian Andrzej Siewior
  2026-03-09 15:52 ` [PATCH RFC net-next v2 1/2] hsr: Allow to send a specific port and with HSR header Sebastian Andrzej Siewior
  2026-03-09 15:52 ` [PATCH RFC net-next v2 2/2] af_packet: Add port specific handling for HSR Sebastian Andrzej Siewior
  0 siblings, 2 replies; 16+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-03-09 15:52 UTC (permalink / raw)
  To: netdev
  Cc: Sebastian Andrzej Siewior, (JC), Jayachandran, David S. Miller,
	Andrew Lunn, Chintan Vankar, Danish Anwar, Daolin Qiu,
	Eric Dumazet, Felix Maurer, Jakub Kicinski, Paolo Abeni,
	Richard Cochran, Simon Horman, Willem de Bruijn

I am trying to extend linuxptp to support PTP over a HSR network.

This is the kernel side of the changes. In short PTP over HSR sends its
packets to a 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 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.

This solves the following:
- Forwarding a SYNC and a FOLLOW_UP packet.
  Userland receives a SYNC, FOLLOW_UP and timestamp packet from port A.
  The received port is known and recorded. The SYNC packet and the
  updated FOLLOW_UP packet can then be forwarded on port B. The update
  is based on the time spent during the forward so the forwarding delay
  is accounted for.
  In this scenario the HSR header is used from the original sender of
  the SYNC and FOLLOW_UP header and the stack must not prepand the
  system's HSR header nor replace the provided header.

- Sending PDELAY_REQ and PDELAY_RESP*
  These packets are only exchanged between the two nodes directly
  connected and they must not be forwarded within the HSR ring.
  These packets are sent as PTP packets and the HSR stack must prepand
  system's HSR header including a sequence number.
  This logic is also used for SYNC packet if the node acts as a GM.

This has been tested in a pure software environment and in an HW-assited
environment where the HW is able to duplicate and deduplicate packets
but does not do it for PTP packets.
It has not been tested within an enviroment where the HW is able to
forward the PTP packet and correctly update the timming information.

---
v1…v2: https://patch.msgid.link/20260204-hsr_ptp-v1-0-b421c69a77da@linutronix.de
- Added PRP support
- skb extention is used instead of extending struct skb_shared_info
- in af_packet
  - packet_sendmsg_spkt() is no longer extended
  - jump labels are used to avoid the overhead if there no socket that
    is using this HSR extension.

---
Sebastian Andrzej Siewior (2):
      hsr: Allow to send a specific port and with HSR header
      af_packet: Add port specific handling for HSR

 include/linux/if_hsr.h         |  81 ++++++++++++++++++++
 include/linux/skbuff.h         |   3 +
 include/uapi/linux/if_packet.h |   9 +++
 net/core/skbuff.c              |   4 +
 net/hsr/Kconfig                |   1 +
 net/hsr/hsr_device.c           |   7 ++
 net/hsr/hsr_forward.c          | 118 ++++++++++++++++++++++++++---
 net/hsr/hsr_framereg.h         |   1 +
 net/hsr/hsr_slave.c            |  35 +++++++--
 net/packet/af_packet.c         | 167 +++++++++++++++++++++++++++++++++++++++++
 net/packet/internal.h          |   1 +
 11 files changed, 412 insertions(+), 15 deletions(-)
---
base-commit: 3daa4f5dc6cc1ac1ab2f95b5b4c16bc5fb87f48f
change-id: 20260204-hsr_ptp-1f6380f1d35f

Best regards,
-- 
Sebastian Andrzej Siewior <bigeasy@linutronix.de>


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-03-24 16:38 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 15:52 [PATCH RFC net-next v2 0/2] hsr: Add additional info to send/ receive skbs Sebastian Andrzej Siewior
2026-03-09 15:52 ` [PATCH RFC net-next v2 1/2] hsr: Allow to send a specific port and with HSR header Sebastian Andrzej Siewior
2026-03-09 15:52 ` [PATCH RFC net-next v2 2/2] af_packet: Add port specific handling for HSR Sebastian Andrzej Siewior
2026-03-10  1:38   ` Willem de Bruijn
2026-03-10 10:55     ` Sebastian Andrzej Siewior
2026-03-10 21:35       ` Willem de Bruijn
2026-03-12 15:42         ` Sebastian Andrzej Siewior
2026-03-12 21:43           ` Willem de Bruijn
2026-03-13  9:22             ` Sebastian Andrzej Siewior
2026-03-13 16:04               ` Sebastian Andrzej Siewior
2026-03-16 20:12                 ` Willem de Bruijn
2026-03-17 17:29                   ` Sebastian Andrzej Siewior
2026-03-19 13:29                     ` Willem de Bruijn
2026-03-19 14:26                       ` Sebastian Andrzej Siewior
2026-03-19 16:27                         ` Willem de Bruijn
2026-03-24 16:38                           ` Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox