Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7959400rdb; Thu, 4 Jan 2024 13:24:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPxgaP8qDlazzcLoADGljoF3AUCy/sj0UocKEfCPnQOIhYYSkvAvHgXa+1FX84afgKynmy X-Received: by 2002:a05:620a:47:b0:781:54f2:75d5 with SMTP id t7-20020a05620a004700b0078154f275d5mr1253577qkt.48.1704403488515; Thu, 04 Jan 2024 13:24:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704403488; cv=none; d=google.com; s=arc-20160816; b=LlGAPpXtXyFO59aV0IBgCCEdqzwxqQg7nUzMhvgHpG5fitTPkerFWQ+SCkX9rQifAt 1cQSuxBQwwMNU0c2odb7Ym3SbTYIayM02/z+Gs7MefsVpbdV0PuyD4ZmyCE/rBRKw+ZG iDmma9qaRUr0Qa8jacTYFpGIacX4UIrhYMdeWcifBLustfA/XsIjf4p0oq4w39WPxvCU u08gxsYQJNkS7nsjyyWcFfKIcTbeDaCjNSYoJsfMdbHBsKqBuDkZVaEHB3bwt7bwzlPx CudakjlapfiEAwaj99zYzv7d0J3xuVUYWo1qnmVL/v4QBoGaploo+PlYl4ww9Dl04WLf MJ1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=onZJJ0p7bA1O18bnzOb7QEzuO2YArUzN5u9fFaWOrIg=; fh=eue65t437wyhmkSPHQRWvmcc1fbOXiku5Au2KSH9hQ4=; b=qxsTaHAx4IPmB8uwFl5l2ZrRCQ6otPgb2rwnnsqI92XRKwauSPXK9Lgo3CHA+PSuSy 5ZqUtXBbBUVdvpKRZgViTfl0XTyZ6XxQV7p/xMLgtMi5IiIG6t4lbC3lgeNKX61geKU7 0qk/YcA/kq4/qsmXWiEKbmcpxm60Z3+khd/rVfZjkmnbYBQk6gTAxqpzv/8z69YWwwbc MH/yUkOJCRRZUoIF3n+t3bxUfBf3gx1YAxWDjgvJSf6HSYmKrMAjpHUN9Km7Sjx8Y4VV hqdNAkwK9MTT55A4OPVIc+4DYHhzyU1r3RlVQQa0jBJtsbgHBQr21LmlSnBfrlkaHdnE MjUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Hqoqay1H; spf=pass (google.com: domain of linux-kernel+bounces-17234-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pc35-20020a05620a842300b00781bac0816fsi308973qkn.205.2024.01.04.13.24.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 13:24:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17234-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Hqoqay1H; spf=pass (google.com: domain of linux-kernel+bounces-17234-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 46B171C24072 for ; Thu, 4 Jan 2024 21:24:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3199F2C843; Thu, 4 Jan 2024 21:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Hqoqay1H" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 064442C6B2 for ; Thu, 4 Jan 2024 21:24:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--maheshb.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5e744f7ca3bso15205177b3.2 for ; Thu, 04 Jan 2024 13:24:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704403476; x=1705008276; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=onZJJ0p7bA1O18bnzOb7QEzuO2YArUzN5u9fFaWOrIg=; b=Hqoqay1HIT5WOZo2whBFWAyj2Pa3m+0EoqzKCYRx+f21h/P7/EQux97ivA27UeIhWi 0rLU0hmxxCgNffAD7MAj+K3/xmjD4o7ibCn+Dr/eK3FUjxaooojhH/WdBHPzJks0sPu1 7QSSc6or9JXBat2wsk8p+2tOyE+8ux1rp4t27D/SUygwYHo3H2uj83XGp+2ozGij1ZBJ qPTMl64EhXDErdRBdRAD/zf0jUHzZ5T+4/OKPcmSDmhXPmwdc1mQcuO226q61S7Tx6lh lENTohR4ZmDJrUANSyEFYkVnI55/BwJB3nhTAU0po9h1myX0VpCJS/LURoKRzxhzJ5DD qQLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704403476; x=1705008276; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=onZJJ0p7bA1O18bnzOb7QEzuO2YArUzN5u9fFaWOrIg=; b=CT4NRqg9m5as8h1vcKxHk3OBg+Ps4Y4gKTonyv05zzqxghP4E88wxABwQkNjzXI41Y lkoppC5h/wJ7r59WPpd23KkiPrmSMWXaT0p2ReCn9cx954X1CAJkQ/iUUcnE1HOI6cJH NB5isMm2T6/RhhnDtPBBO+dnVCgfvtlAH2iCGtyGt1jjLOvFBUUXBLOY37SKL1F4NV2Z PmCQlT8iRazRmGYG/B+hKsy9fasYchT8NS+QZyZ1OksC9j750bj5l06+3Mkw3WWs4lmn TsEvYyMbG33qfMGUvr3SxTpTFKPUtLMgRDlIxtHH4AWn9kFBFZiKumGIFcBGI9IOai36 /JnQ== X-Gm-Message-State: AOJu0YzWFF/UcHnaFy1xOgSFNJ5UTQDXx8/2Bp2F8QuUq6V7taFjwHiC 1IQ1L3MByNIzH+N2SYJE4Ox+s8af7u0pYFD5liQ= X-Received: from coldfire.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2b7a]) (user=maheshb job=sendgmr) by 2002:a05:690c:3692:b0:5e7:1536:f4b3 with SMTP id fu18-20020a05690c369200b005e71536f4b3mr484304ywb.9.1704403475921; Thu, 04 Jan 2024 13:24:35 -0800 (PST) Date: Thu, 4 Jan 2024 13:24:31 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.195.gebba966016-goog Message-ID: <20240104212431.3275688-1-maheshb@google.com> Subject: [PATCHv3 net-next 0/3] add ptp_gettimex64any() API From: Mahesh Bandewar To: Netdev , Linux , David Miller , Jakub Kicinski , Eric Dumazet , Paolo Abeni Cc: Jonathan Corbet , John Stultz , Don Hatchett , Yuliang Li , Mahesh Bandewar , Mahesh Bandewar , Richard Cochran , Willem de Bruijn Content-Type: text/plain; charset="UTF-8" Applications that are very sensitive to time precision always measure the latency of the PHC (hardware clock) read. The best suited API for this is getcrosststamp(), however, not all platforms can architecturally support it, hence sandwich-ts APIs become more important for these categories of applications. The purpose of the sandwich API is to measure the width of the PHC-read syscall. The current API that reads PHC supports only one timebase for it (CLOCK_REALTIME). CLOCK_REALTIME is disciplined by NTP or NTP-like service, and hence the value is subject to change. This makes some applications want the sandwich TS to be delivered in other timebases. Ideally, there should be only one API that delivers the PHC-read with the sandwich-TS of the timebase given by the user, but modifying the existing API (gettimex64) would break compatibility. This series implements an API similar to gettimex64() with a parameter that allows the user to choose the timebase needed for these sandwich timestamps. About the name: This is a superset of the current gettimex64(). Since the timebase for gettimex64 is fixed and is only sys-time (CLOCK_REALTIME), I'm appending 'any' to add the choice factor. So gettimex64any() would give you eXtended time with sandwich TS of a timebase of your choice. If there is a better name, I won't mind changing. The timebase options are: CLOCK_REALTIME, CLOCK_MONOTONIC, and CLOCK_MONOTONIC_RAW The CLOCK_REALTIME option is equivalent to using the current gettimex64() method. The first patch adds this new PTP method, while the second patch adds the ioctl support for this PTP method. The last patch in the series updates the selftest to exercise this new API. Mahesh Bandewar (3): ptp: add new method ptp_gettimex64any() ptp: add ioctl interface for ptp_gettimex64any() selftest/ptp: extend test to include ptp_gettimex64any() drivers/ptp/ptp_chardev.c | 37 +++++++++++ include/linux/ptp_clock_kernel.h | 50 +++++++++++++- include/uapi/linux/ptp_clock.h | 14 ++++ tools/testing/selftests/ptp/testptp.c | 96 ++++++++++++++++++++++++++- 4 files changed, 193 insertions(+), 4 deletions(-) Signed-off-by: Mahesh Bandewar CC: Richard Cochran CC: "David S. Miller" CC: John Stultz CC: Jakub Kicinski CC: "Willem de Bruijn" CC: netdev@vger.kernel.org -- 2.43.0.195.gebba966016-goog