lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240813125602.155827-3-maciek@machnikowski.net>
Date: Tue, 13 Aug 2024 12:56:01 +0000
From: Maciek Machnikowski <maciek@...hnikowski.net>
To: maciek@...hnikowski.net
Cc: netdev@...r.kernel.org,
	richardcochran@...il.com,
	jacob.e.keller@...el.com,
	vadfed@...a.com,
	darinzon@...zon.com,
	kuba@...nel.org
Subject: [RFC 2/3] ptp: Implement support for esterror in ptp_mock

Implement basic example of handling the esterror using
getesterror/setesterror functions of the ptp_clock_info

Signed-off-by: Maciek Machnikowski <maciek@...hnikowski.net>
---
 drivers/ptp/ptp_mock.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/ptp/ptp_mock.c b/drivers/ptp/ptp_mock.c
index e7b459c846a2..1786da790f82 100644
--- a/drivers/ptp/ptp_mock.c
+++ b/drivers/ptp/ptp_mock.c
@@ -35,10 +35,13 @@
 
 struct mock_phc {
 	struct ptp_clock_info info;
+	struct timespec64 sys_ts;
+	struct timespec64 hw_ts;
 	struct ptp_clock *clock;
 	struct timecounter tc;
 	struct cyclecounter cc;
 	spinlock_t lock;
+	long esterror;
 };
 
 static u64 mock_phc_cc_read(const struct cyclecounter *cc)
@@ -100,6 +103,31 @@ static int mock_phc_gettime64(struct ptp_clock_info *info, struct timespec64 *ts
 	return 0;
 }
 
+static int mock_phc_getesterror(struct ptp_clock_info *info, long *esterror,
+				struct timespec64 *hw_ts, struct timespec64 *sys_ts)
+{
+	struct mock_phc *phc = info_to_phc(info);
+
+	*esterror = phc->esterror;
+	if (hw_ts)
+		*hw_ts = phc->hw_ts;
+	if (sys_ts)
+		*sys_ts = phc->sys_ts;
+
+	return 0;
+}
+
+static int mock_phc_setesterror(struct ptp_clock_info *info, long esterror)
+{
+	struct mock_phc *phc = info_to_phc(info);
+
+	phc->esterror = esterror;
+	phc->hw_ts = ns_to_timespec64(timecounter_read(&phc->tc));
+	phc->sys_ts = ns_to_timespec64(ktime_get_raw_ns());
+
+	return 0;
+}
+
 static long mock_phc_refresh(struct ptp_clock_info *info)
 {
 	struct timespec64 ts;
@@ -134,6 +162,8 @@ struct mock_phc *mock_phc_create(struct device *dev)
 		.adjtime	= mock_phc_adjtime,
 		.gettime64	= mock_phc_gettime64,
 		.settime64	= mock_phc_settime64,
+		.getesterror	= mock_phc_getesterror,
+		.setesterror	= mock_phc_setesterror,
 		.do_aux_work	= mock_phc_refresh,
 	};
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ