2 * Copyright (c) 2014 Stefan Sørensen <stefan.sorensen@spectralink.com>
3 * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
4 * Copyright (c) 2014-2018 The strace developers.
7 * SPDX-License-Identifier: LGPL-2.1-or-later
12 #ifdef HAVE_STRUCT_PTP_SYS_OFFSET
14 # include <linux/ioctl.h>
15 # include <linux/ptp_clock.h>
17 # include "print_fields.h"
18 # include "xlat/ptp_flags_options.h"
21 ptp_ioctl(struct tcb *const tcp, const unsigned int code,
22 const kernel_ulong_t arg)
28 case PTP_EXTTS_REQUEST: {
29 struct ptp_extts_request extts;
32 if (umove_or_printaddr(tcp, arg, &extts))
35 PRINT_FIELD_D("{", extts, index);
36 PRINT_FIELD_FLAGS(", ", extts, flags, ptp_flags_options, "PTP_???");
41 case PTP_PEROUT_REQUEST: {
42 struct ptp_perout_request perout;
45 if (umove_or_printaddr(tcp, arg, &perout))
48 PRINT_FIELD_D("{start={", perout.start, sec);
49 PRINT_FIELD_U(", ", perout.start, nsec);
50 PRINT_FIELD_D("}, period={", perout.period, sec);
51 PRINT_FIELD_U(", ", perout.period, nsec);
52 PRINT_FIELD_D("}, ", perout, index);
53 PRINT_FIELD_FLAGS(", ", perout, flags, ptp_flags_options, "PTP_???");
59 tprintf(", %" PRI_kld, arg);
62 case PTP_SYS_OFFSET: {
63 struct ptp_sys_offset sysoff;
67 if (umove_or_printaddr(tcp, arg, &sysoff))
70 PRINT_FIELD_U("{", sysoff, n_samples);
73 unsigned int n_samples, i;
81 if (umove(tcp, arg, &sysoff) < 0) {
87 n_samples = sysoff.n_samples > PTP_MAX_SAMPLES ?
88 PTP_MAX_SAMPLES : sysoff.n_samples;
89 for (i = 0; i < 2 * n_samples + 1; ++i) {
92 PRINT_FIELD_D("{", sysoff.ts[i], sec);
93 PRINT_FIELD_U(", ", sysoff.ts[i], nsec);
96 if (sysoff.n_samples > PTP_MAX_SAMPLES)
102 case PTP_CLOCK_GETCAPS: {
103 struct ptp_clock_caps caps;
109 if (umove_or_printaddr(tcp, arg, &caps))
112 PRINT_FIELD_D("{", caps, max_adj);
113 PRINT_FIELD_D(", ", caps, n_alarm);
114 PRINT_FIELD_D(", ", caps, n_ext_ts);
115 PRINT_FIELD_D(", ", caps, n_per_out);
116 PRINT_FIELD_D(", ", caps, pps);
125 return RVAL_IOCTL_DECODED;
128 #endif /* HAVE_STRUCT_PTP_SYS_OFFSET */