From: Jakub Kicinski <kuba@kernel.org>
To: Maciek Machnikowski <maciek@machnikowski.net>
Cc: netdev@vger.kernel.org, richardcochran@gmail.com,
milena.olech@intel.com, willemdebruijn.kernel@gmail.com,
andrew@lunn.ch, vadim.fedorenko@linux.dev, horms@kernel.org
Subject: Re: [PATCH v3 net-next 2/3] netdevsim: Implement basic ptp support
Date: Wed, 25 Feb 2026 18:01:50 -0800 [thread overview]
Message-ID: <20260225180150.7eccfb08@kernel.org> (raw)
In-Reply-To: <20260225153858.29486-3-maciek@machnikowski.net>
On Wed, 25 Feb 2026 16:38:57 +0100 Maciek Machnikowski wrote:
> diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
> index 6285fbefe..b1161c1ca 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>
Alphabetical sort please
> struct netdevsim *peer_ns;
> struct netdev_config *cfg;
> + bool gen_tx_tstamp = false;
> struct nsim_rq *rq;
reverse xmas tree
> + gen_tx_tstamp = skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP;
> + if (gen_tx_tstamp) {
> + ptp_info = mock_phc_get_ptp_info(ns->phc);
> +
> + /* Create a copy of tx skb to keep the tx reference */
> + skb_orig = skb;
> + skb = skb_copy(skb_orig, GFP_ATOMIC);
> + skb_shinfo(skb_orig)->tx_flags |= SKBTX_IN_PROGRESS;
> +
> + /* Timestamp as late as possible */
> + if (ptp_info)
> + ptp_info->gettime64(ptp_info, &tx_ts);
> + }
Do we have to copy the packet? We can't deliver the timestamp before
we run Rx, on the original skb?
> if (unlikely(nsim_forward_skb(dev, peer_dev,
> skb, rq, psp_ext) == NET_RX_DROP))
> goto out_drop_cnt;
'Cause I think this leaks skb_orig now.
> + /* Generate Rx tstamp based on the peer clock */
> + ptp_info = mock_phc_get_ptp_info(peer_ns->phc);
> + if (ptp_info) {
we can still gate this on whether timestamps are enabled, no?
> + ptp_info->gettime64(ptp_info, &rx_ts);
> + skb_hwtstamps(skb)->hwtstamp = timespec64_to_ktime(rx_ts);
next prev parent reply other threads:[~2026-02-26 2:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 15:38 [PATCH v3 net-next 0/3] Implement PTP support in netdevsim Maciek Machnikowski
2026-02-25 15:38 ` [PATCH v3 net-next 1/3] ptp_mock: Expose ptp_clock_info to external drivers Maciek Machnikowski
2026-02-26 1:57 ` Jakub Kicinski
2026-02-25 15:38 ` [PATCH v3 net-next 2/3] netdevsim: Implement basic ptp support Maciek Machnikowski
2026-02-25 16:32 ` Sai Krishna Gajula
2026-02-26 2:01 ` Jakub Kicinski [this message]
2026-03-04 12:41 ` Maciek Machnikowski
2026-03-04 15:19 ` Willem de Bruijn
2026-03-04 15:48 ` Willem de Bruijn
2026-02-25 15:38 ` [PATCH v3 net-next 3/3] selftests:net: Implement ptp4l sync test using netdevsim Maciek Machnikowski
2026-02-25 16:45 ` Sai Krishna Gajula
2026-03-04 12:44 ` Maciek Machnikowski
2026-02-26 2:41 ` Jakub Kicinski
2026-03-04 15:21 ` Willem de Bruijn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260225180150.7eccfb08@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=horms@kernel.org \
--cc=maciek@machnikowski.net \
--cc=milena.olech@intel.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox