Article View: linux.kernel.netdev
Article #12835[PATCH v12 net-next 0/3] Implement PTP support in netdevsim
From: Maciek Machnikowski
Date: Sun, 08 Nov 2026 20:15
Date: Sun, 08 Nov 2026 20:15
91 lines
13015 bytes
13015 bytes
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. v12: - Unclone the skb before writing hwtstamp to not corrupt the TX errqueue clone - Clear the TX hwtstamp when peer RX timestamping is off - Set SKBTX_IN_PROGRESS before skb_tx_timestamp() to avoid SW+HW duplicates - Use skb_unclone() instead of skb_unclone_full() - Return -EOPNOTSUPP from nsim_get_ts_config() when there is no PHC - Use isolated ptp4l UDS paths in the selftest - Explicitly kill the remote ptp4l leader in the selftest - Tolerate the deferred pkill finding no ptp4l process in the selftest v11: - Avoid aliasing the RX hwtstamp write with AF_XDP completion metadata (skb_shared_info's hwtstamps/xsk_meta union) by orphaning the skb first, addressing the Critical finding from Simon Horman's review. Link: https://lore.kernel.org/netdev/20260819101706.GP265046@horms.kernel.org/ - Only unshare the skb when an RX timestamp is written into it - Reject non-zero hwtstamp flags and accept the PTP V2 L2 RX filters - Use READ_ONCE() in ndo_hwtstamp_get and stop overwriting the whole config struct - Skip the selftest if either the local or the remote device lacks hardware timestamping support - Forward declare struct ptp_clock_info in ptp_mock.h - Fix the ptp_mock commit message wording v10: - Drop the local_irq_save()/local_irq_restore() around the PHC reads. v9: - Unshare the skb instead of copying it - Move the PTP timestamping off the xmit fast path - Sample the TX and RX PHCs with IRQs disabled to keep the reads adjacent - Validate the hwtstamp config before touching device state - Report a -1 PHC index from ethtool for ports without a PHC (VFs) - Clamp the ptp4l poll timeout in the selftest to a non-negative value v8: - Fix the lockless tstamp_config access in netdevsim with READ_ONCE()/WRITE_ONCE() - Clarify the TX/RX timestamp handling in netdevsim comments v7: - Moved the test script to tools/testing/selftest/drivers/net - Optimized implementation to avoid potential edge cases reported v6: - Enable PTP Mock in the tools/testing/selftests/net/config v5: - Rebase v4: - Check if Rx timestamps are enabled before generating a timestamp - Replace bash selftest script with a python one - Optimized Tx timestamp generation 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_bh v2: - Added selftest/net/ptp.sh - Modified ptp_mock to use spin_lock_bh - Populate ethtool defaults using ethtool_op_get_ts_info Maciek Machnikowski (3): ptp_mock: Expose ptp_clock_info to external drivers netdevsim: Implement basic ptp support selftests: drivers/net: Implement ptp4l sync test using netdevsim drivers/net/netdevsim/ethtool.c | 15 +++ drivers/net/netdevsim/netdev.c | 124 +++++++++++++++++++ drivers/net/netdevsim/netdevsim.h | 1 + drivers/ptp/ptp_mock.c | 26 ++-- include/linux/ptp_mock.h | 7 ++ tools/testing/selftests/drivers/net/Makefile | 1 + tools/testing/selftests/drivers/net/config | 1 + tools/testing/selftests/drivers/net/ptp.py | 112 +++++++++++++++++ 8 files changed, 279 insertions(+), 8 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/ptp.py -- 2.56.0
Technical Details
Message-ID:
<20261108201503.85000-1-maciek@machnikowski.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358846-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358846-linux-kernel-netdev=dewy.ru From: maciek@machnikowski.net (Maciek Machnikowski) Newsgroups: linux.kernel.netdev Subject: [PATCH v12 net-next 0/3] Implement PTP support in netdevsim Date: Sun, 8 Nov 2026 21:15:00 +0100 Organization: Usenet Network Message-ID: <20261108201503.85000-1-maciek@machnikowski.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="199074"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:fPLXT75mm//5EU7zYkjX6wH5gG4= sha256:LyMHdCzBbGCmY7tft0flhMmrZ26EEz4EVSqldESfHOU= sha1:9cyngMN+wX3nXwpjSinV3TkVdc8= sha256:J04IHzZZHlDen07Jqpz6VAX50ggFncNA4Yt7hWK/M70= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 23CAD113603; Sun, 8 Nov 2026 23:43:44 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.851 X-Spam-Status: No, score=-2.851 tagged_above=-9999 required=6.31 tests=[DKIM_INVALID=0.1, DKIM_SIGNED=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=machnikowski.net X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yJY2WACbEL95; Sun, 8 Nov 2026 23:43:40 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-358846-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=machnikowski.net X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 3BBCC1135FF; Sun, 8 Nov 2026 23:43:31 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id E6A5A61D39D; Sun, 8 Nov 2026 20:38:42 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794169567; b=4NzpgLUDrRzPMBBUh2jD7Omdj/wbhzOhJ+mPB4A5SpkbjPVlVkd0TqAlghk1O4wIYKEo nCo+XTedo662WIam58usqGH0m+WJPy3A9XxEeEzIpYNB9Jc5piDfd9GNXddymAE6d9zVJ PGGm/ArSnQgq19Kf8D5JVZ0lmLWkB+zFpUNhoSlWnvSlekN2es+99t8GNN1z+30uIzRD+ tepJ75XlT+3vdg/qRKL2Id5dx9gN3xMCNJ7ggleZrithxS9WYxmcfVyCHGQJpqj/qEhAA xp81xrdmZpNgYiRk51iP21csf0eop8UwOWiTRPxgPTt5FUjVTgGAm2j5lEs0TJF0l8Q== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794169567; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding:X-ZohoMailClient; bh=PbvsLTUx5RTKZcO2SfSuvDv0Qx70PnJIRKcLI1CRGa0=; b=TwWupgVXwt8QgAqYyRdecZaybgMYGVnFmY/hLrb5lUaEbV/k5nfroy870ja6DAirXJgF tDXS+gIKwYUFh5ipwEkRHr2ZQBTqMdJg9LZHTRtF2zU0SniC0isCrMH3w02frZfX/+DXc cIIe8DSnsiOTKGvAFd9utz3Ytpt3lyHZFxx6ga6IBpzgWPKSTmuRgxPA73wV9WiH8CU1R upJ+mJFjG8PrG00VXortAJwuIRxZICrHRJH9cYPDKc0+m+djHE97G90yw6cDSkBG4LQzV 0rbuJsGwy7rLZ/1myPw2WyOy3DMFiipywM99xKwFF3yg36DM+Lpwo5HoOmAVWz2+PeQ== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" header.d=machnikowski.net header.i=@machnikowski.net header.a=rsa-sha256 header.s=zoho header.b=FCfFgVaG; dmarc=none header.from=machnikowski.net; spf=pass smtp.mailfrom=machnikowski.net; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 972F1606B11B; Sun, 8 Nov 2026 20:26:07 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=machnikowski.net header.i=@machnikowski.net header.a=rsa-sha256 header.s=zoho header.b=FCfFgVaG X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.54 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794169566; b=cxEwuP0VYAAHRFItYZaKc/CP4EgOqXWw969VnsyQkESZGZQ8PCqYt4KlyjZenKhX3XVc kmHrNckX2y8kKtwAOgsyX1LPhCw1TYf4ldv0DLzxuyiSRzVo126EIsSPBa8qiTBQMEnxt P/PKk/eoepClyDYN5H6E83NH+/fbFICuPYZgHSpXdVeViM6fVDy/NAOqVXgNDURQigx8z 8W+h/81jXLHF1b9hj7wu8R556dPS0UqWgyl5F/lHTq09kWldbC0knewnyLtjggpDL6IDE KORRRQi99pSjin8tw4jRgmrm8D9ROzghZq7qh8CT6o6IEIiFV2ygV4AlEoZ1rXud84w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794169566; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-ZohoMailClient; bh=PbvsLTUx5RTKZcO2SfSuvDv0Qx70PnJIRKcLI1CRGa0=; b=2iY3JUfjsjYuXs2XuPu9SW3wzfaMsphSiF8rQg0RwPLSl7iwHwALDxrIyfVI/xswb3/1 wNxvnSrGdBN0ArA8Gvd2MLqqVY/RvZtBUQG7H5DGmIaXRing5+5rv8FYuVxZEoaoE/z/4 rNqbk+LfKkCYXq6vQnT62bJP+rAMsreoVpDz5irHj8YHtNaW9RZq+mmdZv6AJOUxnlSed 6bkB9UoBR0pOkpWD94CWUtNom7x/tHiovg2B6tmDYCf8eKESulyHQS5EbjQIxB3utd7fY g8Uu0vpYqwobNyEcY66lZJmYiLGW+/S4sawLhZ6ASyFBlMOZ1yXrnPcJlYyD/Lqp7WQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=machnikowski.net; spf=pass smtp.mailfrom=machnikowski.net; dkim=pass header.d=machnikowski.net header.i=@machnikowski.net header.a=rsa-sha256 header.s=zoho header.b=FCfFgVaG; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.54 X-Received: from sender5-of-o54.zoho.com (sender5-of-o54.zoho.com [165.173.182.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 173BF606A31C for <netdev@vger.kernel.org>; Sun, 8 Nov 2026 20:26:05 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 173BF606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=machnikowski.net X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=machnikowski.net X-ARC-Seal: i=1; a=rsa-sha256; t=1794169548; cv=none; d=zohomail.com; s=zohoarc; b=A1p003UzVbtvT7FN+mHc3KPzZWyUJp54nQB8ei8a/LFwWGp9iUijp+q+BCvl0i+g6HzV3oYlziH7ykXeLMDieHLUm171Fs9tcQ+TUh4QlTFu0StzikSnlDDzyjFq17b6mYBoQC52+6O56TpQ9K36Zr0b+3vmqMadlJ5InncKz6s= X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794169548; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=PbvsLTUx5RTKZcO2SfSuvDv0Qx70PnJIRKcLI1CRGa0=; b=VcOqKvQC5C5ITZXaeqgravMFLcZTwonZQcVc2cWoc4wuo7vi8FJwiDYmKhWuLA328GLPH7RXy2yM2b6Br0aX4h2UcZfX49iAbCZ27UWjpUMaxPAXRhfNKs0u/begO4cU6hH+uJOzYyIlQBZfm3BSc1onKOG0oGyujcTXDymhd0Y= X-ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=machnikowski.net; spf=pass smtp.mailfrom=maciek@machnikowski.net; dmarc=pass header.from=<maciek@machnikowski.net> X-DKIM-Signature: a=rsa-sha256; b=FCfFgVaGXLLOCRMnCjuQsfvN9hcdSUlRNwJueIV30cu45n4TBxPsJ/+q8XDBn7Fa9wK5+ckp/9n3RTge8QN7RXt0ZS5kpx0mhfzxj5tBvnrmGxEWxcEIp7pcgVdEkol/S6KFGuc2FnDAut+dWfDKp2HAGoFXtVG1DpNdORtG/W4IlKQ3qBAJ3wfkYAnZLLdM0WfW/AgRPqzBYe6n4/GIkrLdHJL5uRENKHrvtrPQbRyBH9VT24eijPe/XpGqbYa7OxRyc/a9NfrJnzUpoQCUzTKrqPtT3C9tUhDz7l7ssWA1uWKmxGMtmK2yz3RTIRdcuMCq7nuov9b1nhlMtOz5tA==; c=relaxed/relaxed; s=zoho; d=machnikowski.net; v=1; bh=PbvsLTUx5RTKZcO2SfSuvDv0Qx70PnJIRKcLI1CRGa0=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; X-Received: by smtp.zohomail.com with SMTPS id 1794169547263692.6246799169581; Sun, 8 Nov 2026 12:25:47 -0800 (PST) X-Cc: kuba@kernel.org, maciek@machnikowski.net, richardcochran@gmail.com, milena.olech@intel.com, willemdebruijn.kernel@gmail.com, andrew@lunn.ch, vadim.fedorenko@linux.dev, horms@kernel.org, almasrymina@google.com X-Mailer: git-send-email 2.56.0 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-ZohoMailClient: External