From nobody Sun Feb 8 09:16:37 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E75433290B; Tue, 27 Jan 2026 09:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504822; cv=none; b=XQDlMPwD0Xj/B9xFCzLuNcyphfO3ySO8kOiuUO233KOjtmmUIyxYGbyXJQP6RNSickzclc5wmxmPwpmdDO8QKUe3JVsLQuAeiCmqD3PokFle41rWP58EOKg4ZSu/HE/3Vpsj7D02MSRofc0r6sS0W34Sn2p+YJLVSN2+E6B43l0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504822; c=relaxed/simple; bh=N3ryQbGEWD3cPHtfikuGqfoTM8sOAlPC0aYgdbP0Wxw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e1rOl4qAW3gEARzJaMaoRiM+r2NEV98cM4E6GZxZ2DkwY0TiYbEpHkR/pcPjcQpHjSaD9zaaCYzOGvstiVLmVjJ8F8ijQzVdfX3SEdevhsyYE2eeovnpU1krg6F9awaGJ5jZyWD0nmi1Q57hZBxobpUCUfhZm6WZPM7Ic7u5xT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=fQWjHsO9; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="fQWjHsO9" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 346FC1A2A6D; Tue, 27 Jan 2026 09:06:54 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0AF42606F5; Tue, 27 Jan 2026 09:06:54 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 95E0F119A867A; Tue, 27 Jan 2026 10:06:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769504813; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=gkMPdwGfu8X4F3+hrF5ewptOuduz1YxWL/Ffa1MnO38=; b=fQWjHsO9tfDbtXAmwrc5QlQJPvzKjHAcIFmCQrAapjxfLcQmrVxlFtvYX9QoFvVZyxsQ8/ QguLLR2mQOotirZMD9/YKX/ZFc42vKKAXQcZa6gWhuImpnFKvN6PefahLjMRwEWUrzjSTa 2AYtrqpT/2LUELE+SPoegWX42wLQsSmFqpoSSJ+hCNCBdf6FxgYmhJHjkDSE0V0ev+AfXG YSgref+WyuYf+Yzu1GWZLJ1WoQHsE25IhNm0ZFw/oLGywk47mPCcICUKQS/tAT4fIF9s8l Fl4hlAoVcK4xNKVlvYgjJnEUZsxcS0hiFVbGIB/tZLofjxZz+K1rAN/0XxCr2A== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 27 Jan 2026 10:06:43 +0100 Subject: [PATCH net-next v4 1/8] net: dsa: microchip: Add support for KSZ8463 global irq Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260127-ksz8463-ptp-v4-1-652e021aae86@bootlin.com> References: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> In-Reply-To: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Simon Horman Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 KSZ8463's interrupt scheme differs from the others KSZ swicthes. Its global interrupt handling is done through an 'enable irq' register instead of a 'mask irq' one, so the bit logic to enable/disable interrupt is reversed. Also its interrupts registers are 16-bits registers and don't have the same address. Add ksz8463-specific global interrupt setup function that still relies on the ksz_irq_common_setup(). Add a check on the device type in the irq_chip operations to adjust the bit logic for KSZ8463 Signed-off-by: Bastien Curutchet (Schneider Electric) Reviewed-by: Maxime Chevallier --- drivers/net/dsa/microchip/ksz_common.c | 40 +++++++++++++++++++++++++++++-= ---- drivers/net/dsa/microchip/ksz_common.h | 3 +++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index e5fa1f5fc09b37c1a9d907175f8cd2cd60aee180..82ec7142a02c432f162e472c831= faa010c035123 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2817,14 +2817,20 @@ static void ksz_irq_mask(struct irq_data *d) { struct ksz_irq *kirq =3D irq_data_get_irq_chip_data(d); =20 - kirq->masked |=3D BIT(d->hwirq); + if (ksz_is_ksz8463(kirq->dev)) + kirq->masked &=3D ~BIT(d->hwirq); + else + kirq->masked |=3D BIT(d->hwirq); } =20 static void ksz_irq_unmask(struct irq_data *d) { struct ksz_irq *kirq =3D irq_data_get_irq_chip_data(d); =20 - kirq->masked &=3D ~BIT(d->hwirq); + if (ksz_is_ksz8463(kirq->dev)) + kirq->masked |=3D BIT(d->hwirq); + else + kirq->masked &=3D ~BIT(d->hwirq); } =20 static void ksz_irq_bus_lock(struct irq_data *d) @@ -2840,7 +2846,10 @@ static void ksz_irq_bus_sync_unlock(struct irq_data = *d) struct ksz_device *dev =3D kirq->dev; int ret; =20 - ret =3D ksz_write8(dev, kirq->reg_mask, kirq->masked); + if (ksz_is_ksz8463(dev)) + ret =3D ksz_write16(dev, kirq->reg_mask, kirq->masked); + else + ret =3D ksz_write8(dev, kirq->reg_mask, kirq->masked); if (ret) dev_err(dev->dev, "failed to change IRQ mask\n"); =20 @@ -2890,14 +2899,14 @@ static irqreturn_t ksz_irq_thread_fn(int irq, void = *dev_id) unsigned int nhandled =3D 0; struct ksz_device *dev; unsigned int sub_irq; - u8 data; + u16 data; int ret; u8 n; =20 dev =3D kirq->dev; =20 /* Read interrupt status register */ - ret =3D ksz_read8(dev, kirq->reg_status, &data); + ret =3D ksz_read16(dev, kirq->reg_status, &data); if (ret) goto out; =20 @@ -2939,6 +2948,22 @@ static int ksz_irq_common_setup(struct ksz_device *d= ev, struct ksz_irq *kirq) return ret; } =20 +static int ksz8463_girq_setup(struct dsa_switch *ds) +{ + struct ksz_device *dev =3D ds->priv; + struct ksz_irq *girq =3D &dev->girq; + + girq->nirqs =3D 15; + girq->reg_mask =3D KSZ8463_REG_IER; + girq->reg_status =3D KSZ8463_REG_ISR; + girq->masked =3D 0; + snprintf(girq->name, sizeof(girq->name), "global_irq"); + + girq->irq_num =3D dev->irq; + + return ksz_irq_common_setup(dev, girq); +} + static int ksz_girq_setup(struct ksz_device *dev) { struct ksz_irq *girq =3D &dev->girq; @@ -3044,7 +3069,10 @@ static int ksz_setup(struct dsa_switch *ds) p->learning =3D true; =20 if (dev->irq > 0) { - ret =3D ksz_girq_setup(dev); + if (ksz_is_ksz8463(dev)) + ret =3D ksz8463_girq_setup(ds); + else + ret =3D ksz_girq_setup(dev); if (ret) return ret; =20 diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index 929aff4c55de5254defdc1afb52b224b3898233b..67a488a3b5787f93f9e2a9266ce= 04f6611b56bf8 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -839,6 +839,9 @@ static inline bool ksz_is_sgmii_port(struct ksz_device = *dev, int port) #define KSZ87XX_INT_PME_MASK BIT(4) =20 /* Interrupt */ +#define KSZ8463_REG_ISR 0x190 +#define KSZ8463_REG_IER 0x192 + #define REG_SW_PORT_INT_STATUS__1 0x001B #define REG_SW_PORT_INT_MASK__1 0x001F =20 --=20 2.52.0 From nobody Sun Feb 8 09:16:37 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ADF9332919 for ; Tue, 27 Jan 2026 09:07:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504824; cv=none; b=YwaDBTBgfo3C57ihITLYG8w5doDiHwK+QRXNAIF7MCwlOAXXmh51D2BOeYGzHGNOvXisBEE93ZBEsvREpsq8+Psc9fFuev/0OMPDdm8DpS9UALZaKNvYmeAzZaZOVfUxwvVPQb2ru7F+CJLHMhVizMsy44v94X8XaHCrLDw/tnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504824; c=relaxed/simple; bh=Mq588nrNPw+uc5oepjcOMjmGegEoAI+0BQA2zqK9rvc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aQGhU65kRiXrqOHKTa5/qwf59HEQjnVboiB7ylsD+2XuIER5+MMjrQhp3TJ5Dy5SKk/HceSIZkPqll0PlNX1yQc0o9QKw5CXfaZ3mhqw9xP4nG/1cU0D6B52zJnsFJbQrNrhGbj1nC9ckSs/aHnEQlK2zHuZB+VkcMmiWBR2fwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ML+8wrb2; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ML+8wrb2" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 263C1C211D1; Tue, 27 Jan 2026 09:06:58 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 29410606F5; Tue, 27 Jan 2026 09:06:56 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 70482119A867E; Tue, 27 Jan 2026 10:06:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769504815; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=msjsmNWxtn13jWdt/GBOpxERpRumsKymvRVrflpMg/g=; b=ML+8wrb2c3P03ykzUAZenBM6YIG4GfNLivVfNhPXP0RwhOcS9sqP2FI1rqZo9wkqKPllYv IXCRb3DlwHdgRCSRvHc1wD/C+qB31/Iua+ld7C41aLcMxfxlcoCxKmeGWqPlNgIAglH7iP HqJjptHHBq9h1bE6OVElh/YDE4wtuNZybPDc7buA72yli0xB3h9IouMFgsK9VKG8h6IVjM ay36IqcUdJOKHaQGWiuB25XdaY4Xm+KiECJFzufoY9DHhvhHdtrshQ7iNlHd5A6hQAXhF6 baR9+VhRWuaU/C0jZ7rNEDG6nMPP9rIQfJIfO36H/dGyxbYEINFdazLZQVrlDA== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 27 Jan 2026 10:06:44 +0100 Subject: [PATCH net-next v4 2/8] net: dsa: microchip: Decorrelate IRQ domain from port Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260127-ksz8463-ptp-v4-2-652e021aae86@bootlin.com> References: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> In-Reply-To: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Simon Horman Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 KSZ8463 has one register holding interrupt bits from both port 1 and 2. So it has to use one IRQ domain for both of its ports. This conflicts with the current initialization procedure that ties one IRQ domain to each port. Decorrelate IRQ domain from port so a port can use an IRQ domain not directly related to itself. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_ptp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index 4a2cc57a628f97bd51fcb11057bc4effda9205dd..3b0dddf918595e9318c9e977903= 5d5152dcd9dde 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -1099,18 +1099,17 @@ static void ksz_ptp_msg_irq_free(struct ksz_port *p= ort, u8 n) irq_dispose_mapping(ptpmsg_irq->num); } =20 -static int ksz_ptp_msg_irq_setup(struct ksz_port *port, u8 n) +static int ksz_ptp_msg_irq_setup(struct irq_domain *domain, struct ksz_por= t *port, u8 n) { u16 ts_reg[] =3D {REG_PTP_PORT_PDRESP_TS, REG_PTP_PORT_XDELAY_TS, REG_PTP_PORT_SYNC_TS}; static const char * const name[] =3D {"pdresp-msg", "xdreq-msg", "sync-msg"}; const struct ksz_dev_ops *ops =3D port->ksz_dev->dev_ops; - struct ksz_irq *ptpirq =3D &port->ptpirq; struct ksz_ptp_irq *ptpmsg_irq; =20 ptpmsg_irq =3D &port->ptpmsg_irq[n]; - ptpmsg_irq->num =3D irq_create_mapping(ptpirq->domain, n); + ptpmsg_irq->num =3D irq_create_mapping(domain, n); if (!ptpmsg_irq->num) return -EINVAL; =20 @@ -1162,7 +1161,7 @@ int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p) goto out; =20 for (irq =3D 0; irq < ptpirq->nirqs; irq++) { - ret =3D ksz_ptp_msg_irq_setup(port, irq); + ret =3D ksz_ptp_msg_irq_setup(ptpirq->domain, port, irq); if (ret) goto out_ptp_msg; } --=20 2.52.0 From nobody Sun Feb 8 09:16:37 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45FBB33509C for ; Tue, 27 Jan 2026 09:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504827; cv=none; b=JRaU/v0/3n+Up/10EB+cmD0WB6Hy+Vgl/c6SV/40KCGsaVLe+23rkhqbYMe8LTdpus/JGSTdRHa1SR2+KDIJtGGPXmXTHcazQNZKWWMrHn2vm+EmLmDG1qD0WD71uZKXu5m6HkO2LZFXZ25tM8yTNUmCPsSYd8J7uglneWd2UI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504827; c=relaxed/simple; bh=5JRPbX6ZNpbbjxewpLGryuvTwhcPES2z48M948O/Y2Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aZv2jwRNdYL51BOcMOVAXCUX8Fwr8fiPhp/W3ssVFDOTYUfwgIl2jnKkGt7/CnBepT1gafYJSzUGov6eH5w9w3Aoo6yy9HupOyeDKhCLAfKUp+cL4OKl0+WZBZJLYdEsaB+yMsXkWF5QFIgSvkUFzAkNNbMT4jV93N25dGPB+tM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=bYvwtL2D; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="bYvwtL2D" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 78E604E422CD; Tue, 27 Jan 2026 09:06:58 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4E475606F5; Tue, 27 Jan 2026 09:06:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 86137119A8673; Tue, 27 Jan 2026 10:06:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769504817; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=raSc7l7Hms0kVCTaWY56CLFkcCyEbYi+dFevYnfrWHg=; b=bYvwtL2DgboCj5gDnd5OYC+lTZCcfIuY0xcVY4mYu7mHFW8gSQihZ6W5NyT0YRn0a5FBxF v3DvzIi5WEaRtKBeE53N/FmmDRbuy9ttABCCFPWF3CYrZKPnwcle8nDyTHcxMxmyZFdnNE ey18gayxwIzPOXow5NIsCQmvYPLpTrnxh+SNa+NMK7VWasqxp2Z5YO82FPtdyjUTkWENqA nEQ8Ye3T3MfOKUdOqKQcbZ8+qeHBhemXz7lUQNFIyzdTOltFv/Bhb1w0jNcP2I1m3iMzqA t4cCiMKzwkXNQMw+/PuoAcWSHu4NCwNAw2loCInBBBEe0ca63P6n+tzMtX7Srw== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 27 Jan 2026 10:06:45 +0100 Subject: [PATCH net-next v4 3/8] net: dsa: microchip: Decorrelate msg_irq index from IRQ bit offset Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260127-ksz8463-ptp-v4-3-652e021aae86@bootlin.com> References: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> In-Reply-To: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Simon Horman Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 KSZ8463 has one register containing all the PTP-related interrupts from all ports. So it will use one IRQ domain for all of them, leading to 4 interrupt bits to be dispatched in two ports. Current implementation doesn't allow to do so because the IRQ bit offset is also used as index to store the struct ptpmsg_irq in the table held by the port. Add a new input to the setup() function to independently provide the interrupt bit offset and the ptpmsg_irq index. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_ptp.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index 3b0dddf918595e9318c9e9779035d5152dcd9dde..ae46ba41c588c076de2c3b70c7c= 6702ad85263d5 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -1099,7 +1099,8 @@ static void ksz_ptp_msg_irq_free(struct ksz_port *por= t, u8 n) irq_dispose_mapping(ptpmsg_irq->num); } =20 -static int ksz_ptp_msg_irq_setup(struct irq_domain *domain, struct ksz_por= t *port, u8 n) +static int ksz_ptp_msg_irq_setup(struct irq_domain *domain, struct ksz_por= t *port, + u8 index, int irq) { u16 ts_reg[] =3D {REG_PTP_PORT_PDRESP_TS, REG_PTP_PORT_XDELAY_TS, REG_PTP_PORT_SYNC_TS}; @@ -1108,15 +1109,15 @@ static int ksz_ptp_msg_irq_setup(struct irq_domain = *domain, struct ksz_port *por const struct ksz_dev_ops *ops =3D port->ksz_dev->dev_ops; struct ksz_ptp_irq *ptpmsg_irq; =20 - ptpmsg_irq =3D &port->ptpmsg_irq[n]; - ptpmsg_irq->num =3D irq_create_mapping(domain, n); + ptpmsg_irq =3D &port->ptpmsg_irq[index]; + ptpmsg_irq->num =3D irq_create_mapping(domain, irq); if (!ptpmsg_irq->num) return -EINVAL; =20 ptpmsg_irq->port =3D port; - ptpmsg_irq->ts_reg =3D ops->get_port_addr(port->num, ts_reg[n]); + ptpmsg_irq->ts_reg =3D ops->get_port_addr(port->num, ts_reg[index]); =20 - strscpy(ptpmsg_irq->name, name[n]); + strscpy(ptpmsg_irq->name, name[index]); =20 return request_threaded_irq(ptpmsg_irq->num, NULL, ksz_ptp_msg_thread_fn, IRQF_ONESHOT, @@ -1161,7 +1162,7 @@ int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p) goto out; =20 for (irq =3D 0; irq < ptpirq->nirqs; irq++) { - ret =3D ksz_ptp_msg_irq_setup(ptpirq->domain, port, irq); + ret =3D ksz_ptp_msg_irq_setup(ptpirq->domain, port, irq, irq); if (ret) goto out_ptp_msg; } --=20 2.52.0 From nobody Sun Feb 8 09:16:37 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4BF333290C for ; Tue, 27 Jan 2026 09:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504823; cv=none; b=d+X1gbfZfxS3jCDLOxUYyBRbMaNLhun8DFbnU0sFwOIToEhFN7ZryGCYf7oKNWVMURwTZ+9+r/F0NzBkAsmoMf16iUMdW+zlt+GCRz2iOhelB7KSEJfl5NaPcgVzI+FgTF4BtQIGyN5BXSOME+vTQqXY051Y8lHrkr3tKn6kZkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504823; c=relaxed/simple; bh=/mlP9kI2Or8o2p8fWqvo/LN25FOpFuVX1gQxxlQpdws=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DgHdF/xDlNTpkR81yFxZBBJIJ7/uonM/qLqHUG3tejsmxLY9dZVfl+ph0iRynUI1etesJaeRF7gTyeY8W+4SnaOz5/62FNnfmG3xBu6KvtHPDdzTsprYyOtpFM+wWgqqR8XOfTRZDS+QOrOvb9t5Gb4NBmPDYs3RAl9cOG+o/XY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=pNrVIaij; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="pNrVIaij" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id BFEE01A2A71; Tue, 27 Jan 2026 09:07:00 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 95918606F5; Tue, 27 Jan 2026 09:07:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BD725119A867A; Tue, 27 Jan 2026 10:06:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769504819; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=CP8mvXRQhRbUnoQ95hOGvB8ViUY7+K61hwEjmpRAZp8=; b=pNrVIaiji9uIXXwL1p0sTwNkhY973ZYzYoR4GzV/e62BhcfCXJZbkF2wIcjwcE7rV1FDIv QOJUj8Ab8D3YsW/G7j3A2uaaAEfx796WGjGfFuSloGMSQNnc3knNp+JmWjuPLo1ZJabybT IWko7mp4pQyek2tVDtMFIo3MhFS+FQNVahLn84iHndSQbQZHMAlkcB5ET/bUXEVvtBqCsk Y6RjMB8ccBwqIq/pkRczlr28OvNoVJg3AOu630cy6mMRLCBieEUj9X5WJac0mEvlcPJiTD 3nxNtWbr3/3mkqXBxHwec7uKqJ4WyVZKkvCqr+VLhh7y3YSzrhi28P8cHTjUDQ== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 27 Jan 2026 10:06:46 +0100 Subject: [PATCH net-next v4 4/8] net: dsa: microchip: Add support for KSZ8463's PTP interrupts Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260127-ksz8463-ptp-v4-4-652e021aae86@bootlin.com> References: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> In-Reply-To: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Simon Horman Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 KSZ8463 PTP interrupts aren't handled by the driver. The interrupt layout in KSZ8463 has nothing to do with the other switches: - all the interrupts of all ports are grouped into one status register while others have one interrupt register per port - xdelay_req and pdresp timestamps share one single interrupt bit on the KSZ8463 while each of them has its own interrupt bit on other switches Add KSZ8463-specific IRQ setup()/free() functions to support KSZ8463. Both ports share one IRQ domain held by port n=C2=B01. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_common.c | 49 +++++++++----- drivers/net/dsa/microchip/ksz_common.h | 2 + drivers/net/dsa/microchip/ksz_ptp.c | 112 ++++++++++++++++++++++++++++= +++- drivers/net/dsa/microchip/ksz_ptp.h | 9 +++ drivers/net/dsa/microchip/ksz_ptp_reg.h | 7 ++ 5 files changed, 160 insertions(+), 19 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 82ec7142a02c432f162e472c831faa010c035123..224be307b3417bf30d62da5c94e= fc6714d914dc6 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3076,15 +3076,21 @@ static int ksz_setup(struct dsa_switch *ds) if (ret) return ret; =20 - dsa_switch_for_each_user_port(dp, dev->ds) { - ret =3D ksz_pirq_setup(dev, dp->index); + if (ksz_is_ksz8463(dev)) { + ret =3D ksz8463_ptp_irq_setup(ds); if (ret) - goto port_release; - - if (dev->info->ptp_capable) { - ret =3D ksz_ptp_irq_setup(ds, dp->index); + goto girq_release; + } else { + dsa_switch_for_each_user_port(dp, dev->ds) { + ret =3D ksz_pirq_setup(dev, dp->index); if (ret) - goto pirq_release; + goto port_release; + + if (dev->info->ptp_capable) { + ret =3D ksz_ptp_irq_setup(ds, dp->index); + if (ret) + goto pirq_release; + } } } } @@ -3119,14 +3125,20 @@ static int ksz_setup(struct dsa_switch *ds) ksz_ptp_clock_unregister(ds); port_release: if (dev->irq > 0) { - dsa_switch_for_each_user_port_continue_reverse(dp, dev->ds) { - if (dev->info->ptp_capable) - ksz_ptp_irq_free(ds, dp->index); + if (ksz_is_ksz8463(dev)) { + ksz8463_ptp_irq_free(ds); + } else { + dsa_switch_for_each_user_port_continue_reverse(dp, dev->ds) { + if (dev->info->ptp_capable) + ksz_ptp_irq_free(ds, dp->index); pirq_release: - ksz_irq_free(&dev->ports[dp->index].pirq); + ksz_irq_free(&dev->ports[dp->index].pirq); + } } - ksz_irq_free(&dev->girq); } +girq_release: + if (dev->irq > 0) + ksz_irq_free(&dev->girq); =20 return ret; } @@ -3140,11 +3152,14 @@ static void ksz_teardown(struct dsa_switch *ds) ksz_ptp_clock_unregister(ds); =20 if (dev->irq > 0) { - dsa_switch_for_each_user_port(dp, dev->ds) { - if (dev->info->ptp_capable) - ksz_ptp_irq_free(ds, dp->index); - - ksz_irq_free(&dev->ports[dp->index].pirq); + if (ksz_is_ksz8463(dev)) { + ksz8463_ptp_irq_free(ds); + } else { + dsa_switch_for_each_user_port(dp, dev->ds) { + if (dev->info->ptp_capable) + ksz_ptp_irq_free(ds, dp->index); + ksz_irq_free(&dev->ports[dp->index].pirq); + } } =20 ksz_irq_free(&dev->girq); diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index 67a488a3b5787f93f9e2a9266ce04f6611b56bf8..dfbc3d13daca8d7a8b9d3ffe6a7= c1ec9927863f2 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -851,6 +851,8 @@ static inline bool ksz_is_sgmii_port(struct ksz_device = *dev, int port) #define PORT_SRC_PHY_INT 1 #define PORT_SRC_PTP_INT 2 =20 +#define KSZ8463_SRC_PTP_INT 12 + #define KSZ8795_HUGE_PACKET_SIZE 2000 #define KSZ8863_HUGE_PACKET_SIZE 1916 #define KSZ8863_NORMAL_PACKET_SIZE 1536 diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index ae46ba41c588c076de2c3b70c7c6702ad85263d5..5daadf62689e6d60ab32e7a5a6c= 1f3fac3024b87 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -31,6 +31,9 @@ #define KSZ_PTP_SUBNS_BITS 32 =20 #define KSZ_PTP_INT_START 13 +#define KSZ8463_PTP_PORT1_INT_START 12 +#define KSZ8463_PTP_PORT2_INT_START 14 +#define KSZ8463_PTP_INT_START KSZ8463_PTP_PORT1_INT_START =20 static int ksz_ptp_tou_gpio(struct ksz_device *dev) { @@ -1102,6 +1105,7 @@ static void ksz_ptp_msg_irq_free(struct ksz_port *por= t, u8 n) static int ksz_ptp_msg_irq_setup(struct irq_domain *domain, struct ksz_por= t *port, u8 index, int irq) { + static const char * const ksz8463_name[] =3D {"sync-msg", "delay-msg"}; u16 ts_reg[] =3D {REG_PTP_PORT_PDRESP_TS, REG_PTP_PORT_XDELAY_TS, REG_PTP_PORT_SYNC_TS}; static const char * const name[] =3D {"pdresp-msg", "xdreq-msg", @@ -1115,15 +1119,106 @@ static int ksz_ptp_msg_irq_setup(struct irq_domain= *domain, struct ksz_port *por return -EINVAL; =20 ptpmsg_irq->port =3D port; - ptpmsg_irq->ts_reg =3D ops->get_port_addr(port->num, ts_reg[index]); =20 - strscpy(ptpmsg_irq->name, name[index]); + if (ksz_is_ksz8463(port->ksz_dev)) { + ts_reg[0] =3D KSZ8463_REG_PORT_SYNC_TS; + ts_reg[1] =3D KSZ8463_REG_PORT_DREQ_TS; + strscpy(ptpmsg_irq->name, ksz8463_name[index]); + } else { + strscpy(ptpmsg_irq->name, name[index]); + } + + ptpmsg_irq->ts_reg =3D ops->get_port_addr(port->num, ts_reg[index]); =20 return request_threaded_irq(ptpmsg_irq->num, NULL, ksz_ptp_msg_thread_fn, IRQF_ONESHOT, ptpmsg_irq->name, ptpmsg_irq); } =20 +static int ksz8463_ptp_port_irq_setup(struct ksz_irq *ptpirq, struct ksz_p= ort *port, int hw_irq) +{ + int ret; + int i; + + init_completion(&port->tstamp_msg_comp); + + for (i =3D 0; i < 2; i++) { + ret =3D ksz_ptp_msg_irq_setup(ptpirq->domain, port, i, hw_irq++); + if (ret) + goto release_msg_irq; + } + + return 0; + +release_msg_irq: + while (i--) + ksz_ptp_msg_irq_free(port, i); + + return ret; +} + +static void ksz8463_ptp_port_irq_teardown(struct ksz_port *port) +{ + int i; + + for (i =3D 0; i < 2; i++) + ksz_ptp_msg_irq_free(port, i); +} + +int ksz8463_ptp_irq_setup(struct dsa_switch *ds) +{ + struct ksz_device *dev =3D ds->priv; + struct ksz_port *port1, *port2; + struct ksz_irq *ptpirq; + int ret; + + port1 =3D &dev->ports[0]; + port2 =3D &dev->ports[1]; + ptpirq =3D &port1->ptpirq; + + ptpirq->irq_num =3D irq_find_mapping(dev->girq.domain, KSZ8463_SRC_PTP_IN= T); + if (!ptpirq->irq_num) + return -EINVAL; + + ptpirq->dev =3D dev; + ptpirq->nirqs =3D 4; + ptpirq->reg_mask =3D KSZ8463_PTP_TS_IER; + ptpirq->reg_status =3D KSZ8463_PTP_TS_ISR; + ptpirq->irq0_offset =3D KSZ8463_PTP_INT_START; + snprintf(ptpirq->name, sizeof(ptpirq->name), "ptp-irq"); + + ptpirq->domain =3D irq_domain_create_linear(dev_fwnode(dev->dev), ptpirq-= >nirqs, + &ksz_ptp_irq_domain_ops, ptpirq); + if (!ptpirq->domain) + return -ENOMEM; + + ret =3D request_threaded_irq(ptpirq->irq_num, NULL, ksz_ptp_irq_thread_fn, + IRQF_ONESHOT, ptpirq->name, ptpirq); + if (ret) + goto release_domain; + + ret =3D ksz8463_ptp_port_irq_setup(ptpirq, port1, + KSZ8463_PTP_PORT1_INT_START - KSZ8463_PTP_INT_START); + if (ret) + goto release_irq; + + ret =3D ksz8463_ptp_port_irq_setup(ptpirq, port2, + KSZ8463_PTP_PORT2_INT_START - KSZ8463_PTP_INT_START); + if (ret) + goto free_port1; + + return 0; + +free_port1: + ksz8463_ptp_port_irq_teardown(port1); +release_irq: + free_irq(ptpirq->irq_num, ptpirq); +release_domain: + irq_domain_remove(ptpirq->domain); + + return ret; +} + int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p) { struct ksz_device *dev =3D ds->priv; @@ -1181,6 +1276,19 @@ int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p) return ret; } =20 +void ksz8463_ptp_irq_free(struct dsa_switch *ds) +{ + struct ksz_device *dev =3D ds->priv; + struct ksz_port *port1 =3D &dev->ports[0]; + struct ksz_port *port2 =3D &dev->ports[1]; + struct ksz_irq *ptpirq =3D &port1->ptpirq; + + ksz8463_ptp_port_irq_teardown(port1); + ksz8463_ptp_port_irq_teardown(port2); + free_irq(ptpirq->irq_num, ptpirq); + irq_domain_remove(ptpirq->domain); +} + void ksz_ptp_irq_free(struct dsa_switch *ds, u8 p) { struct ksz_device *dev =3D ds->priv; diff --git a/drivers/net/dsa/microchip/ksz_ptp.h b/drivers/net/dsa/microchi= p/ksz_ptp.h index 3086e519b1b641e9e4126cb6ff43409f6d7f29a5..46494caacc4287b845b8e5c3a68= bcfc7a03bcf9d 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.h +++ b/drivers/net/dsa/microchip/ksz_ptp.h @@ -48,6 +48,8 @@ void ksz_port_txtstamp(struct dsa_switch *ds, int port, s= truct sk_buff *skb); void ksz_port_deferred_xmit(struct kthread_work *work); bool ksz_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *sk= b, unsigned int type); +int ksz8463_ptp_irq_setup(struct dsa_switch *ds); +void ksz8463_ptp_irq_free(struct dsa_switch *ds); int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p); void ksz_ptp_irq_free(struct dsa_switch *ds, u8 p); =20 @@ -65,6 +67,13 @@ static inline int ksz_ptp_clock_register(struct dsa_swit= ch *ds) =20 static inline void ksz_ptp_clock_unregister(struct dsa_switch *ds) { } =20 +static inline int ksz8463_ptp_irq_setup(struct dsa_switch *ds) +{ + return 0; +} + +static inline void ksz8463_ptp_irq_free(struct dsa_switch *ds) {} + static inline int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p) { return 0; diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/micr= ochip/ksz_ptp_reg.h index eab9aecb7fa8a50323de4140695b2004d1beab8c..e80fb4bd1a0e970ba3570374d3d= c82c8e2cc15b4 100644 --- a/drivers/net/dsa/microchip/ksz_ptp_reg.h +++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h @@ -121,6 +121,10 @@ #define REG_PTP_PORT_SYNC_TS 0x0C0C #define REG_PTP_PORT_PDRESP_TS 0x0C10 =20 +#define KSZ8463_REG_PORT_DREQ_TS 0x0648 +#define KSZ8463_REG_PORT_SYNC_TS 0x064C +#define KSZ8463_REG_PORT_DRESP_TS 0x0650 + #define REG_PTP_PORT_TX_INT_STATUS__2 0x0C14 #define REG_PTP_PORT_TX_INT_ENABLE__2 0x0C16 =20 @@ -131,4 +135,7 @@ #define KSZ_XDREQ_MSG 1 #define KSZ_PDRES_MSG 0 =20 +#define KSZ8463_PTP_TS_ISR 0x68C +#define KSZ8463_PTP_TS_IER 0x68E + #endif --=20 2.52.0 From nobody Sun Feb 8 09:16:37 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21696331A7E for ; Tue, 27 Jan 2026 09:07:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504825; cv=none; b=XM2Hj1kmafUsHtlv6/y3cYLo+llns59R5PybzIpNzFKiusgZsr2qFMlhE6kZ2DyP0nPH53wWjcUFtYU+gLUgHdNPH00hd5QZAhnmaihQJrmwkCTSUHkUQTPdnaqCmckPuoz7FUN6HQ2CQD+6gUIiywDN7OImGCe2QU1a1N0oPgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504825; c=relaxed/simple; bh=NXBqTeRrMdmbv9KNJEvENd/g8zIiTw3uvoCmEedoIqM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RLd6pgCyGkYmT76mPDbu5dA9CDmcz8fyGidm9aXPCeS8nX6rkRPED8jTGoxXqhz4rNXsRjkHSZPbIQLsqLrR4oQ1h6vZBetGQ9s0MZie6ZiHHH+p6N1TQ5pEk/VtoJu/0TfLWsM7BSISCkfXI9LoD+8RjKiTYel9xRPtfJzkxYw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=OZwTOJjT; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="OZwTOJjT" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id C493D1A2A6C; Tue, 27 Jan 2026 09:07:02 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 901B9606F5; Tue, 27 Jan 2026 09:07:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EE7AF119A867E; Tue, 27 Jan 2026 10:06:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769504821; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=mAdxSZE83xUC1VcdJ9laK4kQl5LwI5jSzJL0hyvTGo8=; b=OZwTOJjTivWyivf9AVGyHUFR/afyOM/m89r+rLBC3D8W1vLTUx7GS1KOGt/H29MEsTvLsE cZZs38lDRgsc5FSJiKLkkaC0XpDYP2WinEAPMNNXZ3yHK/0eAJeFWHMLDaz7ZrBmDOqsoF JCaMRjtdFxrA788ylqHbRhyA3/gddvVfTVDH5SyzUL/T17vhJFA5Cz36rqB0dnYI60Jirk ieYN7zmnvF7cB5vaObhRK/frzvBhs1/gGI7ixTRsFRgXtbC9tyLSm/TNc2QhFgdRj5bkHK fj+0E5LLDscdTL/nbkz8BirkvciK851nNoTQUgSqaDem+dId/KdpfdkeZTc3gw== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 27 Jan 2026 10:06:47 +0100 Subject: [PATCH net-next v4 5/8] net: dsa: microchip: Add KSZ8463 tail tag handling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260127-ksz8463-ptp-v4-5-652e021aae86@bootlin.com> References: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> In-Reply-To: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Simon Horman Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 KSZ8463 uses the KSZ9893 DSA TAG driver. However, the KSZ8463 doesn't use the tail tag to convey timestamps to the host as KSZ9893 does. It uses the reserved fields in the PTP header instead. Add a KSZ8463-specifig DSA_TAG driver to handle KSZ8463 timestamps. There is no information in the tail tag to distinguish PTP packets from others so use the ptp_classify_raw() helper to find the PTP packets and extract the timestamp from their PTP headers. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_common.c | 5 ++- include/net/dsa.h | 2 + net/dsa/tag_ksz.c | 70 ++++++++++++++++++++++++++++++= ++++ 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 224be307b3417bf30d62da5c94efc6714d914dc6..5141343d2f40bbd380c0b52f691= 9b842fb71a8fd 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3580,8 +3580,10 @@ static enum dsa_tag_protocol ksz_get_tag_protocol(st= ruct dsa_switch *ds, if (ksz_is_ksz87xx(dev) || ksz_is_8895_family(dev)) proto =3D DSA_TAG_PROTO_KSZ8795; =20 + if (dev->chip_id =3D=3D KSZ8463_CHIP_ID) + proto =3D DSA_TAG_PROTO_KSZ8463; + if (dev->chip_id =3D=3D KSZ88X3_CHIP_ID || - dev->chip_id =3D=3D KSZ8463_CHIP_ID || dev->chip_id =3D=3D KSZ8563_CHIP_ID || dev->chip_id =3D=3D KSZ9893_CHIP_ID || dev->chip_id =3D=3D KSZ9563_CHIP_ID) @@ -3611,6 +3613,7 @@ static int ksz_connect_tag_protocol(struct dsa_switch= *ds, return 0; case DSA_TAG_PROTO_KSZ9893: case DSA_TAG_PROTO_KSZ9477: + case DSA_TAG_PROTO_KSZ8463: case DSA_TAG_PROTO_LAN937X: tagger_data =3D ksz_tagger_data(ds); tagger_data->xmit_work_fn =3D ksz_port_deferred_xmit; diff --git a/include/net/dsa.h b/include/net/dsa.h index 6b2b5ed64ea4cee6ab59c9e6eaab30f07f82816a..5b5fed6e6f9171f5875d61c1395= 758065ac5808a 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -57,6 +57,7 @@ struct tc_action; #define DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE 29 #define DSA_TAG_PROTO_YT921X_VALUE 30 #define DSA_TAG_PROTO_MXL_GSW1XX_VALUE 31 +#define DSA_TAG_PROTO_KSZ8463_VALUE 32 =20 enum dsa_tag_protocol { DSA_TAG_PROTO_NONE =3D DSA_TAG_PROTO_NONE_VALUE, @@ -91,6 +92,7 @@ enum dsa_tag_protocol { DSA_TAG_PROTO_VSC73XX_8021Q =3D DSA_TAG_PROTO_VSC73XX_8021Q_VALUE, DSA_TAG_PROTO_YT921X =3D DSA_TAG_PROTO_YT921X_VALUE, DSA_TAG_PROTO_MXL_GSW1XX =3D DSA_TAG_PROTO_MXL_GSW1XX_VALUE, + DSA_TAG_PROTO_KSZ8463 =3D DSA_TAG_PROTO_KSZ8463_VALUE, }; =20 struct dsa_switch; diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index 9170a0148cc43b4213ec4bd8e81d338589671f23..f6590549908e016ca224501e6bc= 296c9c5feafb3 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c @@ -16,6 +16,7 @@ #define KSZ9477_NAME "ksz9477" #define KSZ9893_NAME "ksz9893" #define LAN937X_NAME "lan937x" +#define KSZ8463_NAME "ksz8463" =20 /* Typically only one byte is used for tail tag. */ #define KSZ_PTP_TAG_LEN 4 @@ -383,6 +384,74 @@ static const struct dsa_device_ops ksz9893_netdev_ops = =3D { DSA_TAG_DRIVER(ksz9893_netdev_ops); MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ9893, KSZ9893_NAME); =20 +#define KSZ8463_TAIL_TAG_PRIO GENMASK(4, 3) +#define KSZ8463_TAIL_TAG_EG_PORT_M GENMASK(2, 0) + +static struct sk_buff *ksz8463_xmit(struct sk_buff *skb, + struct net_device *dev) +{ + u16 queue_mapping =3D skb_get_queue_mapping(skb); + u8 prio =3D netdev_txq_to_tc(dev, queue_mapping); + struct dsa_port *dp =3D dsa_user_to_port(dev); + u8 *tag; + + if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL && skb_checksum_help(skb)) + return NULL; + + tag =3D skb_put(skb, KSZ_INGRESS_TAG_LEN); + + *tag =3D BIT(dp->index); + *tag |=3D FIELD_PREP(KSZ8463_TAIL_TAG_PRIO, prio); + + return ksz_defer_xmit(dp, skb); +} + +static struct sk_buff *ksz8463_rcv(struct sk_buff *skb, struct net_device = *dev) +{ + unsigned int len =3D KSZ_EGRESS_TAG_LEN; + struct ptp_header *ptp_hdr; + unsigned int ptp_class; + unsigned int port; + ktime_t tstamp; + u8 *tag; + + if (skb_linearize(skb)) + return NULL; + + /* Tag decoding */ + tag =3D skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN; + port =3D tag[0] & KSZ8463_TAIL_TAG_EG_PORT_M; + + __skb_push(skb, ETH_HLEN); + ptp_class =3D ptp_classify_raw(skb); + __skb_pull(skb, ETH_HLEN); + if (ptp_class =3D=3D PTP_CLASS_NONE) + goto common_rcv; + + ptp_hdr =3D ptp_parse_header(skb, ptp_class); + if (ptp_hdr) { + tstamp =3D ksz_decode_tstamp(get_unaligned_be32(&ptp_hdr->reserved2)); + KSZ_SKB_CB(skb)->tstamp =3D tstamp; + ptp_hdr->reserved2 =3D 0; + } + +common_rcv: + return ksz_common_rcv(skb, dev, port, len); +} + +static const struct dsa_device_ops ksz8463_netdev_ops =3D { + .name =3D KSZ8463_NAME, + .proto =3D DSA_TAG_PROTO_KSZ8463, + .xmit =3D ksz8463_xmit, + .rcv =3D ksz8463_rcv, + .connect =3D ksz_connect, + .disconnect =3D ksz_disconnect, + .needed_tailroom =3D KSZ_INGRESS_TAG_LEN, +}; + +DSA_TAG_DRIVER(ksz8463_netdev_ops); +MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ8463, KSZ8463_NAME); + /* For xmit, 2/6 bytes are added before FCS. * -----------------------------------------------------------------------= ---- * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|ts(4bytes)|tag0(1byte)|tag1(1by= te)| @@ -457,6 +526,7 @@ static struct dsa_tag_driver *dsa_tag_driver_array[] = =3D { &DSA_TAG_DRIVER_NAME(ksz9477_netdev_ops), &DSA_TAG_DRIVER_NAME(ksz9893_netdev_ops), &DSA_TAG_DRIVER_NAME(lan937x_netdev_ops), + &DSA_TAG_DRIVER_NAME(ksz8463_netdev_ops), }; =20 module_dsa_tag_drivers(dsa_tag_driver_array); --=20 2.52.0 From nobody Sun Feb 8 09:16:37 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACEF2332EA1; Tue, 27 Jan 2026 09:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504827; cv=none; b=nkmHNSrrIWeSzqU5pPotqbDrelCaalQL7otut4CSTbNc1xjHoSyvX6yXk8AyKuBtxrFi7dses1nC5T55rWGtiyk9i7T8dWOQyjCaOpyHuOj79Tl+j5fs7wpTnEuJp11ffshYXhi8R2IpSa22sB6gGLDmXIdI2jK3//bzHkZYTB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504827; c=relaxed/simple; bh=kS+B5OilLXGZ1gQvzUctLuiqxVciKaom7Efo5RZq9XI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JQyYVm9BRRrEJkpLlv9MPJpkeuXCoJQjKF86sGe1lf8+ad/ruhlLW398w42mp1nRT/cmFEjwo0vJimxNkqjN1FoDqWtxO2FwNLmm6bJkahnYTzAGF13+nFYPTtzDnAK4jaPQlXBCyLHKzI6tlrNvxIKvKbeKhmoi9atMshN4KTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=1f5wbYp1; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="1f5wbYp1" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 8162A1A2A6D; Tue, 27 Jan 2026 09:07:04 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 58189606F5; Tue, 27 Jan 2026 09:07:04 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C9BAC119A8687; Tue, 27 Jan 2026 10:07:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769504823; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=m/Z7ATQ6+ydNQ6rrHsbH1591WnW/lV+NFsdbKJ+MOOw=; b=1f5wbYp12K7eRm/s11SVydzICy21FpKRCOORGMB/ubbTQfNnBoRZqnufrk4oaThI88mFTf Fgj6BqeGh4jYbjFR1L3l2AZy98RmOG6t5AV9RPAaeg5BVK6SH+GAK7r/0PZLNLLTvz1GEB lI3FkKwT4zr7goQU6bM46MqEeCAQjK4iFmFYXUhfB9ZCr9t3HhMQnelJaG1vtWbXc8K1U1 Ja8C1B0fH6sJbT7MI5VvlIFx0JWS53pW/C8qbMyifSBMij2qSsIetF5lbrf7y5NsKay5qv n2jJukcy0ZZOWdkXcGLeucHzT4GeVricOhjR5tmitLLV7WcmdjbqRxXq2SVuPg== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 27 Jan 2026 10:06:48 +0100 Subject: [PATCH net-next v4 6/8] net: dsa: microchip: Enable Ethernet PTP detection Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260127-ksz8463-ptp-v4-6-652e021aae86@bootlin.com> References: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> In-Reply-To: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Simon Horman Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 KSZ8463 needs to enable the Ethernet PTP detection to fire the interrupts when a timestamp is captured. Enable Ethernet PTP detection. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_ptp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index 5daadf62689e6d60ab32e7a5a6c1f3fac3024b87..7eb033157f226b1169bc184d715= 69328e9a20a5b 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -947,8 +947,8 @@ int ksz_ptp_clock_register(struct dsa_switch *ds) /* Currently only P2P mode is supported. When 802_1AS bit is set, it * forwards all PTP packets to host port and none to other ports. */ - ret =3D ksz_rmw16(dev, regs[PTP_MSG_CONF1], PTP_TC_P2P | PTP_802_1AS, - PTP_TC_P2P | PTP_802_1AS); + ret =3D ksz_rmw16(dev, regs[PTP_MSG_CONF1], PTP_TC_P2P | PTP_802_1AS | PT= P_ETH_ENABLE, + PTP_TC_P2P | PTP_802_1AS | PTP_ETH_ENABLE); if (ret) return ret; =20 --=20 2.52.0 From nobody Sun Feb 8 09:16:37 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A770F3370FF for ; Tue, 27 Jan 2026 09:07:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504829; cv=none; b=T92IeRnhQ/x5FUip3N0evLsVq+PSWDKBfSe8ye0+/rHSkYrJad4QcGor4Kd4/3EigFL7Ph4C2nNqzLgViWlpwygsQmGhONvrzaCUb2PIJgugMvfxlC5+DFj+cBd0FAPKKs1LKipJywdHaN9r0VSGUD372t9R/WT3ymHZlRL3MI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504829; c=relaxed/simple; bh=F3x7ujt23LH7Hzb/IBaAvxfIn3ywNtT91s3EJRLMZe8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AYelksvFmovy060OgfkQXfDto/q1cNtQjav36hvXt+sWPEWOXXceY+2JCVX73swEZYetATijN0QgDFS/uFR7xzRIQuiHqzmUEesxSmG3ueCKqFffDbMVptdVswkgGtj4xy78qOEv4SWrU7QWDm9aAgDj6K3VNQa7mcEfsjFTnEw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=hsoERJOD; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="hsoERJOD" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 7AA82C211D0; Tue, 27 Jan 2026 09:07:08 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 7B614606F5; Tue, 27 Jan 2026 09:07:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D6080119A8683; Tue, 27 Jan 2026 10:07:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769504825; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=5JUfVn7/HeLWZy5Qd02a6wIWBDQq2NcAA2klS+MsO1s=; b=hsoERJODB2UrEXkOw9tThTL0ZGHmlSRobhe6AIBh7Eh2WOyixZx6Gj5DM01c5GU8tU02F3 6NWaYCD5DU4778iwlzWE6iLZLNesqF2bdW9FOzhPyh2uqOl80lDhNZRo8nicE3pE66sSb7 XEozy3q+Eb+gFBhABUP8CZnS99zvRwg03Qmi2Mpwf4Pd9ZKyI1MeVa3HtyNPrnDdT60Xag 6qQYNZC3EqUudJ2UKxRJaFhQswkio85rauEV7j/vh6h73IIVoBQpcoMAZ9udMCC027D4Kf MRTcjukS1xuYVtYGcSx5DYQu/L9en/qkbbrT68brL1ofg9hxpfYKV0wjvKf3pw== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 27 Jan 2026 10:06:49 +0100 Subject: [PATCH net-next v4 7/8] net: dsa: microchip: Adapt port offset for KSZ8463's PTP register Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260127-ksz8463-ptp-v4-7-652e021aae86@bootlin.com> References: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> In-Reply-To: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Simon Horman Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 In KSZ8463 register's layout, the offset between port 1 and port 2 registers isn't the same in the generic control register area than in the PTP register area. The get_port_addr() always uses the same offset so it doesn't work when it's used to access PTP registers. Adapt the port offset in get_port_addr() when the accessed register is in the PTP area. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index c354abdafc1b542a32c276ef939a90db30c67f55..a05527899b8bab6d53509ba38c5= 8101b79e98ee5 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -2020,6 +2020,9 @@ u32 ksz8_get_port_addr(int port, int offset) =20 u32 ksz8463_get_port_addr(int port, int offset) { + if (offset >=3D KSZ8463_PTP_CLK_CTRL) + return offset + 0x20 * port; + return offset + 0x18 * port; } =20 --=20 2.52.0 From nobody Sun Feb 8 09:16:37 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59979339B49 for ; Tue, 27 Jan 2026 09:07:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504834; cv=none; b=GNz8M7w3qbUt3Kqpb3m2rkD391Lsm841IqcqGFGW/LGs9idtktOq27RWTJcQcC1i5tjRLDEzcnpa8WrRjEyPFEGuQkALiC3zjI1ZUJra+fZ1eSK6gu+qldx+NSuXDcN4T0ZWRmpejgQQ5M4qUDjqet05cH6RxdfhQ6/UWEJAF5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769504834; c=relaxed/simple; bh=64Arvmq2sRvqqzk2dsreHnPXzxrgRZpUINVBCX1caPU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dtb0DXUtV5FVjQ2LYjRLKTwhypfV67dX2Wn/yKxbl2hdzRkEf48MOW9A1dcwLlNPbZv9p7BA+Js6VnKZJ8CzKljJs+9QGwl1Nta1pu8HPenGnc5wWeB8DN0tc7rJcsRAVuSs/gqyl7wxKSYfsPQritl6XiAINH/zjQhl3lhTJjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=x7iLdS1c; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="x7iLdS1c" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 74BCD1A2A6D; Tue, 27 Jan 2026 09:07:08 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 498CD606F5; Tue, 27 Jan 2026 09:07:08 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E3AD0119A8686; Tue, 27 Jan 2026 10:07:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769504827; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=sTdHB09lzT72JQy4mNi+vIBCm0pWIK7KzixDxNqCtKE=; b=x7iLdS1cZK0YtkexNBOUUJc+a6UM7h9+LdPRU0VlNE8QFnanwPvHEo58H3NOWiHyR2Nusc sXK3iOIJqyelNbtZdDLx/XIETrStIo4hDLAdXpMC1EHWivQm/dIXEqdxYtCpJx/nsutrzX GBz8jGA3XdiRp2d935ueHfLlnKFJl4IMigd1TnwdoXFs5KMgBqRFmmhNoRU+MV5mwCp8wi ZEnvq4+bbj1BajLeBAAh6QilXYrzuaZUKayiS1kE61OCKnTLvCQgZokaBxQZoM7mYyfCmI QihmenqwLU6JNUs/S1/trw5HuLaYD+l+xcFq4Fsb73benBM1czl8AARY00xFkQ== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 27 Jan 2026 10:06:50 +0100 Subject: [PATCH net-next v4 8/8] net: dsa: microchip: Add two-step PTP support for KSZ8463 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260127-ksz8463-ptp-v4-8-652e021aae86@bootlin.com> References: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> In-Reply-To: <20260127-ksz8463-ptp-v4-0-652e021aae86@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Simon Horman Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 The KSZ8463 switch supports PTP but it's not supported by driver. Add L2 two-step PTP support for the KSZ8463. IPv4 and IPv6 layers aren't supported. Neither is one-step PTP. The pdelay_req and pdelay_resp timestamps share one interrupt bit status. So introduce last_tx_is_pdelayresp to keep track of the last sent event type. Use it to retrieve the relevant timestamp when the interrupt is caught. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 9 ++---- drivers/net/dsa/microchip/ksz8_reg.h | 1 + drivers/net/dsa/microchip/ksz_common.c | 1 + drivers/net/dsa/microchip/ksz_common.h | 1 + drivers/net/dsa/microchip/ksz_ptp.c | 52 ++++++++++++++++++++++++++---= ---- drivers/net/dsa/microchip/ksz_ptp_reg.h | 4 +++ 6 files changed, 51 insertions(+), 17 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index a05527899b8bab6d53509ba38c58101b79e98ee5..f4dfdbd52b9daeab8a0134fb09c= f4c960d9d9409 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -143,9 +143,9 @@ int ksz8_reset_switch(struct ksz_device *dev) KSZ8863_GLOBAL_SOFTWARE_RESET | KSZ8863_PCS_RESET, false); } else if (ksz_is_ksz8463(dev)) { ksz_cfg(dev, KSZ8463_REG_SW_RESET, - KSZ8463_GLOBAL_SOFTWARE_RESET, true); + KSZ8463_GLOBAL_SOFTWARE_RESET | KSZ8463_PTP_SOFTWARE_RESET, true); ksz_cfg(dev, KSZ8463_REG_SW_RESET, - KSZ8463_GLOBAL_SOFTWARE_RESET, false); + KSZ8463_GLOBAL_SOFTWARE_RESET | KSZ8463_PTP_SOFTWARE_RESET, false); } else { /* reset switch */ ksz_write8(dev, REG_POWER_MANAGEMENT_1, @@ -1763,10 +1763,7 @@ void ksz8_config_cpu_port(struct dsa_switch *ds) COPPER_RECEIVE_ADJUSTMENT, 0); } =20 - /* Turn off PTP function as the switch's proprietary way of - * handling timestamp is not supported in current Linux PTP - * stack implementation. - */ + /* Turn off PTP function as the switch enables it by default */ regmap_update_bits(ksz_regmap_16(dev), KSZ8463_PTP_MSG_CONF1, PTP_ENABLE, 0); diff --git a/drivers/net/dsa/microchip/ksz8_reg.h b/drivers/net/dsa/microch= ip/ksz8_reg.h index 332408567b473c141c3695328a524f257f2cfc70..0558740ae57738fa7e4a8f3f429= 254033c54af12 100644 --- a/drivers/net/dsa/microchip/ksz8_reg.h +++ b/drivers/net/dsa/microchip/ksz8_reg.h @@ -765,6 +765,7 @@ #define KSZ8463_REG_SW_RESET 0x126 =20 #define KSZ8463_GLOBAL_SOFTWARE_RESET BIT(0) +#define KSZ8463_PTP_SOFTWARE_RESET BIT(2) =20 #define KSZ8463_PTP_CLK_CTRL 0x600 =20 diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 5141343d2f40bbd380c0b52f6919b842fb71a8fd..55e3fa4791078cb099e236e6e5a= 29515727ed8ab 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1512,6 +1512,7 @@ const struct ksz_chip_data ksz_switch_chips[] =3D { .supports_mii =3D {false, false, true}, .supports_rmii =3D {false, false, true}, .internal_phy =3D {true, true, false}, + .ptp_capable =3D true, }, =20 [KSZ8563] =3D { diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index dfbc3d13daca8d7a8b9d3ffe6a7c1ec9927863f2..1fface82086eed87749d4702b04= 6fcab313663e9 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -150,6 +150,7 @@ struct ksz_port { struct kernel_hwtstamp_config tstamp_config; bool hwts_tx_en; bool hwts_rx_en; + bool last_tx_is_pdelayresp; struct ksz_irq ptpirq; struct ksz_ptp_irq ptpmsg_irq[3]; ktime_t tstamp_msg; diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index 7eb033157f226b1169bc184d71569328e9a20a5b..a86d087b4c0d05120ba532a221e= 66bc704d1dfb5 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -308,15 +308,20 @@ int ksz_get_ts_info(struct dsa_switch *ds, int port, = struct kernel_ethtool_ts_in SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_RAW_HARDWARE; =20 - ts->tx_types =3D BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ONESTEP_P2P); + ts->tx_types =3D BIT(HWTSTAMP_TX_OFF); =20 - if (is_lan937x(dev)) + if (!ksz_is_ksz8463(dev)) + ts->tx_types |=3D BIT(HWTSTAMP_TX_ONESTEP_P2P); + + if (is_lan937x(dev) || ksz_is_ksz8463(dev)) ts->tx_types |=3D BIT(HWTSTAMP_TX_ON); =20 ts->rx_filters =3D BIT(HWTSTAMP_FILTER_NONE) | - BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT) | - BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) | - BIT(HWTSTAMP_FILTER_PTP_V2_EVENT); + BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT); + if (!ksz_is_ksz8463(dev)) { + ts->rx_filters |=3D BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT) | + BIT(HWTSTAMP_FILTER_PTP_V2_EVENT); + } =20 ts->phc_index =3D ptp_clock_index(ptp_data->clock); =20 @@ -353,6 +358,9 @@ static int ksz_set_hwtstamp_config(struct ksz_device *d= ev, prt->hwts_tx_en =3D false; break; case HWTSTAMP_TX_ONESTEP_P2P: + if (ksz_is_ksz8463(dev)) + return -ERANGE; + prt->ptpmsg_irq[KSZ_SYNC_MSG].ts_en =3D false; prt->ptpmsg_irq[KSZ_XDREQ_MSG].ts_en =3D true; prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en =3D false; @@ -364,14 +372,19 @@ static int ksz_set_hwtstamp_config(struct ksz_device = *dev, =20 break; case HWTSTAMP_TX_ON: - if (!is_lan937x(dev)) + if (!is_lan937x(dev) && !ksz_is_ksz8463(dev)) return -ERANGE; =20 - prt->ptpmsg_irq[KSZ_SYNC_MSG].ts_en =3D true; - prt->ptpmsg_irq[KSZ_XDREQ_MSG].ts_en =3D true; - prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en =3D true; - prt->hwts_tx_en =3D true; + if (ksz_is_ksz8463(dev)) { + prt->ptpmsg_irq[KSZ8463_SYNC_MSG].ts_en =3D true; + prt->ptpmsg_irq[KSZ8463_XDREQ_PDRES_MSG].ts_en =3D true; + } else { + prt->ptpmsg_irq[KSZ_SYNC_MSG].ts_en =3D true; + prt->ptpmsg_irq[KSZ_XDREQ_MSG].ts_en =3D true; + prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en =3D true; + } =20 + prt->hwts_tx_en =3D true; ret =3D ksz_rmw16(dev, regs[PTP_MSG_CONF1], PTP_1STEP, 0); if (ret) return ret; @@ -387,6 +400,8 @@ static int ksz_set_hwtstamp_config(struct ksz_device *d= ev, break; case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: + if (ksz_is_ksz8463(dev)) + return -ERANGE; config->rx_filter =3D HWTSTAMP_FILTER_PTP_V2_L4_EVENT; prt->hwts_rx_en =3D true; break; @@ -397,6 +412,8 @@ static int ksz_set_hwtstamp_config(struct ksz_device *d= ev, break; case HWTSTAMP_FILTER_PTP_V2_EVENT: case HWTSTAMP_FILTER_PTP_V2_SYNC: + if (ksz_is_ksz8463(dev)) + return -ERANGE; config->rx_filter =3D HWTSTAMP_FILTER_PTP_V2_EVENT; prt->hwts_rx_en =3D true; break; @@ -518,6 +535,8 @@ void ksz_port_txtstamp(struct dsa_switch *ds, int port,= struct sk_buff *skb) if (!hdr) return; =20 + prt->last_tx_is_pdelayresp =3D false; + ptp_msg_type =3D ptp_get_msgtype(hdr, type); =20 switch (ptp_msg_type) { @@ -528,6 +547,7 @@ void ksz_port_txtstamp(struct dsa_switch *ds, int port,= struct sk_buff *skb) case PTP_MSGTYPE_PDELAY_REQ: break; case PTP_MSGTYPE_PDELAY_RESP: + prt->last_tx_is_pdelayresp =3D true; if (prt->tstamp_config.tx_type =3D=3D HWTSTAMP_TX_ONESTEP_P2P) { KSZ_SKB_CB(skb)->ptp_type =3D type; KSZ_SKB_CB(skb)->update_correction =3D true; @@ -972,7 +992,17 @@ void ksz_ptp_clock_unregister(struct dsa_switch *ds) =20 static int ksz_read_ts(struct ksz_port *port, u16 reg, u32 *ts) { - return ksz_read32(port->ksz_dev, reg, ts); + u16 ts_reg =3D reg; + + /** + * On KSZ8463 DREQ and DRESP timestamps share one interrupt line + * so we have to check the nature of the latest event sent to know + * where the timestamp is located + */ + if (ksz_is_ksz8463(port->ksz_dev) && port->last_tx_is_pdelayresp) + ts_reg +=3D KSZ8463_DRESP_TS_OFFSET; + + return ksz_read32(port->ksz_dev, ts_reg, ts); } =20 static irqreturn_t ksz_ptp_msg_thread_fn(int irq, void *dev_id) diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/micr= ochip/ksz_ptp_reg.h index e80fb4bd1a0e970ba3570374d3dc82c8e2cc15b4..ac9d0f2b348b0469abbeed0e645= fe8ef441d35fb 100644 --- a/drivers/net/dsa/microchip/ksz_ptp_reg.h +++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h @@ -125,6 +125,10 @@ #define KSZ8463_REG_PORT_SYNC_TS 0x064C #define KSZ8463_REG_PORT_DRESP_TS 0x0650 =20 +#define KSZ8463_DRESP_TS_OFFSET (KSZ8463_REG_PORT_DRESP_TS - KSZ8463_REG_= PORT_DREQ_TS) +#define KSZ8463_SYNC_MSG 0 +#define KSZ8463_XDREQ_PDRES_MSG 1 + #define REG_PTP_PORT_TX_INT_STATUS__2 0x0C14 #define REG_PTP_PORT_TX_INT_ENABLE__2 0x0C16 =20 --=20 2.52.0