[lkml]   [2021]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 1/1] can: dev: add software tx timestamps
Call skb_tx_timestamp() within can_put_echo_skb() so that a software
tx timestamp gets attached on the skb.

There two main reasons to include this call in can_put_echo_skb():

* It easily allow to enable the tx timestamp on all devices with
just one small change.

* According to Documentation/networking/timestamping.rst, the tx
timestamps should be generated in the device driver as close as
possible, but always prior to passing the packet to the network
interface. During the call to can_put_echo_skb(), the skb gets
cloned meaning that the driver should not dereference the skb
variable anymore after can_put_echo_skb() returns. This makes
can_put_echo_skb() the very last place we can use the skb without
having to access the echo_skb[] array.


* By default, skb_tx_timestamp() does nothing. It needs to be
activated by passing the SOF_TIMESTAMPING_TX_SOFTWARE flag either
through socket options or control messages.

* The hardware rx timestamp of a local loopback message is the
hardware tx timestamp. This means that there are no needs to


Support for the error queue in CAN RAW sockets (which is needed for tx
timestamps) was introduced in:

Signed-off-by: Vincent Mailhol <>
drivers/net/can/dev.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 3486704c8a95..3904e0874543 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -484,6 +484,8 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,

/* save this skb for tx interrupt echo handling */
priv->echo_skb[idx] = skb;
+ skb_tx_timestamp(skb);
} else {
/* locking problem with netif_stop_queue() ?? */
netdev_err(dev, "%s: BUG! echo_skb %d is occupied!\n", __func__, idx);
 \ /
  Last update: 2021-01-10 11:41    [W:0.043 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site