Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v5 0/8] hsr: Add additional info to send/ receive skbs
@ 2026-05-27 15:08 Sebastian Andrzej Siewior
  2026-05-27 15:08 ` [PATCH net-next v5 1/8] hsr: Add header_ops::parse_protocol Sebastian Andrzej Siewior
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-05-27 15:08 UTC (permalink / raw)
  To: netdev
  Cc: Sebastian Andrzej Siewior, Andrew Lunn, Chintan Vankar,
	Danish Anwar, Daolin Qiu, David S. Miller, Eric Dumazet,
	Felix Maurer, Jakub Kicinski, Neelima Muralidharan, Paolo Abeni,
	Praneeth Bajjuri, Pratheesh Gangadhar TK, Richard Cochran,
	Simon Horman, Vignesh Raghavendra, 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 do 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 slave devices (eth0/ eth1) from
userland in order to receive the PTP packets. Sending happens from the
hsr0 device. The actual packet has an inline header prepended of type
struct hsr_inline_header. The size of the header is equivalent to
ethhdr. The header has a type (h_proto) at the same position as ethhdr
and expects it to be ETH_P_1588 as this extra meta information is only
relevant for PTP packets. It makes no sense to send PTP packets via the
HSR interface because it gets duplicated and the timestamp information
is lost so this should not break anything. As an additional safe guard
there is a magic value at h_source position. The value has '0xaf' at the
most significant byte which makes the address a locally administered
multicast address.

The header passes two information from userland: On which slave port
the packet has to be sent and does the HSR stack need to prepend a
header or not.
The header is skipped so that the remaining stack sees the actual data
and can send it as requested.

The PRP packets are sent directly via the SLAVE interface. The standard
mandates not add a PRP trailer (PRP, redundancy control trailer) to PTP
packets. There is not really a reason to use hsr interface.

HSR hardware offloading is optional. The driver needs to know if the
operating mode is HSR or PRP. In PRP mode it needs to check the ether
type and for ETH_P_1588 it must not perform any offloading.
In HSR mode, for ether-type ETH_P_1588 there must be no offloading. If
the ether-type is ETH_P_HSR there must be no offloading if the
encapsulated protocol is ETH_P_1588.

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

---
v4…v5: https://lore.kernel.org/r/20260508-hsr_ptp-v4-1-aa19aa7c6a71@linutronix.de
- Split the patch into smaller pieces
- Added a test for the added inline header (which signals the port while
  sending packets).
- Replaced __pskb_copy() with skb_clone() + skb_cow_head() in
  hsr_create_tagged_frame() to preserve timestamp request.

v3…v4: https://lore.kernel.org/r/20260429-hsr_ptp-v3-1-afbf8f200f48@linutronix.de
- Removed skb extention. The information within HSR is passed via
  struct hsr_frame_info. Driver with HSR-offloading capabilities need to
  know the HSR mode (HSR or PRP) and parse the skb to decide what needs
  to be done (whether to send on both ports and if adding a header is
  needed).

v2…v3: https://patch.msgid.link/20260309-hsr_ptp-v2-0-798262aad3a4@linutronix.de
- Remove af_packet changes entirely.
- Add an internal header to pass additional information for HSR-PTP
  packets.
- Remove PRP, userland will use slave devices directly.
- Drop all received PTP packets. Userland needs to use the slave device
  for RX.

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 (8):
      hsr: Add header_ops::parse_protocol
      hsr: Use skb_clone() while adding the HSR header
      hsr: Add a magic header for sending PTP packets
      hsr: Drop received PTP packets
      hsr: Use the port and header information in hsr_forward_skb()
      hsr: Assign a socket for cloned skbs
      hsr: Move struct hsr_ethhdr to a global header
      selftests: hsr: Add test for the inline PTP header on HSR

 include/linux/if_hsr.h                         |  16 +
 net/hsr/hsr_device.c                           |  62 +++-
 net/hsr/hsr_forward.c                          |  77 ++++-
 net/hsr/hsr_forward.h                          |   3 +-
 net/hsr/hsr_framereg.h                         |   2 +
 net/hsr/hsr_main.h                             |   5 -
 net/hsr/hsr_slave.c                            |  37 ++-
 tools/testing/selftests/net/hsr/.gitignore     |   1 +
 tools/testing/selftests/net/hsr/Makefile       |   3 +
 tools/testing/selftests/net/hsr/hsr_ptp.sh     | 109 ++++++
 tools/testing/selftests/net/hsr/hsr_ptp_test.c | 438 +++++++++++++++++++++++++
 11 files changed, 710 insertions(+), 43 deletions(-)
---
base-commit: 9e171fc1d7d7ab847a750c03571c87ac3c17bd84
change-id: 20260204-hsr_ptp-1f6380f1d35f

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


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

end of thread, other threads:[~2026-05-27 19:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 15:08 [PATCH net-next v5 0/8] hsr: Add additional info to send/ receive skbs Sebastian Andrzej Siewior
2026-05-27 15:08 ` [PATCH net-next v5 1/8] hsr: Add header_ops::parse_protocol Sebastian Andrzej Siewior
2026-05-27 15:08 ` [PATCH net-next v5 2/8] hsr: Use skb_clone() while adding the HSR header Sebastian Andrzej Siewior
2026-05-27 15:08 ` [PATCH net-next v5 3/8] hsr: Add a magic header for sending PTP packets Sebastian Andrzej Siewior
2026-05-27 15:08 ` [PATCH net-next v5 4/8] hsr: Drop received " Sebastian Andrzej Siewior
2026-05-27 15:08 ` [PATCH net-next v5 5/8] hsr: Use the port and header information in hsr_forward_skb() Sebastian Andrzej Siewior
2026-05-27 15:08 ` [PATCH net-next v5 6/8] hsr: Assign a socket for cloned skbs Sebastian Andrzej Siewior
2026-05-27 15:08 ` [PATCH net-next v5 7/8] hsr: Move struct hsr_ethhdr to a global header Sebastian Andrzej Siewior
2026-05-27 15:08 ` [PATCH net-next v5 8/8] selftests: hsr: Add test for the inline PTP header on HSR Sebastian Andrzej Siewior
2026-05-27 19:12   ` Jakub Kicinski

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