diff options
author | Stephane Grosjean <s.grosjean@peak-system.com> | 2021-09-30 12:46:03 +0300 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2021-10-24 17:26:05 +0300 |
commit | 28e0a70cede3fa6835e36302207776831cc41b8b (patch) | |
tree | 84e610f72dbffe7af1b6a0eaee3cde6979a3a336 /drivers/net/can/usb/peak_usb/pcan_usb_core.c | |
parent | 108194666a3f59ccaf22ff560a038ee0d7355a86 (diff) | |
download | linux-28e0a70cede3fa6835e36302207776831cc41b8b.tar.xz |
can: peak_usb: CANFD: store 64-bits hw timestamps
This patch allows to use the whole 64-bit timestamps received from the
CAN-FD device (expressed in µs) rather than only its low part, in the
hwtstamp structure of the skb transferred to the network layer, when a
CAN/CANFD frame has been received.
Link: https://lore.kernel.org/all/20210930094603.23134-1-s.grosjean@peak-system.com
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/usb/peak_usb/pcan_usb_core.c')
-rw-r--r-- | drivers/net/can/usb/peak_usb/pcan_usb_core.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c index e8f43ed90b72..6107fef9f4a0 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c @@ -205,6 +205,19 @@ int peak_usb_netif_rx(struct sk_buff *skb, return netif_rx(skb); } +/* post received skb with native 64-bit hw timestamp */ +int peak_usb_netif_rx_64(struct sk_buff *skb, u32 ts_low, u32 ts_high) +{ + struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb); + u64 ns_ts; + + ns_ts = (u64)ts_high << 32 | ts_low; + ns_ts *= NSEC_PER_USEC; + hwts->hwtstamp = ns_to_ktime(ns_ts); + + return netif_rx(skb); +} + /* * callback for bulk Rx urb */ |