Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1619747pxb; Sun, 10 Jan 2021 04:53:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKdO8kgX/DTMOyzzzI2hAOB2z7Af1+d8FfY8g5AIaeAIqhSGp4Cf50yll5B7JgEyDqoirT X-Received: by 2002:aa7:cf85:: with SMTP id z5mr11172163edx.274.1610283181315; Sun, 10 Jan 2021 04:53:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610283181; cv=none; d=google.com; s=arc-20160816; b=hvKBvicZvTf5NltoFDrwD7FqqziBIIZ8HFappIedfupvOKoAxXqAEWgxNJapqHYO0l 7cF5o6KEBCHb0PajalVqGd00Da8g/6cHhOPoDFOUUqJAnZayNpW7DFvfx51QvsJT5xdq x52d7tKfMjgY8zKjo1bRQL9ifnwERlEL2Iv2DcRMt27WFXEdF0e9CUq9sZY8fyuBG4cG TQvRNZGk3/ijRxHnknJIFW8EAeOgVyOakerXJ8OnfxB1WSyhS6u482pppYoijJ5RReQX EIfhoyeSez5iLfyScQRnFcgXzF09F1O9rRbom3txDjoHva9X19HkPDay/RHInJNNeGJX mE5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2RqEoOabMsRDLz9spmcqrLnXF43adbm4iO/xWDjAgFE=; b=jyWPrg4brGPr5mJ76Z8cBXfxb2UavgI/Uqhic6749tYS7kBJwj00hwKWrFLU2/xfAU +pUTDfEfbIXmcGVAx+b6S1M1CDGycOQZX7RUcgVowlLkOgJMTxUlEmrJOjs7kKqsfWxr y65OV6pBgnETnfv42cYBJMJHLBIiinqP2f6bZgZUNF4Ff0u3xOW1eUwaJny4ibWBKPDy w/duOBjsLm7zibtrdsSPuHkKuhrzTQd5q4/3oD9xvGSqXT+WaXVtCV4pp8D8uhPEv6Ow 4su2jiIdZzjn3zkvy9t0y9/M3xIdt6Ujfc2KUQFt6btqtNlEupqgQcBiIrXaM9BeqOMC y1YA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si5686650edq.546.2021.01.10.04.52.37; Sun, 10 Jan 2021 04:53:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726566AbhAJMvV (ORCPT + 99 others); Sun, 10 Jan 2021 07:51:21 -0500 Received: from smtp07.smtpout.orange.fr ([80.12.242.129]:48272 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726494AbhAJMvV (ORCPT ); Sun, 10 Jan 2021 07:51:21 -0500 Received: from localhost.localdomain ([153.202.107.157]) by mwinf5d13 with ME id F0pW240033PnFJp030paM0; Sun, 10 Jan 2021 13:49:37 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: bWFpbGhvbC52aW5jZW50QHdhbmFkb28uZnI= X-ME-Date: Sun, 10 Jan 2021 13:49:37 +0100 X-ME-IP: 153.202.107.157 From: Vincent Mailhol To: Marc Kleine-Budde , linux-can@vger.kernel.org, Jeroen Hofstee Cc: Vincent Mailhol , Wolfgang Grandegger , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 1/1] can: dev: add software tx timestamps Date: Sun, 10 Jan 2021 21:49:03 +0900 Message-Id: <20210110124903.109773-2-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210110124903.109773-1-mailhol.vincent@wanadoo.fr> References: <20210110124903.109773-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Put the call to skb_tx_timestamp() just before adding it to the array: https://lkml.org/lkml/2021/1/10/54 Signed-off-by: Vincent Mailhol --- drivers/net/can/dev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index 3486704c8a95..850759c7677f 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c @@ -481,6 +481,7 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, 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; -- 2.26.2