Message ID | 20250203-ptp-mock-dev-v1-1-f84c56fd9e45@weissschuh.net (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] ptp: Add mock device | expand |
On Mon, Feb 03, 2025 at 08:50:46PM +0100, Thomas Weißschuh wrote: > 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. What does this add which netdevsim does not provide? Andrew
On 2025-02-03 21:07:29+0100, Andrew Lunn wrote: > On Mon, Feb 03, 2025 at 08:50:46PM +0100, Thomas Weißschuh wrote: > > 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. > > What does this add which netdevsim does not provide? Nothing. I did not know this existed. Thanks for the hint. Thomas
On Mon, 03 Feb 2025 20:50:46 +0100 Thomas Weißschuh wrote: > 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. FTR we (netdev) do not accept mock devices unless there are selftests which exercise them in a meaningful way. Otherwise we get a stream of impossible to judge patches for such devices :(
On Mon, Feb 03, 2025 at 08:50:46PM +0100, Thomas Weißschuh wrote: > 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. Since netdevsim already has this functionality, lets drop this patch. Andrew --- pw-bot: rejected
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@weissschuh.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@weissschuh.net>"); +MODULE_LICENSE("GPL");
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@weissschuh.net> --- drivers/ptp/Kconfig | 10 ++++++++++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_mock_dev.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) --- base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b change-id: 20250122-ptp-mock-dev-a8cd3d37d9e9 Best regards,