From: Alex Maftei <alex.maftei@amd.com>
To: <richardcochran@gmail.com>, <shuah@kernel.org>
Cc: Alex Maftei <alex.maftei@amd.com>,
<linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<netdev@vger.kernel.org>
Subject: [PATCH net 2/2] selftests/ptp: Add -X option for testing PTP_SYS_OFFSET_PRECISE
Date: Fri, 16 Jun 2023 23:48:45 +0100 [thread overview]
Message-ID: <e679110fb29bbf3d8bc7f27a60c48a25e1fa6600.1686955631.git.alex.maftei@amd.com> (raw)
In-Reply-To: <cover.1686955631.git.alex.maftei@amd.com>
The -X option was chosen because X looks like a cross, and the underlying
callback is 'get cross timestamp'.
Signed-off-by: Alex Maftei <alex.maftei@amd.com>
---
tools/testing/selftests/ptp/testptp.c | 29 +++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tools/testing/selftests/ptp/testptp.c b/tools/testing/selftests/ptp/testptp.c
index 2a99973ffc1b..6ab5836b53ff 100644
--- a/tools/testing/selftests/ptp/testptp.c
+++ b/tools/testing/selftests/ptp/testptp.c
@@ -143,6 +143,7 @@ static void usage(char *progname)
" -t val shift the ptp clock time by 'val' seconds\n"
" -T val set the ptp clock time to 'val' seconds\n"
" -x val get an extended ptp clock time with the desired number of samples (up to %d)\n"
+ " -X get a ptp clock cross timestamp\n"
" -z test combinations of rising/falling external time stamp flags\n",
progname, PTP_MAX_SAMPLES);
}
@@ -159,6 +160,7 @@ int main(int argc, char *argv[])
struct ptp_clock_time *pct;
struct ptp_sys_offset *sysoff;
struct ptp_sys_offset_extended *soe;
+ struct ptp_sys_offset_precise *xts;
char *progname;
unsigned int i;
@@ -177,6 +179,7 @@ int main(int argc, char *argv[])
int list_pins = 0;
int pct_offset = 0;
int getextended = 0;
+ int getcross = 0;
int n_samples = 0;
int pin_index = -1, pin_func;
int pps = -1;
@@ -260,6 +263,9 @@ int main(int argc, char *argv[])
return -1;
}
break;
+ case 'X':
+ getcross = 1;
+ break;
case 'z':
flagtest = 1;
break;
@@ -554,6 +560,29 @@ int main(int argc, char *argv[])
free(soe);
}
+ if (getcross) {
+ xts = calloc(1, sizeof(*xts));
+ if (!xts) {
+ perror("calloc");
+ return -1;
+ }
+
+ if (ioctl(fd, PTP_SYS_OFFSET_PRECISE, xts))
+ perror("PTP_SYS_OFFSET_PRECISE");
+ else {
+ puts("system and phc crosstimestamping request okay");
+
+ printf("device time: %lld.%09u\n",
+ xts->device.sec, xts->device.nsec);
+ printf("system time: %lld.%09u\n",
+ xts->sys_realtime.sec, xts->sys_realtime.nsec);
+ printf("monoraw time: %lld.%09u\n",
+ xts->sys_monoraw.sec, xts->sys_monoraw.nsec);
+ }
+
+ free(xts);
+ }
+
close(fd);
return 0;
}
--
2.28.0
next prev parent reply other threads:[~2023-06-16 22:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-16 22:48 [PATCH net 0/2] selftests/ptp: Add support for new timestamp IOCTLs Alex Maftei
2023-06-16 22:48 ` [PATCH net 1/2] selftests/ptp: Add -x option for testing PTP_SYS_OFFSET_EXTENDED Alex Maftei
2023-06-19 9:39 ` Horatiu Vultur
2023-06-19 9:48 ` Maftei, Alex
2023-06-19 9:46 ` Maftei, Alex
2023-06-20 16:42 ` Jakub Kicinski
2023-06-16 22:48 ` Alex Maftei [this message]
2023-06-17 0:58 ` [PATCH net 0/2] selftests/ptp: Add support for new timestamp IOCTLs Richard Cochran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e679110fb29bbf3d8bc7f27a60c48a25e1fa6600.1686955631.git.alex.maftei@amd.com \
--to=alex.maftei@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).