AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/08/08 03:51 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch modifies the NXP NETC switch driver and its associated DSA tagger and PTP timer. These are vendor-specific PCI devices that require physical hardware and cannot be emulated in standard QEMU. Therefore, the code is unreachable in a virtualized fuzzing environment.",
  "WorthFuzzing": false
}

1/1 2026/08/08 03:51 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 052f7c54e75559f7b61199a7224bf204f8d95844\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Sat Aug 8 03:51:11 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/dsa/netc/Kconfig b/drivers/net/dsa/netc/Kconfig\nindex 793f7691a24f3..8770b65d0f62d 100644\n--- a/drivers/net/dsa/netc/Kconfig\n+++ b/drivers/net/dsa/netc/Kconfig\n@@ -4,6 +4,7 @@ config NET_DSA_NETC_SWITCH\n \tdepends on ARM64 || COMPILE_TEST\n \tdepends on NET_DSA \u0026\u0026 PCI\n \tdepends on NET_VENDOR_FREESCALE\n+\tdepends on PTP_1588_CLOCK_OPTIONAL\n \tselect NET_DSA_TAG_NETC\n \tselect FSL_ENETC_MDIO\n \tselect NXP_NTMP\ndiff --git a/drivers/net/dsa/netc/Makefile b/drivers/net/dsa/netc/Makefile\nindex f40b13c702e07..572b833ad80fc 100644\n--- a/drivers/net/dsa/netc/Makefile\n+++ b/drivers/net/dsa/netc/Makefile\n@@ -1,3 +1,4 @@\n # SPDX-License-Identifier: GPL-2.0-only\n obj-$(CONFIG_NET_DSA_NETC_SWITCH) += nxp-netc-switch.o\n-nxp-netc-switch-objs := netc_main.o netc_platform.o netc_ethtool.o\n+nxp-netc-switch-objs := netc_main.o netc_platform.o netc_ethtool.o \\\n+\t\t\tnetc_ptp.o\ndiff --git a/drivers/net/dsa/netc/netc_main.c b/drivers/net/dsa/netc/netc_main.c\nindex 77077352c1a57..55664045ba19d 100644\n--- a/drivers/net/dsa/netc/netc_main.c\n+++ b/drivers/net/dsa/netc/netc_main.c\n@@ -65,6 +65,21 @@ netc_get_tag_protocol(struct dsa_switch *ds, int port,\n \treturn DSA_TAG_PROTO_NETC;\n }\n \n+static int netc_connect_tag_protocol(struct dsa_switch *ds,\n+\t\t\t\t     enum dsa_tag_protocol proto)\n+{\n+\tstruct netc_tagger_data *tagger_data;\n+\n+\tif (proto != DSA_TAG_PROTO_NETC)\n+\t\treturn -EPROTONOSUPPORT;\n+\n+\ttagger_data = ds-\u003etagger_data;\n+\ttagger_data-\u003eonestep_sync_enqueue = netc_port_onestep_sync_enqueue;\n+\ttagger_data-\u003etwostep_tstamp_handler = netc_port_twostep_tstamp_handler;\n+\n+\treturn 0;\n+}\n+\n static void netc_port_rmw(struct netc_port *np, u32 reg,\n \t\t\t  u32 mask, u32 val)\n {\n@@ -80,7 +95,7 @@ static void netc_port_rmw(struct netc_port *np, u32 reg,\n \tnetc_port_wr(np, reg, new);\n }\n \n-static void netc_mac_port_wr(struct netc_port *np, u32 reg, u32 val)\n+void netc_mac_port_wr(struct netc_port *np, u32 reg, u32 val)\n {\n \tif (is_netc_pseudo_port(np))\n \t\treturn;\n@@ -238,6 +253,21 @@ static void netc_get_switch_capabilities(struct netc_switch *priv)\n \tpriv-\u003enum_bp = FIELD_GET(BPCAPR_NUM_BP, val);\n }\n \n+static void netc_free_user_ports(struct netc_switch *priv)\n+{\n+\tstruct dsa_switch *ds = priv-\u003eds;\n+\tstruct dsa_port *dp;\n+\n+\tdsa_switch_for_each_user_port(dp, ds) {\n+\t\tstruct netc_port *np = NETC_PORT(ds, dp-\u003eindex);\n+\n+\t\tif (np-\u003eonestep) {\n+\t\t\tnetc_onestep_put(np-\u003eonestep);\n+\t\t\tnp-\u003eonestep = NULL;\n+\t\t}\n+\t}\n+}\n+\n static int netc_init_all_ports(struct netc_switch *priv)\n {\n \tstruct device *dev = priv-\u003edev;\n@@ -278,18 +308,38 @@ static int netc_init_all_ports(struct netc_switch *priv)\n \n \t\terr = netc_port_get_info_from_dt(np, dp-\u003edn, dev);\n \t\tif (err)\n-\t\t\treturn err;\n+\t\t\tgoto free_user_ports;\n \n \t\tif (dsa_port_is_user(dp)) {\n \t\t\terr = netc_port_create_mdio_bus(np, dp-\u003edn);\n \t\t\tif (err) {\n \t\t\t\tdev_err(dev, \"Failed to create MDIO bus\\n\");\n-\t\t\t\treturn err;\n+\t\t\t\tgoto free_user_ports;\n \t\t\t}\n+\n+\t\t\t/* The ipft_hf_eid is initialized to an invalid entry\n+\t\t\t * ID because the host flood rule (IPFT entry) has not\n+\t\t\t * been created.\n+\t\t\t */\n+\t\t\tnp-\u003eipft_hf_eid = NTMP_NULL_ENTRY_ID;\n+\n+\t\t\t/* Only the user port needs to support PTP feature, so\n+\t\t\t * PTP-related resources, such as skb_txtstamp_queue,\n+\t\t\t * tstamp_lock, etc., are initialized only for the user\n+\t\t\t * port.\n+\t\t\t */\n+\t\t\terr = netc_port_ptp_init(np);\n+\t\t\tif (err)\n+\t\t\t\tgoto free_user_ports;\n \t\t}\n \t}\n \n \treturn 0;\n+\n+free_user_ports:\n+\tnetc_free_user_ports(priv);\n+\n+\treturn err;\n }\n \n static void netc_init_ntmp_tbl_versions(struct netc_switch *priv)\n@@ -549,6 +599,12 @@ static void netc_port_fixed_config(struct netc_port *np)\n \tnetc_port_rmw(np, NETC_PCR, PCR_L2DOSE | PCR_L3DOSE,\n \t\t      PCR_L2DOSE | PCR_L3DOSE);\n \n+\t/* Enable ingress port filter table lookup, if no match is found,\n+\t * the frame is allowed and passed to the next frame processing\n+\t * function.\n+\t */\n+\tnetc_port_wr(np, NETC_PIPFCR, PIPFCR_EN);\n+\n \t/* Set the quanta value of TX PAUSE frame */\n \tnetc_mac_port_wr(np, NETC_PM_PAUSE_QUANTA(0), NETC_PAUSE_QUANTA);\n \n@@ -869,6 +925,15 @@ static int netc_switch_bpt_default_config(struct netc_switch *priv)\n \treturn 0;\n }\n \n+static struct pci_dev *netc_get_ptp_timer(struct netc_switch *priv)\n+{\n+\tstruct pci_bus *bus = priv-\u003epdev-\u003ebus;\n+\tu32 devfn = priv-\u003einfo-\u003etmr_devfn;\n+\n+\treturn pci_get_domain_bus_and_slot(pci_domain_nr(bus),\n+\t\t\t\t\t   bus-\u003enumber, devfn);\n+}\n+\n static int netc_setup(struct dsa_switch *ds)\n {\n \tstruct netc_switch *priv = ds-\u003epriv;\n@@ -881,13 +946,23 @@ static int netc_setup(struct dsa_switch *ds)\n \n \tnetc_get_switch_capabilities(priv);\n \n+\t/* The PTP timer sits on the same PCI bus as the switch. PCI creates\n+\t * every function's pci_dev during bus enumeration, before any driver\n+\t * probes, so we can grab the timer's pci_dev here even if the timer\n+\t * driver has not probed yet.\n+\t */\n+\tpriv-\u003etmr_dev = netc_get_ptp_timer(priv);\n+\tif (!priv-\u003etmr_dev)\n+\t\tdev_info(priv-\u003edev,\n+\t\t\t \"PTP timer PCI device not found\\n\");\n+\n \terr = netc_init_all_ports(priv);\n \tif (err)\n-\t\treturn err;\n+\t\tgoto put_ptp_timer;\n \n \terr = netc_init_ntmp_user(priv);\n \tif (err)\n-\t\treturn err;\n+\t\tgoto free_user_ports;\n \n \tINIT_HLIST_HEAD(\u0026priv-\u003efdb_list);\n \tmutex_init(\u0026priv-\u003efdbt_lock);\n@@ -926,6 +1001,10 @@ static int netc_setup(struct dsa_switch *ds)\n \tmutex_destroy(\u0026priv-\u003efdbt_lock);\n \tmutex_destroy(\u0026priv-\u003evft_lock);\n \tnetc_free_ntmp_user(priv);\n+free_user_ports:\n+\tnetc_free_user_ports(priv);\n+put_ptp_timer:\n+\tpci_dev_put(priv-\u003etmr_dev);\n \n \treturn err;\n }\n@@ -938,20 +1017,30 @@ static void netc_destroy_all_lists(struct netc_switch *priv)\n \tmutex_destroy(\u0026priv-\u003evft_lock);\n }\n \n-static void netc_free_host_flood_rules(struct netc_switch *priv)\n+static void netc_free_ports_resources(struct netc_switch *priv)\n {\n \tstruct dsa_port *dp;\n \n-\tdsa_switch_for_each_user_port(dp, priv-\u003eds) {\n+\tdsa_switch_for_each_available_port(dp, priv-\u003eds) {\n \t\tstruct netc_port *np = priv-\u003eports[dp-\u003eindex];\n \n-\t\t/* No need to clear the hardware IPFT entry. Because PCIe\n-\t\t * FLR will be performed when the switch is re-registered,\n-\t\t * it will reset hardware state. So only need to free the\n-\t\t * memory to avoid memory leak.\n+\t\tif (!dsa_port_is_user(dp))\n+\t\t\tcontinue;\n+\n+\t\tnetc_port_purge_txtstamp_queue(np);\n+\n+\t\t/* dsa_tree_teardown() calls dsa_tree_teardown_ports() before\n+\t\t * dsa_tree_teardown_switches(), so netc_port_disable() is\n+\t\t * executed before netc_teardown() and purges onestep-\u003equeue,\n+\t\t * so here we only need to drop the port's owner reference.\n+\t\t * In-flight one-step skbs still hold references via the\n+\t\t * destructor; the context (and its work) is freed only after\n+\t\t * the conduit frees the last in-flight skb. By then np may\n+\t\t * be gone, but the work no longer dereferences np because\n+\t\t * onestep-\u003eactive has been cleared.\n \t\t */\n-\t\tkfree(np-\u003ehost_flood);\n-\t\tnp-\u003ehost_flood = NULL;\n+\t\tnetc_onestep_put(np-\u003eonestep);\n+\t\tnp-\u003eonestep = NULL;\n \t}\n }\n \n@@ -961,8 +1050,9 @@ static void netc_teardown(struct dsa_switch *ds)\n \n \tdisable_delayed_work_sync(\u0026priv-\u003efdbt_ageing_work);\n \tnetc_destroy_all_lists(priv);\n-\tnetc_free_host_flood_rules(priv);\n \tnetc_free_ntmp_user(priv);\n+\tnetc_free_ports_resources(priv);\n+\tpci_dev_put(priv-\u003etmr_dev);\n }\n \n static bool netc_port_is_emdio_consumer(struct device_node *node)\n@@ -1505,6 +1595,7 @@ static int netc_port_enable(struct dsa_switch *ds, int port,\n \t\t\t    struct phy_device *phy)\n {\n \tstruct netc_port *np = NETC_PORT(ds, port);\n+\tstruct netc_onestep *onestep = np-\u003eonestep;\n \tint err;\n \n \tif (np-\u003eenable)\n@@ -1517,6 +1608,12 @@ static int netc_port_enable(struct dsa_switch *ds, int port,\n \t\treturn err;\n \t}\n \n+\tif (onestep) {\n+\t\tmutex_lock(\u0026onestep-\u003ework_lock);\n+\t\tonestep-\u003eactive = true;\n+\t\tmutex_unlock(\u0026onestep-\u003ework_lock);\n+\t}\n+\n \tnp-\u003eenable = true;\n \n \treturn 0;\n@@ -1525,6 +1622,7 @@ static int netc_port_enable(struct dsa_switch *ds, int port,\n static void netc_port_disable(struct dsa_switch *ds, int port)\n {\n \tstruct netc_port *np = NETC_PORT(ds, port);\n+\tstruct netc_onestep *onestep = np-\u003eonestep;\n \n \t/* When .port_disable() is called, .port_enable() may not have been\n \t * called. In this case, both the prepare_count and enable_count of\n@@ -1534,6 +1632,13 @@ static void netc_port_disable(struct dsa_switch *ds, int port)\n \tif (!np-\u003eenable)\n \t\treturn;\n \n+\tif (onestep) {\n+\t\tmutex_lock(\u0026onestep-\u003ework_lock);\n+\t\tonestep-\u003eactive = false;\n+\t\tnetc_port_purge_onestep_queue(onestep, true);\n+\t\tmutex_unlock(\u0026onestep-\u003ework_lock);\n+\t}\n+\n \tclk_disable_unprepare(np-\u003eref_clk);\n \tnp-\u003eenable = false;\n }\n@@ -1720,8 +1825,6 @@ static int netc_port_add_host_flood_rule(struct netc_port *np,\n \tint err;\n \n \tif (!uc \u0026\u0026 !mc) {\n-\t\t/* Disable ingress port filter table lookup */\n-\t\tnetc_port_wr(np, NETC_PIPFCR, 0);\n \t\tnp-\u003euc = false;\n \t\tnp-\u003emc = false;\n \n@@ -1759,40 +1862,36 @@ static int netc_port_add_host_flood_rule(struct netc_port *np,\n \tcfge-\u003ecfg = cpu_to_le32(cfg);\n \n \terr = ntmp_ipft_add_entry(\u0026priv-\u003entmp, host_flood);\n-\tif (err) {\n-\t\tkfree(host_flood);\n-\t\treturn err;\n-\t}\n+\tif (err)\n+\t\tgoto free_host_flood;\n \n \tnp-\u003euc = uc;\n \tnp-\u003emc = mc;\n-\tnp-\u003ehost_flood = host_flood;\n-\t/* Enable ingress port filter table lookup */\n-\tnetc_port_wr(np, NETC_PIPFCR, PIPFCR_EN);\n+\tnp-\u003eipft_hf_eid = host_flood-\u003eentry_id;\n \n-\treturn 0;\n+free_host_flood:\n+\tkfree(host_flood);\n+\n+\treturn err;\n }\n \n-static void netc_port_remove_host_flood(struct netc_port *np,\n-\t\t\t\t\tstruct ipft_entry_data *host_flood)\n+static void netc_port_remove_host_flood(struct netc_port *np, u32 entry_id)\n {\n \tstruct netc_switch *priv = np-\u003eswitch_priv;\n \tbool disable_host_flood = false;\n \n-\tif (!host_flood)\n+\tif (entry_id == NTMP_NULL_ENTRY_ID)\n \t\treturn;\n \n-\tif (np-\u003ehost_flood == host_flood)\n+\tif (np-\u003eipft_hf_eid == entry_id)\n \t\tdisable_host_flood = true;\n \n-\tntmp_ipft_delete_entry(\u0026priv-\u003entmp, host_flood-\u003eentry_id);\n-\tkfree(host_flood);\n+\tntmp_ipft_delete_entry(\u0026priv-\u003entmp, entry_id);\n \n \tif (disable_host_flood) {\n-\t\tnp-\u003ehost_flood = NULL;\n+\t\tnp-\u003eipft_hf_eid = NTMP_NULL_ENTRY_ID;\n \t\tnp-\u003euc = false;\n \t\tnp-\u003emc = false;\n-\t\tnetc_port_wr(np, NETC_PIPFCR, 0);\n \t}\n }\n \n@@ -1800,7 +1899,7 @@ static void netc_port_set_host_flood(struct dsa_switch *ds, int port,\n \t\t\t\t     bool uc, bool mc)\n {\n \tstruct netc_port *np = NETC_PORT(ds, port);\n-\tstruct ipft_entry_data *old_host_flood;\n+\tu32 old_entry_id;\n \n \t/* Do not add host flood rule to ingress port filter table when\n \t * the port has joined a bridge. Otherwise, the ingress frames\n@@ -1808,7 +1907,7 @@ static void netc_port_set_host_flood(struct dsa_switch *ds, int port,\n \t * will be redirected directly to the CPU port.\n \t */\n \tif (dsa_port_bridge_dev_get(np-\u003edp)) {\n-\t\tnetc_port_remove_host_flood(np, np-\u003ehost_flood);\n+\t\tnetc_port_remove_host_flood(np, np-\u003eipft_hf_eid);\n \n \t\treturn;\n \t}\n@@ -1818,20 +1917,18 @@ static void netc_port_set_host_flood(struct dsa_switch *ds, int port,\n \n \t/* IPFT does not support in-place updates to the KEYE element,\n \t * we need to add a new entry and then delete the old one. So\n-\t * save the old entry first.\n+\t * save the old entry ID first.\n \t */\n-\told_host_flood = np-\u003ehost_flood;\n-\tnp-\u003ehost_flood = NULL;\n+\told_entry_id = np-\u003eipft_hf_eid;\n \n \tif (netc_port_add_host_flood_rule(np, uc, mc)) {\n-\t\tnp-\u003ehost_flood = old_host_flood;\n \t\tdev_err(ds-\u003edev, \"Failed to add host flood rule on port %d\\n\",\n \t\t\tport);\n \t\treturn;\n \t}\n \n \t/* Remove the old host flood entry */\n-\tnetc_port_remove_host_flood(np, old_host_flood);\n+\tnetc_port_remove_host_flood(np, old_entry_id);\n }\n \n static int netc_single_vlan_aware_bridge(struct dsa_switch *ds,\n@@ -2020,7 +2117,7 @@ static int netc_port_bridge_join(struct dsa_switch *ds, int port,\n \tnetc_port_set_pvid(np, vlan_unaware_pvid);\n \n out:\n-\tnetc_port_remove_host_flood(np, np-\u003ehost_flood);\n+\tnetc_port_remove_host_flood(np, np-\u003eipft_hf_eid);\n \n \tif (atomic_inc_return(\u0026priv-\u003ebr_cnt) == 1)\n \t\tschedule_delayed_work(\u0026priv-\u003efdbt_ageing_work,\n@@ -2402,6 +2499,7 @@ static const struct phylink_mac_ops netc_phylink_mac_ops = {\n \n static const struct dsa_switch_ops netc_switch_ops = {\n \t.get_tag_protocol\t\t= netc_get_tag_protocol,\n+\t.connect_tag_protocol\t\t= netc_connect_tag_protocol,\n \t.setup\t\t\t\t= netc_setup,\n \t.teardown\t\t\t= netc_teardown,\n \t.phylink_get_caps\t\t= netc_phylink_get_caps,\n@@ -2430,6 +2528,11 @@ static const struct dsa_switch_ops netc_switch_ops = {\n \t.get_sset_count\t\t\t= netc_port_get_sset_count,\n \t.get_strings\t\t\t= netc_port_get_strings,\n \t.get_ethtool_stats\t\t= netc_port_get_ethtool_stats,\n+\t.get_ts_info\t\t\t= netc_get_ts_info,\n+\t.port_hwtstamp_set\t\t= netc_port_hwtstamp_set,\n+\t.port_hwtstamp_get\t\t= netc_port_hwtstamp_get,\n+\t.port_rxtstamp\t\t\t= netc_port_rxtstamp,\n+\t.port_txtstamp\t\t\t= netc_port_txtstamp,\n };\n \n static int netc_switch_probe(struct pci_dev *pdev,\ndiff --git a/drivers/net/dsa/netc/netc_platform.c b/drivers/net/dsa/netc/netc_platform.c\nindex 34aeb6fceb3cb..4fd0ce6770c33 100644\n--- a/drivers/net/dsa/netc/netc_platform.c\n+++ b/drivers/net/dsa/netc/netc_platform.c\n@@ -50,6 +50,7 @@ static void imx94_switch_phylink_get_caps(int port,\n \n static const struct netc_switch_info imx94_info = {\n \t.num_ports = 4,\n+\t.tmr_devfn = PCI_DEVFN(0, 1),\n \t.phylink_get_caps = imx94_switch_phylink_get_caps,\n };\n \ndiff --git a/drivers/net/dsa/netc/netc_ptp.c b/drivers/net/dsa/netc/netc_ptp.c\nnew file mode 100644\nindex 0000000000000..d0423b3c8c33a\n--- /dev/null\n+++ b/drivers/net/dsa/netc/netc_ptp.c\n@@ -0,0 +1,866 @@\n+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)\n+/*\n+ * NXP NETC switch driver\n+ * Copyright 2025-2026 NXP\n+ */\n+\n+#include \u003clinux/kref.h\u003e\n+#include \u003clinux/ptp_classify.h\u003e\n+#include \u003clinux/ptp_clock_kernel.h\u003e\n+#include \u003clinux/slab.h\u003e\n+\n+#include \"netc_switch.h\"\n+\n+#define NETC_NUM_TS_REQ_ID\t\t16\n+#define NETC_TXTSTAMP_TIMEOUT\t\t(5 * HZ)\n+#define NETC_MAX_STEP_OFFSET\t\t0x1ff\n+\n+static void netc_port_set_onestep_control(struct netc_port *np,\n+\t\t\t\t\t  bool csum_update, int offset)\n+{\n+\tu32 val;\n+\n+\tval = PM_SINGLE_STEP_EN | FIELD_PREP(PM_SINGLE_STEP_OFFSET, offset);\n+\tif (csum_update)\n+\t\tval |= PM_SINGLE_STEP_CH;\n+\tnetc_mac_port_wr(np, NETC_PM_SINGLE_STEP(0), val);\n+}\n+\n+static void netc_onestep_destroy_work(struct work_struct *work)\n+{\n+\tstruct netc_onestep *onestep = container_of(work, struct netc_onestep,\n+\t\t\t\t\t\t    destroy_work);\n+\n+\t/* refcnt reaching zero does not by itself mean onestep-\u003ework has\n+\t * stopped: the last in-flight skb destructor calls schedule_work(\u0026work)\n+\t * *before* the netc_onestep_put() that drops the final reference, so at\n+\t * the moment refcnt hits zero onestep-\u003ework may still be pending or\n+\t * running on another CPU. destroy_work and work are distinct work_structs\n+\t * and can run concurrently, so cancel_work_sync() is required to drain\n+\t * onestep-\u003ework before mutex_destroy()/kfree() below, otherwise a\n+\t * still-running work would touch freed memory. No new schedule_work(\u0026work)\n+\t * can occur after this point because no references remain, so this\n+\t * cancel is final.\n+\t */\n+\tcancel_work_sync(\u0026onestep-\u003ework);\n+\tmutex_destroy(\u0026onestep-\u003ework_lock);\n+\tkfree(onestep);\n+}\n+\n+static void netc_onestep_release(struct kref *ref)\n+{\n+\tstruct netc_onestep *onestep = container_of(ref, struct netc_onestep,\n+\t\t\t\t\t\t    refcnt);\n+\n+\t/* This may be called from the skb destructor in softirq context\n+\t * (napi_consume_skb()), where cancel_work_sync() must not be used.\n+\t * Defer the final teardown to process context.\n+\t */\n+\tschedule_work(\u0026onestep-\u003edestroy_work);\n+}\n+\n+static void netc_onestep_get(struct netc_onestep *onestep)\n+{\n+\tkref_get(\u0026onestep-\u003erefcnt);\n+}\n+\n+void netc_onestep_put(struct netc_onestep *onestep)\n+{\n+\tkref_put(\u0026onestep-\u003erefcnt, netc_onestep_release);\n+}\n+\n+static void netc_onestep_skb_destructor(struct sk_buff *skb)\n+{\n+\tstruct netc_onestep *onestep = skb_shinfo(skb)-\u003edestructor_arg;\n+\n+\t/* skb has been transmitted by hardware. Schedule work to send the next\n+\t * queued one-step Sync packet, then release this skb's reference on the\n+\t * context. If the port has already been torn down and this is the last\n+\t * reference, the context is freed via netc_onestep_release().\n+\t */\n+\tschedule_work(\u0026onestep-\u003ework);\n+\tnetc_onestep_put(onestep);\n+}\n+\n+static void netc_port_program_onestep(struct netc_port *np,\n+\t\t\t\t      struct netc_onestep *onestep,\n+\t\t\t\t      struct sk_buff *skb,\n+\t\t\t\t      u64 tstamp)\n+{\n+\tu16 correction_offset = NETC_SKB_CB(skb)-\u003ecorrection_offset;\n+\tu16 tstamp_offset = NETC_SKB_CB(skb)-\u003etimestamp_offset;\n+\tu8 *hdr = skb_mac_header(skb);\n+\tbool csum_update = false;\n+\t__be32 new_sec_l, new_ns;\n+\t__be16 new_sec_h;\n+\tu64 sec;\n+\tu32 ns;\n+\n+\tNETC_SKB_CB(skb)-\u003etstamp = tstamp;\n+\tNETC_SKB_CB(skb)-\u003eptp_flag = NETC_PTP_FLAG_ONESTEP;\n+\n+\t/* Update originTimestamp field of Sync packet\n+\t * - 48 bits seconds field\n+\t * - 32 bits nanoseconds field\n+\t */\n+\tsec = div_u64_rem(tstamp, NSEC_PER_SEC, \u0026ns);\n+\tnew_sec_h = htons((sec \u003e\u003e 32) \u0026 0xffff);\n+\tnew_sec_l = htonl(sec \u0026 0xffffffff);\n+\tnew_ns = htonl(ns);\n+\n+\tif (NETC_SKB_CB(skb)-\u003eis_udp) {\n+\t\t__be32 old_sec_l, old_ns;\n+\t\tstruct udphdr *uh;\n+\t\t__be16 old_sec_h;\n+\n+\t\tif (skb-\u003eip_summed == CHECKSUM_PARTIAL) {\n+\t\t\tcsum_update = true;\n+\t\t\tgoto update_timestamp;\n+\t\t}\n+\n+\t\tif (unlikely(!skb_transport_header_was_set(skb)))\n+\t\t\tuh = (struct udphdr *)(hdr + tstamp_offset -\n+\t\t\t\t\t       sizeof(struct ptp_header) -\n+\t\t\t\t\t       sizeof(struct udphdr));\n+\t\telse\n+\t\t\tuh = udp_hdr(skb);\n+\n+\t\t/* For IPv4, a UDP checksum of zero on the wire means \"no\n+\t\t * checksum\". For IPv6, its UDP checksum is mandatory and\n+\t\t * never zero.\n+\t\t */\n+\t\tif (!uh-\u003echeck)\n+\t\t\tgoto update_timestamp;\n+\n+\t\told_sec_h = __get_unaligned_t(__be16, hdr + tstamp_offset);\n+\t\told_sec_l = __get_unaligned_t(__be32, hdr + tstamp_offset + 2);\n+\t\told_ns = __get_unaligned_t(__be32, hdr + tstamp_offset + 6);\n+\t\tinet_proto_csum_replace2(\u0026uh-\u003echeck, skb, old_sec_h,\n+\t\t\t\t\t new_sec_h, false);\n+\t\tinet_proto_csum_replace4(\u0026uh-\u003echeck, skb, old_sec_l,\n+\t\t\t\t\t new_sec_l, false);\n+\t\tinet_proto_csum_replace4(\u0026uh-\u003echeck, skb, old_ns,\n+\t\t\t\t\t new_ns, false);\n+\t\tcsum_update = true;\n+\t}\n+\n+update_timestamp:\n+\t__put_unaligned_t(__be16, new_sec_h, hdr + tstamp_offset);\n+\t__put_unaligned_t(__be32, new_sec_l, hdr + tstamp_offset + 2);\n+\t__put_unaligned_t(__be32, new_ns, hdr + tstamp_offset + 6);\n+\n+\tnetc_port_set_onestep_control(np, csum_update, correction_offset);\n+\n+\t/* Orphan the skb to release the socket send buffer quota immediately.\n+\t * This is safe because sock_wfree() does not access skb-\u003edata or any\n+\t * frame content. After skb_orphan(), we install our own destructor so\n+\t * that when the conduit driver frees the skb after TX completion, we\n+\t * get notified to send the next queued Sync packet.\n+\t */\n+\tskb_orphan(skb);\n+\tnetc_onestep_get(onestep); /* in-flight reference */\n+\tskb_shinfo(skb)-\u003edestructor_arg = onestep;\n+\tskb-\u003edestructor = netc_onestep_skb_destructor;\n+}\n+\n+static u64 netc_get_phc_time(struct netc_switch *priv)\n+{\n+\tif (unlikely(!priv-\u003etmr_dev))\n+\t\treturn 0;\n+\n+\treturn netc_timer_get_current_time(priv-\u003etmr_dev);\n+}\n+\n+void netc_port_onestep_work(struct work_struct *work)\n+{\n+\tstruct netc_onestep *onestep = container_of(work, struct netc_onestep,\n+\t\t\t\t\t\t    work);\n+\tstruct netc_tagger_data *tagger_data;\n+\tstruct netc_switch *priv;\n+\tstruct netc_port *np;\n+\tstruct sk_buff *skb;\n+\tu64 tstamp;\n+\n+\t/* Serialize the whole hardware access against port disable. work_lock\n+\t * is a mutex (this runs in process context and netc_get_phc_time() may\n+\t * sleep). If the port has been disabled, bail out immediately; np and\n+\t * priv are only dereferenced after the @active check passes, so they\n+\t * are always valid here.\n+\t */\n+\tmutex_lock(\u0026onestep-\u003ework_lock);\n+\tif (unlikely(!onestep-\u003eactive)) {\n+\t\tnetc_port_purge_onestep_queue(onestep, true);\n+\t\tgoto unlock_work;\n+\t}\n+\n+\t/* Send only one queued Sync per run. The shared SINGLE_STEP register\n+\t * must match the frame currently being transmitted, so the next frame\n+\t * is programmed only after this one completes TX, when its skb\n+\t * destructor reschedules this work. Dequeue under onestep-\u003equeue_lock,\n+\t * and if the queue has drained, release the in-flight slot so a later\n+\t * frame from the xmit path kicks the work again.\n+\t */\n+\tspin_lock_bh(\u0026onestep-\u003equeue_lock);\n+\tskb = __skb_dequeue(\u0026onestep-\u003equeue);\n+\tif (!skb) {\n+\t\tonestep-\u003ein_flight = false;\n+\t\tspin_unlock_bh(\u0026onestep-\u003equeue_lock);\n+\t\tgoto unlock_work;\n+\t}\n+\tspin_unlock_bh(\u0026onestep-\u003equeue_lock);\n+\n+\tnp = onestep-\u003enp;\n+\tpriv = np-\u003eswitch_priv;\n+\ttstamp = netc_get_phc_time(priv);\n+\tif (unlikely(!tstamp)) {\n+\t\t/* The PTP timer is not available, so there is no correct\n+\t\t * timestamp to program. Drop this frame and re-kick to process\n+\t\t * the remaining queued frames.\n+\t\t *\n+\t\t * netc_port_program_onestep() has not run for this skb yet, so\n+\t\t * netc_onestep_skb_destructor() is not installed on it. Freeing\n+\t\t * it therefore does not reschedule the work, so the work must be\n+\t\t * rescheduled explicitly to keep draining the queue.\n+\t\t */\n+\t\tdev_dbg_ratelimited(priv-\u003edev,\n+\t\t\t\t    \"Port %d PTP timer unavailable, drop Sync\\n\",\n+\t\t\t\t    np-\u003edp-\u003eindex);\n+\t\tkfree_skb(skb);\n+\t\tschedule_work(\u0026onestep-\u003ework);\n+\t\tgoto unlock_work;\n+\t}\n+\n+\t/* Reuse the offsets cached at enqueue time; only the timestamp is\n+\t * read fresh so it reflects the actual TX moment.\n+\t */\n+\tnetc_port_program_onestep(np, onestep, skb, tstamp);\n+\n+\t/* Tag and hand the frame directly to the conduit via the tagger,\n+\t * bypassing dsa_user_xmit() so the TX stats are not counted twice.\n+\t * And there is no need to check if tagger_data is NULL, because\n+\t * dsa_tree_teardown_ports() executes before\n+\t * dsa_switch_teardown_tag_protocol(), so tagger_data cannot be\n+\t * NULL when onestep-\u003eactive is set.\n+\t */\n+\ttagger_data = priv-\u003eds-\u003etagger_data;\n+\ttagger_data-\u003eonestep_sync_xmit(skb, np-\u003edp-\u003euser);\n+\n+unlock_work:\n+\tmutex_unlock(\u0026onestep-\u003ework_lock);\n+}\n+\n+static int netc_port_onestep_alloc(struct netc_port *np)\n+{\n+\tstruct netc_onestep *onestep;\n+\n+\tonestep = kzalloc_obj(*onestep);\n+\tif (!onestep)\n+\t\treturn -ENOMEM;\n+\n+\tkref_init(\u0026onestep-\u003erefcnt); /* port (owner) reference */\n+\tnp-\u003eonestep = onestep;\n+\tonestep-\u003enp = np;\n+\tmutex_init(\u0026onestep-\u003ework_lock);\n+\tspin_lock_init(\u0026onestep-\u003equeue_lock);\n+\t__skb_queue_head_init(\u0026onestep-\u003equeue);\n+\tINIT_WORK(\u0026onestep-\u003ework, netc_port_onestep_work);\n+\tINIT_WORK(\u0026onestep-\u003edestroy_work, netc_onestep_destroy_work);\n+\n+\treturn 0;\n+}\n+\n+int netc_port_ptp_init(struct netc_port *np)\n+{\n+\t/* Initialize to invalid entry IDs */\n+\tfor (int i = 0; i \u003c NETC_PTP_MAX; i++)\n+\t\tnp-\u003eptp_ipft_eid[i] = NTMP_NULL_ENTRY_ID;\n+\n+\tspin_lock_init(\u0026np-\u003etstamp_lock);\n+\t__skb_queue_head_init(\u0026np-\u003eskb_txtstamp_queue);\n+\n+\treturn netc_port_onestep_alloc(np);\n+}\n+\n+static int netc_get_phc_index(struct netc_switch *priv)\n+{\n+\tif (!priv-\u003etmr_dev)\n+\t\treturn -1;\n+\n+\treturn ptp_clock_index_by_dev(\u0026priv-\u003etmr_dev-\u003edev);\n+}\n+\n+int netc_get_ts_info(struct dsa_switch *ds, int port,\n+\t\t     struct kernel_ethtool_ts_info *info)\n+{\n+\tstruct netc_switch *priv = ds-\u003epriv;\n+\n+\tinfo-\u003ephc_index = netc_get_phc_index(priv);\n+\tif (info-\u003ephc_index \u003c 0)\n+\t\treturn 0;\n+\n+\tinfo-\u003eso_timestamping |= SOF_TIMESTAMPING_TX_HARDWARE |\n+\t\t\t\t SOF_TIMESTAMPING_RX_HARDWARE |\n+\t\t\t\t SOF_TIMESTAMPING_RAW_HARDWARE;\n+\n+\tinfo-\u003etx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON) |\n+\t\t\t BIT(HWTSTAMP_TX_ONESTEP_SYNC);\n+\n+\tinfo-\u003erx_filters = BIT(HWTSTAMP_FILTER_NONE) |\n+\t\t\t   BIT(HWTSTAMP_FILTER_PTP_V2_EVENT) |\n+\t\t\t   BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |\n+\t\t\t   BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT);\n+\n+\treturn 0;\n+}\n+\n+static void netc_port_del_ptp_filter(struct netc_port *np)\n+{\n+\tstruct netc_switch *priv = np-\u003eswitch_priv;\n+\tu32 entry_id;\n+\tint i;\n+\n+\tfor (i = 0; i \u003c NETC_PTP_MAX; i++) {\n+\t\tentry_id = np-\u003eptp_ipft_eid[i];\n+\t\tif (entry_id != NTMP_NULL_ENTRY_ID) {\n+\t\t\t/* There is no need to check the return value of\n+\t\t\t * ntmp_ipft_delete_entry(); in general, deleted\n+\t\t\t * existing entries will be successful.\n+\t\t\t */\n+\t\t\tntmp_ipft_delete_entry(\u0026priv-\u003entmp, entry_id);\n+\t\t\tnp-\u003eptp_ipft_eid[i] = NTMP_NULL_ENTRY_ID;\n+\t\t}\n+\t}\n+}\n+\n+static int netc_build_ptp_ipft_keye(struct ipft_keye_data *keye, int port,\n+\t\t\t\t    enum netc_ptp_type type)\n+{\n+\tu16 src_port, frm_attr_flags;\n+\n+\tkeye-\u003eprecedence = cpu_to_le16(NETC_IPFT_PTP_PRECEDENCE);\n+\tsrc_port = FIELD_PREP(IPFT_SRC_PORT, port);\n+\tsrc_port |= IPFT_SRC_PORT_MASK;\n+\tkeye-\u003esrc_port = cpu_to_le16(src_port);\n+\n+\tswitch (type) {\n+\tcase NETC_PTP_L2:\n+\t\tkeye-\u003eethertype = htons(ETH_P_1588);\n+\t\tkeye-\u003eethertype_mask = htons(0xffff);\n+\t\tbreak;\n+\tcase NETC_PTP_L4_IPV4_EVENT:\n+\tcase NETC_PTP_L4_IPV4_GENERAL:\n+\tcase NETC_PTP_L4_IPV6_EVENT:\n+\tcase NETC_PTP_L4_IPV6_GENERAL:\n+\t\tfrm_attr_flags = IPFT_FAF_IP_HDR | FIELD_PREP(IPFT_FAF_L4_CODE,\n+\t\t\t\t IPFT_FAF_UDP_HDR);\n+\t\tif (type == NETC_PTP_L4_IPV6_EVENT ||\n+\t\t    type == NETC_PTP_L4_IPV6_GENERAL)\n+\t\t\tfrm_attr_flags |= IPFT_FAF_IP_VER6;\n+\n+\t\tkeye-\u003efrm_attr_flags = cpu_to_le16(frm_attr_flags);\n+\n+\t\t/* Set IP version bit in flags_mask to match IPv4 or IPv6\n+\t\t * packets\n+\t\t */\n+\t\tfrm_attr_flags |= IPFT_FAF_IP_VER6;\n+\t\tkeye-\u003efrm_attr_flags_mask = cpu_to_le16(frm_attr_flags);\n+\t\tkeye-\u003eip_protocol = IPPROTO_UDP;\n+\t\tkeye-\u003eip_protocol_mask = 0xff;\n+\n+\t\tif (type == NETC_PTP_L4_IPV4_EVENT ||\n+\t\t    type == NETC_PTP_L4_IPV6_EVENT)\n+\t\t\tkeye-\u003el4_dst_port = htons(PTP_EV_PORT);\n+\t\telse\n+\t\t\tkeye-\u003el4_dst_port = htons(PTP_GEN_PORT);\n+\n+\t\tkeye-\u003el4_dst_port_mask = htons(0xffff);\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -ERANGE;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int netc_port_add_ipft_ptp_entry(struct netc_port *np,\n+\t\t\t\t\tenum netc_ptp_type type)\n+{\n+\tstruct netc_switch *priv = np-\u003eswitch_priv;\n+\tstruct ipft_entry_data *entry;\n+\tstruct ipft_keye_data *keye;\n+\tu32 cfg;\n+\tint err;\n+\n+\tentry = kzalloc_obj(*entry);\n+\tif (!entry)\n+\t\treturn -ENOMEM;\n+\n+\tkeye = \u0026entry-\u003ekeye;\n+\terr = netc_build_ptp_ipft_keye(keye, np-\u003edp-\u003eindex, type);\n+\tif (err)\n+\t\tgoto free_entry;\n+\n+\tcfg = FIELD_PREP(IPFT_FLTFA, IPFT_FLTFA_REDIRECT);\n+\tcfg |= FIELD_PREP(IPFT_HR, NETC_HR_PTP_TRAP);\n+\tcfg |= IPFT_TIMECAPE | IPFT_RRT;\n+\tentry-\u003ecfge.cfg = cpu_to_le32(cfg);\n+\n+\terr = ntmp_ipft_add_entry(\u0026priv-\u003entmp, entry);\n+\tif (err)\n+\t\tgoto free_entry;\n+\n+\tnp-\u003eptp_ipft_eid[type] = entry-\u003eentry_id;\n+\n+free_entry:\n+\tkfree(entry);\n+\n+\treturn err;\n+}\n+\n+static int netc_port_add_l2_ptp_filter(struct netc_port *np)\n+{\n+\treturn netc_port_add_ipft_ptp_entry(np, NETC_PTP_L2);\n+}\n+\n+static int netc_port_add_l4_ptp_filter(struct netc_port *np)\n+{\n+\tint err;\n+\n+\terr = netc_port_add_ipft_ptp_entry(np, NETC_PTP_L4_IPV4_EVENT);\n+\tif (err)\n+\t\treturn err;\n+\n+\terr = netc_port_add_ipft_ptp_entry(np, NETC_PTP_L4_IPV4_GENERAL);\n+\tif (err)\n+\t\tgoto del_ptp_filter;\n+\n+\terr = netc_port_add_ipft_ptp_entry(np, NETC_PTP_L4_IPV6_EVENT);\n+\tif (err)\n+\t\tgoto del_ptp_filter;\n+\n+\terr = netc_port_add_ipft_ptp_entry(np, NETC_PTP_L4_IPV6_GENERAL);\n+\tif (err)\n+\t\tgoto del_ptp_filter;\n+\n+\treturn 0;\n+\n+del_ptp_filter:\n+\tnetc_port_del_ptp_filter(np);\n+\n+\treturn err;\n+}\n+\n+static int netc_port_add_l2_l4_ptp_filter(struct netc_port *np)\n+{\n+\tint err;\n+\n+\terr = netc_port_add_l2_ptp_filter(np);\n+\tif (err)\n+\t\treturn err;\n+\n+\terr = netc_port_add_l4_ptp_filter(np);\n+\tif (err)\n+\t\tgoto del_ptp_filter;\n+\n+\treturn 0;\n+\n+del_ptp_filter:\n+\tnetc_port_del_ptp_filter(np);\n+\n+\treturn err;\n+}\n+\n+static int netc_port_set_ptp_filter(struct netc_port *np, int rx_filter)\n+{\n+\tint err = 0;\n+\n+\tif (np-\u003eptp_rx_filter == rx_filter)\n+\t\treturn 0;\n+\n+\tif (np-\u003eptp_rx_filter != HWTSTAMP_FILTER_NONE ||\n+\t    rx_filter == HWTSTAMP_FILTER_NONE) {\n+\t\tnetc_port_del_ptp_filter(np);\n+\t\tnp-\u003eptp_rx_filter = HWTSTAMP_FILTER_NONE;\n+\t}\n+\n+\tswitch (rx_filter) {\n+\tcase HWTSTAMP_FILTER_NONE:\n+\t\tbreak;\n+\tcase HWTSTAMP_FILTER_PTP_V2_L2_EVENT:\n+\t\terr = netc_port_add_l2_ptp_filter(np);\n+\t\tbreak;\n+\tcase HWTSTAMP_FILTER_PTP_V2_L4_EVENT:\n+\t\terr = netc_port_add_l4_ptp_filter(np);\n+\t\tbreak;\n+\tcase HWTSTAMP_FILTER_PTP_V2_EVENT:\n+\t\terr = netc_port_add_l2_l4_ptp_filter(np);\n+\t\tbreak;\n+\tdefault:\n+\t\terr = -ERANGE;\n+\t}\n+\n+\tif (err)\n+\t\treturn err;\n+\n+\tnp-\u003eptp_rx_filter = rx_filter;\n+\n+\treturn 0;\n+}\n+\n+void netc_port_purge_txtstamp_queue(struct netc_port *np)\n+{\n+\tstruct sk_buff_head free_list;\n+\n+\t__skb_queue_head_init(\u0026free_list);\n+\n+\tspin_lock_bh(\u0026np-\u003etstamp_lock);\n+\tskb_queue_splice_init(\u0026np-\u003eskb_txtstamp_queue, \u0026free_list);\n+\tspin_unlock_bh(\u0026np-\u003etstamp_lock);\n+\n+\t__skb_queue_purge(\u0026free_list);\n+}\n+\n+void netc_port_purge_onestep_queue(struct netc_onestep *onestep,\n+\t\t\t\t   bool clear_flight)\n+{\n+\tstruct sk_buff_head free_list;\n+\n+\t__skb_queue_head_init(\u0026free_list);\n+\n+\tspin_lock_bh(\u0026onestep-\u003equeue_lock);\n+\tskb_queue_splice_init(\u0026onestep-\u003equeue, \u0026free_list);\n+\tif (clear_flight)\n+\t\tonestep-\u003ein_flight = false;\n+\tspin_unlock_bh(\u0026onestep-\u003equeue_lock);\n+\n+\t__skb_queue_purge(\u0026free_list);\n+}\n+\n+int netc_port_hwtstamp_set(struct dsa_switch *ds, int port,\n+\t\t\t   struct kernel_hwtstamp_config *config,\n+\t\t\t   struct netlink_ext_ack *extack)\n+{\n+\tstruct netc_port *np = NETC_PORT(ds, port);\n+\tstruct netc_switch *priv = ds-\u003epriv;\n+\tint rx_filter, err;\n+\n+\tif ((config-\u003etx_type != HWTSTAMP_TX_OFF ||\n+\t     config-\u003erx_filter != HWTSTAMP_FILTER_NONE) \u0026\u0026\n+\t    !priv-\u003etmr_dev)\n+\t\treturn -EOPNOTSUPP;\n+\n+\tswitch (config-\u003etx_type) {\n+\tcase HWTSTAMP_TX_ON:\n+\tcase HWTSTAMP_TX_OFF:\n+\tcase HWTSTAMP_TX_ONESTEP_SYNC:\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -ERANGE;\n+\t}\n+\n+\tswitch (config-\u003erx_filter) {\n+\tcase HWTSTAMP_FILTER_NONE:\n+\t\trx_filter = HWTSTAMP_FILTER_NONE;\n+\t\tbreak;\n+\tcase HWTSTAMP_FILTER_PTP_V2_L4_EVENT:\n+\tcase HWTSTAMP_FILTER_PTP_V2_L4_SYNC:\n+\tcase HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:\n+\t\trx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;\n+\t\tbreak;\n+\tcase HWTSTAMP_FILTER_PTP_V2_L2_EVENT:\n+\tcase HWTSTAMP_FILTER_PTP_V2_L2_SYNC:\n+\tcase HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:\n+\t\trx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;\n+\t\tbreak;\n+\tcase HWTSTAMP_FILTER_PTP_V2_EVENT:\n+\tcase HWTSTAMP_FILTER_PTP_V2_SYNC:\n+\tcase HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:\n+\t\trx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -ERANGE;\n+\t}\n+\n+\terr = netc_port_set_ptp_filter(np, rx_filter);\n+\tif (err) {\n+\t\tNL_SET_ERR_MSG_MOD(extack, \"Failed to set PTP filter\");\n+\t\treturn err;\n+\t}\n+\n+\tWRITE_ONCE(np-\u003eptp_tx_type, config-\u003etx_type);\n+\tif (config-\u003etx_type == HWTSTAMP_TX_OFF)\n+\t\tnetc_port_purge_txtstamp_queue(np);\n+\n+\tif (config-\u003etx_type != HWTSTAMP_TX_ONESTEP_SYNC)\n+\t\tnetc_port_purge_onestep_queue(np-\u003eonestep, false);\n+\n+\tconfig-\u003erx_filter = rx_filter;\n+\n+\treturn 0;\n+}\n+\n+int netc_port_hwtstamp_get(struct dsa_switch *ds, int port,\n+\t\t\t   struct kernel_hwtstamp_config *config)\n+{\n+\tstruct netc_port *np = NETC_PORT(ds, port);\n+\n+\tconfig-\u003etx_type = READ_ONCE(np-\u003eptp_tx_type);\n+\tconfig-\u003erx_filter = np-\u003eptp_rx_filter;\n+\n+\treturn 0;\n+}\n+\n+static void netc_port_txtstamp_twostep(struct netc_port *np,\n+\t\t\t\t       struct sk_buff *nskb)\n+{\n+\tDECLARE_BITMAP(ts_req_id_bitmap, NETC_NUM_TS_REQ_ID);\n+\tstruct sk_buff *clone = skb_clone_sk(nskb);\n+\tstruct netc_switch *priv = np-\u003eswitch_priv;\n+\tstruct sk_buff_head free_list;\n+\tstruct sk_buff *skb, *skb_tmp;\n+\tunsigned long ts_req_id;\n+\tint err = 0;\n+\n+\tif (unlikely(!clone))\n+\t\treturn;\n+\n+\tbitmap_zero(ts_req_id_bitmap, NETC_NUM_TS_REQ_ID);\n+\t__skb_queue_head_init(\u0026free_list);\n+\tspin_lock_bh(\u0026np-\u003etstamp_lock);\n+\n+\tskb_queue_walk_safe(\u0026np-\u003eskb_txtstamp_queue, skb, skb_tmp) {\n+\t\tif (time_before(NETC_SKB_CB(skb)-\u003eptp_tx_time +\n+\t\t\t\tNETC_TXTSTAMP_TIMEOUT, jiffies)) {\n+\t\t\tdev_dbg_ratelimited(priv-\u003edev,\n+\t\t\t\t\t    \"Port %d ts_req_id %u which seems lost\\n\",\n+\t\t\t\t\t    np-\u003edp-\u003eindex, NETC_SKB_CB(skb)-\u003ets_req_id);\n+\n+\t\t\t__skb_unlink(skb, \u0026np-\u003eskb_txtstamp_queue);\n+\t\t\t__skb_queue_tail(\u0026free_list, skb);\n+\t\t} else {\n+\t\t\t__set_bit(NETC_SKB_CB(skb)-\u003ets_req_id, ts_req_id_bitmap);\n+\t\t}\n+\t}\n+\n+\tts_req_id = find_first_zero_bit(ts_req_id_bitmap, NETC_NUM_TS_REQ_ID);\n+\tif (ts_req_id == NETC_NUM_TS_REQ_ID) {\n+\t\tdev_dbg_ratelimited(priv-\u003edev,\n+\t\t\t\t    \"Port %d has no available ts_req_id\\n\",\n+\t\t\t\t    np-\u003edp-\u003eindex);\n+\t\terr = -EBUSY;\n+\t\tgoto unlock_tstamp;\n+\t}\n+\n+\tNETC_SKB_CB(nskb)-\u003eptp_flag = NETC_PTP_FLAG_TWOSTEP;\n+\tNETC_SKB_CB(nskb)-\u003ets_req_id = ts_req_id;\n+\tNETC_SKB_CB(clone)-\u003ets_req_id = ts_req_id;\n+\tNETC_SKB_CB(clone)-\u003eptp_tx_time = jiffies;\n+\tskb_shinfo(clone)-\u003etx_flags |= SKBTX_IN_PROGRESS;\n+\t__skb_queue_tail(\u0026np-\u003eskb_txtstamp_queue, clone);\n+\n+unlock_tstamp:\n+\tspin_unlock_bh(\u0026np-\u003etstamp_lock);\n+\n+\tif (err)\n+\t\tkfree_skb(clone);\n+\n+\t/* Free timed-out SKBs outside the spinlock to avoid calling\n+\t * kfree_skb() with a destructor (sock_efree) under a spinlock.\n+\t */\n+\t__skb_queue_purge(\u0026free_list);\n+}\n+\n+void netc_port_twostep_tstamp_handler(struct dsa_switch *ds, int port,\n+\t\t\t\t      u8 ts_req_id, u64 ts)\n+{\n+\tstruct sk_buff *skb, *skb_tmp, *skb_match = NULL;\n+\tstruct netc_port *np = NETC_PORT(ds, port);\n+\tstruct skb_shared_hwtstamps hwtstamps;\n+\tstruct netc_switch *priv = ds-\u003epriv;\n+\n+\tspin_lock_bh(\u0026np-\u003etstamp_lock);\n+\tskb_queue_walk_safe(\u0026np-\u003eskb_txtstamp_queue, skb, skb_tmp) {\n+\t\tif (NETC_SKB_CB(skb)-\u003ets_req_id != ts_req_id)\n+\t\t\tcontinue;\n+\n+\t\t__skb_unlink(skb, \u0026np-\u003eskb_txtstamp_queue);\n+\t\tskb_match = skb;\n+\t\tbreak;\n+\t}\n+\tspin_unlock_bh(\u0026np-\u003etstamp_lock);\n+\n+\tif (!skb_match) {\n+\t\tdev_dbg_ratelimited(priv-\u003edev,\n+\t\t\t\t    \"Port %d ts_req_id %u which seems lost\\n\",\n+\t\t\t\t    port, ts_req_id);\n+\t\treturn;\n+\t}\n+\n+\thwtstamps.hwtstamp = ns_to_ktime(ts);\n+\tskb_complete_tx_timestamp(skb_match, \u0026hwtstamps);\n+}\n+\n+bool netc_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb,\n+\t\t\tunsigned int type)\n+{\n+\tstruct skb_shared_hwtstamps *hwtstamps = skb_hwtstamps(skb);\n+\tu64 ts = NETC_SKB_CB(skb)-\u003etstamp;\n+\n+\t/* ts == 0 indicates the hardware did not capture the RX timestamp\n+\t * of the frame.\n+\t */\n+\tif (!ts)\n+\t\treturn false;\n+\n+\thwtstamps-\u003ehwtstamp = ns_to_ktime(ts);\n+\n+\treturn false;\n+}\n+\n+static void netc_port_prepare_onestep_sync(struct netc_port *np,\n+\t\t\t\t\t   struct sk_buff *skb,\n+\t\t\t\t\t   u32 ptp_class, bool *twostep)\n+{\n+\tstruct netc_switch *priv = np-\u003eswitch_priv;\n+\tu16 correction_offset, tstamp_offset;\n+\tstruct ptp_header *ptp_hdr;\n+\tu8 msg_type, twostep_flag;\n+\tbool is_udp = false;\n+\tu32 pkt_type;\n+\tu8 *pkt_hdr;\n+\n+\tif (unlikely(skb_linearize(skb))) {\n+\t\tNETC_SKB_CB(skb)-\u003eptp_flag = NETC_PTP_FLAG_DROP;\n+\t\treturn;\n+\t}\n+\n+\tptp_hdr = ptp_parse_header(skb, ptp_class);\n+\tif (unlikely(!ptp_hdr)) {\n+\t\tNETC_SKB_CB(skb)-\u003eptp_flag = NETC_PTP_FLAG_DROP;\n+\t\tdev_dbg_ratelimited(priv-\u003edev,\n+\t\t\t\t    \"Port %d failed to parse Sync header\\n\",\n+\t\t\t\t    np-\u003edp-\u003eindex);\n+\t\treturn;\n+\t}\n+\n+\tmsg_type = ptp_get_msgtype(ptp_hdr, ptp_class);\n+\ttwostep_flag = ptp_hdr-\u003eflag_field[0] \u0026 0x2;\n+\n+\tpkt_hdr = skb_mac_header(skb);\n+\tcorrection_offset = (u8 *)\u0026ptp_hdr-\u003ecorrection - pkt_hdr;\n+\ttstamp_offset = (u8 *)ptp_hdr + sizeof(*ptp_hdr) - pkt_hdr;\n+\n+\t/* Ensure that the entire originTimestamp field is present in the\n+\t * linear buffer of the skb and the correction_offset must be within\n+\t * the hardware capability.\n+\t */\n+\tif (unlikely(tstamp_offset + 10 \u003e skb_headlen(skb) ||\n+\t\t     correction_offset \u003e NETC_MAX_STEP_OFFSET)) {\n+\t\tNETC_SKB_CB(skb)-\u003eptp_flag = NETC_PTP_FLAG_DROP;\n+\t\tdev_dbg_ratelimited(priv-\u003edev,\n+\t\t\t\t    \"Port %d PTP offset check error\\n\",\n+\t\t\t\t    np-\u003edp-\u003eindex);\n+\t\treturn;\n+\t}\n+\n+\t/* Only a Sync frame with the twoStepFlag cleared can use one-step\n+\t * timestamping. A frame that requests two-step (or is not a Sync)\n+\t * carries different on-wire fields, so this is a real classification;\n+\t * report it through *twostep so the caller falls back to the two-step\n+\t * path.\n+\t */\n+\tif (msg_type != PTP_MSGTYPE_SYNC || twostep_flag != 0) {\n+\t\t*twostep = true;\n+\t\treturn;\n+\t}\n+\n+\t/* This is a genuine one-step Sync frame. skb_shinfo()-\u003edestructor_arg\n+\t * is later used to pass the np-\u003eonestep pointer to\n+\t * netc_onestep_skb_destructor() for TX completion notification.\n+\t * MSG_ZEROCOPY also uses destructor_arg (via skb_zcopy_init()) to\n+\t * track user-space page references. Overwriting it in that case would\n+\t * leak the ubuf_info reference and prevent user pages from being\n+\t * released. PTP applications do not use MSG_ZEROCOPY, but guard\n+\t * against it defensively.\n+\t */\n+\tif (skb_zcopy(skb)) {\n+\t\tNETC_SKB_CB(skb)-\u003eptp_flag = NETC_PTP_FLAG_DROP;\n+\t\tdev_dbg_ratelimited(priv-\u003edev,\n+\t\t\t\t    \"Port %d one-step Sync not supported on zerocopy skb\\n\",\n+\t\t\t\t    np-\u003edp-\u003eindex);\n+\t\treturn;\n+\t}\n+\n+\tpkt_type = ptp_class \u0026 PTP_CLASS_PMASK;\n+\tif (pkt_type == PTP_CLASS_IPV4 || pkt_type == PTP_CLASS_IPV6)\n+\t\tis_udp = true;\n+\n+\t/* Cache the parsing results so the tagger xmit path and the deferred\n+\t * work do not need to re-parse the PTP header, and so that\n+\t * netc_port_program_onestep() can derive these parameters from the\n+\t * skb.\n+\t */\n+\tNETC_SKB_CB(skb)-\u003ecorrection_offset = correction_offset;\n+\tNETC_SKB_CB(skb)-\u003etimestamp_offset = tstamp_offset;\n+\tNETC_SKB_CB(skb)-\u003eis_udp = is_udp;\n+\tNETC_SKB_CB(skb)-\u003eptp_flag = NETC_PTP_FLAG_ONESTEP;\n+}\n+\n+void netc_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)\n+{\n+\tstruct netc_port *np = NETC_PORT(ds, port);\n+\tint tx_type = READ_ONCE(np-\u003eptp_tx_type);\n+\tbool twostep = false;\n+\tu32 ptp_class;\n+\n+\tNETC_SKB_CB(skb)-\u003eptp_flag = 0;\n+\tptp_class = ptp_classify_raw(skb);\n+\tif (ptp_class == PTP_CLASS_NONE)\n+\t\treturn;\n+\n+\tif (tx_type == HWTSTAMP_TX_ONESTEP_SYNC)\n+\t\tnetc_port_prepare_onestep_sync(np, skb, ptp_class, \u0026twostep);\n+\n+\tif (tx_type == HWTSTAMP_TX_ON || twostep)\n+\t\tnetc_port_txtstamp_twostep(np, skb);\n+}\n+\n+void netc_port_onestep_sync_enqueue(struct dsa_switch *ds, int port,\n+\t\t\t\t    struct sk_buff *skb)\n+{\n+\tstruct netc_port *np = NETC_PORT(ds, port);\n+\tstruct netc_onestep *onestep = np-\u003eonestep;\n+\tbool kick = false;\n+\n+\t/* This runs in the xmit path (softirq / BH-disabled), so it must not\n+\t * sleep: only queue the frame here and let netc_port_onestep_work()\n+\t * program the SINGLE_STEP register and transmit it from process\n+\t * context. The shared SINGLE_STEP register can describe only one frame\n+\t * at a time, so at most one one-step Sync may be in flight. Track that\n+\t * with @in_flight under onestep-\u003equeue_lock.\n+\t *\n+\t * Enqueue the frame and, only if no frame is currently in flight, claim\n+\t * the in-flight slot and kick the work. When a frame is already in\n+\t * flight, just queue: its skb destructor will kick the work to send the\n+\t * next one once it completes TX, so the frames are transmitted strictly\n+\t * one at a time in order.\n+\t *\n+\t * PTP Sync frames are periodic, low-rate control-plane frames and only\n+\t * reach this TX path when the local socket requested hardware TX\n+\t * timestamping on a one-step port, so the queue cannot be flooded and\n+\t * needs no depth cap.\n+\t */\n+\tspin_lock_bh(\u0026onestep-\u003equeue_lock);\n+\t__skb_queue_tail(\u0026onestep-\u003equeue, skb);\n+\tif (!onestep-\u003ein_flight) {\n+\t\tonestep-\u003ein_flight = true;\n+\t\tkick = true;\n+\t}\n+\tspin_unlock_bh(\u0026onestep-\u003equeue_lock);\n+\n+\t/* Ownership is transferred to the queue; netc_xmit() stops processing\n+\t * this skb. The work will program and transmit it.\n+\t */\n+\tif (kick)\n+\t\tschedule_work(\u0026onestep-\u003ework);\n+}\ndiff --git a/drivers/net/dsa/netc/netc_switch.h b/drivers/net/dsa/netc/netc_switch.h\nindex 305f2a92e2f9a..98d4842441df2 100644\n--- a/drivers/net/dsa/netc/netc_switch.h\n+++ b/drivers/net/dsa/netc/netc_switch.h\n@@ -9,6 +9,7 @@\n #include \u003clinux/dsa/tag_netc.h\u003e\n #include \u003clinux/fsl/netc_global.h\u003e\n #include \u003clinux/fsl/ntmp.h\u003e\n+#include \u003clinux/mutex.h\u003e\n #include \u003clinux/of_device.h\u003e\n #include \u003clinux/of_net.h\u003e\n #include \u003clinux/pci.h\u003e\n@@ -53,10 +54,16 @@\n #define NETC_FDBT_AGEING_DELAY\t\t(3 * HZ)\n #define NETC_FDBT_AGEING_THRESH\t\t100\n \n+/* PTP frames have a higher priority, so a higher priority is defined to\n+ * prioritize matching.\n+ */\n+#define NETC_IPFT_PTP_PRECEDENCE\t0xf000\n+\n struct netc_switch;\n \n struct netc_switch_info {\n \tu32 num_ports;\n+\tu32 tmr_devfn;\n \tvoid (*phylink_get_caps)(int port, struct phylink_config *config);\n };\n \n@@ -66,9 +73,57 @@ struct netc_port_caps {\n \tu32 pseudo_link:1;\n };\n \n+enum netc_ptp_type {\n+\tNETC_PTP_L2,\n+\tNETC_PTP_L4_IPV4_EVENT,\n+\tNETC_PTP_L4_IPV4_GENERAL,\n+\tNETC_PTP_L4_IPV6_EVENT,\n+\tNETC_PTP_L4_IPV6_GENERAL,\n+\tNETC_PTP_MAX,\n+};\n+\n enum netc_host_reason {\n \t/* Software defined host reasons */\n \tNETC_HR_HOST_FLOOD = 8,\n+\tNETC_HR_PTP_TRAP   = 9,\n+};\n+\n+/* One-step Sync serialization context.\n+ *\n+ * Its lifetime is decoupled from the devm-allocated netc_port. An in-flight\n+ * one-step Sync skb keeps a reference on this context via its skb destructor,\n+ * so the context outlives the port teardown until the conduit frees the last\n+ * in-flight skb after TX completion. Once the port is disabled, @active is\n+ * cleared and the work stops touching any devm memory (netc_port/netc_switch)\n+ * or the unregistered user netdev or the tagger_data.\n+ */\n+struct netc_onestep {\n+\tstruct netc_port *np;\n+\tstruct kref refcnt;\n+\t/* Process-context lock: serializes the deferred TX work against port\n+\t * teardown, so the work never touches the devm-allocated netc_port /\n+\t * netc_switch or the unregistered user netdev after teardown. Held\n+\t * across netc_get_phc_time(), which may sleep, hence a mutex.\n+\t */\n+\tstruct mutex work_lock;\n+\t/* Serialize access to in_flight and queue */\n+\tspinlock_t queue_lock;\n+\tbool active;\t/* set when port is enabled, under @work_lock */\n+\t/* In-flight slot: true while one one-step Sync frame is programmed\n+\t * into the shared SINGLE_STEP register and being transmitted. Only one\n+\t * frame may be in flight at a time, so the next queued frame is sent\n+\t * only after the current one completes TX (its skb destructor kicks\n+\t * the work). Accessed under queue_lock, from both the softirq xmit\n+\t * path and the process-context work.\n+\t */\n+\tbool in_flight;\n+\t/* Pending one-step Sync frames. Enqueued from the softirq xmit path and\n+\t * dequeued by the process-context work; the list is serialized by\n+\t * queue_lock together with @in_flight.\n+\t */\n+\tstruct sk_buff_head queue;\n+\tstruct work_struct work;\t/* drains @queue */\n+\tstruct work_struct destroy_work; /* frees the context in process ctx */\n };\n \n struct netc_port {\n@@ -84,7 +139,17 @@ struct netc_port {\n \tu16 uc:1;\n \tu16 mc:1;\n \tu16 pvid;\n-\tstruct ipft_entry_data *host_flood;\n+\tu32 ipft_hf_eid;\n+\n+\t/* Serialize access to skb_txtstamp_queue and ts_req_id */\n+\tspinlock_t tstamp_lock;\n+\t/* skb queue for two-step timestamp frames */\n+\tstruct sk_buff_head skb_txtstamp_queue;\n+\t/* one-step Sync serialization context (ref-counted, kzalloc'd) */\n+\tstruct netc_onestep *onestep;\n+\tint ptp_tx_type;\n+\tint ptp_rx_filter;\n+\tu32 ptp_ipft_eid[NETC_PTP_MAX];\n };\n \n struct netc_switch_regs {\n@@ -139,6 +204,7 @@ struct netc_switch {\n \tu32 num_bp;\n \n \tstruct bpt_cfge_data *bpt_list;\n+\tstruct pci_dev *tmr_dev; /* The PTP Timer PCI device */\n };\n \n #define NETC_PRIV(ds)\t\t\t((struct netc_switch *)((ds)-\u003epriv))\n@@ -187,6 +253,7 @@ static inline void netc_del_vlan_entry(struct netc_vlan_entry *entry)\n }\n \n int netc_switch_platform_probe(struct netc_switch *priv);\n+void netc_mac_port_wr(struct netc_port *np, u32 reg, u32 val);\n \n /* ethtool APIs */\n void netc_port_get_pause_stats(struct dsa_switch *ds, int port,\n@@ -203,4 +270,26 @@ void netc_port_get_strings(struct dsa_switch *ds, int port,\n \t\t\t   u32 sset, u8 *data);\n void netc_port_get_ethtool_stats(struct dsa_switch *ds, int port, u64 *data);\n \n+/* PTP APIs */\n+int netc_port_ptp_init(struct netc_port *np);\n+int netc_get_ts_info(struct dsa_switch *ds, int port,\n+\t\t     struct kernel_ethtool_ts_info *info);\n+void netc_port_purge_txtstamp_queue(struct netc_port *np);\n+int netc_port_hwtstamp_set(struct dsa_switch *ds, int port,\n+\t\t\t   struct kernel_hwtstamp_config *config,\n+\t\t\t   struct netlink_ext_ack *extack);\n+int netc_port_hwtstamp_get(struct dsa_switch *ds, int port,\n+\t\t\t   struct kernel_hwtstamp_config *config);\n+void netc_port_twostep_tstamp_handler(struct dsa_switch *ds, int port,\n+\t\t\t\t      u8 ts_req_id, u64 ts);\n+bool netc_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb,\n+\t\t\tunsigned int type);\n+void netc_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb);\n+void netc_onestep_put(struct netc_onestep *onestep);\n+void netc_port_purge_onestep_queue(struct netc_onestep *onestep,\n+\t\t\t\t   bool clear_flight);\n+void netc_port_onestep_work(struct work_struct *work);\n+void netc_port_onestep_sync_enqueue(struct dsa_switch *ds, int port,\n+\t\t\t\t    struct sk_buff *skb);\n+\n #endif\ndiff --git a/drivers/net/dsa/netc/netc_switch_hw.h b/drivers/net/dsa/netc/netc_switch_hw.h\nindex 1404ae41c7bcb..37d1dd7ec2c7f 100644\n--- a/drivers/net/dsa/netc/netc_switch_hw.h\n+++ b/drivers/net/dsa/netc/netc_switch_hw.h\n@@ -203,6 +203,11 @@ enum netc_stg_stage {\n #define   SSP_10M\t\t\t1\n #define   SSP_1G\t\t\t2\n \n+#define NETC_PM_SINGLE_STEP(a)\t\t(0x10c0 + (a) * 0x400)\n+#define  PM_SINGLE_STEP_CH\t\tBIT(6)\n+#define  PM_SINGLE_STEP_OFFSET\t\tGENMASK(15, 7)\n+#define  PM_SINGLE_STEP_EN\t\tBIT(31)\n+\n /* Port MAC 0/1 Receive Ethernet Octets Counter */\n #define NETC_PM_REOCT(a)\t\t(0x1100 + (a) * 0x400)\n \ndiff --git a/drivers/ptp/ptp_netc.c b/drivers/ptp/ptp_netc.c\nindex 1c20d7efab929..27f85818d6a8a 100644\n--- a/drivers/ptp/ptp_netc.c\n+++ b/drivers/ptp/ptp_netc.c\n@@ -127,6 +127,17 @@ struct netc_timer {\n \n #define netc_timer_rd(p, o)\t\tnetc_read((p)-\u003ebase + (o))\n #define netc_timer_wr(p, o, v)\t\tnetc_write((p)-\u003ebase + (o), v)\n+\n+/* The 64-bit timer registers consist of a low (L) and high (H) register pair.\n+ * Hardware requires a strict access order: for writes, TMR_xxx_L must be\n+ * written first, which latches the value into a shadow register; the write\n+ * to TMR_xxx_H then atomically transfers both shadow registers into the live\n+ * counter. For reads, TMR_xxx_L must be read first to capture a coherent\n+ * snapshot. iowrite64_lo_hi() and ioread64_lo_hi() enforce this L-before-H\n+ * ordering.\n+ */\n+#define netc_timer_rd64(p, o)\t\tioread64_lo_hi((p)-\u003ebase + (o))\n+#define netc_timer_wr64(p, o, v)\tiowrite64_lo_hi(v, (p)-\u003ebase + (o))\n #define ptp_to_netc_timer(ptp)\t\tcontainer_of((ptp), struct netc_timer, caps)\n \n static const char *const timer_clk_src[] = {\n@@ -136,66 +147,69 @@ static const char *const timer_clk_src[] = {\n \n static void netc_timer_cnt_write(struct netc_timer *priv, u64 ns)\n {\n-\tu32 tmr_cnt_h = upper_32_bits(ns);\n-\tu32 tmr_cnt_l = lower_32_bits(ns);\n-\n-\t/* Writes to the TMR_CNT_L register copies the written value\n-\t * into the shadow TMR_CNT_L register. Writes to the TMR_CNT_H\n-\t * register copies the values written into the shadow TMR_CNT_H\n-\t * register. Contents of the shadow registers are copied into\n-\t * the TMR_CNT_L and TMR_CNT_H registers following a write into\n-\t * the TMR_CNT_H register. So the user must writes to TMR_CNT_L\n-\t * register first. Other H/L registers should have the same\n-\t * behavior.\n-\t */\n-\tnetc_timer_wr(priv, NETC_TMR_CNT_L, tmr_cnt_l);\n-\tnetc_timer_wr(priv, NETC_TMR_CNT_H, tmr_cnt_h);\n+\tnetc_timer_wr64(priv, NETC_TMR_CNT_L, ns);\n }\n \n static u64 netc_timer_offset_read(struct netc_timer *priv)\n {\n-\tu32 tmr_off_l, tmr_off_h;\n-\tu64 offset;\n-\n-\ttmr_off_l = netc_timer_rd(priv, NETC_TMR_OFF_L);\n-\ttmr_off_h = netc_timer_rd(priv, NETC_TMR_OFF_H);\n-\toffset = (((u64)tmr_off_h) \u003c\u003c 32) | tmr_off_l;\n-\n-\treturn offset;\n+\treturn netc_timer_rd64(priv, NETC_TMR_OFF_L);\n }\n \n static void netc_timer_offset_write(struct netc_timer *priv, u64 offset)\n {\n-\tu32 tmr_off_h = upper_32_bits(offset);\n-\tu32 tmr_off_l = lower_32_bits(offset);\n-\n-\tnetc_timer_wr(priv, NETC_TMR_OFF_L, tmr_off_l);\n-\tnetc_timer_wr(priv, NETC_TMR_OFF_H, tmr_off_h);\n+\tnetc_timer_wr64(priv, NETC_TMR_OFF_L, offset);\n }\n \n static u64 netc_timer_cur_time_read(struct netc_timer *priv)\n {\n-\tu32 time_h, time_l;\n-\tu64 ns;\n+\treturn netc_timer_rd64(priv, NETC_TMR_CUR_TIME_L);\n+}\n+\n+/**\n+ * netc_timer_get_current_time - read the current PTP time from the NETC Timer\n+ * @pdev: PCI device of the NETC Timer\n+ *\n+ * Reads the 64-bit current time register (TMR_CUR_TIME) from the NETC Timer\n+ * device associated with @pdev. Returns 0 if the Timer driver has not yet\n+ * probed or has already been removed.\n+ *\n+ * Context: Process context only. Acquires the device mutex via device_lock(),\n+ *          which may sleep. Must not be called from atomic context, softirq,\n+ *          BH, or while holding a spinlock.\n+ *\n+ * Return: Current PTP time in nanoseconds, or 0 if the timer is unavailable.\n+ */\n+u64 netc_timer_get_current_time(struct pci_dev *pdev)\n+{\n+\tstruct netc_timer *priv;\n+\tunsigned long flags;\n+\tu64 cur_time = 0;\n \n-\t/* The user should read NETC_TMR_CUR_TIME_L first to\n-\t * get correct current time.\n+\t/* Serialize against driver unbind: the remove() callback runs under\n+\t * the device lock, so holding it here ensures that priv remains valid\n+\t * for the entire duration of the register read.\n \t */\n-\ttime_l = netc_timer_rd(priv, NETC_TMR_CUR_TIME_L);\n-\ttime_h = netc_timer_rd(priv, NETC_TMR_CUR_TIME_H);\n-\tns = (u64)time_h \u003c\u003c 32 | time_l;\n+\tdevice_lock(\u0026pdev-\u003edev);\n+\n+\tpriv = pci_get_drvdata(pdev);\n+\tif (!priv)\n+\t\tgoto unlock_device;\n+\n+\tspin_lock_irqsave(\u0026priv-\u003elock, flags);\n+\tcur_time = netc_timer_cur_time_read(priv);\n+\tspin_unlock_irqrestore(\u0026priv-\u003elock, flags);\n+\n+unlock_device:\n+\tdevice_unlock(\u0026pdev-\u003edev);\n \n-\treturn ns;\n+\treturn cur_time;\n }\n+EXPORT_SYMBOL_GPL(netc_timer_get_current_time);\n \n static void netc_timer_alarm_write(struct netc_timer *priv,\n \t\t\t\t   u64 alarm, int index)\n {\n-\tu32 alarm_h = upper_32_bits(alarm);\n-\tu32 alarm_l = lower_32_bits(alarm);\n-\n-\tnetc_timer_wr(priv, NETC_TMR_ALARM_L(index), alarm_l);\n-\tnetc_timer_wr(priv, NETC_TMR_ALARM_H(index), alarm_h);\n+\tnetc_timer_wr64(priv, NETC_TMR_ALARM_L(index), alarm);\n }\n \n static u32 netc_timer_get_integral_period(struct netc_timer *priv)\n@@ -497,22 +511,19 @@ static void netc_timer_handle_etts_event(struct netc_timer *priv, int index,\n \t\t\t\t\t bool update_event)\n {\n \tstruct ptp_clock_event event;\n-\tu32 etts_l = 0, etts_h = 0;\n+\tu64 etts = 0;\n \n-\twhile (netc_timer_rd(priv, NETC_TMR_STAT) \u0026 TMR_STAT_ETS_VLD(index)) {\n-\t\tetts_l = netc_timer_rd(priv, NETC_TMR_ETTS_L(index));\n-\t\tetts_h = netc_timer_rd(priv, NETC_TMR_ETTS_H(index));\n-\t}\n+\twhile (netc_timer_rd(priv, NETC_TMR_STAT) \u0026 TMR_STAT_ETS_VLD(index))\n+\t\tetts = netc_timer_rd64(priv, NETC_TMR_ETTS_L(index));\n \n \t/* Invalid time stamp */\n-\tif (!etts_l \u0026\u0026 !etts_h)\n+\tif (!etts)\n \t\treturn;\n \n \tif (update_event) {\n \t\tevent.type = PTP_CLOCK_EXTTS;\n \t\tevent.index = index;\n-\t\tevent.timestamp = (u64)etts_h \u003c\u003c 32;\n-\t\tevent.timestamp |= etts_l;\n+\t\tevent.timestamp = etts;\n \t\tptp_clock_event(priv-\u003eclock, \u0026event);\n \t}\n }\n@@ -804,7 +815,6 @@ static int netc_timer_pci_probe(struct pci_dev *pdev)\n \tif (!priv)\n \t\treturn -ENOMEM;\n \n-\tpcie_flr(pdev);\n \terr = pci_enable_device_mem(pdev);\n \tif (err)\n \t\treturn dev_err_probe(dev, err, \"Failed to enable device\\n\");\n@@ -826,6 +836,7 @@ static int netc_timer_pci_probe(struct pci_dev *pdev)\n \t\tgoto release_mem_regions;\n \t}\n \n+\tspin_lock_init(\u0026priv-\u003elock);\n \tpci_set_drvdata(pdev, priv);\n \n \treturn 0;\n@@ -996,7 +1007,6 @@ static int netc_timer_probe(struct pci_dev *pdev,\n \tpriv-\u003ecaps = netc_timer_ptp_caps;\n \tpriv-\u003eoclk_prsc = NETC_TMR_DEFAULT_PRSC;\n \tpriv-\u003epps_channel = NETC_TMR_INVALID_CHANNEL;\n-\tspin_lock_init(\u0026priv-\u003elock);\n \tsnprintf(priv-\u003eirq_name, sizeof(priv-\u003eirq_name), \"ptp-netc %s\",\n \t\t pci_name(pdev));\n \ndiff --git a/include/linux/dsa/tag_netc.h b/include/linux/dsa/tag_netc.h\nindex fe964722e5b03..5ac5e2e72dff2 100644\n--- a/include/linux/dsa/tag_netc.h\n+++ b/include/linux/dsa/tag_netc.h\n@@ -10,5 +10,48 @@\n #include \u003cnet/dsa.h\u003e\n \n #define NETC_TAG_MAX_LEN\t\t\t14\n+#define NETC_PTP_FLAG_ONESTEP\t\t\tBIT(0)\n+#define NETC_PTP_FLAG_TWOSTEP\t\t\tBIT(1)\n+#define NETC_PTP_FLAG_DROP\t\t\tBIT(2)\n+\n+struct netc_skb_cb {\n+\tunsigned long ptp_tx_time;\n+\tu64 tstamp;\n+\tu8 ptp_flag;\n+\tu8 ts_req_id;\n+\t/* One-step Sync parsing results, computed in netc_port_txtstamp()\n+\t * and reused in the tagger xmit path and the deferred work, to avoid\n+\t * re-parsing the PTP header. Valid only while\n+\t * ptp_flag == NETC_PTP_FLAG_ONESTEP.\n+\t */\n+\tu16 correction_offset;\n+\tu16 timestamp_offset;\n+\tbool is_udp;\n+};\n+\n+#define NETC_SKB_CB(skb)\t((struct netc_skb_cb *)((skb)-\u003ecb))\n+\n+/**\n+ * struct netc_tagger_data - NETC tagger/switch-driver shared operations\n+ * @twostep_tstamp_handler: Called by the tagger when a two-step transmit\n+ *\ttimestamp response is received, to deliver the timestamp to the\n+ *\tswitch driver.\n+ * @onestep_sync_enqueue: Called from the tagger xmit path for a one-step Sync\n+ *\tframe. The switch driver takes ownership of the skb and queues it for\n+ *\tdeferred transmission from process context, where the shared\n+ *\tPM_SINGLE_STEP register can be programmed and the PTP timer read\n+ *\t(which may sleep). The tagger must not touch the skb after this call\n+ *\tand returns NULL to dsa_user_xmit().\n+ * @onestep_sync_xmit: Called by the switch driver to transmit a deferred\n+ *\tone-step Sync frame directly to the conduit, bypassing dsa_user_xmit().\n+ */\n+struct netc_tagger_data {\n+\tvoid (*twostep_tstamp_handler)(struct dsa_switch *ds, int port,\n+\t\t\t\t       u8 ts_req_id, u64 ts);\n+\tvoid (*onestep_sync_enqueue)(struct dsa_switch *ds, int port,\n+\t\t\t\t     struct sk_buff *skb);\n+\tnetdev_tx_t (*onestep_sync_xmit)(struct sk_buff *skb,\n+\t\t\t\t\t struct net_device *ndev);\n+};\n \n #endif\ndiff --git a/include/linux/fsl/netc_global.h b/include/linux/fsl/netc_global.h\nindex 5b8ff528d3699..ace0bcde1e2ca 100644\n--- a/include/linux/fsl/netc_global.h\n+++ b/include/linux/fsl/netc_global.h\n@@ -6,6 +6,7 @@\n \n #include \u003clinux/io.h\u003e\n #include \u003clinux/io-64-nonatomic-lo-hi.h\u003e\n+#include \u003clinux/pci.h\u003e\n \n static inline u32 netc_read(void __iomem *reg)\n {\n@@ -22,4 +23,13 @@ static inline u64 netc_read64(void __iomem *reg)\n \treturn ioread64(reg);\n }\n \n+#if IS_REACHABLE(CONFIG_PTP_NETC_V4_TIMER)\n+u64 netc_timer_get_current_time(struct pci_dev *timer_dev);\n+#else\n+static inline u64 netc_timer_get_current_time(struct pci_dev *timer_dev)\n+{\n+\treturn 0;\n+}\n+#endif\n+\n #endif\ndiff --git a/net/dsa/tag_netc.c b/net/dsa/tag_netc.c\nindex df72a61796ad5..91548fb7ed1b3 100644\n--- a/net/dsa/tag_netc.c\n+++ b/net/dsa/tag_netc.c\n@@ -16,6 +16,10 @@\n #define NETC_TAG_TO_PORT\t\t1\n /* SubType0: No request to perform timestamping */\n #define NETC_TAG_TP_SUBTYPE0\t\t0\n+/* SubType1: Request to perform one-step timestamping */\n+#define NETC_TAG_TP_SUBTYPE1\t\t1\n+/* SubType2: Request to perform two-step timestamping */\n+#define NETC_TAG_TP_SUBTYPE2\t\t2\n \n /* To_Host NXP switch tag */\n #define NETC_TAG_TO_HOST\t\t2\n@@ -29,6 +33,8 @@\n /* NETC switch tag lengths */\n #define NETC_TAG_FORWARD_LEN\t\t6\n #define NETC_TAG_TP_SUBTYPE0_LEN\t6\n+#define NETC_TAG_TP_SUBTYPE1_LEN\t10\n+#define NETC_TAG_TP_SUBTYPE2_LEN\t6\n #define NETC_TAG_TH_SUBTYPE0_LEN\t6\n #define NETC_TAG_TH_SUBTYPE1_LEN\t14\n #define NETC_TAG_TH_SUBTYPE2_LEN\t14\n@@ -40,6 +46,8 @@\n #define NETC_TAG_IPV\t\t\tGENMASK(4, 2)\n #define NETC_TAG_SWITCH\t\t\tGENMASK(2, 0)\n #define NETC_TAG_PORT\t\t\tGENMASK(7, 3)\n+#define NETC_TAG_TS_REQ_ID\t\tGENMASK(3, 0)\n+#define NETC_TAG_TIMESTAMP\t\tGENMASK(29, 0)\n \n struct netc_tag_cmn {\n \t__be16 tpid;\n@@ -48,6 +56,29 @@ struct netc_tag_cmn {\n \tu8 switch_port;\n } __packed;\n \n+struct netc_tag_tp_subtype1 {\n+\tstruct netc_tag_cmn cmn;\n+\tu8 resv;\n+\t__be32 timestamp;\n+} __packed;\n+\n+struct netc_tag_tp_subtype2 {\n+\tstruct netc_tag_cmn cmn;\n+\tu8 ts_req_id;\n+} __packed;\n+\n+struct netc_tag_th_subtype1 {\n+\tstruct netc_tag_cmn cmn;\n+\tu8 host_reason;\n+\t__be64 timestamp;\n+} __packed;\n+\n+struct netc_tag_th_subtype2 {\n+\tstruct netc_tag_cmn cmn;\n+\tu8 hr_tsreq_id;\n+\t__be64 timestamp;\n+} __packed;\n+\n static void netc_fill_common_tag(struct netc_tag_cmn *tag, u8 type,\n \t\t\t\t u8 subtype, u8 sw_id, u8 port, u8 ipv)\n {\n@@ -97,15 +128,126 @@ static void netc_fill_tp_tag_subtype0(struct sk_buff *skb,\n \t\t\t\tNETC_TAG_TP_SUBTYPE0_LEN);\n }\n \n-/* Currently only support To_Port tag, subtype 0 */\n+static void netc_fill_tp_tag_subtype1(struct sk_buff *skb,\n+\t\t\t\t      struct net_device *ndev)\n+{\n+\tu32 ts = FIELD_PREP(NETC_TAG_TIMESTAMP, NETC_SKB_CB(skb)-\u003etstamp);\n+\tstruct netc_tag_tp_subtype1 *tag;\n+\n+\ttag = netc_fill_common_tp_tag(skb, ndev, NETC_TAG_TP_SUBTYPE1,\n+\t\t\t\t      NETC_TAG_TP_SUBTYPE1_LEN);\n+\ttag-\u003etimestamp = htonl(ts);\n+}\n+\n+static void netc_fill_tp_tag_subtype2(struct sk_buff *skb,\n+\t\t\t\t      struct net_device *ndev)\n+{\n+\tu8 ts_req_id = NETC_SKB_CB(skb)-\u003ets_req_id;\n+\tstruct netc_tag_tp_subtype2 *tag;\n+\n+\ttag = netc_fill_common_tp_tag(skb, ndev, NETC_TAG_TP_SUBTYPE2,\n+\t\t\t\t      NETC_TAG_TP_SUBTYPE2_LEN);\n+\ttag-\u003ets_req_id = FIELD_PREP(NETC_TAG_TS_REQ_ID, ts_req_id);\n+}\n+\n+static netdev_tx_t netc_onestep_sync_xmit(struct sk_buff *skb,\n+\t\t\t\t\t  struct net_device *dev)\n+{\n+\t/* This deferred one-step Sync frame already went through\n+\t * dsa_user_xmit()'s skb_ensure_writable_head_tail() and eth_skb_pad()\n+\t * before it was queued in netc_xmit(), and nothing has cloned it or\n+\t * shrunk its head/tail room since. So the head/tail room is still\n+\t * guaranteed and the skb is still writable; only the tag needs to be\n+\t * pushed before handing it directly to the conduit, bypassing\n+\t * dsa_user_xmit() so that dev_sw_netstats_tx_add() is not invoked a\n+\t * second time for the same frame.\n+\t */\n+\tnetc_fill_tp_tag_subtype1(skb, dev);\n+\n+\treturn dsa_enqueue_skb(skb, dev);\n+}\n+\n+static void netc_onestep_sync_enqueue(struct sk_buff *skb,\n+\t\t\t\t      struct net_device *ndev)\n+{\n+\tstruct dsa_port *dp = dsa_user_to_port(ndev);\n+\tstruct netc_tagger_data *tagger_data;\n+\n+\ttagger_data = dp-\u003eds-\u003etagger_data;\n+\tif (unlikely(!tagger_data-\u003eonestep_sync_enqueue)) {\n+\t\tkfree_skb(skb);\n+\t\treturn;\n+\t}\n+\n+\t/* Hand the one-step Sync to the switch driver, which takes ownership\n+\t * and queues it for deferred transmission from its work. The tagger\n+\t * must not touch the skb after this point.\n+\t */\n+\ttagger_data-\u003eonestep_sync_enqueue(dp-\u003eds, dp-\u003eindex, skb);\n+}\n+\n static struct sk_buff *netc_xmit(struct sk_buff *skb,\n \t\t\t\t struct net_device *ndev)\n {\n-\tnetc_fill_tp_tag_subtype0(skb, ndev);\n+\tu8 ptp_flag = NETC_SKB_CB(skb)-\u003eptp_flag;\n+\n+\t/* Fast path: the overwhelming majority of frames are not PTP frames */\n+\tif (likely(!ptp_flag)) {\n+\t\tnetc_fill_tp_tag_subtype0(skb, ndev);\n+\t\treturn skb;\n+\t}\n+\n+\tif (ptp_flag == NETC_PTP_FLAG_ONESTEP) {\n+\t\t/* The switch driver takes ownership of the one-step Sync and\n+\t\t * queues it for deferred TX; the deferred work tags it subtype 1\n+\t\t * and transmits it directly to the conduit. Return NULL so\n+\t\t * dsa_user_xmit() stops processing this skb.\n+\t\t */\n+\t\tnetc_onestep_sync_enqueue(skb, ndev);\n+\t\treturn NULL;\n+\t} else if (ptp_flag == NETC_PTP_FLAG_TWOSTEP) {\n+\t\tnetc_fill_tp_tag_subtype2(skb, ndev);\n+\t} else { /* NETC_PTP_FLAG_DROP */\n+\t\tkfree_skb(skb);\n+\t\treturn NULL;\n+\t}\n \n \treturn skb;\n }\n \n+static int netc_rx_tstamp_process(struct netc_tag_th_subtype1 *tag,\n+\t\t\t\t  struct sk_buff *skb)\n+{\n+\tu64 ts = get_unaligned_be64(\u0026tag-\u003etimestamp);\n+\n+\t/* To_Host Subtype 1 tag is 14 bytes, ensure it and the EtherType\n+\t * behind it are fully present in the linear area before netc_rcv()\n+\t * calls dsa_strip_etype_header() to strip the tag.\n+\t */\n+\tif (unlikely(!pskb_may_pull(skb, NETC_TAG_TH_SUBTYPE1_LEN)))\n+\t\treturn -ENOBUFS;\n+\n+\tNETC_SKB_CB(skb)-\u003etstamp = ts;\n+\n+\treturn 0;\n+}\n+\n+static void netc_twostep_tstamp_process(struct netc_tag_th_subtype2 *tag,\n+\t\t\t\t\tstruct sk_buff *skb)\n+{\n+\tu8 ts_req_id = FIELD_GET(NETC_TAG_TS_REQ_ID, tag-\u003ehr_tsreq_id);\n+\tstruct dsa_port *dp = dsa_user_to_port(skb-\u003edev);\n+\tu64 ts = get_unaligned_be64(\u0026tag-\u003etimestamp);\n+\tstruct netc_tagger_data *tagger_data;\n+\tstruct dsa_switch *ds = dp-\u003eds;\n+\n+\ttagger_data = ds-\u003etagger_data;\n+\tif (unlikely(!tagger_data-\u003etwostep_tstamp_handler))\n+\t\treturn;\n+\n+\ttagger_data-\u003etwostep_tstamp_handler(ds, dp-\u003eindex, ts_req_id, ts);\n+}\n+\n static int netc_get_rx_tag_len(int type, int subtype)\n {\n \t/* Only NETC_TAG_TO_HOST and NETC_TAG_FORWARD are expected in RX,\n@@ -129,11 +271,22 @@ static struct sk_buff *netc_rcv(struct sk_buff *skb,\n \tstruct netc_tag_cmn *tag_cmn;\n \tint tag_len, sw_id, port;\n \tint type, subtype;\n+\tvoid *tag;\n \n-\tif (unlikely(!pskb_may_pull(skb, NETC_TAG_MAX_LEN)))\n+\t/* eth_type_trans() pulled ETH_HLEN bytes, so skb-\u003edata sits 2 bytes\n+\t * past the start of the switch tag (past the TPID) and skb-\u003elen is\n+\t * ETH_HLEN bytes shorter than the original frame length. The longest\n+\t * switch tag is NETC_TAG_MAX_LEN (14) bytes, but since 2 of those\n+\t * bytes are already behind skb-\u003edata, only NETC_TAG_MAX_LEN - 2 bytes\n+\t * need to be in the linear buffer. For the To_Host subtype 2 response\n+\t * frame, whose total length is only 26 bytes with no payload after the\n+\t * tag, this check is the only guard against a too-short frame.\n+\t */\n+\tif (unlikely(!pskb_may_pull(skb, NETC_TAG_MAX_LEN - 2)))\n \t\tgoto err_free_skb;\n \n-\ttag_cmn = dsa_etype_header_pos_rx(skb);\n+\ttag = dsa_etype_header_pos_rx(skb);\n+\ttag_cmn = tag;\n \tif (ntohs(tag_cmn-\u003etpid) != ETH_P_NXP_NETC) {\n \t\tdev_warn_ratelimited(\u0026ndev-\u003edev, \"Unknown TPID 0x%04x\\n\",\n \t\t\t\t     ntohs(tag_cmn-\u003etpid));\n@@ -156,17 +309,40 @@ static struct sk_buff *netc_rcv(struct sk_buff *skb,\n \tif (!skb-\u003edev)\n \t\tgoto err_free_skb;\n \n+\t/* skb-\u003ecb may be used to store hardware RX timestamp, so it must\n+\t * be cleared before processing to avoid data pollution from the\n+\t * previous layer.\n+\t */\n+\tNETC_SKB_CB(skb)-\u003etstamp = 0;\n+\n \ttype = FIELD_GET(NETC_TAG_TYPE, tag_cmn-\u003etype);\n \tsubtype = FIELD_GET(NETC_TAG_SUBTYPE, tag_cmn-\u003etype);\n \tif (type == NETC_TAG_FORWARD) {\n \t\tdsa_default_offload_fwd_mark(skb);\n \t} else if (type == NETC_TAG_TO_HOST) {\n-\t\t/* Currently only subtype0 supported */\n-\t\tif (subtype != NETC_TAG_TH_SUBTYPE0)\n+\t\tswitch (subtype) {\n+\t\tcase NETC_TAG_TH_SUBTYPE0:\n+\t\t\tbreak;\n+\t\tcase NETC_TAG_TH_SUBTYPE1:\n+\t\t\tif (netc_rx_tstamp_process(tag, skb))\n+\t\t\t\tgoto err_free_skb;\n+\t\t\tbreak;\n+\t\tcase NETC_TAG_TH_SUBTYPE2:\n+\t\t\t/* This skb is a hardware-generated response to a\n+\t\t\t * two-step transmit timestamp request. The tag\n+\t\t\t * driver must free the skb after processing.\n+\t\t\t */\n+\t\t\tnetc_twostep_tstamp_process(tag, skb);\n \t\t\tgoto err_free_skb;\n+\t\tdefault:\n+\t\t\tdev_warn_ratelimited(\u0026ndev-\u003edev,\n+\t\t\t\t\t     \"Unsupported To_Host subtype: %d\\n\",\n+\t\t\t\t\t     subtype);\n+\t\t\tgoto err_free_skb;\n+\t\t}\n \t} else {\n \t\tdev_warn_ratelimited(\u0026ndev-\u003edev,\n-\t\t\t\t     \"Unexpected  tag type %d\\n\", type);\n+\t\t\t\t     \"Unexpected tag type %d\\n\", type);\n \t\tgoto err_free_skb;\n \t}\n \n@@ -200,6 +376,28 @@ static void netc_flow_dissect(const struct sk_buff *skb, __be16 *proto,\n \t*proto = ((__be16 *)skb-\u003edata)[(tag_len / 2) - 1];\n }\n \n+static int netc_connect(struct dsa_switch *ds)\n+{\n+\tstruct netc_tagger_data *tagger_data;\n+\n+\ttagger_data = kzalloc_obj(*tagger_data);\n+\tif (!tagger_data)\n+\t\treturn -ENOMEM;\n+\n+\ttagger_data-\u003eonestep_sync_xmit = netc_onestep_sync_xmit;\n+\tds-\u003etagger_data = tagger_data;\n+\n+\treturn 0;\n+}\n+\n+static void netc_disconnect(struct dsa_switch *ds)\n+{\n+\tstruct netc_tagger_data *tagger_data = ds-\u003etagger_data;\n+\n+\tkfree(tagger_data);\n+\tds-\u003etagger_data = NULL;\n+}\n+\n static const struct dsa_device_ops netc_netdev_ops = {\n \t.name\t\t\t= NETC_NAME,\n \t.proto\t\t\t= DSA_TAG_PROTO_NETC,\n@@ -207,6 +405,8 @@ static const struct dsa_device_ops netc_netdev_ops = {\n \t.rcv\t\t\t= netc_rcv,\n \t.needed_headroom\t= NETC_TAG_MAX_LEN,\n \t.flow_dissect\t\t= netc_flow_dissect,\n+\t.connect\t\t= netc_connect,\n+\t.disconnect\t\t= netc_disconnect,\n };\n \n MODULE_DESCRIPTION(\"DSA tag driver for NXP NETC switch family\");\n"
}

2/1 2026/08/08 03:51 agent patch-evaluator
0m Model:
best-expensive

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the NXP NETC switch driver and its associated DSA tagger and PTP timer. These are vendor-specific PCI devices that require physical hardware and cannot be emulated in standard QEMU. Therefore, the code is unreachable in a virtualized fuzzing environment.",
  "WorthFuzzing": false
}

Instruction:
You are an expert Linux kernel maintainer.
Your job is to review a provided patch series and determine
if it makes functional changes to the kernel that should be fuzzed.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively
use your code access tools to examine the actual source code and confirm any assumptions.

Return WorthFuzzing=false if the patch only contains:
- Modifications to Documentation/, Kconfig files, or code comments.
- Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints.
- Changes to numeric constants or macros that do not functionally alter execution flow.
- Code paths that are impossible to reach in virtualized environments like GCE or QEMU,
  even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim).
- Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed,
  ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU.
- Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove)
  that are executed only during PCI hot-unplug or sysfs driver unbind operations.

If it modifies reachable core kernel logic, drivers, or architectures, use your code search
tools to verify the code can be executed, then return WorthFuzzing=true.

When returning WorthFuzzing=true, you MUST ALSO:
1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols.
   Avoid listing generic hot-path functions to prevent skewed test distributions.
   Prefer non-static, non-inlined API entrypoint functions over internal static helper functions
   (which are inlined by the compiler and do not have distinct symbol addresses).
2. Identify any specific CONFIG_ options required to properly test this new/modified feature.
   Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions.
   Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs
   needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs
   output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
For your convenience, here is the diff of the changes:
commit 052f7c54e75559f7b61199a7224bf204f8d95844
Author: syz-cluster <triage@syzkaller.com>
Date:   Sat Aug 8 03:51:11 2026 +0000

    syz-cluster: applied patch under review

diff --git a/drivers/net/dsa/netc/Kconfig b/drivers/net/dsa/netc/Kconfig
index 793f7691a24f3..8770b65d0f62d 100644
--- a/drivers/net/dsa/netc/Kconfig
+++ b/drivers/net/dsa/netc/Kconfig
@@ -4,6 +4,7 @@ config NET_DSA_NETC_SWITCH
 	depends on ARM64 || COMPILE_TEST
 	depends on NET_DSA && PCI
 	depends on NET_VENDOR_FREESCALE
+	depends on PTP_1588_CLOCK_OPTIONAL
 	select NET_DSA_TAG_NETC
 	select FSL_ENETC_MDIO
 	select NXP_NTMP
diff --git a/drivers/net/dsa/netc/Makefile b/drivers/net/dsa/netc/Makefile
index f40b13c702e07..572b833ad80fc 100644
--- a/drivers/net/dsa/netc/Makefile
+++ b/drivers/net/dsa/netc/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_NET_DSA_NETC_SWITCH) += nxp-netc-switch.o
-nxp-netc-switch-objs := netc_main.o netc_platform.o netc_ethtool.o
+nxp-netc-switch-objs := netc_main.o netc_platform.o netc_ethtool.o \
+			netc_ptp.o
diff --git a/drivers/net/dsa/netc/netc_main.c b/drivers/net/dsa/netc/netc_main.c
index 77077352c1a57..55664045ba19d 100644
--- a/drivers/net/dsa/netc/netc_main.c
+++ b/drivers/net/dsa/netc/netc_main.c
@@ -65,6 +65,21 @@ netc_get_tag_protocol(struct dsa_switch *ds, int port,
 	return DSA_TAG_PROTO_NETC;
 }
 
+static int netc_connect_tag_protocol(struct dsa_switch *ds,
+				     enum dsa_tag_protocol proto)
+{
+	struct netc_tagger_data *tagger_data;
+
+	if (proto != DSA_TAG_PROTO_NETC)
+		return -EPROTONOSUPPORT;
+
+	tagger_data = ds->tagger_data;
+	tagger_data->onestep_sync_enqueue = netc_port_onestep_sync_enqueue;
+	tagger_data->twostep_tstamp_handler = netc_port_twostep_tstamp_handler;
+
+	return 0;
+}
+
 static void netc_port_rmw(struct netc_port *np, u32 reg,
 			  u32 mask, u32 val)
 {
@@ -80,7 +95,7 @@ static void netc_port_rmw(struct netc_port *np, u32 reg,
 	netc_port_wr(np, reg, new);
 }
 
-static void netc_mac_port_wr(struct netc_port *np, u32 reg, u32 val)
+void netc_mac_port_wr(struct netc_port *np, u32 reg, u32 val)
 {
 	if (is_netc_pseudo_port(np))
 		return;
@@ -238,6 +253,21 @@ static void netc_get_switch_capabilities(struct netc_switch *priv)
 	priv->num_bp = FIELD_GET(BPCAPR_NUM_BP, val);
 }
 
+static void netc_free_user_ports(struct netc_switch *priv)
+{
+	struct dsa_switch *ds = priv->ds;
+	struct dsa_port *dp;
+
+	dsa_switch_for_each_user_port(dp, ds) {
+		struct netc_port *np = NETC_PORT(ds, dp->index);
+
+		if (np->onestep) {
+			netc_onestep_put(np->onestep);
+			np->onestep = NULL;
+		}
+	}
+}
+
 static int netc_init_all_ports(struct netc_switch *priv)
 {
 	struct device *dev = priv->dev;
@@ -278,18 +308,38 @@ static int netc_init_all_ports(struct netc_switch *priv)
 
 		err = netc_port_get_info_from_dt(np, dp->dn, dev);
 		if (err)
-			return err;
+			goto free_user_ports;
 
 		if (dsa_port_is_user(dp)) {
 			err = netc_port_create_mdio_bus(np, dp->dn);
 			if (err) {
 				dev_err(dev, "Failed to create MDIO bus\n");
-				return err;
+				goto free_user_ports;
 			}
+
+			/* The ipft_hf_eid is initialized to an invalid entry
+			 * ID because the host flood rule (IPFT entry) has not
+			 * been created.
+			 */
+			np->ipft_hf_eid = NTMP_NULL_ENTRY_ID;
+
+			/* Only the user port needs to support PTP feature, so
+			 * PTP-related resources, such as skb_txtstamp_queue,
+			 * tstamp_lock, etc., are initialized only for the user
+			 * port.
+			 */
+			err = netc_port_ptp_init(np);
+			if (err)
+				goto free_user_ports;
 		}
 	}
 
 	return 0;
+
+free_user_ports:
+	netc_free_user_ports(priv);
+
+	return err;
 }
 
 static void netc_init_ntmp_tbl_versions(struct netc_switch *priv)
@@ -549,6 +599,12 @@ static void netc_port_fixed_config(struct netc_port *np)
 	netc_port_rmw(np, NETC_PCR, PCR_L2DOSE | PCR_L3DOSE,
 		      PCR_L2DOSE | PCR_L3DOSE);
 
+	/* Enable ingress port filter table lookup, if no match is found,
+	 * the frame is allowed and passed to the next frame processing
+	 * function.
+	 */
+	netc_port_wr(np, NETC_PIPFCR, PIPFCR_EN);
+
 	/* Set the quanta value of TX PAUSE frame */
 	netc_mac_port_wr(np, NETC_PM_PAUSE_QUANTA(0), NETC_PAUSE_QUANTA);
 
@@ -869,6 +925,15 @@ static int netc_switch_bpt_default_config(struct netc_switch *priv)
 	return 0;
 }
 
+static struct pci_dev *netc_get_ptp_timer(struct netc_switch *priv)
+{
+	struct pci_bus *bus = priv->pdev->bus;
+	u32 devfn = priv->info->tmr_devfn;
+
+	return pci_get_domain_bus_and_slot(pci_domain_nr(bus),
+					   bus->number, devfn);
+}
+
 static int netc_setup(struct dsa_switch *ds)
 {
 	struct netc_switch *priv = ds->priv;
@@ -881,13 +946,23 @@ static int netc_setup(struct dsa_switch *ds)
 
 	netc_get_switch_capabilities(priv);
 
+	/* The PTP timer sits on the same PCI bus as the switch. PCI creates
+	 * every function's pci_dev during bus enumeration, before any driver
+	 * probes, so we can grab the timer's pci_dev here even if the timer
+	 * driver has not probed yet.
+	 */
+	priv->tmr_dev = netc_get_ptp_timer(priv);
+	if (!priv->tmr_dev)
+		dev_info(priv->dev,
+			 "PTP timer PCI device not found\n");
+
 	err = netc_init_all_ports(priv);
 	if (err)
-		return err;
+		goto put_ptp_timer;
 
 	err = netc_init_ntmp_user(priv);
 	if (err)
-		return err;
+		goto free_user_ports;
 
 	INIT_HLIST_HEAD(&priv->fdb_list);
 	mutex_init(&priv->fdbt_lock);
@@ -926,6 +1001,10 @@ static int netc_setup(struct dsa_switch *ds)
 	mutex_destroy(&priv->fdbt_lock);
 	mutex_destroy(&priv->vft_lock);
 	netc_free_ntmp_user(priv);
+free_user_ports:
+	netc_free_user_ports(priv);
+put_ptp_timer:
+	pci_dev_put(priv->tmr_dev);
 
 	return err;
 }
@@ -938,20 +1017,30 @@ static void netc_destroy_all_lists(struct netc_switch *priv)
 	mutex_destroy(&priv->vft_lock);
 }
 
-static void netc_free_host_flood_rules(struct netc_switch *priv)
+static void netc_free_ports_resources(struct netc_switch *priv)
 {
 	struct dsa_port *dp;
 
-	dsa_switch_for_each_user_port(dp, priv->ds) {
+	dsa_switch_for_each_available_port(dp, priv->ds) {
 		struct netc_port *np = priv->ports[dp->index];
 
-		/* No need to clear the hardware IPFT entry. Because PCIe
-		 * FLR will be performed when the switch is re-registered,
-		 * it will reset hardware state. So only need to free the
-		 * memory to avoid memory leak.
+		if (!dsa_port_is_user(dp))
+			continue;
+
+		netc_port_purge_txtstamp_queue(np);
+
+		/* dsa_tree_teardown() calls dsa_tree_teardown_ports() before
+		 * dsa_tree_teardown_switches(), so netc_port_disable() is
+		 * executed before netc_teardown() and purges onestep->queue,
+		 * so here we only need to drop the port's owner reference.
+		 * In-flight one-step skbs still hold references via the
+		 * destructor; the context (and its work) is freed only after
+		 * the conduit frees the last in-flight skb. By then np may
+		 * be gone, but the work no longer dereferences np because
+		 * onestep->active has been cleared.
 		 */
-		kfree(np->host_flood);
-		np->host_flood = NULL;
+		netc_onestep_put(np->onestep);
+		np->onestep = NULL;
 	}
 }
 
@@ -961,8 +1050,9 @@ static void netc_teardown(struct dsa_switch *ds)
 
 	disable_delayed_work_sync(&priv->fdbt_ageing_work);
 	netc_destroy_all_lists(priv);
-	netc_free_host_flood_rules(priv);
 	netc_free_ntmp_user(priv);
+	netc_free_ports_resources(priv);
+	pci_dev_put(priv->tmr_dev);
 }
 
 static bool netc_port_is_emdio_consumer(struct device_node *node)
@@ -1505,6 +1595,7 @@ static int netc_port_enable(struct dsa_switch *ds, int port,
 			    struct phy_device *phy)
 {
 	struct netc_port *np = NETC_PORT(ds, port);
+	struct netc_onestep *onestep = np->onestep;
 	int err;
 
 	if (np->enable)
@@ -1517,6 +1608,12 @@ static int netc_port_enable(struct dsa_switch *ds, int port,
 		return err;
 	}
 
+	if (onestep) {
+		mutex_lock(&onestep->work_lock);
+		onestep->active = true;
+		mutex_unlock(&onestep->work_lock);
+	}
+
 	np->enable = true;
 
 	return 0;
@@ -1525,6 +1622,7 @@ static int netc_port_enable(struct dsa_switch *ds, int port,
 static void netc_port_disable(struct dsa_switch *ds, int port)
 {
 	struct netc_port *np = NETC_PORT(ds, port);
+	struct netc_onestep *onestep = np->onestep;
 
 	/* When .port_disable() is called, .port_enable() may not have been
 	 * called. In this case, both the prepare_count and enable_count of
@@ -1534,6 +1632,13 @@ static void netc_port_disable(struct dsa_switch *ds, int port)
 	if (!np->enable)
 		return;
 
+	if (onestep) {
+		mutex_lock(&onestep->work_lock);
+		onestep->active = false;
+		netc_port_purge_onestep_queue(onestep, true);
+		mutex_unlock(&onestep->work_lock);
+	}
+
 	clk_disable_unprepare(np->ref_clk);
 	np->enable = false;
 }
@@ -1720,8 +1825,6 @@ static int netc_port_add_host_flood_rule(struct netc_port *np,
 	int err;
 
 	if (!uc && !mc) {
-		/* Disable ingress port filter table lookup */
-		netc_port_wr(np, NETC_PIPFCR, 0);
 		np->uc = false;
 		np->mc = false;
 
@@ -1759,40 +1862,36 @@ static int netc_port_add_host_flood_rule(struct netc_port *np,
 	cfge->cfg = cpu_to_le32(cfg);
 
 	err = ntmp_ipft_add_entry(&priv->ntmp, host_flood);
-	if (err) {
-		kfree(host_flood);
-		return err;
-	}
+	if (err)
+		goto free_host_flood;
 
 	np->uc = uc;
 	np->mc = mc;
-	np->host_flood = host_flood;
-	/* Enable ingress port filter table lookup */
-	netc_port_wr(np, NETC_PIPFCR, PIPFCR_EN);
+	np->ipft_hf_eid = host_flood->entry_id;
 
-	return 0;
+free_host_flood:
+	kfree(host_flood);
+
+	return err;
 }
 
-static void netc_port_remove_host_flood(struct netc_port *np,
-					struct ipft_entry_data *host_flood)
+static void netc_port_remove_host_flood(struct netc_port *np, u32 entry_id)
 {
 	struct netc_switch *priv = np->switch_priv;
 	bool disable_host_flood = false;
 
-	if (!host_flood)
+	if (entry_id == NTMP_NULL_ENTRY_ID)
 		return;
 
-	if (np->host_flood == host_flood)
+	if (np->ipft_hf_eid == entry_id)
 		disable_host_flood = true;
 
-	ntmp_ipft_delete_entry(&priv->ntmp, host_flood->entry_id);
-	kfree(host_flood);
+	ntmp_ipft_delete_entry(&priv->ntmp, entry_id);
 
 	if (disable_host_flood) {
-		np->host_flood = NULL;
+		np->ipft_hf_eid = NTMP_NULL_ENTRY_ID;
 		np->uc = false;
 		np->mc = false;
-		netc_port_wr(np, NETC_PIPFCR, 0);
 	}
 }
 
@@ -1800,7 +1899,7 @@ static void netc_port_set_host_flood(struct dsa_switch *ds, int port,
 				     bool uc, bool mc)
 {
 	struct netc_port *np = NETC_PORT(ds, port);
-	struct ipft_entry_data *old_host_flood;
+	u32 old_entry_id;
 
 	/* Do not add host flood rule to ingress port filter table when
 	 * the port has joined a bridge. Otherwise, the ingress frames
@@ -1808,7 +1907,7 @@ static void netc_port_set_host_flood(struct dsa_switch *ds, int port,
 	 * will be redirected directly to the CPU port.
 	 */
 	if (dsa_port_bridge_dev_get(np->dp)) {
-		netc_port_remove_host_flood(np, np->host_flood);
+		netc_port_remove_host_flood(np, np->ipft_hf_eid);
 
 		return;
 	}
@@ -1818,20 +1917,18 @@ static void netc_port_set_host_flood(struct dsa_switch *ds, int port,
 
 	/* IPFT does not support in-place updates to the KEYE element,
 	 * we need to add a new entry and then delete the old one. So
-	 * save the old entry first.
+	 * save the old entry ID first.
 	 */
-	old_host_flood = np->host_flood;
-	np->host_flood = NULL;
+	old_entry_id = np->ipft_hf_eid;
 
 	if (netc_port_add_host_flood_rule(np, uc, mc)) {
-		np->host_flood = old_host_flood;
 		dev_err(ds->dev, "Failed to add host flood rule on port %d\n",
 			port);
 		return;
 	}
 
 	/* Remove the old host flood entry */
-	netc_port_remove_host_flood(np, old_host_flood);
+	netc_port_remove_host_flood(np, old_entry_id);
 }
 
 static int netc_single_vlan_aware_bridge(struct dsa_switch *ds,
@@ -2020,7 +2117,7 @@ static int netc_port_bridge_join(struct dsa_switch *ds, int port,
 	netc_port_set_pvid(np, vlan_unaware_pvid);
 
 out:
-	netc_port_remove_host_flood(np, np->host_flood);
+	netc_port_remove_host_flood(np, np->ipft_hf_eid);
 
 	if (atomic_inc_return(&priv->br_cnt) == 1)
 		schedule_delayed_work(&priv->fdbt_ageing_work,
@@ -2402,6 +2499,7 @@ static const struct phylink_mac_ops netc_phylink_mac_ops = {
 
 static const struct dsa_switch_ops netc_switch_ops = {
 	.get_tag_protocol		= netc_get_tag_protocol,
+	.connect_tag_protocol		= netc_connect_tag_protocol,
 	.setup				= netc_setup,
 	.teardown			= netc_teardown,
 	.phylink_get_caps		= netc_phylink_get_caps,
@@ -2430,6 +2528,11 @@ static const struct dsa_switch_ops netc_switch_ops = {
 	.get_sset_count			= netc_port_get_sset_count,
 	.get_strings			= netc_port_get_strings,
 	.get_ethtool_stats		= netc_port_get_ethtool_stats,
+	.get_ts_info			= netc_get_ts_info,
+	.port_hwtstamp_set		= netc_port_hwtstamp_set,
+	.port_hwtstamp_get		= netc_port_hwtstamp_get,
+	.port_rxtstamp			= netc_port_rxtstamp,
+	.port_txtstamp			= netc_port_txtstamp,
 };
 
 static int netc_switch_probe(struct pci_dev *pdev,
diff --git a/drivers/net/dsa/netc/netc_platform.c b/drivers/net/dsa/netc/netc_platform.c
index 34aeb6fceb3cb..4fd0ce6770c33 100644
--- a/drivers/net/dsa/netc/netc_platform.c
+++ b/drivers/net/dsa/netc/netc_platform.c
@@ -50,6 +50,7 @@ static void imx94_switch_phylink_get_caps(int port,
 
 static const struct netc_switch_info imx94_info = {
 	.num_ports = 4,
+	.tmr_devfn = PCI_DEVFN(0, 1),
 	.phylink_get_caps = imx94_switch_phylink_get_caps,
 };
 
diff --git a/drivers/net/dsa/netc/netc_ptp.c b/drivers/net/dsa/netc/netc_ptp.c
new file mode 100644
index 0000000000000..d0423b3c8c33a
--- /dev/null
+++ b/drivers/net/dsa/netc/netc_ptp.c
@@ -0,0 +1,866 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
+/*
+ * NXP NETC switch driver
+ * Copyright 2025-2026 NXP
+ */
+
+#include <linux/kref.h>
+#include <linux/ptp_classify.h>
+#include <linux/ptp_clock_kernel.h>
+#include <linux/slab.h>
+
+#include "netc_switch.h"
+
+#define NETC_NUM_TS_REQ_ID		16
+#define NETC_TXTSTAMP_TIMEOUT		(5 * HZ)
+#define NETC_MAX_STEP_OFFSET		0x1ff
+
+static void netc_port_set_onestep_control(struct netc_port *np,
+					  bool csum_update, int offset)
+{
+	u32 val;
+
+	val = PM_SINGLE_STEP_EN | FIELD_PREP(PM_SINGLE_STEP_OFFSET, offset);
+	if (csum_update)
+		val |= PM_SINGLE_STEP_CH;
+	netc_mac_port_wr(np, NETC_PM_SINGLE_STEP(0), val);
+}
+
+static void netc_onestep_destroy_work(struct work_struct *work)
+{
+	struct netc_onestep *onestep = container_of(work, struct netc_onestep,
+						    destroy_work);
+
+	/* refcnt reaching zero does not by itself mean onestep->work has
+	 * stopped: the last in-flight skb destructor calls schedule_work(&work)
+	 * *before* the netc_onestep_put() that drops the final reference, so at
+	 * the moment refcnt hits zero onestep->work may still be pending or
+	 * running on another CPU. destroy_work and work are distinct work_structs
+	 * and can run concurrently, so cancel_work_sync() is required to drain
+	 * onestep->work before mutex_destroy()/kfree() below, otherwise a
+	 * still-running work would touch freed memory. No new schedule_work(&work)
+	 * can occur after this point because no references remain, so this
+	 * cancel is final.
+	 */
+	cancel_work_sync(&onestep->work);
+	mutex_destroy(&onestep->work_lock);
+	kfree(onestep);
+}
+
+static void netc_onestep_release(struct kref *ref)
+{
+	struct netc_onestep *onestep = container_of(ref, struct netc_onestep,
+						    refcnt);
+
+	/* This may be called from the skb destructor in softirq context
+	 * (napi_consume_skb()), where cancel_work_sync() must not be used.
+	 * Defer the final teardown to process context.
+	 */
+	schedule_work(&onestep->destroy_work);
+}
+
+static void netc_onestep_get(struct netc_onestep *onestep)
+{
+	kref_get(&onestep->refcnt);
+}
+
+void netc_onestep_put(struct netc_onestep *onestep)
+{
+	kref_put(&onestep->refcnt, netc_onestep_release);
+}
+
+static void netc_onestep_skb_destructor(struct sk_buff *skb)
+{
+	struct netc_onestep *onestep = skb_shinfo(skb)->destructor_arg;
+
+	/* skb has been transmitted by hardware. Schedule work to send the next
+	 * queued one-step Sync packet, then release this skb's reference on the
+	 * context. If the port has already been torn down and this is the last
+	 * reference, the context is freed via netc_onestep_release().
+	 */
+	schedule_work(&onestep->work);
+	netc_onestep_put(onestep);
+}
+
+static void netc_port_program_onestep(struct netc_port *np,
+				      struct netc_onestep *onestep,
+				      struct sk_buff *skb,
+				      u64 tstamp)
+{
+	u16 correction_offset = NETC_SKB_CB(skb)->correction_offset;
+	u16 tstamp_offset = NETC_SKB_CB(skb)->timestamp_offset;
+	u8 *hdr = skb_mac_header(skb);
+	bool csum_update = false;
+	__be32 new_sec_l, new_ns;
+	__be16 new_sec_h;
+	u64 sec;
+	u32 ns;
+
+	NETC_SKB_CB(skb)->tstamp = tstamp;
+	NETC_SKB_CB(skb)->ptp_flag = NETC_PTP_FLAG_ONESTEP;
+
+	/* Update originTimestamp field of Sync packet
+	 * - 48 bits seconds field
+	 * - 32 bits nanoseconds field
+	 */
+	sec = div_u64_rem(tstamp, NSEC_PER_SEC, &ns);
+	new_sec_h = htons((sec >> 32) & 0xffff);
+	new_sec_l = htonl(sec & 0xffffffff);
+	new_ns = htonl(ns);
+
+	if (NETC_SKB_CB(skb)->is_udp) {
+		__be32 old_sec_l, old_ns;
+		struct udphdr *uh;
+		__be16 old_sec_h;
+
+		if (skb->ip_summed == CHECKSUM_PARTIAL) {
+			csum_update = true;
+			goto update_timestamp;
+		}
+
+		if (unlikely(!skb_transport_header_was_set(skb)))
+			uh = (struct udphdr *)(hdr + tstamp_offset -
+					       sizeof(struct ptp_header) -
+					       sizeof(struct udphdr));
+		else
+			uh = udp_hdr(skb);
+
+		/* For IPv4, a UDP checksum of zero on the wire means "no
+		 * checksum". For IPv6, its UDP checksum is mandatory and
+		 * never zero.
+		 */
+		if (!uh->check)
+			goto update_timestamp;
+
+		old_sec_h = __get_unaligned_t(__be16, hdr + tstamp_offset);
+		old_sec_l = __get_unaligned_t(__be32, hdr + tstamp_offset + 2);
+		old_ns = __get_unaligned_t(__be32, hdr + tstamp_offset + 6);
+		inet_proto_csum_replace2(&uh->check, skb, old_sec_h,
+					 new_sec_h, false);
+		inet_proto_csum_replace4(&uh->check, skb, old_sec_l,
+					 new_sec_l, false);
+		inet_proto_csum_replace4(&uh->check, skb, old_ns,
+					 new_ns, false);
+		csum_update = true;
+	}
+
+update_timestamp:
+	__put_unaligned_t(__be16, new_sec_h, hdr + tstamp_offset);
+	__put_unaligned_t(__be32, new_sec_l, hdr + tstamp_offset + 2);
+	__put_unaligned_t(__be32, new_ns, hdr + tstamp_offset + 6);
+
+	netc_port_set_onestep_control(np, csum_update, correction_offset);
+
+	/* Orphan the skb to release the socket send buffer quota immediately.
+	 * This is safe because sock_wfree() does not access skb->data or any
+	 * frame content. After skb_orphan(), we install our own destructor so
+	 * that when the conduit driver frees the skb after TX completion, we
+	 * get notified to send the next queued Sync packet.
+	 */
+	skb_orphan(skb);
+	netc_onestep_get(onestep); /* in-flight reference */
+	skb_shinfo(skb)->destructor_arg = onestep;
+	skb->destructor = netc_onestep_skb_destructor;
+}
+
+static u64 netc_get_phc_time(struct netc_switch *priv)
+{
+	if (unlikely(!priv->tmr_dev))
+		return 0;
+
+	return netc_timer_get_current_time(priv->tmr_dev);
+}
+
+void netc_port_onestep_work(struct work_struct *work)
+{
+	struct netc_onestep *onestep = container_of(work, struct netc_onestep,
+						    work);
+	struct netc_tagger_data *tagger_data;
+	struct netc_switch *priv;
+	struct netc_port *np;
+	struct sk_buff *skb;
+	u64 tstamp;
+
+	/* Serialize the whole hardware access against port disable. work_lock
+	 * is a mutex (this runs in process context and netc_get_phc_time() may
+	 * sleep). If the port has been disabled, bail out immediately; np and
+	 * priv are only dereferenced after the @active check passes, so they
+	 * are always valid here.
+	 */
+	mutex_lock(&onestep->work_lock);
+	if (unlikely(!onestep->active)) {
+		netc_port_purge_onestep_queue(onestep, true);
+		goto unlock_work;
+	}
+
+	/* Send only one queued Sync per run. The shared SINGLE_STEP register
+	 * must match the frame currently being transmitted, so the next frame
+	 * is programmed only after this one completes TX, when its skb
+	 * destructor reschedules this work. Dequeue under onestep->queue_lock,
+	 * and if the queue has drained, release the in-flight slot so a later
+	 * frame from the xmit path kicks the work again.
+	 */
+	spin_lock_bh(&onestep->queue_lock);
+	skb = __skb_dequeue(&onestep->queue);
+	if (!skb) {
+		onestep->in_flight = false;
+		spin_unlock_bh(&onestep->queue_lock);
+		goto unlock_work;
+	}
+	spin_unlock_bh(&onestep->queue_lock);
+
+	np = onestep->np;
+	priv = np->switch_priv;
+	tstamp = netc_get_phc_time(priv);
+	if (unlikely(!tstamp)) {
+		/* The PTP timer is not available, so there is no correct
+		 * timestamp to program. Drop this frame and re-kick to process
+		 * the remaining queued frames.
+		 *
+		 * netc_port_program_onestep() has not run for this skb yet, so
+		 * netc_onestep_skb_destructor() is not installed on it. Freeing
+		 * it therefore does not reschedule the work, so the work must be
+		 * rescheduled explicitly to keep draining the queue.
+		 */
+		dev_dbg_ratelimited(priv->dev,
+				    "Port %d PTP timer unavailable, drop Sync\n",
+				    np->dp->index);
+		kfree_skb(skb);
+		schedule_work(&onestep->work);
+		goto unlock_work;
+	}
+
+	/* Reuse the offsets cached at enqueue time; only the timestamp is
+	 * read fresh so it reflects the actual TX moment.
+	 */
+	netc_port_program_onestep(np, onestep, skb, tstamp);
+
+	/* Tag and hand the frame directly to the conduit via the tagger,
+	 * bypassing dsa_user_xmit() so the TX stats are not counted twice.
+	 * And there is no need to check if tagger_data is NULL, because
+	 * dsa_tree_teardown_ports() executes before
+	 * dsa_switch_teardown_tag_protocol(), so tagger_data cannot be
+	 * NULL when onestep->active is set.
+	 */
+	tagger_data = priv->ds->tagger_data;
+	tagger_data->onestep_sync_xmit(skb, np->dp->user);
+
+unlock_work:
+	mutex_unlock(&onestep->work_lock);
+}
+
+static int netc_port_onestep_alloc(struct netc_port *np)
+{
+	struct netc_onestep *onestep;
+
+	onestep = kzalloc_obj(*onestep);
+	if (!onestep)
+		return -ENOMEM;
+
+	kref_init(&onestep->refcnt); /* port (owner) reference */
+	np->onestep = onestep;
+	onestep->np = np;
+	mutex_init(&onestep->work_lock);
+	spin_lock_init(&onestep->queue_lock);
+	__skb_queue_head_init(&onestep->queue);
+	INIT_WORK(&onestep->work, netc_port_onestep_work);
+	INIT_WORK(&onestep->destroy_work, netc_onestep_destroy_work);
+
+	return 0;
+}
+
+int netc_port_ptp_init(struct netc_port *np)
+{
+	/* Initialize to invalid entry IDs */
+	for (int i = 0; i < NETC_PTP_MAX; i++)
+		np->ptp_ipft_eid[i] = NTMP_NULL_ENTRY_ID;
+
+	spin_lock_init(&np->tstamp_lock);
+	__skb_queue_head_init(&np->skb_txtstamp_queue);
+
+	return netc_port_onestep_alloc(np);
+}
+
+static int netc_get_phc_index(struct netc_switch *priv)
+{
+	if (!priv->tmr_dev)
+		return -1;
+
+	return ptp_clock_index_by_dev(&priv->tmr_dev->dev);
+}
+
+int netc_get_ts_info(struct dsa_switch *ds, int port,
+		     struct kernel_ethtool_ts_info *info)
+{
+	struct netc_switch *priv = ds->priv;
+
+	info->phc_index = netc_get_phc_index(priv);
+	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) |
+			 BIT(HWTSTAMP_TX_ONESTEP_SYNC);
+
+	info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
+			   BIT(HWTSTAMP_FILTER_PTP_V2_EVENT) |
+			   BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
+			   BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT);
+
+	return 0;
+}
+
+static void netc_port_del_ptp_filter(struct netc_port *np)
+{
+	struct netc_switch *priv = np->switch_priv;
+	u32 entry_id;
+	int i;
+
+	for (i = 0; i < NETC_PTP_MAX; i++) {
+		entry_id = np->ptp_ipft_eid[i];
+		if (entry_id != NTMP_NULL_ENTRY_ID) {
+			/* There is no need to check the return value of
+			 * ntmp_ipft_delete_entry(); in general, deleted
+			 * existing entries will be successful.
+			 */
+			ntmp_ipft_delete_entry(&priv->ntmp, entry_id);
+			np->ptp_ipft_eid[i] = NTMP_NULL_ENTRY_ID;
+		}
+	}
+}
+
+static int netc_build_ptp_ipft_keye(struct ipft_keye_data *keye, int port,
+				    enum netc_ptp_type type)
+{
+	u16 src_port, frm_attr_flags;
+
+	keye->precedence = cpu_to_le16(NETC_IPFT_PTP_PRECEDENCE);
+	src_port = FIELD_PREP(IPFT_SRC_PORT, port);
+	src_port |= IPFT_SRC_PORT_MASK;
+	keye->src_port = cpu_to_le16(src_port);
+
+	switch (type) {
+	case NETC_PTP_L2:
+		keye->ethertype = htons(ETH_P_1588);
+		keye->ethertype_mask = htons(0xffff);
+		break;
+	case NETC_PTP_L4_IPV4_EVENT:
+	case NETC_PTP_L4_IPV4_GENERAL:
+	case NETC_PTP_L4_IPV6_EVENT:
+	case NETC_PTP_L4_IPV6_GENERAL:
+		frm_attr_flags = IPFT_FAF_IP_HDR | FIELD_PREP(IPFT_FAF_L4_CODE,
+				 IPFT_FAF_UDP_HDR);
+		if (type == NETC_PTP_L4_IPV6_EVENT ||
+		    type == NETC_PTP_L4_IPV6_GENERAL)
+			frm_attr_flags |= IPFT_FAF_IP_VER6;
+
+		keye->frm_attr_flags = cpu_to_le16(frm_attr_flags);
+
+		/* Set IP version bit in flags_mask to match IPv4 or IPv6
+		 * packets
+		 */
+		frm_attr_flags |= IPFT_FAF_IP_VER6;
+		keye->frm_attr_flags_mask = cpu_to_le16(frm_attr_flags);
+		keye->ip_protocol = IPPROTO_UDP;
+		keye->ip_protocol_mask = 0xff;
+
+		if (type == NETC_PTP_L4_IPV4_EVENT ||
+		    type == NETC_PTP_L4_IPV6_EVENT)
+			keye->l4_dst_port = htons(PTP_EV_PORT);
+		else
+			keye->l4_dst_port = htons(PTP_GEN_PORT);
+
+		keye->l4_dst_port_mask = htons(0xffff);
+		break;
+	default:
+		return -ERANGE;
+	}
+
+	return 0;
+}
+
+static int netc_port_add_ipft_ptp_entry(struct netc_port *np,
+					enum netc_ptp_type type)
+{
+	struct netc_switch *priv = np->switch_priv;
+	struct ipft_entry_data *entry;
+	struct ipft_keye_data *keye;
+	u32 cfg;
+	int err;
+
+	entry = kzalloc_obj(*entry);
+	if (!entry)
+		return -ENOMEM;
+
+	keye = &entry->keye;
+	err = netc_build_ptp_ipft_keye(keye, np->dp->index, type);
+	if (err)
+		goto free_entry;
+
+	cfg = FIELD_PREP(IPFT_FLTFA, IPFT_FLTFA_REDIRECT);
+	cfg |= FIELD_PREP(IPFT_HR, NETC_HR_PTP_TRAP);
+	cfg |= IPFT_TIMECAPE | IPFT_RRT;
+	entry->cfge.cfg = cpu_to_le32(cfg);
+
+	err = ntmp_ipft_add_entry(&priv->ntmp, entry);
+	if (err)
+		goto free_entry;
+
+	np->ptp_ipft_eid[type] = entry->entry_id;
+
+free_entry:
+	kfree(entry);
+
+	return err;
+}
+
+static int netc_port_add_l2_ptp_filter(struct netc_port *np)
+{
+	return netc_port_add_ipft_ptp_entry(np, NETC_PTP_L2);
+}
+
+static int netc_port_add_l4_ptp_filter(struct netc_port *np)
+{
+	int err;
+
+	err = netc_port_add_ipft_ptp_entry(np, NETC_PTP_L4_IPV4_EVENT);
+	if (err)
+		return err;
+
+	err = netc_port_add_ipft_ptp_entry(np, NETC_PTP_L4_IPV4_GENERAL);
+	if (err)
+		goto del_ptp_filter;
+
+	err = netc_port_add_ipft_ptp_entry(np, NETC_PTP_L4_IPV6_EVENT);
+	if (err)
+		goto del_ptp_filter;
+
+	err = netc_port_add_ipft_ptp_entry(np, NETC_PTP_L4_IPV6_GENERAL);
+	if (err)
+		goto del_ptp_filter;
+
+	return 0;
+
+del_ptp_filter:
+	netc_port_del_ptp_filter(np);
+
+	return err;
+}
+
+static int netc_port_add_l2_l4_ptp_filter(struct netc_port *np)
+{
+	int err;
+
+	err = netc_port_add_l2_ptp_filter(np);
+	if (err)
+		return err;
+
+	err = netc_port_add_l4_ptp_filter(np);
+	if (err)
+		goto del_ptp_filter;
+
+	return 0;
+
+del_ptp_filter:
+	netc_port_del_ptp_filter(np);
+
+	return err;
+}
+
+static int netc_port_set_ptp_filter(struct netc_port *np, int rx_filter)
+{
+	int err = 0;
+
+	if (np->ptp_rx_filter == rx_filter)
+		return 0;
+
+	if (np->ptp_rx_filter != HWTSTAMP_FILTER_NONE ||
+	    rx_filter == HWTSTAMP_FILTER_NONE) {
+		netc_port_del_ptp_filter(np);
+		np->ptp_rx_filter = HWTSTAMP_FILTER_NONE;
+	}
+
+	switch (rx_filter) {
+	case HWTSTAMP_FILTER_NONE:
+		break;
+	case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
+		err = netc_port_add_l2_ptp_filter(np);
+		break;
+	case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
+		err = netc_port_add_l4_ptp_filter(np);
+		break;
+	case HWTSTAMP_FILTER_PTP_V2_EVENT:
+		err = netc_port_add_l2_l4_ptp_filter(np);
+		break;
+	default:
+		err = -ERANGE;
+	}
+
+	if (err)
+		return err;
+
+	np->ptp_rx_filter = rx_filter;
+
+	return 0;
+}
+
+void netc_port_purge_txtstamp_queue(struct netc_port *np)
+{
+	struct sk_buff_head free_list;
+
+	__skb_queue_head_init(&free_list);
+
+	spin_lock_bh(&np->tstamp_lock);
+	skb_queue_splice_init(&np->skb_txtstamp_queue, &free_list);
+	spin_unlock_bh(&np->tstamp_lock);
+
+	__skb_queue_purge(&free_list);
+}
+
+void netc_port_purge_onestep_queue(struct netc_onestep *onestep,
+				   bool clear_flight)
+{
+	struct sk_buff_head free_list;
+
+	__skb_queue_head_init(&free_list);
+
+	spin_lock_bh(&onestep->queue_lock);
+	skb_queue_splice_init(&onestep->queue, &free_list);
+	if (clear_flight)
+		onestep->in_flight = false;
+	spin_unlock_bh(&onestep->queue_lock);
+
+	__skb_queue_purge(&free_list);
+}
+
+int netc_port_hwtstamp_set(struct dsa_switch *ds, int port,
+			   struct kernel_hwtstamp_config *config,
+			   struct netlink_ext_ack *extack)
+{
+	struct netc_port *np = NETC_PORT(ds, port);
+	struct netc_switch *priv = ds->priv;
+	int rx_filter, err;
+
+	if ((config->tx_type != HWTSTAMP_TX_OFF ||
+	     config->rx_filter != HWTSTAMP_FILTER_NONE) &&
+	    !priv->tmr_dev)
+		return -EOPNOTSUPP;
+
+	switch (config->tx_type) {
+	case HWTSTAMP_TX_ON:
+	case HWTSTAMP_TX_OFF:
+	case HWTSTAMP_TX_ONESTEP_SYNC:
+		break;
+	default:
+		return -ERANGE;
+	}
+
+	switch (config->rx_filter) {
+	case HWTSTAMP_FILTER_NONE:
+		rx_filter = HWTSTAMP_FILTER_NONE;
+		break;
+	case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
+	case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
+	case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
+		rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
+		break;
+	case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
+	case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
+	case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
+		rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
+		break;
+	case HWTSTAMP_FILTER_PTP_V2_EVENT:
+	case HWTSTAMP_FILTER_PTP_V2_SYNC:
+	case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
+		rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
+		break;
+	default:
+		return -ERANGE;
+	}
+
+	err = netc_port_set_ptp_filter(np, rx_filter);
+	if (err) {
+		NL_SET_ERR_MSG_MOD(extack, "Failed to set PTP filter");
+		return err;
+	}
+
+	WRITE_ONCE(np->ptp_tx_type, config->tx_type);
+	if (config->tx_type == HWTSTAMP_TX_OFF)
+		netc_port_purge_txtstamp_queue(np);
+
+	if (config->tx_type != HWTSTAMP_TX_ONESTEP_SYNC)
+		netc_port_purge_onestep_queue(np->onestep, false);
+
+	config->rx_filter = rx_filter;
+
+	return 0;
+}
+
+int netc_port_hwtstamp_get(struct dsa_switch *ds, int port,
+			   struct kernel_hwtstamp_config *config)
+{
+	struct netc_port *np = NETC_PORT(ds, port);
+
+	config->tx_type = READ_ONCE(np->ptp_tx_type);
+	config->rx_filter = np->ptp_rx_filter;
+
+	return 0;
+}
+
+static void netc_port_txtstamp_twostep(struct netc_port *np,
+				       struct sk_buff *nskb)
+{
+	DECLARE_BITMAP(ts_req_id_bitmap, NETC_NUM_TS_REQ_ID);
+	struct sk_buff *clone = skb_clone_sk(nskb);
+	struct netc_switch *priv = np->switch_priv;
+	struct sk_buff_head free_list;
+	struct sk_buff *skb, *skb_tmp;
+	unsigned long ts_req_id;
+	int err = 0;
+
+	if (unlikely(!clone))
+		return;
+
+	bitmap_zero(ts_req_id_bitmap, NETC_NUM_TS_REQ_ID);
+	__skb_queue_head_init(&free_list);
+	spin_lock_bh(&np->tstamp_lock);
+
+	skb_queue_walk_safe(&np->skb_txtstamp_queue, skb, skb_tmp) {
+		if (time_before(NETC_SKB_CB(skb)->ptp_tx_time +
+				NETC_TXTSTAMP_TIMEOUT, jiffies)) {
+			dev_dbg_ratelimited(priv->dev,
+					    "Port %d ts_req_id %u which seems lost\n",
+					    np->dp->index, NETC_SKB_CB(skb)->ts_req_id);
+
+			__skb_unlink(skb, &np->skb_txtstamp_queue);
+			__skb_queue_tail(&free_list, skb);
+		} else {
+			__set_bit(NETC_SKB_CB(skb)->ts_req_id, ts_req_id_bitmap);
+		}
+	}
+
+	ts_req_id = find_first_zero_bit(ts_req_id_bitmap, NETC_NUM_TS_REQ_ID);
+	if (ts_req_id == NETC_NUM_TS_REQ_ID) {
+		dev_dbg_ratelimited(priv->dev,
+				    "Port %d has no available ts_req_id\n",
+				    np->dp->index);
+		err = -EBUSY;
+		goto unlock_tstamp;
+	}
+
+	NETC_SKB_CB(nskb)->ptp_flag = NETC_PTP_FLAG_TWOSTEP;
+	NETC_SKB_CB(nskb)->ts_req_id = ts_req_id;
+	NETC_SKB_CB(clone)->ts_req_id = ts_req_id;
+	NETC_SKB_CB(clone)->ptp_tx_time = jiffies;
+	skb_shinfo(clone)->tx_flags |= SKBTX_IN_PROGRESS;
+	__skb_queue_tail(&np->skb_txtstamp_queue, clone);
+
+unlock_tstamp:
+	spin_unlock_bh(&np->tstamp_lock);
+
+	if (err)
+		kfree_skb(clone);
+
+	/* Free timed-out SKBs outside the spinlock to avoid calling
+	 * kfree_skb() with a destructor (sock_efree) under a spinlock.
+	 */
+	__skb_queue_purge(&free_list);
+}
+
+void netc_port_twostep_tstamp_handler(struct dsa_switch *ds, int port,
+				      u8 ts_req_id, u64 ts)
+{
+	struct sk_buff *skb, *skb_tmp, *skb_match = NULL;
+	struct netc_port *np = NETC_PORT(ds, port);
+	struct skb_shared_hwtstamps hwtstamps;
+	struct netc_switch *priv = ds->priv;
+
+	spin_lock_bh(&np->tstamp_lock);
+	skb_queue_walk_safe(&np->skb_txtstamp_queue, skb, skb_tmp) {
+		if (NETC_SKB_CB(skb)->ts_req_id != ts_req_id)
+			continue;
+
+		__skb_unlink(skb, &np->skb_txtstamp_queue);
+		skb_match = skb;
+		break;
+	}
+	spin_unlock_bh(&np->tstamp_lock);
+
+	if (!skb_match) {
+		dev_dbg_ratelimited(priv->dev,
+				    "Port %d ts_req_id %u which seems lost\n",
+				    port, ts_req_id);
+		return;
+	}
+
+	hwtstamps.hwtstamp = ns_to_ktime(ts);
+	skb_complete_tx_timestamp(skb_match, &hwtstamps);
+}
+
+bool netc_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb,
+			unsigned int type)
+{
+	struct skb_shared_hwtstamps *hwtstamps = skb_hwtstamps(skb);
+	u64 ts = NETC_SKB_CB(skb)->tstamp;
+
+	/* ts == 0 indicates the hardware did not capture the RX timestamp
+	 * of the frame.
+	 */
+	if (!ts)
+		return false;
+
+	hwtstamps->hwtstamp = ns_to_ktime(ts);
+
+	return false;
+}
+
+static void netc_port_prepare_onestep_sync(struct netc_port *np,
+					   struct sk_buff *skb,
+					   u32 ptp_class, bool *twostep)
+{
+	struct netc_switch *priv = np->switch_priv;
+	u16 correction_offset, tstamp_offset;
+	struct ptp_header *ptp_hdr;
+	u8 msg_type, twostep_flag;
+	bool is_udp = false;
+	u32 pkt_type;
+	u8 *pkt_hdr;
+
+	if (unlikely(skb_linearize(skb))) {
+		NETC_SKB_CB(skb)->ptp_flag = NETC_PTP_FLAG_DROP;
+		return;
+	}
+
+	ptp_hdr = ptp_parse_header(skb, ptp_class);
+	if (unlikely(!ptp_hdr)) {
+		NETC_SKB_CB(skb)->ptp_flag = NETC_PTP_FLAG_DROP;
+		dev_dbg_ratelimited(priv->dev,
+				    "Port %d failed to parse Sync header\n",
+				    np->dp->index);
+		return;
+	}
+
+	msg_type = ptp_get_msgtype(ptp_hdr, ptp_class);
+	twostep_flag = ptp_hdr->flag_field[0] & 0x2;
+
+	pkt_hdr = skb_mac_header(skb);
+	correction_offset = (u8 *)&ptp_hdr->correction - pkt_hdr;
+	tstamp_offset = (u8 *)ptp_hdr + sizeof(*ptp_hdr) - pkt_hdr;
+
+	/* Ensure that the entire originTimestamp field is present in the
+	 * linear buffer of the skb and the correction_offset must be within
+	 * the hardware capability.
+	 */
+	if (unlikely(tstamp_offset + 10 > skb_headlen(skb) ||
+		     correction_offset > NETC_MAX_STEP_OFFSET)) {
+		NETC_SKB_CB(skb)->ptp_flag = NETC_PTP_FLAG_DROP;
+		dev_dbg_ratelimited(priv->dev,
+				    "Port %d PTP offset check error\n",
+				    np->dp->index);
+		return;
+	}
+
+	/* Only a Sync frame with the twoStepFlag cleared can use one-step
+	 * timestamping. A frame that requests two-step (or is not a Sync)
+	 * carries different on-wire fields, so this is a real classification;
+	 * report it through *twostep so the caller falls back to the two-step
+	 * path.
+	 */
+	if (msg_type != PTP_MSGTYPE_SYNC || twostep_flag != 0) {
+		*twostep = true;
+		return;
+	}
+
+	/* This is a genuine one-step Sync frame. skb_shinfo()->destructor_arg
+	 * is later used to pass the np->onestep pointer to
+	 * netc_onestep_skb_destructor() for TX completion notification.
+	 * MSG_ZEROCOPY also uses destructor_arg (via skb_zcopy_init()) to
+	 * track user-space page references. Overwriting it in that case would
+	 * leak the ubuf_info reference and prevent user pages from being
+	 * released. PTP applications do not use MSG_ZEROCOPY, but guard
+	 * against it defensively.
+	 */
+	if (skb_zcopy(skb)) {
+		NETC_SKB_CB(skb)->ptp_flag = NETC_PTP_FLAG_DROP;
+		dev_dbg_ratelimited(priv->dev,
+				    "Port %d one-step Sync not supported on zerocopy skb\n",
+				    np->dp->index);
+		return;
+	}
+
+	pkt_type = ptp_class & PTP_CLASS_PMASK;
+	if (pkt_type == PTP_CLASS_IPV4 || pkt_type == PTP_CLASS_IPV6)
+		is_udp = true;
+
+	/* Cache the parsing results so the tagger xmit path and the deferred
+	 * work do not need to re-parse the PTP header, and so that
+	 * netc_port_program_onestep() can derive these parameters from the
+	 * skb.
+	 */
+	NETC_SKB_CB(skb)->correction_offset = correction_offset;
+	NETC_SKB_CB(skb)->timestamp_offset = tstamp_offset;
+	NETC_SKB_CB(skb)->is_udp = is_udp;
+	NETC_SKB_CB(skb)->ptp_flag = NETC_PTP_FLAG_ONESTEP;
+}
+
+void netc_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
+{
+	struct netc_port *np = NETC_PORT(ds, port);
+	int tx_type = READ_ONCE(np->ptp_tx_type);
+	bool twostep = false;
+	u32 ptp_class;
+
+	NETC_SKB_CB(skb)->ptp_flag = 0;
+	ptp_class = ptp_classify_raw(skb);
+	if (ptp_class == PTP_CLASS_NONE)
+		return;
+
+	if (tx_type == HWTSTAMP_TX_ONESTEP_SYNC)
+		netc_port_prepare_onestep_sync(np, skb, ptp_class, &twostep);
+
+	if (tx_type == HWTSTAMP_TX_ON || twostep)
+		netc_port_txtstamp_twostep(np, skb);
+}
+
+void netc_port_onestep_sync_enqueue(struct dsa_switch *ds, int port,
+				    struct sk_buff *skb)
+{
+	struct netc_port *np = NETC_PORT(ds, port);
+	struct netc_onestep *onestep = np->onestep;
+	bool kick = false;
+
+	/* This runs in the xmit path (softirq / BH-disabled), so it must not
+	 * sleep: only queue the frame here and let netc_port_onestep_work()
+	 * program the SINGLE_STEP register and transmit it from process
+	 * context. The shared SINGLE_STEP register can describe only one frame
+	 * at a time, so at most one one-step Sync may be in flight. Track that
+	 * with @in_flight under onestep->queue_lock.
+	 *
+	 * Enqueue the frame and, only if no frame is currently in flight, claim
+	 * the in-flight slot and kick the work. When a frame is already in
+	 * flight, just queue: its skb destructor will kick the work to send the
+	 * next one once it completes TX, so the frames are transmitted strictly
+	 * one at a time in order.
+	 *
+	 * PTP Sync frames are periodic, low-rate control-plane frames and only
+	 * reach this TX path when the local socket requested hardware TX
+	 * timestamping on a one-step port, so the queue cannot be flooded and
+	 * needs no depth cap.
+	 */
+	spin_lock_bh(&onestep->queue_lock);
+	__skb_queue_tail(&onestep->queue, skb);
+	if (!onestep->in_flight) {
+		onestep->in_flight = true;
+		kick = true;
+	}
+	spin_unlock_bh(&onestep->queue_lock);
+
+	/* Ownership is transferred to the queue; netc_xmit() stops processing
+	 * this skb. The work will program and transmit it.
+	 */
+	if (kick)
+		schedule_work(&onestep->work);
+}
diff --git a/drivers/net/dsa/netc/netc_switch.h b/drivers/net/dsa/netc/netc_switch.h
index 305f2a92e2f9a..98d4842441df2 100644
--- a/drivers/net/dsa/netc/netc_switch.h
+++ b/drivers/net/dsa/netc/netc_switch.h
@@ -9,6 +9,7 @@
 #include <linux/dsa/tag_netc.h>
 #include <linux/fsl/netc_global.h>
 #include <linux/fsl/ntmp.h>
+#include <linux/mutex.h>
 #include <linux/of_device.h>
 #include <linux/of_net.h>
 #include <linux/pci.h>
@@ -53,10 +54,16 @@
 #define NETC_FDBT_AGEING_DELAY		(3 * HZ)
 #define NETC_FDBT_AGEING_THRESH		100
 
+/* PTP frames have a higher priority, so a higher priority is defined to
+ * prioritize matching.
+ */
+#define NETC_IPFT_PTP_PRECEDENCE	0xf000
+
 struct netc_switch;
 
 struct netc_switch_info {
 	u32 num_ports;
+	u32 tmr_devfn;
 	void (*phylink_get_caps)(int port, struct phylink_config *config);
 };
 
@@ -66,9 +73,57 @@ struct netc_port_caps {
 	u32 pseudo_link:1;
 };
 
+enum netc_ptp_type {
+	NETC_PTP_L2,
+	NETC_PTP_L4_IPV4_EVENT,
+	NETC_PTP_L4_IPV4_GENERAL,
+	NETC_PTP_L4_IPV6_EVENT,
+	NETC_PTP_L4_IPV6_GENERAL,
+	NETC_PTP_MAX,
+};
+
 enum netc_host_reason {
 	/* Software defined host reasons */
 	NETC_HR_HOST_FLOOD = 8,
+	NETC_HR_PTP_TRAP   = 9,
+};
+
+/* One-step Sync serialization context.
+ *
+ * Its lifetime is decoupled from the devm-allocated netc_port. An in-flight
+ * one-step Sync skb keeps a reference on this context via its skb destructor,
+ * so the context outlives the port teardown until the conduit frees the last
+ * in-flight skb after TX completion. Once the port is disabled, @active is
+ * cleared and the work stops touching any devm memory (netc_port/netc_switch)
+ * or the unregistered user netdev or the tagger_data.
+ */
+struct netc_onestep {
+	struct netc_port *np;
+	struct kref refcnt;
+	/* Process-context lock: serializes the deferred TX work against port
+	 * teardown, so the work never touches the devm-allocated netc_port /
+	 * netc_switch or the unregistered user netdev after teardown. Held
+	 * across netc_get_phc_time(), which may sleep, hence a mutex.
+	 */
+	struct mutex work_lock;
+	/* Serialize access to in_flight and queue */
+	spinlock_t queue_lock;
+	bool active;	/* set when port is enabled, under @work_lock */
+	/* In-flight slot: true while one one-step Sync frame is programmed
+	 * into the shared SINGLE_STEP register and being transmitted. Only one
+	 * frame may be in flight at a time, so the next queued frame is sent
+	 * only after the current one completes TX (its skb destructor kicks
+	 * the work). Accessed under queue_lock, from both the softirq xmit
+	 * path and the process-context work.
+	 */
+	bool in_flight;
+	/* Pending one-step Sync frames. Enqueued from the softirq xmit path and
+	 * dequeued by the process-context work; the list is serialized by
+	 * queue_lock together with @in_flight.
+	 */
+	struct sk_buff_head queue;
+	struct work_struct work;	/* drains @queue */
+	struct work_struct destroy_work; /* frees the context in process ctx */
 };
 
 struct netc_port {
@@ -84,7 +139,17 @@ struct netc_port {
 	u16 uc:1;
 	u16 mc:1;
 	u16 pvid;
-	struct ipft_entry_data *host_flood;
+	u32 ipft_hf_eid;
+
+	/* Serialize access to skb_txtstamp_queue and ts_req_id */
+	spinlock_t tstamp_lock;
+	/* skb queue for two-step timestamp frames */
+	struct sk_buff_head skb_txtstamp_queue;
+	/* one-step Sync serialization context (ref-counted, kzalloc'd) */
+	struct netc_onestep *onestep;
+	int ptp_tx_type;
+	int ptp_rx_filter;
+	u32 ptp_ipft_eid[NETC_PTP_MAX];
 };
 
 struct netc_switch_regs {
@@ -139,6 +204,7 @@ struct netc_switch {
 	u32 num_bp;
 
 	struct bpt_cfge_data *bpt_list;
+	struct pci_dev *tmr_dev; /* The PTP Timer PCI device */
 };
 
 #define NETC_PRIV(ds)			((struct netc_switch *)((ds)->priv))
@@ -187,6 +253,7 @@ static inline void netc_del_vlan_entry(struct netc_vlan_entry *entry)
 }
 
 int netc_switch_platform_probe(struct netc_switch *priv);
+void netc_mac_port_wr(struct netc_port *np, u32 reg, u32 val);
 
 /* ethtool APIs */
 void netc_port_get_pause_stats(struct dsa_switch *ds, int port,
@@ -203,4 +270,26 @@ void netc_port_get_strings(struct dsa_switch *ds, int port,
 			   u32 sset, u8 *data);
 void netc_port_get_ethtool_stats(struct dsa_switch *ds, int port, u64 *data);
 
+/* PTP APIs */
+int netc_port_ptp_init(struct netc_port *np);
+int netc_get_ts_info(struct dsa_switch *ds, int port,
+		     struct kernel_ethtool_ts_info *info);
+void netc_port_purge_txtstamp_queue(struct netc_port *np);
+int netc_port_hwtstamp_set(struct dsa_switch *ds, int port,
+			   struct kernel_hwtstamp_config *config,
+			   struct netlink_ext_ack *extack);
+int netc_port_hwtstamp_get(struct dsa_switch *ds, int port,
+			   struct kernel_hwtstamp_config *config);
+void netc_port_twostep_tstamp_handler(struct dsa_switch *ds, int port,
+				      u8 ts_req_id, u64 ts);
+bool netc_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb,
+			unsigned int type);
+void netc_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb);
+void netc_onestep_put(struct netc_onestep *onestep);
+void netc_port_purge_onestep_queue(struct netc_onestep *onestep,
+				   bool clear_flight);
+void netc_port_onestep_work(struct work_struct *work);
+void netc_port_onestep_sync_enqueue(struct dsa_switch *ds, int port,
+				    struct sk_buff *skb);
+
 #endif
diff --git a/drivers/net/dsa/netc/netc_switch_hw.h b/drivers/net/dsa/netc/netc_switch_hw.h
index 1404ae41c7bcb..37d1dd7ec2c7f 100644
--- a/drivers/net/dsa/netc/netc_switch_hw.h
+++ b/drivers/net/dsa/netc/netc_switch_hw.h
@@ -203,6 +203,11 @@ enum netc_stg_stage {
 #define   SSP_10M			1
 #define   SSP_1G			2
 
+#define NETC_PM_SINGLE_STEP(a)		(0x10c0 + (a) * 0x400)
+#define  PM_SINGLE_STEP_CH		BIT(6)
+#define  PM_SINGLE_STEP_OFFSET		GENMASK(15, 7)
+#define  PM_SINGLE_STEP_EN		BIT(31)
+
 /* Port MAC 0/1 Receive Ethernet Octets Counter */
 #define NETC_PM_REOCT(a)		(0x1100 + (a) * 0x400)
 
diff --git a/drivers/ptp/ptp_netc.c b/drivers/ptp/ptp_netc.c
index 1c20d7efab929..27f85818d6a8a 100644
--- a/drivers/ptp/ptp_netc.c
+++ b/drivers/ptp/ptp_netc.c
@@ -127,6 +127,17 @@ struct netc_timer {
 
 #define netc_timer_rd(p, o)		netc_read((p)->base + (o))
 #define netc_timer_wr(p, o, v)		netc_write((p)->base + (o), v)
+
+/* The 64-bit timer registers consist of a low (L) and high (H) register pair.
+ * Hardware requires a strict access order: for writes, TMR_xxx_L must be
+ * written first, which latches the value into a shadow register; the write
+ * to TMR_xxx_H then atomically transfers both shadow registers into the live
+ * counter. For reads, TMR_xxx_L must be read first to capture a coherent
+ * snapshot. iowrite64_lo_hi() and ioread64_lo_hi() enforce this L-before-H
+ * ordering.
+ */
+#define netc_timer_rd64(p, o)		ioread64_lo_hi((p)->base + (o))
+#define netc_timer_wr64(p, o, v)	iowrite64_lo_hi(v, (p)->base + (o))
 #define ptp_to_netc_timer(ptp)		container_of((ptp), struct netc_timer, caps)
 
 static const char *const timer_clk_src[] = {
@@ -136,66 +147,69 @@ static const char *const timer_clk_src[] = {
 
 static void netc_timer_cnt_write(struct netc_timer *priv, u64 ns)
 {
-	u32 tmr_cnt_h = upper_32_bits(ns);
-	u32 tmr_cnt_l = lower_32_bits(ns);
-
-	/* Writes to the TMR_CNT_L register copies the written value
-	 * into the shadow TMR_CNT_L register. Writes to the TMR_CNT_H
-	 * register copies the values written into the shadow TMR_CNT_H
-	 * register. Contents of the shadow registers are copied into
-	 * the TMR_CNT_L and TMR_CNT_H registers following a write into
-	 * the TMR_CNT_H register. So the user must writes to TMR_CNT_L
-	 * register first. Other H/L registers should have the same
-	 * behavior.
-	 */
-	netc_timer_wr(priv, NETC_TMR_CNT_L, tmr_cnt_l);
-	netc_timer_wr(priv, NETC_TMR_CNT_H, tmr_cnt_h);
+	netc_timer_wr64(priv, NETC_TMR_CNT_L, ns);
 }
 
 static u64 netc_timer_offset_read(struct netc_timer *priv)
 {
-	u32 tmr_off_l, tmr_off_h;
-	u64 offset;
-
-	tmr_off_l = netc_timer_rd(priv, NETC_TMR_OFF_L);
-	tmr_off_h = netc_timer_rd(priv, NETC_TMR_OFF_H);
-	offset = (((u64)tmr_off_h) << 32) | tmr_off_l;
-
-	return offset;
+	return netc_timer_rd64(priv, NETC_TMR_OFF_L);
 }
 
 static void netc_timer_offset_write(struct netc_timer *priv, u64 offset)
 {
-	u32 tmr_off_h = upper_32_bits(offset);
-	u32 tmr_off_l = lower_32_bits(offset);
-
-	netc_timer_wr(priv, NETC_TMR_OFF_L, tmr_off_l);
-	netc_timer_wr(priv, NETC_TMR_OFF_H, tmr_off_h);
+	netc_timer_wr64(priv, NETC_TMR_OFF_L, offset);
 }
 
 static u64 netc_timer_cur_time_read(struct netc_timer *priv)
 {
-	u32 time_h, time_l;
-	u64 ns;
+	return netc_timer_rd64(priv, NETC_TMR_CUR_TIME_L);
+}
+
+/**
+ * netc_timer_get_current_time - read the current PTP time from the NETC Timer
+ * @pdev: PCI device of the NETC Timer
+ *
+ * Reads the 64-bit current time register (TMR_CUR_TIME) from the NETC Timer
+ * device associated with @pdev. Returns 0 if the Timer driver has not yet
+ * probed or has already been removed.
+ *
+ * Context: Process context only. Acquires the device mutex via device_lock(),
+ *          which may sleep. Must not be called from atomic context, softirq,
+ *          BH, or while holding a spinlock.
+ *
+ * Return: Current PTP time in nanoseconds, or 0 if the timer is unavailable.
+ */
+u64 netc_timer_get_current_time(struct pci_dev *pdev)
+{
+	struct netc_timer *priv;
+	unsigned long flags;
+	u64 cur_time = 0;
 
-	/* The user should read NETC_TMR_CUR_TIME_L first to
-	 * get correct current time.
+	/* Serialize against driver unbind: the remove() callback runs under
+	 * the device lock, so holding it here ensures that priv remains valid
+	 * for the entire duration of the register read.
 	 */
-	time_l = netc_timer_rd(priv, NETC_TMR_CUR_TIME_L);
-	time_h = netc_timer_rd(priv, NETC_TMR_CUR_TIME_H);
-	ns = (u64)time_h << 32 | time_l;
+	device_lock(&pdev->dev);
+
+	priv = pci_get_drvdata(pdev);
+	if (!priv)
+		goto unlock_device;
+
+	spin_lock_irqsave(&priv->lock, flags);
+	cur_time = netc_timer_cur_time_read(priv);
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+unlock_device:
+	device_unlock(&pdev->dev);
 
-	return ns;
+	return cur_time;
 }
+EXPORT_SYMBOL_GPL(netc_timer_get_current_time);
 
 static void netc_timer_alarm_write(struct netc_timer *priv,
 				   u64 alarm, int index)
 {
-	u32 alarm_h = upper_32_bits(alarm);
-	u32 alarm_l = lower_32_bits(alarm);
-
-	netc_timer_wr(priv, NETC_TMR_ALARM_L(index), alarm_l);
-	netc_timer_wr(priv, NETC_TMR_ALARM_H(index), alarm_h);
+	netc_timer_wr64(priv, NETC_TMR_ALARM_L(index), alarm);
 }
 
 static u32 netc_timer_get_integral_period(struct netc_timer *priv)
@@ -497,22 +511,19 @@ static void netc_timer_handle_etts_event(struct netc_timer *priv, int index,
 					 bool update_event)
 {
 	struct ptp_clock_event event;
-	u32 etts_l = 0, etts_h = 0;
+	u64 etts = 0;
 
-	while (netc_timer_rd(priv, NETC_TMR_STAT) & TMR_STAT_ETS_VLD(index)) {
-		etts_l = netc_timer_rd(priv, NETC_TMR_ETTS_L(index));
-		etts_h = netc_timer_rd(priv, NETC_TMR_ETTS_H(index));
-	}
+	while (netc_timer_rd(priv, NETC_TMR_STAT) & TMR_STAT_ETS_VLD(index))
+		etts = netc_timer_rd64(priv, NETC_TMR_ETTS_L(index));
 
 	/* Invalid time stamp */
-	if (!etts_l && !etts_h)
+	if (!etts)
 		return;
 
 	if (update_event) {
 		event.type = PTP_CLOCK_EXTTS;
 		event.index = index;
-		event.timestamp = (u64)etts_h << 32;
-		event.timestamp |= etts_l;
+		event.timestamp = etts;
 		ptp_clock_event(priv->clock, &event);
 	}
 }
@@ -804,7 +815,6 @@ static int netc_timer_pci_probe(struct pci_dev *pdev)
 	if (!priv)
 		return -ENOMEM;
 
-	pcie_flr(pdev);
 	err = pci_enable_device_mem(pdev);
 	if (err)
 		return dev_err_probe(dev, err, "Failed to enable device\n");
@@ -826,6 +836,7 @@ static int netc_timer_pci_probe(struct pci_dev *pdev)
 		goto release_mem_regions;
 	}
 
+	spin_lock_init(&priv->lock);
 	pci_set_drvdata(pdev, priv);
 
 	return 0;
@@ -996,7 +1007,6 @@ static int netc_timer_probe(struct pci_dev *pdev,
 	priv->caps = netc_timer_ptp_caps;
 	priv->oclk_prsc = NETC_TMR_DEFAULT_PRSC;
 	priv->pps_channel = NETC_TMR_INVALID_CHANNEL;
-	spin_lock_init(&priv->lock);
 	snprintf(priv->irq_name, sizeof(priv->irq_name), "ptp-netc %s",
 		 pci_name(pdev));
 
diff --git a/include/linux/dsa/tag_netc.h b/include/linux/dsa/tag_netc.h
index fe964722e5b03..5ac5e2e72dff2 100644
--- a/include/linux/dsa/tag_netc.h
+++ b/include/linux/dsa/tag_netc.h
@@ -10,5 +10,48 @@
 #include <net/dsa.h>
 
 #define NETC_TAG_MAX_LEN			14
+#define NETC_PTP_FLAG_ONESTEP			BIT(0)
+#define NETC_PTP_FLAG_TWOSTEP			BIT(1)
+#define NETC_PTP_FLAG_DROP			BIT(2)
+
+struct netc_skb_cb {
+	unsigned long ptp_tx_time;
+	u64 tstamp;
+	u8 ptp_flag;
+	u8 ts_req_id;
+	/* One-step Sync parsing results, computed in netc_port_txtstamp()
+	 * and reused in the tagger xmit path and the deferred work, to avoid
+	 * re-parsing the PTP header. Valid only while
+	 * ptp_flag == NETC_PTP_FLAG_ONESTEP.
+	 */
+	u16 correction_offset;
+	u16 timestamp_offset;
+	bool is_udp;
+};
+
+#define NETC_SKB_CB(skb)	((struct netc_skb_cb *)((skb)->cb))
+
+/**
+ * struct netc_tagger_data - NETC tagger/switch-driver shared operations
+ * @twostep_tstamp_handler: Called by the tagger when a two-step transmit
+ *	timestamp response is received, to deliver the timestamp to the
+ *	switch driver.
+ * @onestep_sync_enqueue: Called from the tagger xmit path for a one-step Sync
+ *	frame. The switch driver takes ownership of the skb and queues it for
+ *	deferred transmission from process context, where the shared
+ *	PM_SINGLE_STEP register can be programmed and the PTP timer read
+ *	(which may sleep). The tagger must not touch the skb after this call
+ *	and returns NULL to dsa_user_xmit().
+ * @onestep_sync_xmit: Called by the switch driver to transmit a deferred
+ *	one-step Sync frame directly to the conduit, bypassing dsa_user_xmit().
+ */
+struct netc_tagger_data {
+	void (*twostep_tstamp_handler)(struct dsa_switch *ds, int port,
+				       u8 ts_req_id, u64 ts);
+	void (*onestep_sync_enqueue)(struct dsa_switch *ds, int port,
+				     struct sk_buff *skb);
+	netdev_tx_t (*onestep_sync_xmit)(struct sk_buff *skb,
+					 struct net_device *ndev);
+};
 
 #endif
diff --git a/include/linux/fsl/netc_global.h b/include/linux/fsl/netc_global.h
index 5b8ff528d3699..ace0bcde1e2ca 100644
--- a/include/linux/fsl/netc_global.h
+++ b/include/linux/fsl/netc_global.h
@@ -6,6 +6,7 @@
 
 #include <linux/io.h>
 #include <linux/io-64-nonatomic-lo-hi.h>
+#include <linux/pci.h>
 
 static inline u32 netc_read(void __iomem *reg)
 {
@@ -22,4 +23,13 @@ static inline u64 netc_read64(void __iomem *reg)
 	return ioread64(reg);
 }
 
+#if IS_REACHABLE(CONFIG_PTP_NETC_V4_TIMER)
+u64 netc_timer_get_current_time(struct pci_dev *timer_dev);
+#else
+static inline u64 netc_timer_get_current_time(struct pci_dev *timer_dev)
+{
+	return 0;
+}
+#endif
+
 #endif
diff --git a/net/dsa/tag_netc.c b/net/dsa/tag_netc.c
index df72a61796ad5..91548fb7ed1b3 100644
--- a/net/dsa/tag_netc.c
+++ b/net/dsa/tag_netc.c
@@ -16,6 +16,10 @@
 #define NETC_TAG_TO_PORT		1
 /* SubType0: No request to perform timestamping */
 #define NETC_TAG_TP_SUBTYPE0		0
+/* SubType1: Request to perform one-step timestamping */
+#define NETC_TAG_TP_SUBTYPE1		1
+/* SubType2: Request to perform two-step timestamping */
+#define NETC_TAG_TP_SUBTYPE2		2
 
 /* To_Host NXP switch tag */
 #define NETC_TAG_TO_HOST		2
@@ -29,6 +33,8 @@
 /* NETC switch tag lengths */
 #define NETC_TAG_FORWARD_LEN		6
 #define NETC_TAG_TP_SUBTYPE0_LEN	6
+#define NETC_TAG_TP_SUBTYPE1_LEN	10
+#define NETC_TAG_TP_SUBTYPE2_LEN	6
 #define NETC_TAG_TH_SUBTYPE0_LEN	6
 #define NETC_TAG_TH_SUBTYPE1_LEN	14
 #define NETC_TAG_TH_SUBTYPE2_LEN	14
@@ -40,6 +46,8 @@
 #define NETC_TAG_IPV			GENMASK(4, 2)
 #define NETC_TAG_SWITCH			GENMASK(2, 0)
 #define NETC_TAG_PORT			GENMASK(7, 3)
+#define NETC_TAG_TS_REQ_ID		GENMASK(3, 0)
+#define NETC_TAG_TIMESTAMP		GENMASK(29, 0)
 
 struct netc_tag_cmn {
 	__be16 tpid;
@@ -48,6 +56,29 @@ struct netc_tag_cmn {
 	u8 switch_port;
 } __packed;
 
+struct netc_tag_tp_subtype1 {
+	struct netc_tag_cmn cmn;
+	u8 resv;
+	__be32 timestamp;
+} __packed;
+
+struct netc_tag_tp_subtype2 {
+	struct netc_tag_cmn cmn;
+	u8 ts_req_id;
+} __packed;
+
+struct netc_tag_th_subtype1 {
+	struct netc_tag_cmn cmn;
+	u8 host_reason;
+	__be64 timestamp;
+} __packed;
+
+struct netc_tag_th_subtype2 {
+	struct netc_tag_cmn cmn;
+	u8 hr_tsreq_id;
+	__be64 timestamp;
+} __packed;
+
 static void netc_fill_common_tag(struct netc_tag_cmn *tag, u8 type,
 				 u8 subtype, u8 sw_id, u8 port, u8 ipv)
 {
@@ -97,15 +128,126 @@ static void netc_fill_tp_tag_subtype0(struct sk_buff *skb,
 				NETC_TAG_TP_SUBTYPE0_LEN);
 }
 
-/* Currently only support To_Port tag, subtype 0 */
+static void netc_fill_tp_tag_subtype1(struct sk_buff *skb,
+				      struct net_device *ndev)
+{
+	u32 ts = FIELD_PREP(NETC_TAG_TIMESTAMP, NETC_SKB_CB(skb)->tstamp);
+	struct netc_tag_tp_subtype1 *tag;
+
+	tag = netc_fill_common_tp_tag(skb, ndev, NETC_TAG_TP_SUBTYPE1,
+				      NETC_TAG_TP_SUBTYPE1_LEN);
+	tag->timestamp = htonl(ts);
+}
+
+static void netc_fill_tp_tag_subtype2(struct sk_buff *skb,
+				      struct net_device *ndev)
+{
+	u8 ts_req_id = NETC_SKB_CB(skb)->ts_req_id;
+	struct netc_tag_tp_subtype2 *tag;
+
+	tag = netc_fill_common_tp_tag(skb, ndev, NETC_TAG_TP_SUBTYPE2,
+				      NETC_TAG_TP_SUBTYPE2_LEN);
+	tag->ts_req_id = FIELD_PREP(NETC_TAG_TS_REQ_ID, ts_req_id);
+}
+
+static netdev_tx_t netc_onestep_sync_xmit(struct sk_buff *skb,
+					  struct net_device *dev)
+{
+	/* This deferred one-step Sync frame already went through
+	 * dsa_user_xmit()'s skb_ensure_writable_head_tail() and eth_skb_pad()
+	 * before it was queued in netc_xmit(), and nothing has cloned it or
+	 * shrunk its head/tail room since. So the head/tail room is still
+	 * guaranteed and the skb is still writable; only the tag needs to be
+	 * pushed before handing it directly to the conduit, bypassing
+	 * dsa_user_xmit() so that dev_sw_netstats_tx_add() is not invoked a
+	 * second time for the same frame.
+	 */
+	netc_fill_tp_tag_subtype1(skb, dev);
+
+	return dsa_enqueue_skb(skb, dev);
+}
+
+static void netc_onestep_sync_enqueue(struct sk_buff *skb,
+				      struct net_device *ndev)
+{
+	struct dsa_port *dp = dsa_user_to_port(ndev);
+	struct netc_tagger_data *tagger_data;
+
+	tagger_data = dp->ds->tagger_data;
+	if (unlikely(!tagger_data->onestep_sync_enqueue)) {
+		kfree_skb(skb);
+		return;
+	}
+
+	/* Hand the one-step Sync to the switch driver, which takes ownership
+	 * and queues it for deferred transmission from its work. The tagger
+	 * must not touch the skb after this point.
+	 */
+	tagger_data->onestep_sync_enqueue(dp->ds, dp->index, skb);
+}
+
 static struct sk_buff *netc_xmit(struct sk_buff *skb,
 				 struct net_device *ndev)
 {
-	netc_fill_tp_tag_subtype0(skb, ndev);
+	u8 ptp_flag = NETC_SKB_CB(skb)->ptp_flag;
+
+	/* Fast path: the overwhelming majority of frames are not PTP frames */
+	if (likely(!ptp_flag)) {
+		netc_fill_tp_tag_subtype0(skb, ndev);
+		return skb;
+	}
+
+	if (ptp_flag == NETC_PTP_FLAG_ONESTEP) {
+		/* The switch driver takes ownership of the one-step Sync and
+		 * queues it for deferred TX; the deferred work tags it subtype 1
+		 * and transmits it directly to the conduit. Return NULL so
+		 * dsa_user_xmit() stops processing this skb.
+		 */
+		netc_onestep_sync_enqueue(skb, ndev);
+		return NULL;
+	} else if (ptp_flag == NETC_PTP_FLAG_TWOSTEP) {
+		netc_fill_tp_tag_subtype2(skb, ndev);
+	} else { /* NETC_PTP_FLAG_DROP */
+		kfree_skb(skb);
+		return NULL;
+	}
 
 	return skb;
 }
 
+static int netc_rx_tstamp_process(struct netc_tag_th_subtype1 *tag,
+				  struct sk_buff *skb)
+{
+	u64 ts = get_unaligned_be64(&tag->timestamp);
+
+	/* To_Host Subtype 1 tag is 14 bytes, ensure it and the EtherType
+	 * behind it are fully present in the linear area before netc_rcv()
+	 * calls dsa_strip_etype_header() to strip the tag.
+	 */
+	if (unlikely(!pskb_may_pull(skb, NETC_TAG_TH_SUBTYPE1_LEN)))
+		return -ENOBUFS;
+
+	NETC_SKB_CB(skb)->tstamp = ts;
+
+	return 0;
+}
+
+static void netc_twostep_tstamp_process(struct netc_tag_th_subtype2 *tag,
+					struct sk_buff *skb)
+{
+	u8 ts_req_id = FIELD_GET(NETC_TAG_TS_REQ_ID, tag->hr_tsreq_id);
+	struct dsa_port *dp = dsa_user_to_port(skb->dev);
+	u64 ts = get_unaligned_be64(&tag->timestamp);
+	struct netc_tagger_data *tagger_data;
+	struct dsa_switch *ds = dp->ds;
+
+	tagger_data = ds->tagger_data;
+	if (unlikely(!tagger_data->twostep_tstamp_handler))
+		return;
+
+	tagger_data->twostep_tstamp_handler(ds, dp->index, ts_req_id, ts);
+}
+
 static int netc_get_rx_tag_len(int type, int subtype)
 {
 	/* Only NETC_TAG_TO_HOST and NETC_TAG_FORWARD are expected in RX,
@@ -129,11 +271,22 @@ static struct sk_buff *netc_rcv(struct sk_buff *skb,
 	struct netc_tag_cmn *tag_cmn;
 	int tag_len, sw_id, port;
 	int type, subtype;
+	void *tag;
 
-	if (unlikely(!pskb_may_pull(skb, NETC_TAG_MAX_LEN)))
+	/* eth_type_trans() pulled ETH_HLEN bytes, so skb->data sits 2 bytes
+	 * past the start of the switch tag (past the TPID) and skb->len is
+	 * ETH_HLEN bytes shorter than the original frame length. The longest
+	 * switch tag is NETC_TAG_MAX_LEN (14) bytes, but since 2 of those
+	 * bytes are already behind skb->data, only NETC_TAG_MAX_LEN - 2 bytes
+	 * need to be in the linear buffer. For the To_Host subtype 2 response
+	 * frame, whose total length is only 26 bytes with no payload after the
+	 * tag, this check is the only guard against a too-short frame.
+	 */
+	if (unlikely(!pskb_may_pull(skb, NETC_TAG_MAX_LEN - 2)))
 		goto err_free_skb;
 
-	tag_cmn = dsa_etype_header_pos_rx(skb);
+	tag = dsa_etype_header_pos_rx(skb);
+	tag_cmn = tag;
 	if (ntohs(tag_cmn->tpid) != ETH_P_NXP_NETC) {
 		dev_warn_ratelimited(&ndev->dev, "Unknown TPID 0x%04x\n",
 				     ntohs(tag_cmn->tpid));
@@ -156,17 +309,40 @@ static struct sk_buff *netc_rcv(struct sk_buff *skb,
 	if (!skb->dev)
 		goto err_free_skb;
 
+	/* skb->cb may be used to store hardware RX timestamp, so it must
+	 * be cleared before processing to avoid data pollution from the
+	 * previous layer.
+	 */
+	NETC_SKB_CB(skb)->tstamp = 0;
+
 	type = FIELD_GET(NETC_TAG_TYPE, tag_cmn->type);
 	subtype = FIELD_GET(NETC_TAG_SUBTYPE, tag_cmn->type);
 	if (type == NETC_TAG_FORWARD) {
 		dsa_default_offload_fwd_mark(skb);
 	} else if (type == NETC_TAG_TO_HOST) {
-		/* Currently only subtype0 supported */
-		if (subtype != NETC_TAG_TH_SUBTYPE0)
+		switch (subtype) {
+		case NETC_TAG_TH_SUBTYPE0:
+			break;
+		case NETC_TAG_TH_SUBTYPE1:
+			if (netc_rx_tstamp_process(tag, skb))
+				goto err_free_skb;
+			break;
+		case NETC_TAG_TH_SUBTYPE2:
+			/* This skb is a hardware-generated response to a
+			 * two-step transmit timestamp request. The tag
+			 * driver must free the skb after processing.
+			 */
+			netc_twostep_tstamp_process(tag, skb);
 			goto err_free_skb;
+		default:
+			dev_warn_ratelimited(&ndev->dev,
+					     "Unsupported To_Host subtype: %d\n",
+					     subtype);
+			goto err_free_skb;
+		}
 	} else {
 		dev_warn_ratelimited(&ndev->dev,
-				     "Unexpected  tag type %d\n", type);
+				     "Unexpected tag type %d\n", type);
 		goto err_free_skb;
 	}
 
@@ -200,6 +376,28 @@ static void netc_flow_dissect(const struct sk_buff *skb, __be16 *proto,
 	*proto = ((__be16 *)skb->data)[(tag_len / 2) - 1];
 }
 
+static int netc_connect(struct dsa_switch *ds)
+{
+	struct netc_tagger_data *tagger_data;
+
+	tagger_data = kzalloc_obj(*tagger_data);
+	if (!tagger_data)
+		return -ENOMEM;
+
+	tagger_data->onestep_sync_xmit = netc_onestep_sync_xmit;
+	ds->tagger_data = tagger_data;
+
+	return 0;
+}
+
+static void netc_disconnect(struct dsa_switch *ds)
+{
+	struct netc_tagger_data *tagger_data = ds->tagger_data;
+
+	kfree(tagger_data);
+	ds->tagger_data = NULL;
+}
+
 static const struct dsa_device_ops netc_netdev_ops = {
 	.name			= NETC_NAME,
 	.proto			= DSA_TAG_PROTO_NETC,
@@ -207,6 +405,8 @@ static const struct dsa_device_ops netc_netdev_ops = {
 	.rcv			= netc_rcv,
 	.needed_headroom	= NETC_TAG_MAX_LEN,
 	.flow_dissect		= netc_flow_dissect,
+	.connect		= netc_connect,
+	.disconnect		= netc_disconnect,
 };
 
 MODULE_DESCRIPTION("DSA tag driver for NXP NETC switch family");

3/2 2026/08/08 03:51 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 28533
							output: 18
							thoughts: 1124
						

Thoughts:
**Analyzing the NXP NETC PTP Patch for Fuzzing Suitability**

Okay, so I have a patch here that adds PTP support to the NXP NETC switch driver. It's touching a bunch of files, including the usual Kconfig, Makefile stuff, and core driver files like `netc_main.c` and `netc_platform.c`, as well as some PTP-specific code.  Crucially, it's also modifying the DSA tagger for NETC (`net/dsa/tag_netc.c`).

Now, I need to figure out if this is worth fuzzing. The prompt flags "vendor-specific PCIe switch, SmartNIC, or GPU drivers that require physical hardware" as not worth fuzzing.  So, the first question is, what *is* the NXP NETC?  It looks like it's an integrated switch on NXP SoCs. Let's dig deeper. The Kconfig file in the driver indicates that it depends on `NET_DSA` and, importantly, `PCI`.

Right, `PCI` means it binds to a PCI device.  Looking at `netc_main.c` I see `netc_switch_probe(struct pci_dev *pdev, ...)` which confirms it's a PCI device driver.  The prompt suggests that vendor-specific PCIe switch drivers that rely on *physical* hardware are not good candidates.  I'm betting this isn't emulated well in standard QEMU; these integrated switches often need the real silicon. Syzkaller doesn't emulate this either.

So, is the NETC a "vendor-specific PCIe switch"?  Well, it's an NXP NETC switch driver, and it binds to a PCI device.  It's an Ethernet switch, but it's *accessed* via PCI.  The key part is that it requires a piece of hardware, or syzkaller/QEMU doesn't emulate the switch.

Now, let's consider the DSA tagger. Even if this driver has DSA taggers (which I can confirm from looking at the files modified) these are executed when packets are sent/received through the DSA switch.  If the switch isn't present, the tagger isn't used, unless there is a test setup using `dsa_loop`, which I need to investigate. Syzkaller can inject DSA packets, but it doesn't setup the tagger. Is there a way to hit the tagger without the real hardware? `dsa_loop` uses `DSA_TAG_PROTO_DSA` by default, but maybe it can be changed? Usually DSA requires the switch driver. No, there isn't a simple way to test the tagger without the physical switch driver (unless there is a dummy driver).

Alright, so the patch touches: `drivers/net/dsa/netc/*`, `drivers/ptp/ptp_netc.c`, `include/linux/dsa/tag_netc.h`, `include/linux/fsl/netc_global.h`, and `net/dsa/tag_netc.c`.

I'm checking `net/dsa/tag_netc.c` using `grepper` tool to search for `tag_netc`.

So, bottom line: NXP NETC is a vendor-specific PCI device.  It's an Ethernet switch driver that relies on specific hardware (an NXP SoC with an integrated switch).  The DSA tagger code is likely *not* reachable in a meaningful way without that hardware. Since this driver requires physical hardware, and is not emulated in standard QEMU, according to the prompt, this patch is probably *not* worth fuzzing.



4/2 2026/08/08 03:51 tool grepper
0m Args:
{
  "Expression": "tag_netc"
}

Results:
{
  "Output": "MAINTAINERS=19547=F:\tdrivers/net/dsa/netc/\nMAINTAINERS:19548:F:\tinclude/linux/dsa/tag_netc.h\nMAINTAINERS:19549:F:\tnet/dsa/tag_netc.c\nMAINTAINERS-19550-\n--\ndrivers/net/dsa/netc/netc_switch.h-8-\ndrivers/net/dsa/netc/netc_switch.h:9:#include \u003clinux/dsa/tag_netc.h\u003e\ndrivers/net/dsa/netc/netc_switch.h-10-#include \u003clinux/fsl/netc_global.h\u003e\n--\nnet/dsa/Makefile=32=obj-$(CONFIG_NET_DSA_TAG_MXL_GSW1XX) += tag_mxl-gsw1xx.o\nnet/dsa/Makefile:33:obj-$(CONFIG_NET_DSA_TAG_NETC) += tag_netc.o\nnet/dsa/Makefile-34-obj-$(CONFIG_NET_DSA_TAG_NONE) += tag_none.o\n--\nnet/dsa/tag_netc.c-5-\nnet/dsa/tag_netc.c:6:#include \u003clinux/dsa/tag_netc.h\u003e\nnet/dsa/tag_netc.c-7-\n"
}

5/2 2026/08/08 03:51 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 30841
							output: 23
							thoughts: 206
						

Thoughts:
**Analyzing the Reachability of `tag_netc.c`**

Okay, so the code in `tag_netc.c` and its associated driver, `drivers/net/dsa/netc/`, is apparently only used by that specific driver. My understanding is that `drivers/net/dsa/netc/` is a PCI driver designed for NXP hardware. Since QEMU is the standard virtualization tool and I know that QEMU doesn't fully emulate PCI devices perfectly, especially vendor-specific hardware, there is no way for the `netc` driver to be probed.

Now, let's connect this to the prompt. It clearly states that patches targeting vendor-specific PCIe switch drivers, or things that require physical hardware, should be marked as uninteresting for fuzzing. Given the description, I need to confirm that `netc` can be classified that way. The text strongly suggests it's a PCI device driver, which is equivalent to a PCIe switch driver. So, my focus shifts to confirming the 'PCI device driver' classification, as that would make this code uninteresting, as described in the prompt.



6/2 2026/08/08 03:51 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "pci_register_driver.*netc"
}

Results:
{
  "error": "no matches"
}

7/2 2026/08/08 03:51 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 31325
							output: 22
							thoughts: 29
						

Thoughts:
Okay, here's my interpretation of that thought process, from an expert's perspective:

**Diving into the NetC DSA Driver**

Alright, the objective is likely related to PCI device driver configuration within the NetC (Network Controller) DSA (Distributed Switch Architecture) framework. Let me zero in on `drivers/net/dsa/netc/netc_main.c` right away. That's the logical place to start looking for the core initialization and management routines for the NetC driver. Specifically, I need to check how it registers or interacts with the `pci_driver` structure. My intuition is telling me that this will be the heart of the PCI device attachment process within the driver, given that NetC interacts with devices over PCI. I'm expecting to find the PCI probe and removal functions, and the overall device lifecycle management tied in with the PCI bus. It could be a simple registration of the driver with the PCI subsystem, or possibly a more elaborate handling of multiple PCI functions or specific device features within the NetC context. Time to get down to the code!



8/2 2026/08/08 03:51 tool grepper
0m Args:
{
  "Expression": "struct pci_driver.*netc"
}

Results:
{
  "Output": "drivers/ata/pata_netcell.c=86=static const struct pci_device_id netcell_pci_tbl[] = {\n--\ndrivers/ata/pata_netcell.c-91-\ndrivers/ata/pata_netcell.c:92:static struct pci_driver netcell_pci_driver = {\ndrivers/ata/pata_netcell.c-93-\t.name\t\t\t= DRV_NAME,\n--\ndrivers/net/dsa/netc/netc_main.c=2615=MODULE_DEVICE_TABLE(pci, netc_switch_ids);\ndrivers/net/dsa/netc/netc_main.c-2616-\ndrivers/net/dsa/netc/netc_main.c:2617:static struct pci_driver netc_switch_driver = {\ndrivers/net/dsa/netc/netc_main.c-2618-\t.name\t\t= KBUILD_MODNAME,\n--\ndrivers/net/ethernet/freescale/enetc/enetc4_pf.c=1117=MODULE_DEVICE_TABLE(pci, enetc4_pf_id_table);\ndrivers/net/ethernet/freescale/enetc/enetc4_pf.c-1118-\ndrivers/net/ethernet/freescale/enetc/enetc4_pf.c:1119:static struct pci_driver enetc4_pf_driver = {\ndrivers/net/ethernet/freescale/enetc/enetc4_pf.c-1120-\t.name = KBUILD_MODNAME,\n--\ndrivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c=132=MODULE_DEVICE_TABLE(pci, enetc_pci_mdio_id_table);\ndrivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c-133-\ndrivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c:134:static struct pci_driver enetc_pci_mdio_driver = {\ndrivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c-135-\t.name = KBUILD_MODNAME,\n--\ndrivers/net/ethernet/freescale/enetc/enetc_pf.c=955=MODULE_DEVICE_TABLE(pci, enetc_pf_id_table);\ndrivers/net/ethernet/freescale/enetc/enetc_pf.c-956-\ndrivers/net/ethernet/freescale/enetc/enetc_pf.c:957:static struct pci_driver enetc_pf_driver = {\ndrivers/net/ethernet/freescale/enetc/enetc_pf.c-958-\t.name = KBUILD_MODNAME,\n--\ndrivers/net/ethernet/freescale/enetc/enetc_ptp.c=129=MODULE_DEVICE_TABLE(pci, enetc_ptp_id_table);\ndrivers/net/ethernet/freescale/enetc/enetc_ptp.c-130-\ndrivers/net/ethernet/freescale/enetc/enetc_ptp.c:131:static struct pci_driver enetc_ptp_driver = {\ndrivers/net/ethernet/freescale/enetc/enetc_ptp.c-132-\t.name = KBUILD_MODNAME,\n--\ndrivers/net/ethernet/freescale/enetc/enetc_vf.c=414=MODULE_DEVICE_TABLE(pci, enetc_vf_id_table);\ndrivers/net/ethernet/freescale/enetc/enetc_vf.c-415-\ndrivers/net/ethernet/freescale/enetc/enetc_vf.c:416:static struct pci_driver enetc_vf_driver = {\ndrivers/net/ethernet/freescale/enetc/enetc_vf.c-417-\t.name = KBUILD_MODNAME,\n--\ndrivers/ptp/ptp_netc.c=1052=MODULE_DEVICE_TABLE(pci, netc_timer_id_table);\ndrivers/ptp/ptp_netc.c-1053-\ndrivers/ptp/ptp_netc.c:1054:static struct pci_driver netc_timer_driver = {\ndrivers/ptp/ptp_netc.c-1055-\t.name = KBUILD_MODNAME,\n"
}

9/2 2026/08/08 03:51 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 32741
							output: 88
							thoughts: 70
						

Thoughts:
**Assessing the Fuzzing Worthiness of Drivers**

Okay, so I'm taking a look at these drivers, `netc_switch_driver` and `netc_timer_driver`. Yep, confirmed. They're both PCI drivers. That immediately signals something to me: they're vendor-specific, which means they're intrinsically tied to physical hardware. And as any expert knows, standard QEMU setup isn't going to cut it for probing those. I'm not going to be able to simply spin up a virtual environment and start throwing things at them. The overhead of setting up a viable test environment for PCI drivers in this context, when compared to the value gained from fuzzing, just isn't there. Considering the effort, the changes are simply not worth fuzzing. I'm going to update the relevant flag to indicate this. I'll set `WorthFuzzing` to `false` and move on to something more productive.



10/2 2026/08/08 03:51 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the NXP NETC switch driver and its associated DSA tagger and PTP timer. These are vendor-specific PCI devices that require physical hardware and cannot be emulated in standard QEMU. Therefore, the code is unreachable in a virtualized fuzzing environment.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the NXP NETC switch driver and its associated DSA tagger and PTP timer. These are vendor-specific PCI devices that require physical hardware and cannot be emulated in standard QEMU. Therefore, the code is unreachable in a virtualized fuzzing environment.",
  "WorthFuzzing": false
}

11/1 2026/08/08 03:51 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)