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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250203-ptp-mock-dev-v1-1-f84c56fd9e45@weissschuh.net>
Date: Mon, 03 Feb 2025 20:50:46 +0100
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Richard Cochran <richardcochran@...il.com>, 
 Andrew Lunn <andrew+netdev@...n.ch>, 
 "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, 
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>
Cc: linux-kernel@...r.kernel.org, netdev@...r.kernel.org, 
 Thomas Weißschuh <linux@...ssschuh.net>
Subject: [PATCH net] ptp: Add mock device

While working on the PTP core or userspace components,
a real PTP device is not always available.
Introduce a tiny module which creates a mock PTP device.

Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
 drivers/ptp/Kconfig        | 10 ++++++++++
 drivers/ptp/Makefile       |  1 +
 drivers/ptp/ptp_mock_dev.c | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index 07bf7f9aae019ca26aa6d39a3c19b9dd0420f9bb..f0bbf0cbf13fb89c8cbf8934f6f2f0b81e622466 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -195,6 +195,16 @@ config PTP_1588_CLOCK_MOCK
 	  To compile this driver as a module, choose M here: the module
 	  will be called ptp_mock.
 
+config PTP_1588_CLOCK_MOCK_DEV
+	tristate "Mock-up PTP clock device"
+	depends on PTP_1588_CLOCK_MOCK
+	help
+	  Instantiante a dummy PTP clock device derived from the system
+	  monotonic time.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called ptp_mock_dev.
+
 config PTP_1588_CLOCK_VMW
 	tristate "VMware virtual PTP clock"
 	depends on ACPI && HYPERVISOR_GUEST && X86
diff --git a/drivers/ptp/Makefile b/drivers/ptp/Makefile
index 25f846fe48c9f0406a02c75d83027a0e6cfa10bf..216065f68e152963b35c55594ec1fd0b33db097a 100644
--- a/drivers/ptp/Makefile
+++ b/drivers/ptp/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_PTP_1588_CLOCK_IDTCM)	+= ptp_clockmatrix.o
 obj-$(CONFIG_PTP_1588_CLOCK_FC3W)	+= ptp_fc3.o
 obj-$(CONFIG_PTP_1588_CLOCK_IDT82P33)	+= ptp_idt82p33.o
 obj-$(CONFIG_PTP_1588_CLOCK_MOCK)	+= ptp_mock.o
+obj-$(CONFIG_PTP_1588_CLOCK_MOCK_DEV)	+= ptp_mock_dev.o
 obj-$(CONFIG_PTP_1588_CLOCK_VMW)	+= ptp_vmw.o
 obj-$(CONFIG_PTP_1588_CLOCK_OCP)	+= ptp_ocp.o
 obj-$(CONFIG_PTP_DFL_TOD)		+= ptp_dfl_tod.o
diff --git a/drivers/ptp/ptp_mock_dev.c b/drivers/ptp/ptp_mock_dev.c
new file mode 100644
index 0000000000000000000000000000000000000000..3423e2f0c45a4082875c2e031883735388d27b64
--- /dev/null
+++ b/drivers/ptp/ptp_mock_dev.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2025 Thomas Weißschuh <linux@...ssschuh.net>
+ *
+ * Mock-up PTP Hardware Clock device
+ *
+ * Create a PTP device which offers PTP time manipulation operations
+ * using a timecounter/cyclecounter on top of CLOCK_MONOTONIC_RAW.
+ */
+
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/ptp_mock.h>
+
+static struct mock_phc *phc;
+
+static int __init ptp_mock_dev_init(void)
+{
+	phc = mock_phc_create(NULL);
+	return PTR_ERR_OR_ZERO(phc);
+}
+module_init(ptp_mock_dev_init);
+
+static void __exit ptp_mock_dev_exit(void)
+{
+	mock_phc_destroy(phc);
+}
+module_exit(ptp_mock_dev_exit);
+
+MODULE_DESCRIPTION("Mock-up PTP Hardware Clock device");
+MODULE_AUTHOR("Thomas Weißschuh <linux@...ssschuh.net>");
+MODULE_LICENSE("GPL");

---
base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
change-id: 20250122-ptp-mock-dev-a8cd3d37d9e9

Best regards,
-- 
Thomas Weißschuh <linux@...ssschuh.net>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ