raw: Add HSR handling
In a HSR network each device as two port attached to the HSR ring. The
two ports are usually called port A and port B. The communication is
Ethernet based and the payload part is ETH_P_HSR. After the HSR header,
for PTP the payload is ETH_P_1588 as usual. So we have either
┌─────────┬─────────┬─────────┬─────┐
│ MAC DST │ MAC SRC │ HSR-TAG │ PTP │
└─────────┴─────────┴─────────┴─────┘
or with VLAN enabled
┌─────────┬─────────┬──────────┬─────────┬─────┐
│ MAC DST │ MAC SRC │ VLAN-TAG │ HSR-TAG │ PTP │
└─────────┴─────────┴──────────┴─────────┴─────┘
The kernel is supposed not to forward HSR packets with ETH_P_1588
payload. Also it must support socket option PACKET_HSR_BIND_PORT to bind
the hsr device to one of the two ports via PACKET_HSR_BIND_PORT_A or
PACKET_HSR_BIND_PORT_B. It needs to support PACKET_HSR_INFO with the
option PACKET_HSR_INFO_HAS_HDR for the control message in order to send
HSR with a HSR header. These changes are not merged into the upstream.
This interface is used by ptp4l to receive both copies of a packets and
to send a packet on one of the two ports including a PTP timestamp.
The clock is setup as TC which means the forwarding done by ptp4l will
properly update the correction header. The HSR header of a received
message is saved so it can be used while the packet is forwarded. This
is important to keep the MAC address of the sender but also to keep HSR
fields such as sequence number or port.
The PDELAY_* packets are not forwarded and instead responded to. Here
the HSR header is constructed by the HSR stack and the packet is sent
only on the request port.
The added BPF filter is based on the existing one and adds HSR type
handling and ignores possible VLAN. The filter drops all packets which
are sent by "us". The sender is supposed to remove his packets from the
ring.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
5 files changed