From: Christian Eggers <ceggers@arri.de>
To: <matt.becker@l3harris.com>, <Brian.Hutchinson@l3harris.com>
Cc: <arun.ramadoss@microchip.com>, <netdev@vger.kernel.org>,
<UNGLinuxDriver@microchip.com>
Subject: Re: Attempting Yocto Scarthgap prototype using 0001-net-dsa-microchip-ksz9477-add-E2E-support.patch
Date: Thu, 30 Apr 2026 09:58:45 +0200 [thread overview]
Message-ID: <10847188.nUPlyArG6x@n9w6sw14> (raw)
In-Reply-To: <BN1P110MB057898FE6C49EDDB74498DD3C334A@BN1P110MB0578.NAMP110.PROD.OUTLOOK.COM>
[-- Attachment #1: Type: text/plain, Size: 3801 bytes --]
CC: UNGLinuxDriver@microchip.com
CC: netdev@vger.kernel.org
Hi Matt, hi Brian,
although I did the initial development of the KSZ PTP patches, this never went
into our final products. Because of this, I am quite happy that Arun from
Microchip took over this and made several improvements.
The E2E patch was originally rejected (AFAIR), because the KSZ applies
(unwanted) filtering on the PTP messages. For E2E this means, that the
KSZ hardware filter needs to "know" whether this node is currently master or
slave clock. As there is no (and probably never will be) interface between
ptp4l and the kernel for communicating the current master/slave state, there
was no interest in merging this.
As we do not use PTP in our current software, I have only forward ported
the patch(es) for being compile clean (see attachment). But I haven't done
any real tests with newer kernels / ptp4l versions.
Unfortunately I will not be able to spent any time on this for the next
3 weeks. If the problem still persists then, I can try to have a look on
this. If you find the solution yourself, I would be happy getting an
update on this.
regards,
Christian
On Wednesday, 29 April 2026, 21:27:12 CEST, matt.becker@L3Harris.com wrote:
> Christian/Arun,
>
> My name is Matt Becker. I work with Brian Hutchinson at L3Harris.
>
> A few years back we received & applied patches (net-dsa-microchip-ptp*) from Christian for our embedded board (imx8mm Arm processor + KSZ Microchip part). At the time these patches were developed for Yocto Dunfell (3.1) + Linux Kernel 5.10.69 + linuxptp-2.0 .
>
> We followed up and reapplied these patches with success on the same board when we upgraded to Yocto Kirkstone (4.0.x) + Linux Kernel 6.1.38 + linuxptp-3.1.1.
>
> We’re now attempting to bring this same board up to the most recent Yocto LTS release (Scarthgap 5.0.16) + Linux Kernel 6.6.50 + linuxptp-4.1 . This is where we’re running into some difficulty.
>
> It looks like most of the patches from a few years back were already merged back to the 6.6 kernel level. I only had to re-apply the patch 0001-net-dsa-microchip-ksz9477-add-E2E-support.patch as this was not merged back. It seems this change alone might not be sufficient. Our Scarthgap board is now able to select a grandmaster clock and it is able to receive adjustments. However, the master_offset values are very large, and PTP never converges.
>
> My suspicion is that I may need other changes to make this work on this new OS/kernel/PTP configuration.
>
> I was wondering if you might be able to offer any guidance:
>
> * Have you ever tried bringing this functionality (net-dsa-microchip-ksz9477-add-E2E-support) forward to a newer Linux kernel and/or PTP?
> * If so, do you have any unofficial patches we might be able to try?
> * If not, do you have any other advice on a path forward (e.g. changes that might be necessary outside of the original patches)?
>
> I attached an email thread with myself & Brian that has a little bit more detail.
>
> If you have any ideas or help you can offer it would be greatly appreciated!
>
> Sincerely,
>
> -Matt Becker
>
> matt.becker@L3Harris.com<mailto:matt.becker@L3Harris.com>
> (585) 369-1184
>
>
>
> CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient and may contain material that is proprietary, confidential, privileged or otherwise legally protected or restricted under applicable government laws. Any review, disclosure, distributing or other use without expressed permission of the sender is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies without reading, printing, or saving.
>
>
[-- Attachment #2: 0a4fdb38cfe8eec90a2149cf529da4da7a1f6d25.patch --]
[-- Type: text/x-patch, Size: 6253 bytes --]
From 0a4fdb38cfe8eec90a2149cf529da4da7a1f6d25 Mon Sep 17 00:00:00 2001
From: Christian Eggers <ceggers@arri.de>
Date: Tue, 12 Sep 2023 18:39:54 +0200
Subject: [PATCH] net: dsa: microchip: ksz9477: add E2E support
Requires manual switching between master and slave mode via sysfs
attribute.
Signed-off-by: Christian Eggers <ceggers@arri.de>
---
drivers/net/dsa/microchip/ksz_ptp.c | 164 ++++++++++++++++++++++++++++
1 file changed, 164 insertions(+)
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index 7ef5fac69657f..81b386b8ebece 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -11,6 +11,7 @@
#include <linux/kernel.h>
#include <linux/ptp_classify.h>
#include <linux/ptp_clock_kernel.h>
+#include <linux/sysfs.h>
#include "ksz_common.h"
#include "ksz_ptp.h"
@@ -383,16 +384,19 @@ static int ksz_set_hwtstamp_config(struct ksz_device *dev,
break;
case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
config->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
prt->hwts_rx_en = true;
break;
case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
config->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
prt->hwts_rx_en = true;
break;
case HWTSTAMP_FILTER_PTP_V2_EVENT:
case HWTSTAMP_FILTER_PTP_V2_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
prt->hwts_rx_en = true;
break;
@@ -526,6 +530,7 @@ void ksz_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
if (prt->tstamp_config.tx_type == HWTSTAMP_TX_ONESTEP_P2P)
return;
break;
+ case PTP_MSGTYPE_DELAY_REQ:
case PTP_MSGTYPE_PDELAY_REQ:
break;
case PTP_MSGTYPE_PDELAY_RESP:
@@ -900,6 +905,155 @@ static int ksz_ptp_start_clock(struct ksz_device *dev)
return 0;
}
+
+/* device attributes */
+
+enum ksz9477_ptp_tcmode {
+ KSZ9477_PTP_TCMODE_E2E,
+ KSZ9477_PTP_TCMODE_P2P,
+};
+
+static int ksz9477_ptp_tcmode_get(struct ksz_device *dev, enum ksz9477_ptp_tcmode *tcmode)
+{
+ u16 data;
+ int ret;
+
+ ret = ksz_read16(dev, REG_PTP_MSG_CONF1, &data);
+ if (ret)
+ return ret;
+
+ *tcmode = (data & PTP_TC_P2P) ? KSZ9477_PTP_TCMODE_P2P : KSZ9477_PTP_TCMODE_E2E;
+
+ return 0;
+}
+
+static int ksz9477_ptp_tcmode_set(struct ksz_device *dev,
+ enum ksz9477_ptp_tcmode tcmode)
+{
+ u16 data;
+ int ret;
+
+ ret = ksz_read16(dev, REG_PTP_MSG_CONF1, &data);
+ if (ret)
+ return ret;
+
+ if (tcmode == KSZ9477_PTP_TCMODE_P2P)
+ data |= PTP_TC_P2P;
+ else
+ data &= ~PTP_TC_P2P;
+
+ return ksz_write16(dev, REG_PTP_MSG_CONF1, data);
+}
+
+static ssize_t tcmode_show(struct device *dev, struct device_attribute *attr __always_unused,
+ char *buf)
+{
+ struct ksz_device *ksz = dev_get_drvdata(dev);
+ enum ksz9477_ptp_tcmode tcmode;
+ int ret = ksz9477_ptp_tcmode_get(ksz, &tcmode);
+
+ if (ret)
+ return ret;
+
+ return sprintf(buf, "%s\n", tcmode == KSZ9477_PTP_TCMODE_P2P ? "P2P" : "E2E");
+}
+
+static ssize_t tcmode_store(struct device *dev, struct device_attribute *attr __always_unused,
+ char const *buf, size_t count)
+{
+ struct ksz_device *ksz = dev_get_drvdata(dev);
+ int ret;
+
+ if (strcasecmp(buf, "E2E") == 0)
+ ret = ksz9477_ptp_tcmode_set(ksz, KSZ9477_PTP_TCMODE_E2E);
+ else if (strcasecmp(buf, "P2P") == 0)
+ ret = ksz9477_ptp_tcmode_set(ksz, KSZ9477_PTP_TCMODE_P2P);
+ else
+ return -EINVAL;
+
+ return ret ? ret : (ssize_t)count;
+}
+
+static DEVICE_ATTR_RW(tcmode);
+
+enum ksz9477_ptp_ocmode {
+ KSZ9477_PTP_OCMODE_SLAVE,
+ KSZ9477_PTP_OCMODE_MASTER,
+};
+
+static int ksz9477_ptp_ocmode_get(struct ksz_device *dev, enum ksz9477_ptp_ocmode *ocmode)
+{
+ u16 data;
+ int ret;
+
+ ret = ksz_read16(dev, REG_PTP_MSG_CONF1, &data);
+ if (ret)
+ return ret;
+
+ *ocmode = (data & PTP_MASTER) ? KSZ9477_PTP_OCMODE_MASTER : KSZ9477_PTP_OCMODE_SLAVE;
+
+ return 0;
+}
+
+static int ksz9477_ptp_ocmode_set(struct ksz_device *dev,
+ enum ksz9477_ptp_ocmode ocmode)
+{
+ u16 data;
+ int ret;
+
+ ret = ksz_read16(dev, REG_PTP_MSG_CONF1, &data);
+ if (ret)
+ return ret;
+
+ if (ocmode == KSZ9477_PTP_OCMODE_MASTER)
+ data |= PTP_MASTER;
+ else
+ data &= ~PTP_MASTER;
+
+ return ksz_write16(dev, REG_PTP_MSG_CONF1, data);
+}
+
+static ssize_t ocmode_show(struct device *dev, struct device_attribute *attr __always_unused,
+ char *buf)
+{
+ struct ksz_device *ksz = dev_get_drvdata(dev);
+ enum ksz9477_ptp_ocmode ocmode;
+ int ret = ksz9477_ptp_ocmode_get(ksz, &ocmode);
+
+ if (ret)
+ return ret;
+
+ return sprintf(buf, "%s\n", ocmode == KSZ9477_PTP_OCMODE_MASTER ? "master" : "slave");
+}
+
+static ssize_t ocmode_store(struct device *dev, struct device_attribute *attr __always_unused,
+ char const *buf, size_t count)
+{
+ struct ksz_device *ksz = dev_get_drvdata(dev);
+ int ret;
+
+ if (strcasecmp(buf, "master") == 0)
+ ret = ksz9477_ptp_ocmode_set(ksz, KSZ9477_PTP_OCMODE_MASTER);
+ else if (strcasecmp(buf, "slave") == 0)
+ ret = ksz9477_ptp_ocmode_set(ksz, KSZ9477_PTP_OCMODE_SLAVE);
+ else
+ return -EINVAL;
+
+ return ret ? ret : (ssize_t)count;
+}
+
+static DEVICE_ATTR_RW(ocmode);
+
+static struct attribute *ksz9477_ptp_attrs[] = {
+ &dev_attr_tcmode.attr,
+ &dev_attr_ocmode.attr,
+ NULL,
+};
+
+static struct attribute_group ksz9477_ptp_attrgrp = {
+ .attrs = ksz9477_ptp_attrs,
+};
+
int ksz_ptp_clock_register(struct dsa_switch *ds)
{
struct ksz_device *dev = ds->priv;
@@ -951,7 +1105,16 @@ int ksz_ptp_clock_register(struct dsa_switch *ds)
if (IS_ERR_OR_NULL(ptp_data->clock))
return PTR_ERR(ptp_data->clock);
+ /* Init attributes */
+ ret = sysfs_create_group(&dev->dev->kobj, &ksz9477_ptp_attrgrp);
+ if (ret)
+ goto error_unregister_clock;
+
return 0;
+
+error_unregister_clock:
+ ptp_clock_unregister(ptp_data->clock);
+ return ret;
}
void ksz_ptp_clock_unregister(struct dsa_switch *ds)
@@ -959,6 +1122,7 @@ void ksz_ptp_clock_unregister(struct dsa_switch *ds)
struct ksz_device *dev = ds->priv;
struct ksz_ptp_data *ptp_data;
+ sysfs_remove_group(&dev->dev->kobj, &ksz9477_ptp_attrgrp);
ptp_data = &dev->ptp_data;
if (ptp_data->clock)
--
GitLab
parent reply other threads:[~2026-04-30 7:58 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <BN1P110MB057898FE6C49EDDB74498DD3C334A@BN1P110MB0578.NAMP110.PROD.OUTLOOK.COM>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10847188.nUPlyArG6x@n9w6sw14 \
--to=ceggers@arri.de \
--cc=Brian.Hutchinson@l3harris.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=arun.ramadoss@microchip.com \
--cc=matt.becker@l3harris.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox