]> git.baikalelectronics.ru Git - kernel.git/commit
can: gs_usb: add RX and TX hardware timestamp support
authorJohn Whittington <git@jbrengineering.co.uk>
Mon, 22 Aug 2022 10:01:10 +0000 (12:01 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 6 Sep 2022 06:21:47 +0000 (08:21 +0200)
commit3f8e4fb414a2fd923b9fdbb8bc0eed58f8f33b1d
tree64534cc5b2a1b9f863492bd8f3de065400327ad8
parentade08cb0a9204d88f71c422de4866bbc3cbe8cf2
can: gs_usb: add RX and TX hardware timestamp support

Add support for hardware timestamps, if the firmware includes it as a
feature via the GS_CAN_FEATURE_HW_TIMESTAMP flag. Check for this
feature during probe, extend the RX expected length if it is and
enable it during open.

The struct classic_can_ts and struct canfd_ts are extended to include
the µs timestamp following data as defined in the firmware. The
timestamp is then captured and set using skb_hwtstamps() on each RX
and TX.

The frame µs timestamp is provided from a 32 bit 1 MHz timer which
rolls over every 4294 seconds, so a cyclecounter, timecounter, and
delayed worker are used to convert the timer into a proper ns
timestamp - same implementation as commit 28b81deab3754 ("can:
mcp251xfd: add HW timestamp infrastructure").

Hardware timestamps are added to capabilities as commit
bf0ec5b769bf ("can: mcp251xfd: advertise timestamping capabilities and
add ioctl support").

Signed-off-by: John Whittington <git@jbrengineering.co.uk>
Link: https://github.com/candle-usb/candleLight_fw/issues/100
Link: https://lore.kernel.org/all/20220827221548.3291393-3-mkl@pengutronix.de
Co-developed-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/gs_usb.c