From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8311C433FE for ; Wed, 9 Dec 2020 15:57:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DC7B23B51 for ; Wed, 9 Dec 2020 15:57:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732410AbgLIP5l (ORCPT ); Wed, 9 Dec 2020 10:57:41 -0500 Received: from david.siemens.de ([192.35.17.14]:58483 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730402AbgLIP5g (ORCPT ); Wed, 9 Dec 2020 10:57:36 -0500 Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id 0B9EbMbS007438 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Dec 2020 15:37:22 +0100 Received: from tsnlaptop.atstm41.nbgm.siemens.de ([144.145.220.34]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id 0B9EbGp0002581; Wed, 9 Dec 2020 15:37:16 +0100 From: Erez Geva To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Alexey Kuznetsov , Arnd Bergmann , Cong Wang , "David S . Miller" , Hideaki YOSHIFUJI , Jakub Kicinski , Jamal Hadi Salim , Jiri Pirko , Alexei Starovoitov , Colin Ian King , Daniel Borkmann , Eric Dumazet , Eyal Birger , "Gustavo A . R . Silva" , Jakub Sitnicki , John Ogness , Jon Rosen , Kees Cook , Mao Wenan , Marc Kleine-Budde , Martin KaFai Lau , Matthieu Baerts , Andrei Vagin , Dmitry Safonov <0x7f454c46@gmail.com>, "Eric W . Biederman" , Ingo Molnar , John Stultz , Miaohe Lin , Michal Kubecek , Or Cohen , Oleg Nesterov , Peter Zijlstra , Richard Cochran , Stefan Schmidt , Willem de Bruijn , Xie He , Stephen Boyd , Thomas Gleixner , Vladis Dronov , Sebastian Andrzej Siewior , Frederic Weisbecker Cc: Vinicius Costa Gomes , Vedang Patel , Ines Molzahn , Simon Sudler , Andreas Meisinger , Andreas Bucher , Henning Schild , Jan Kiszka , Andreas Zirkler , Ermin Sakic , An Ninh Nguyen , Michael Saenger , Bernd Maehringer , Gisela Greinert , Erez Geva , Erez Geva Subject: [PATCH 0/3] Add sending TX hardware timestamp for TC ETF Qdisc Date: Wed, 9 Dec 2020 15:37:03 +0100 Message-Id: <20201209143707.13503-1-erez.geva.ext@siemens.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for TX sending hardware timestamp with Traffic control Earliest TxTime First (ETF) Qdisc. Why do we need additional timestamp? Current ETF requires to synchronization the system clock to the PTP Hardware clock (PHC) we want to send through. But there are cases that we can not synchronize the system clock with the desired NIC PHC. 1. We use several NICs with several PTP domains that our device is not allowed to be PTP master of. 2. We are using another clock source which we need for our system. Yet our device is not allowed to be PTP master. Regardless of the exact topology, as the Linux tradition is to allow the user the freedom to choose, we propose a patch that will add a hardware timestamp to the packet. The TC-ETF will use the first timestamp and compare it with the system clock while send the packet to the network interface driver with that hardware timestamp that is correlated with the PHC. Note 1: we do encourage the users to synchronize the system clock with a PTP clock. Synchronizing the system clock with a PTP clock will reduce the frequency difference of the PHC and the system clock, increase the accurecy and may enable the user to reduce the ETF delta. Note 2: In our network usage models sending a frame has to be very precise in relation to the PHC. Our user application does have the exact send time as of PHC perspective so it is able to provide the hw timestamp. Note 3: The user can estimate the clocks conversion error done in the user application and add it to the delta setting of the ETF. The patches contain: 1. A new flag for the SO_TXTIME socket option. 2. A new cmsg header, SCM_HW_TXTIME to pass the TX hardware timestamp. 3. Add the hardware timestamp to the socket cookie and to the inet cork. 4. As ETF Qdisc is irrelevant to TCP, ignore the TCP. 5. A new flag to the ETF Qdisc setting that mandate the use of the hardware timestamp in the SKB. 6. The ETF sort packets according to hardware timestamp, Yet pass the packet to network interface driver based on the system clock timestamp. Note 4: The socket buffer hardware timestamp is used by the network interface driver to send the actual sending timestamp back to the application. The timestamp is used by the TC ETF before the socket buffer arrives in the network interface driver. Erez Geva (3): Add TX sending hardware timestamp. Pass TX sending hardware timestamp to a socket's buffer. The TC ETF Qdisc pass the hardware timestamp to the interface driver. include/net/inet_sock.h | 1 + include/net/sock.h | 2 ++ include/uapi/asm-generic/socket.h | 3 ++ include/uapi/linux/net_tstamp.h | 3 +- include/uapi/linux/pkt_sched.h | 1 + net/core/sock.c | 9 +++++ net/ipv4/ip_output.c | 2 ++ net/ipv4/raw.c | 1 + net/ipv6/ip6_output.c | 2 ++ net/ipv6/raw.c | 1 + net/packet/af_packet.c | 3 ++ net/sched/sch_etf.c | 59 +++++++++++++++++++++++++------ 12 files changed, 75 insertions(+), 12 deletions(-) base-commit: b65054597872ce3aefbc6a666385eabdf9e288da -- 2.20.1