[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <928593CA-9CE9-4A54-B84A-9973126E026D@timebeat.app>
Date: Wed, 20 Apr 2022 15:03:26 +0100
From: Lasse Johnsen <lasse@...ebeat.app>
To: netdev@...r.kernel.org
Cc: richardcochran@...il.com,
Gordon Hollingworth <gordon@...pberrypi.com>,
Ahmad Byagowi <clk@...com>
Subject: Support for IEEE1588 timestamping in the BCM54210PE PHY using the
kernel mii_timestamper interface
Hello,
The attached set of patches adds support for the IEEE1588 functionality on the BCM54210PE PHY using the Linux Kernel mii_timestamper interface. The BCM54210PE PHY can be found in the Raspberry PI Compute Module 4 and the work has been undertaken by Timebeat.app on behalf of Raspberry PI with help and support from the nice engineers at Broadcom.
Design:
After the ethernet frames are identified using the ptp_classify_raw function, they are parsed through the mii_timestamper interface to the bcm54210pe_rxtstamp and bcm54210pe_txtstamp functions via the skb_defer_rx_timestamp and skb_clone_tx_timestamp kernel functions.
In both cases these functions enqueue the sk_buff ptrs and schedules a work struct thread that attaches timestamps and forward the skbs upstream via the netif_rx_ni and skb_complete_tx_timestamp in the bcm54210pe_run_rx_timestamp_match_thread and bcm54210pe_run_tx_timestamp_match_thread functions in a non-interrupt context.
The driver uses poll style behaviour triggered by the rx or tx of frames, but does not use a formal interrupt handler.
In addition to gettime, settime and adjtime and adjfine, I've implemented the gettimex64 function to provide the best possible sync of the kernel clock from the PHC. However, as the PHY is separated from the MAC by the MDIO bus, I cannot lock and prevent the scheduler from interrupting the 3-timestamp process, but performance is nonetheless reasonable and the kernel clock sees offset variations in the 1-2us range.
Features:
In addition the driver add support for perout and extts functionality using ptp_clock_request structs as provided for by the standard SO_TIMESTAMPING API.
Test & Performance:
We have tested the features and accuracy in our lab and are able as a client to run at -7 intervals without significant performance impact on a Raspberry PI CM4 on an IO board. We are able to maintain synchronisation of the PHC within +/-10ns of its grandmaster PTP source and the system clock within 1-2us of the PHC.
I look forward to receiving your feedback.
All the best,
Lasse
View attachment "bcm54210pe-1588.patch.txt" of type "text/plain" (50270 bytes)
Powered by blists - more mailing lists