On 30.09.2021 11:46:03, Stephane Grosjean wrote: > 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. > > Signed-off-by: Stephane Grosjean <s.grosjean@xxxxxxxxxxxxxxx> > --- > drivers/net/can/usb/peak_usb/pcan_usb_core.c | 11 +++++++++++ > drivers/net/can/usb/peak_usb/pcan_usb_core.h | 1 + > drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 9 ++++++--- > 3 files changed, 18 insertions(+), 3 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..4bb6b9d53df4 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,17 @@ 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 = (((u64)ts_high << 32) + ts_low) * NSEC_PER_USEC; > + > + hwts->hwtstamp = ns_to_ktime(ns_ts); > + > + return netif_rx(skb); > +} > + Applied to linux-can-next/testing, and I've reformatted the code a bit: +/* 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); +} regards, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Attachment:
signature.asc
Description: PGP signature