From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pdx-out-015.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-015.esa.us-west-2.outbound.mail-perimeter.amazon.com [50.112.246.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 892533806DC; Wed, 29 Jul 2026 23:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=50.112.246.219 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785368289; cv=none; b=NtAQ5fVaSZftHNl79lditDxGad0vFtipAC8GpqWAyqvY/C1zB0Tx8rgbW1gUM5ipWnu8u4esK6yHPTmJBFu/dTsyR49tdie2c83H9/BzKNcqI6u0iqjEG/ZDQxoP3+up8j0vGRTc7FtBR4WIUQMg1uZw5WT+kEYiS5/54YztIpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785368289; c=relaxed/simple; bh=p63/VyVnvrcpZ4JkDlVtLOwCo4FKOTJQrRtebJlXSbU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RVYHaxM+4eY1RIOBWTX4knURenISvZtxPG1kdkSzGNxDuE7vHbhTtoArelhuMzab2h90BLsZRjzogxOGkZobfrj54OxQ6i2UtAe19S9rPDcXbiomhkeWebeOcaFT7TWcN4Khaao1Wn5Of56yBO/75IVqatPaNQy9NDENXDfYJck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=s1gLkUWJ; arc=none smtp.client-ip=50.112.246.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="s1gLkUWJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1785368288; x=1816904288; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rVehCezAzednY5lkGXLVwgHxJ+0eORcEgWhCQFpAWxI=; b=s1gLkUWJ5DfzuRqVG9ZlEtYpakp5xgaWoWPK5r0xsuDj/s/zH6N/COh4 aynfkN9lxGRJTbUYU1fosQwW5WUG1T15aAsOBhxFkINp+Cd3wYLYGzaiU /L+vQw84R9fBjdu6ik46v1djAeKTyDdK7wMByhROg3LCIZvSZGfxhbkTp 43CLRQMocAlxekBQAVvfAlIFAoQ6GxtmaCYA+c/UiiVcQ3riUAerVRzZm JS0RMgVNOBzyVfzPh2ggOR2IiaSQso+06pecgLPLY7CKt6ItwxjmJfw7Q 1f9BDbvN0Icw25XA0eTaDvPF0kpKR2Bgmnyvjb3ZjMaZlBCoElTAtSt/T g==; X-CSE-ConnectionGUID: OBJzpO7LSqKuaXjleXr0sw== X-CSE-MsgGUID: C7pHPYkAQGOjz7NMotmFRQ== X-IronPort-AV: E=Sophos;i="6.25,193,1779148800"; d="scan'208";a="24417711" Received: from ip-10-5-9-48.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.9.48]) by internal-pdx-out-015.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2026 23:38:05 +0000 Received: from EX19MTAUWB002.ant.amazon.com [205.251.233.111:7833] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.18.129:2525] with esmtp (Farcaster) id 99edd8d6-c17d-4ca6-8210-ee156c130e9c; Wed, 29 Jul 2026 23:38:05 +0000 (UTC) X-Farcaster-Flow-ID: 99edd8d6-c17d-4ca6-8210-ee156c130e9c Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.45; Wed, 29 Jul 2026 23:38:05 +0000 Received: from dev-dsk-akiyano-1c-2138b29d.eu-west-1.amazon.com (172.19.83.6) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.45; Wed, 29 Jul 2026 23:37:59 +0000 From: Arthur Kiyanovski To: David Miller , Jakub Kicinski , Richard Cochran , CC: Arthur Kiyanovski , Eric Dumazet , Paolo Abeni , David Woodhouse , Thomas Gleixner , Miroslav Lichvar , Andrew Lunn , Andrew Lunn , Carolina Jubran , Wen Gu , Xuan Zhuo , "David Woodhouse" , Yonatan Sarna , "Zorik Machulsky" , Alexander Matushevsky , "Saeed Bshara" , Matt Wilson , Anthony Liguori , Nafea Bshara , Evgeny Schmeilin , Netanel Belgazal , Ali Saidi , Benjamin Herrenschmidt , Noam Dagan , David Arinzon , Evgeny Ostrovsky , Ofir Tabachnik , Amit Bernstein , , , , Jonathan Corbet , Shuah Khan , Simon Horman , Bjorn Helgaas , , David Woodhouse Subject: [PATCH v6 net-next 2/7] selftests/ptp: Extract print_system_timestamp helper in testptp Date: Wed, 29 Jul 2026 23:37:31 +0000 Message-ID: <20260729233740.16516-3-akiyano@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260729233740.16516-1-akiyano@amazon.com> References: <20260729233740.16516-1-akiyano@amazon.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D041UWB002.ant.amazon.com (10.13.139.179) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Extract the repeated switch-on-clockid pattern used for printing system timestamps into a reusable helper function. This removes code duplication in the -x (PTP_SYS_OFFSET_EXTENDED) output path and prepares for additional callers. The "after" timestamp lines now include the sample number prefix for consistency with the "before" lines, slightly changing the output format. Signed-off-by: Arthur Kiyanovski Reviewed-by: David Woodhouse --- tools/testing/selftests/ptp/testptp.c | 76 +++++++++++++-------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/tools/testing/selftests/ptp/testptp.c b/tools/testing/selftests/ptp/testptp.c index ed1e2886ba3c..d603d9f82237 100644 --- a/tools/testing/selftests/ptp/testptp.c +++ b/tools/testing/selftests/ptp/testptp.c @@ -153,6 +153,34 @@ static void usage(char *progname) progname, PTP_MAX_SAMPLES); } +static void print_system_timestamp(int sample_num, __kernel_clockid_t clockid, + long long sec, unsigned int nsec, + const char *when) +{ + const char *name; + + switch (clockid) { + case CLOCK_REALTIME: + name = "real"; + break; + case CLOCK_MONOTONIC: + name = "monotonic"; + break; + case CLOCK_MONOTONIC_RAW: + name = "monotonic-raw"; + break; + default: + name = NULL; + break; + } + + if (!name) + return; + + printf("sample #%2d: %s time %s: %lld.%09u\n", + sample_num, name, when, sec, nsec); +} + int main(int argc, char *argv[]) { struct ptp_clock_caps caps; @@ -608,46 +636,18 @@ int main(int argc, char *argv[]) getextended); for (i = 0; i < getextended; i++) { - switch (ext_clockid) { - case CLOCK_REALTIME: - printf("sample #%2d: real time before: %lld.%09u\n", - i, soe->ts[i][0].sec, - soe->ts[i][0].nsec); - break; - case CLOCK_MONOTONIC: - printf("sample #%2d: monotonic time before: %lld.%09u\n", - i, soe->ts[i][0].sec, - soe->ts[i][0].nsec); - break; - case CLOCK_MONOTONIC_RAW: - printf("sample #%2d: monotonic-raw time before: %lld.%09u\n", - i, soe->ts[i][0].sec, - soe->ts[i][0].nsec); - break; - default: - break; - } + print_system_timestamp(i, ext_clockid, + soe->ts[i][0].sec, + soe->ts[i][0].nsec, + "before"); + printf(" phc time: %lld.%09u\n", soe->ts[i][1].sec, soe->ts[i][1].nsec); - switch (ext_clockid) { - case CLOCK_REALTIME: - printf(" real time after: %lld.%09u\n", - soe->ts[i][2].sec, - soe->ts[i][2].nsec); - break; - case CLOCK_MONOTONIC: - printf(" monotonic time after: %lld.%09u\n", - soe->ts[i][2].sec, - soe->ts[i][2].nsec); - break; - case CLOCK_MONOTONIC_RAW: - printf(" monotonic-raw time after: %lld.%09u\n", - soe->ts[i][2].sec, - soe->ts[i][2].nsec); - break; - default: - break; - } + + print_system_timestamp(i, ext_clockid, + soe->ts[i][2].sec, + soe->ts[i][2].nsec, + "after"); } } -- 2.47.3