Message ID | 20210110103526.61047-2-mailhol.vincent@wanadoo.fr (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Add software TX timestamps to the CAN devices | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | warning | Target tree name not specified in the subject |
netdev/cc_maintainers | success | CCed 6 of 6 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 8 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
Hello Vincent, On 1/10/21 11:35 AM, Vincent Mailhol wrote: > Call skb_tx_timestamp() within can_put_echo_skb() so that a software > tx timestamp gets attached on the skb. > [..] > > 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); Personally, I would put the skb_tx_timestamp, before adding it to the array: /* make settings for echo to reduce code in irq context */ skb->pkt_type = PACKET_BROADCAST; skb->ip_summed = CHECKSUM_UNNECESSARY; skb->dev = dev; + skb_tx_timestamp(skb); /* save this skb for tx interrupt echo handling */ priv->echo_skb[idx] = skb; I don't think it actually matters though. Regards, Jeroen
Hello Jeroen, On Sun. 10 Jan 2021 at 20:29, Jeroen Hofstee <jhofstee@victronenergy.com> wrote: > > Hello Vincent, > > On 1/10/21 11:35 AM, Vincent Mailhol wrote: > > Call skb_tx_timestamp() within can_put_echo_skb() so that a software > > tx timestamp gets attached on the skb. > > > [..] > > > > 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); > > Personally, I would put the skb_tx_timestamp, before adding it to the array: > > /* make settings for echo to reduce code in irq context */ > skb->pkt_type = PACKET_BROADCAST; > skb->ip_summed = CHECKSUM_UNNECESSARY; > skb->dev = dev; > + skb_tx_timestamp(skb); > > /* save this skb for tx interrupt echo handling */ > priv->echo_skb[idx] = skb; I agree that it is better like that from an aesthetic point of view. The reason to put it at the very end was to really to blindly follow the doc and do the timestamp as late as possible. > > I don't think it actually matters though. Indeed, but will still follow your suggestion though. Putting it before would just delay the timestamp by a few assembly instructions: it is negligible enough. Yours sincerely, Vincent Mailhol
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);
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. Remarks: * 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 implement SOF_TIMESTAMPING_TX_HARDWARE for CAN sockets. References: Support for the error queue in CAN RAW sockets (which is needed for tx timestamps) was introduced in: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eb88531bdbfaafb827192d1fc6c5a3fcc4fadd96 Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> --- drivers/net/can/dev.c | 2 ++ 1 file changed, 2 insertions(+)