Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1617293pxb; Sun, 10 Jan 2021 04:46:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlZWGhOkiop9sOQdpkEiBL3meoOGxo3D5fbpEmQyBL6cG1kNTXX4cW3GGr7jWkuyVmng+5 X-Received: by 2002:a17:906:134f:: with SMTP id x15mr7939994ejb.278.1610282790888; Sun, 10 Jan 2021 04:46:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610282790; cv=none; d=google.com; s=arc-20160816; b=hQhkOcvxh/Cmr81DVEOx3bf+7mJs5aPH9qtDI5mQEfwsYpReXQ8Xj8KmfWv/XRYbx+ XywXOP5kP4IcFcqkRua2PU/NGFdQ8/c7Ih2o/Gp8aBnUx1UH2w7E6txDuF4OT3raSCdy jAe0MY0bDtlBtWqMiO74V8lBxFn3hBqUBO1QjFJn9y6rsN+gNMcrR87GsmF2aPG+jJxv mG17rT+B4g/v+UDteobTt3h0AN3X0MceVQd98ZwTmBGqnMPzNJZvOX0dl0gTTrEPz3ox pWGKqpnZ1RGfJnEU+j6Dx/HpDF8LP1OXgaHi2wrkhD/l+9JOv4TmW5sumkBkFrESk5QP uLmg== 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=TctgsDuNDZAkAIGg8Do15rjfgDbGBJIDydF8CkrZbYg=; b=KPbmVkVcD2kBVmo27K3YGXqiRqCS9W5oz+bTNxqhLzuomAuNbfg/GC5r8tMKhyRDCL A0Qz5mExV+P+ha4L5sCvtnLnzQ4rqXMSiuFroNQYvMMe042eian7mxgqUcevr0hHo6HR spKCGqTqf9sV/EDWOEs8uyx/VGIQY67xPDZ7qxUP0DZoJKVoj6ibspdX7458Fk4ctHcZ t9pgH9ELQ+PxvQqtXeWMKrGvB8tdbRlU7OCva56vV04HmUcKLftmsw6NEOnwiREAqmf/ 0zu2HxvgCWw2iqs8hxSroR19mhxlgDgK8bYwzp0T+K2g/OWF5lz4pO12FAlekihZOeSm obWg== 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 z1si5540012eji.695.2021.01.10.04.46.07; Sun, 10 Jan 2021 04:46:30 -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 S1726784AbhAJMoL (ORCPT + 99 others); Sun, 10 Jan 2021 07:44:11 -0500 Received: from smtp07.smtpout.orange.fr ([80.12.242.129]:25027 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbhAJMoL (ORCPT ); Sun, 10 Jan 2021 07:44:11 -0500 Received: from localhost.localdomain ([153.202.107.157]) by mwinf5d13 with ME id F0iL2400A3PnFJp030iQzE; Sun, 10 Jan 2021 13:42:27 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: bWFpbGhvbC52aW5jZW50QHdhbmFkb28uZnI= X-ME-Date: Sun, 10 Jan 2021 13:42:27 +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 v2 1/1] can: dev: add software tx timestamps Date: Sun, 10 Jan 2021 21:41:31 +0900 Message-Id: <20210110124132.109326-2-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210110124132.109326-1-mailhol.vincent@wanadoo.fr> References: <20210110124132.109326-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 | 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); -- 2.26.2