* [PATCH v4 net-next 0/3] Implement PTP support in netdevsim
@ 2026-04-27 16:47 Maciek Machnikowski
2026-04-27 16:47 ` [PATCH v4 net-next 1/3] ptp_mock: Expose ptp_clock_info to external drivers Maciek Machnikowski
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Maciek Machnikowski @ 2026-04-27 16:47 UTC (permalink / raw)
To: netdev
Cc: kuba, maciek, richardcochran, milena.olech, willemdebruijn.kernel,
andrew, vadim.fedorenko, horms
This patchset adds support to the PTP HW timestamping emulation in the
netdevsim. It uses existing binding between netdevsim and ptp_mock
driver to generate transmit and receive timestamps.
It also adds the selftest to verify the hw timestamping functionality
running over netdevsim.
v2:
- Added selftest/net/ptp.sh
- Modified ptp_mock to use spin_lock_bh
- Populate ethtool defaults using ethtool_op_get_ts_info
v3:
- Fixed shellcheck issues in the selftest/net/ptp.sh
- Added selftest/net/ptp.sh to the selftest/net/Makefile
- Modified ptp_mock to use spin_lock_irqsave
v4:
- Check if Rx timestamps are enabled before generating a timestamp
- Replace bash selftest script with a python one
- Optimized Tx timestamp generation
Maciek Machnikowski (3):
ptp_mock: Expose ptp_clock_info to external drivers
netdevsim: Implement basic ptp support
selftests:net: Implement ptp4l sync test using netdevsim
drivers/net/netdevsim/ethtool.c | 11 ++
drivers/net/netdevsim/netdev.c | 91 ++++++++++++
drivers/net/netdevsim/netdevsim.h | 1 +
drivers/ptp/ptp_mock.c | 26 ++--
include/linux/ptp_mock.h | 5 +
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/ptp.py | 184 +++++++++++++++++++++++++++
7 files changed, 311 insertions(+), 8 deletions(-)
create mode 100755 tools/testing/selftests/net/ptp.py
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 net-next 1/3] ptp_mock: Expose ptp_clock_info to external drivers
2026-04-27 16:47 [PATCH v4 net-next 0/3] Implement PTP support in netdevsim Maciek Machnikowski
@ 2026-04-27 16:47 ` Maciek Machnikowski
2026-04-27 16:47 ` [PATCH v4 net-next 2/3] netdevsim: Implement basic ptp support Maciek Machnikowski
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Maciek Machnikowski @ 2026-04-27 16:47 UTC (permalink / raw)
To: netdev
Cc: kuba, maciek, richardcochran, milena.olech, willemdebruijn.kernel,
andrew, vadim.fedorenko, horms
Allow exposing the ptp_clock_info of the ptp_mock to the external drivers.
Convert spinlocks to SLIS to allow gettime to be called from the netdevsim.
This is a prerequisite for implementing ptp support on netdevsim.
Co-developed-by: Milena Olech <milena.olech@intel.com>
Signed-off-by: Milena Olech <milena.olech@intel.com>
Signed-off-by: Maciek Machnikowski <maciek@machnikowski.net>
---
drivers/ptp/ptp_mock.c | 26 ++++++++++++++++++--------
include/linux/ptp_mock.h | 5 +++++
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/drivers/ptp/ptp_mock.c b/drivers/ptp/ptp_mock.c
index 4d66b6147121..7a4e5f3274a6 100644
--- a/drivers/ptp/ptp_mock.c
+++ b/drivers/ptp/ptp_mock.c
@@ -49,15 +49,16 @@ static u64 mock_phc_cc_read(struct cyclecounter *cc)
static int mock_phc_adjfine(struct ptp_clock_info *info, long scaled_ppm)
{
struct mock_phc *phc = info_to_phc(info);
+ unsigned long flags;
s64 adj;
adj = (s64)scaled_ppm << MOCK_PHC_FADJ_SHIFT;
adj = div_s64(adj, MOCK_PHC_FADJ_DENOMINATOR);
- spin_lock(&phc->lock);
+ spin_lock_irqsave(&phc->lock, flags);
timecounter_read(&phc->tc);
phc->cc.mult = MOCK_PHC_CC_MULT + adj;
- spin_unlock(&phc->lock);
+ spin_unlock_irqrestore(&phc->lock, flags);
return 0;
}
@@ -65,10 +66,11 @@ static int mock_phc_adjfine(struct ptp_clock_info *info, long scaled_ppm)
static int mock_phc_adjtime(struct ptp_clock_info *info, s64 delta)
{
struct mock_phc *phc = info_to_phc(info);
+ unsigned long flags;
- spin_lock(&phc->lock);
+ spin_lock_irqsave(&phc->lock, flags);
timecounter_adjtime(&phc->tc, delta);
- spin_unlock(&phc->lock);
+ spin_unlock_irqrestore(&phc->lock, flags);
return 0;
}
@@ -78,10 +80,11 @@ static int mock_phc_settime64(struct ptp_clock_info *info,
{
struct mock_phc *phc = info_to_phc(info);
u64 ns = timespec64_to_ns(ts);
+ unsigned long flags;
- spin_lock(&phc->lock);
+ spin_lock_irqsave(&phc->lock, flags);
timecounter_init(&phc->tc, &phc->cc, ns);
- spin_unlock(&phc->lock);
+ spin_unlock_irqrestore(&phc->lock, flags);
return 0;
}
@@ -89,11 +92,12 @@ static int mock_phc_settime64(struct ptp_clock_info *info,
static int mock_phc_gettime64(struct ptp_clock_info *info, struct timespec64 *ts)
{
struct mock_phc *phc = info_to_phc(info);
+ unsigned long flags;
u64 ns;
- spin_lock(&phc->lock);
+ spin_lock_irqsave(&phc->lock, flags);
ns = timecounter_read(&phc->tc);
- spin_unlock(&phc->lock);
+ spin_unlock_irqrestore(&phc->lock, flags);
*ts = ns_to_timespec64(ns);
@@ -171,5 +175,11 @@ void mock_phc_destroy(struct mock_phc *phc)
}
EXPORT_SYMBOL_GPL(mock_phc_destroy);
+struct ptp_clock_info *mock_phc_get_ptp_info(struct mock_phc *phc)
+{
+ return &phc->info;
+}
+EXPORT_SYMBOL_GPL(mock_phc_get_ptp_info);
+
MODULE_DESCRIPTION("Mock-up PTP Hardware Clock driver");
MODULE_LICENSE("GPL");
diff --git a/include/linux/ptp_mock.h b/include/linux/ptp_mock.h
index 72eb401034d9..e33188dec2b7 100644
--- a/include/linux/ptp_mock.h
+++ b/include/linux/ptp_mock.h
@@ -16,6 +16,7 @@ struct mock_phc;
struct mock_phc *mock_phc_create(struct device *dev);
void mock_phc_destroy(struct mock_phc *phc);
int mock_phc_index(struct mock_phc *phc);
+struct ptp_clock_info *mock_phc_get_ptp_info(struct mock_phc *phc);
#else
@@ -33,6 +34,10 @@ static inline int mock_phc_index(struct mock_phc *phc)
return -1;
}
+static inline struct ptp_clock_info *mock_phc_get_ptp_info(struct mock_phc *phc)
+{
+ return NULL;
+}
#endif
#endif /* _PTP_MOCK_H_ */
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 net-next 2/3] netdevsim: Implement basic ptp support
2026-04-27 16:47 [PATCH v4 net-next 0/3] Implement PTP support in netdevsim Maciek Machnikowski
2026-04-27 16:47 ` [PATCH v4 net-next 1/3] ptp_mock: Expose ptp_clock_info to external drivers Maciek Machnikowski
@ 2026-04-27 16:47 ` Maciek Machnikowski
2026-04-27 16:47 ` [PATCH v4 net-next 3/3] selftests:net: Implement ptp4l sync test using netdevsim Maciek Machnikowski
2026-04-27 22:57 ` [PATCH v4 net-next 0/3] Implement PTP support in netdevsim Jakub Kicinski
3 siblings, 0 replies; 5+ messages in thread
From: Maciek Machnikowski @ 2026-04-27 16:47 UTC (permalink / raw)
To: netdev
Cc: kuba, maciek, richardcochran, milena.olech, willemdebruijn.kernel,
andrew, vadim.fedorenko, horms
Add support for virtual timestamping inside the netdevsim driver.
The implementation uses two attached ptp_mock clocks, reads the timestamps
of the ones attached either to the netdevsim or its peer and returns
timestamps using standard timestamps APIs.
This implementation enables running ptp4l on netdevsim adapters and
introduces a new ptp selftest.
Co-developed-by: Milena Olech <milena.olech@intel.com>
Signed-off-by: Milena Olech <milena.olech@intel.com>
Signed-off-by: Maciek Machnikowski <maciek@machnikowski.net>
---
drivers/net/netdevsim/ethtool.c | 11 ++++
drivers/net/netdevsim/netdev.c | 91 +++++++++++++++++++++++++++++++
drivers/net/netdevsim/netdevsim.h | 1 +
3 files changed, 103 insertions(+)
diff --git a/drivers/net/netdevsim/ethtool.c b/drivers/net/netdevsim/ethtool.c
index 36a201533aae..5b709033cc5f 100644
--- a/drivers/net/netdevsim/ethtool.c
+++ b/drivers/net/netdevsim/ethtool.c
@@ -200,7 +200,18 @@ static int nsim_get_ts_info(struct net_device *dev,
{
struct netdevsim *ns = netdev_priv(dev);
+ ethtool_op_get_ts_info(dev, info);
+
info->phc_index = mock_phc_index(ns->phc);
+ if (info->phc_index < 0)
+ return 0;
+
+ info->so_timestamping |= SOF_TIMESTAMPING_TX_HARDWARE |
+ SOF_TIMESTAMPING_RX_HARDWARE |
+ SOF_TIMESTAMPING_RAW_HARDWARE;
+
+ info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
+ info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);
return 0;
}
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index c71b8d116f18..af1783c88753 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -30,6 +30,8 @@
#include <net/rtnetlink.h>
#include <net/udp_tunnel.h>
#include <net/busy_poll.h>
+#include <linux/ptp_clock_kernel.h>
+#include <linux/timecounter.h>
#include "netdevsim.h"
@@ -122,7 +124,11 @@ static int nsim_forward_skb(struct net_device *tx_dev,
static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
+ struct skb_shared_hwtstamps shhwtstamps = {};
struct netdevsim *ns = netdev_priv(dev);
+ struct ptp_clock_info *ptp_info;
+ struct timespec64 tx_ts, rx_ts;
+ struct sk_buff *skb_orig = skb;
struct skb_ext *psp_ext = NULL;
struct net_device *peer_dev;
unsigned int len = skb->len;
@@ -164,6 +170,36 @@ static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev)
skb_linearize(skb);
skb_tx_timestamp(skb);
+
+ /* Generate RX timestamp using the peer's PHC if RX timestamping is enabled */
+ if (peer_ns->tstamp_config.rx_filter != HWTSTAMP_FILTER_NONE) {
+ ptp_info = mock_phc_get_ptp_info(peer_ns->phc);
+ ptp_info->gettime64(ptp_info, &rx_ts);
+ }
+
+ /* If TX hardware timestamping is enabled, generate and attach a TX timestamp */
+ if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP &&
+ peer_ns->tstamp_config.tx_type == HWTSTAMP_TX_ON) {
+ ptp_info = mock_phc_get_ptp_info(ns->phc);
+ ptp_info->gettime64(ptp_info, &tx_ts);
+
+ /* Create a copy of the SKB to forward to peer and prevent
+ * from reporting incorrect TX timestamp when skb_hwtstamps is set.
+ */
+ skb = skb_copy(skb_orig, GFP_ATOMIC);
+ if (skb) {
+ shhwtstamps.hwtstamp = timespec64_to_ktime(tx_ts);
+ skb_tstamp_tx(skb_orig, &shhwtstamps);
+ consume_skb(skb_orig);
+ } else {
+ skb = skb_orig;
+ }
+ }
+
+ /* set the rx timestamp to the skb */
+ if (peer_ns->tstamp_config.rx_filter != HWTSTAMP_FILTER_NONE)
+ skb_hwtstamps(skb)->hwtstamp = timespec64_to_ktime(rx_ts);
+
if (unlikely(nsim_forward_skb(dev, peer_dev,
skb, rq, psp_ext) == NET_RX_DROP))
goto out_drop_cnt;
@@ -185,6 +221,59 @@ static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
}
+static int nsim_set_ts_config(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config,
+ struct netlink_ext_ack *extack)
+{
+ struct netdevsim *ns = netdev_priv(netdev);
+
+ if (!ns->phc)
+ return -EOPNOTSUPP;
+
+ switch (config->tx_type) {
+ case HWTSTAMP_TX_OFF:
+ ns->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
+ break;
+ case HWTSTAMP_TX_ON:
+ ns->tstamp_config.tx_type = HWTSTAMP_TX_ON;
+ break;
+ default:
+ return -ERANGE;
+ }
+
+ switch (config->rx_filter) {
+ case HWTSTAMP_FILTER_NONE:
+ ns->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE;
+ break;
+ case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
+ case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
+ case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
+ case HWTSTAMP_FILTER_PTP_V2_EVENT:
+ case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
+ case HWTSTAMP_FILTER_PTP_V2_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
+ case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
+ case HWTSTAMP_FILTER_NTP_ALL:
+ case HWTSTAMP_FILTER_ALL:
+ ns->tstamp_config.rx_filter = HWTSTAMP_FILTER_ALL;
+ break;
+ default:
+ return -ERANGE;
+ }
+
+ return 0;
+}
+
+static int nsim_get_ts_config(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config)
+{
+ struct netdevsim *ns = netdev_priv(netdev);
+
+ *config = ns->tstamp_config;
+ return 0;
+}
+
static void nsim_set_rx_mode(struct net_device *dev)
{
}
@@ -612,6 +701,8 @@ static const struct net_device_ops nsim_netdev_ops = {
.ndo_open = nsim_open,
.ndo_stop = nsim_stop,
.net_shaper_ops = &nsim_shaper_ops,
+ .ndo_hwtstamp_get = nsim_get_ts_config,
+ .ndo_hwtstamp_set = nsim_set_ts_config,
};
static const struct net_device_ops nsim_vf_netdev_ops = {
diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h
index c7de53706ec4..873a81ed6dcd 100644
--- a/drivers/net/netdevsim/netdevsim.h
+++ b/drivers/net/netdevsim/netdevsim.h
@@ -103,6 +103,7 @@ struct netdevsim {
struct net_device *netdev;
struct nsim_dev *nsim_dev;
struct nsim_dev_port *nsim_dev_port;
+ struct kernel_hwtstamp_config tstamp_config;
struct mock_phc *phc;
struct nsim_rq **rq;
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 net-next 3/3] selftests:net: Implement ptp4l sync test using netdevsim
2026-04-27 16:47 [PATCH v4 net-next 0/3] Implement PTP support in netdevsim Maciek Machnikowski
2026-04-27 16:47 ` [PATCH v4 net-next 1/3] ptp_mock: Expose ptp_clock_info to external drivers Maciek Machnikowski
2026-04-27 16:47 ` [PATCH v4 net-next 2/3] netdevsim: Implement basic ptp support Maciek Machnikowski
@ 2026-04-27 16:47 ` Maciek Machnikowski
2026-04-27 22:57 ` [PATCH v4 net-next 0/3] Implement PTP support in netdevsim Jakub Kicinski
3 siblings, 0 replies; 5+ messages in thread
From: Maciek Machnikowski @ 2026-04-27 16:47 UTC (permalink / raw)
To: netdev
Cc: kuba, maciek, richardcochran, milena.olech, willemdebruijn.kernel,
andrew, vadim.fedorenko, horms
Add PTP synchronization test using ptp4l and netdevsim.
The test creates two netdevsim adapters, links them together
and runs the ptp4l leader and ptp4l follower on two ends
of the netdevsim link and waits for the follower to report the
synchronized state (s2) in its output log.
This implementation runs the test runs over IPv4 link.
Signed-off-by: Maciek Machnikowski <maciek@machnikowski.net>
---
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/ptp.py | 184 +++++++++++++++++++++++++++
2 files changed, 185 insertions(+)
create mode 100755 tools/testing/selftests/net/ptp.py
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 231245a95879..a5fc28183896 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -69,6 +69,7 @@ TEST_PROGS := \
nl_nlctrl.py \
pmtu.sh \
psock_snd.sh \
+ ptp.py \
reuseaddr_ports_exhausted.sh \
reuseport_addr_any.sh \
route_hint.sh \
diff --git a/tools/testing/selftests/net/ptp.py b/tools/testing/selftests/net/ptp.py
new file mode 100755
index 000000000000..dd6f12cf3d91
--- /dev/null
+++ b/tools/testing/selftests/net/ptp.py
@@ -0,0 +1,184 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# By Maciek Machnikowski <maciek@machnikowski.net> (c) 2026,
+#
+# Self-tests for HW timestamping and 1588 synchronization
+#
+# This test runs a ptp4l leader/follower pair and waits for follower sync
+# state (s2), using one common execution path.
+#
+# By default, it:
+# - Creates two netdevsim instances in separate namespaces
+# - Assigns IPv4 addresses and links them together
+# - Uses those interfaces as leader/follower endpoints for ptp4l
+#
+# Optional: --leader and --follower override endpoints with existing
+# interfaces. Each argument can be either "ifname" (initial netns) or
+# "netns:ifname". Both options must be provided together.
+
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+import time
+
+from lib.py import (
+ NetNS,
+ NetdevSimDev,
+ KsftSkipEx,
+ defer,
+ ip,
+ ksft_exit,
+ ksft_pr,
+ ksft_run,
+ ksft_true,
+)
+
+PTP4L_SYNC_TIMEOUT = 40
+
+
+def _parse_interface_spec(spec):
+ """Return (netns_name_or_None, ifname). 'ns:ifname' uses that netns."""
+ if ":" in spec:
+ ns, ifname = spec.split(":", 1)
+ return ns, ifname
+ return None, spec
+
+
+def _strip_ptp_port_args():
+ """
+ Remove --leader/--follower from sys.argv. Return (leader_spec, follower_spec).
+ """
+ leader = follower = None
+ new_argv = [sys.argv[0]]
+ args = iter(sys.argv[1:])
+ for a in args:
+ if a == "--leader":
+ leader = next(args, None)
+ elif a == "--follower":
+ follower = next(args, None)
+ else:
+ new_argv.append(a)
+ sys.argv[:] = new_argv
+ return leader, follower
+
+
+def _run_ptp4l_wait_sync(leader_ifname, follower_ifname,
+ leader_ns=None, follower_ns=None):
+ leader_log_path, follower_log_path = _prepare_ptp4l_logs()
+ leader_proc, leader_log = _start_ptp4l(
+ leader_ifname, leader_log_path, leader_ns, ptp4l_params=["-4"]
+ )
+ follower_proc, follower_log = _start_ptp4l(
+ follower_ifname, follower_log_path, follower_ns, ptp4l_params=["-s", "-4"]
+ )
+ defer(lambda: _stop_ptp4l(leader_proc, leader_log))
+ defer(lambda: _stop_ptp4l(follower_proc, follower_log))
+
+ deadline = time.monotonic() + PTP4L_SYNC_TIMEOUT
+ while time.monotonic() < deadline:
+ try:
+ with open(follower_log_path) as f:
+ if " s2 " in f.read():
+ return
+ except FileNotFoundError:
+ pass
+ time.sleep(1)
+
+ ksft_pr(
+ f"ptp4l follower did not reach locked state (s2) within {PTP4L_SYNC_TIMEOUT}s"
+ )
+ try:
+ with open(follower_log_path) as f:
+ tail = f.read().strip().split("\n")[-10:]
+ ksft_pr("Follower log (last 10 lines): " + " | ".join(tail))
+ except Exception:
+ pass
+ ksft_true(False, "PTP sync timeout")
+
+
+def _start_ptp4l(ifname, log_path, ns_name, ptp4l_params=None):
+ cmd = ["ptp4l", "-i", ifname, "-m", "-P"]
+ if ptp4l_params:
+ cmd.extend(ptp4l_params)
+ if ns_name is not None:
+ cmd = ["ip", "netns", "exec", ns_name] + cmd
+
+ log_file = open(log_path, "w")
+ proc = subprocess.Popen(cmd, stdout=log_file, stderr=subprocess.STDOUT)
+ return proc, log_file
+
+
+def _stop_ptp4l(proc, log_file):
+ try:
+ proc.terminate()
+ proc.wait(timeout=5)
+ except (OSError, subprocess.TimeoutExpired):
+ try:
+ proc.kill()
+ proc.wait(timeout=2)
+ except (OSError, subprocess.TimeoutExpired):
+ pass
+ finally:
+ log_file.close()
+
+
+def _prepare_ptp4l_logs():
+ leader_log = tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".log")
+ follower_log = tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".log")
+ leader_log.close()
+ follower_log.close()
+ defer(os.unlink, leader_log.name)
+ defer(os.unlink, follower_log.name)
+ return leader_log.name, follower_log.name
+
+
+def ptp_sync_test(leader_spec=None, follower_spec=None):
+ if not shutil.which("ptp4l"):
+ raise KsftSkipEx("ptp4l command not found. Skipping PTP sync test")
+
+ use_custom = leader_spec is not None
+ if use_custom ^ (follower_spec is not None):
+ ksft_true(False, "PTP sync: specify both --leader and --follower or neither")
+ return
+
+ if use_custom:
+ leader_ns, if1 = _parse_interface_spec(leader_spec)
+ follower_ns, if2 = _parse_interface_spec(follower_spec)
+
+ _run_ptp4l_wait_sync(if1, if2, leader_ns, follower_ns)
+ return
+
+ with NetNS("nssv") as nssv, NetNS("nscl") as nscl, \
+ NetdevSimDev(port_count=1, queue_count=1, ns=nssv) as nsimdevsv, \
+ NetdevSimDev(port_count=1, queue_count=1, ns=nscl) as nsimdevcl:
+
+ nsimsv = nsimdevsv.nsims[0]
+ nsimcl = nsimdevcl.nsims[0]
+
+ ip(f"addr add 192.168.1.1/24 dev {nsimsv.ifname}", ns=nssv.name)
+ ip(f"link set dev {nsimsv.ifname} up", ns=nssv.name)
+
+ ip(f"addr add 192.168.1.2/24 dev {nsimcl.ifname}", ns=nscl.name)
+ ip(f"link set dev {nsimcl.ifname} up", ns=nscl.name)
+
+ nssv_path = f"/var/run/netns/{nssv.name}"
+ nscl_path = f"/var/run/netns/{nscl.name}"
+
+ with open(nssv_path) as nssv_file, open(nscl_path) as nscl_file:
+ link_val = f"{nssv_file.fileno()}:{nsimsv.ifindex} {nscl_file.fileno()}:{nsimcl.ifindex}"
+ NetdevSimDev.ctrl_write("link_device", link_val)
+ _run_ptp4l_wait_sync(nsimsv.ifname, nsimcl.ifname, nssv.name, nscl.name)
+ NetdevSimDev.ctrl_write("unlink_device", f"{nssv_file.fileno()}:{nsimsv.ifindex}")
+
+
+def main():
+ leader, follower = _strip_ptp_port_args()
+ ksft_run([ptp_sync_test], args=(leader, follower))
+ ksft_exit()
+
+
+if __name__ == "__main__":
+ main()
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4 net-next 0/3] Implement PTP support in netdevsim
2026-04-27 16:47 [PATCH v4 net-next 0/3] Implement PTP support in netdevsim Maciek Machnikowski
` (2 preceding siblings ...)
2026-04-27 16:47 ` [PATCH v4 net-next 3/3] selftests:net: Implement ptp4l sync test using netdevsim Maciek Machnikowski
@ 2026-04-27 22:57 ` Jakub Kicinski
3 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2026-04-27 22:57 UTC (permalink / raw)
To: Maciek Machnikowski
Cc: netdev, richardcochran, milena.olech, willemdebruijn.kernel,
andrew, vadim.fedorenko, horms
On Mon, 27 Apr 2026 18:47:24 +0200 Maciek Machnikowski wrote:
> This patchset adds support to the PTP HW timestamping emulation in the
> netdevsim. It uses existing binding between netdevsim and ptp_mock
> driver to generate transmit and receive timestamps.
>
> It also adds the selftest to verify the hw timestamping functionality
> running over netdevsim.
net-next wasn't open yet, when you posted.
Please resubmit in a couple of days.
BTW the patches don't seem to apply.
--
pw-bot: defer
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-27 22:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 16:47 [PATCH v4 net-next 0/3] Implement PTP support in netdevsim Maciek Machnikowski
2026-04-27 16:47 ` [PATCH v4 net-next 1/3] ptp_mock: Expose ptp_clock_info to external drivers Maciek Machnikowski
2026-04-27 16:47 ` [PATCH v4 net-next 2/3] netdevsim: Implement basic ptp support Maciek Machnikowski
2026-04-27 16:47 ` [PATCH v4 net-next 3/3] selftests:net: Implement ptp4l sync test using netdevsim Maciek Machnikowski
2026-04-27 22:57 ` [PATCH v4 net-next 0/3] Implement PTP support in netdevsim Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox