From nobody Mon Feb 9 01:47:44 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 D3FAA20DD52; Mon, 26 Jan 2026 08:27:41 +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=1769416064; cv=none; b=ajHuWqP0KBxSJeWtZqNmKLyGxAFeJItz5oYFZo+mSo6WS3v2NTWBNDSZrTc6099905YdCBaex6g5N/nyx3+ADpUQc695GGKlCs+skAXV32n8Y8BXwUsO47HCPO8v0SxSVc/H76BJndPDvkdzW1Gg4A8EhY4RsV5NvBBOB4BcVSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769416064; c=relaxed/simple; bh=N3ryQbGEWD3cPHtfikuGqfoTM8sOAlPC0aYgdbP0Wxw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fzEIVE3n09cpqr+Ph9KW4cgl20HZg8IEgND0J3nru/bhfJy+gBGgEM1+GAriFJj/aSOTvOdTE0lw21JurONhUdyLLWEYNOdBdxD+V+AMLfhPQRt33Q7ME1nBMAxyzIEDDTa/6Ikw8oybRJcrPH8UzCvVESLVtwaMp5bnx1PEeZQ= 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=kSvgwcvW; 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="kSvgwcvW" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id F1C6B1A2A4F; Mon, 26 Jan 2026 08:27:39 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B3A2960717; Mon, 26 Jan 2026 08:27:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5844F119A83F1; Mon, 26 Jan 2026 09:27:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769416058; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=gkMPdwGfu8X4F3+hrF5ewptOuduz1YxWL/Ffa1MnO38=; b=kSvgwcvWc6p/ARlrrGo5K5/bRTKHM8DsoCok5MLxzmF2aiP+uDu6UjZobtAFWMd2BkYVon gOzcChQzXLhZmoYVp5dFK8d1ydkrLe3pboWV5iQ134CbpG3apHD5vCWXhbv8zMQDXa/pnF DsROBE4OoVsPo4sGuzmPdP6mObaOql0cZCZBphKYFPA8dl+w3umQxVY7HyLgdUj63vP/Rl skWGm/E5tlfzm8xm3F1F+zMC+ZxfFb9GOCrc0IAu4t+onGOD6p4TFVKtNw8RFlmQSRlx37 rbZeu4akIvjstA5VL+P4UmnOGxaRbPcpUHT+E+FRU0xIFmmW5Gv7Vyfs6J4BFw== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 26 Jan 2026 09:27:29 +0100 Subject: [PATCH net-next v3 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: <20260126-ksz8463-ptp-v3-1-9f092aeb8492@bootlin.com> References: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@bootlin.com> In-Reply-To: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@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) --- 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 Mon Feb 9 01:47:44 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 5A36F2882D6; Mon, 26 Jan 2026 08:27:43 +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=1769416065; cv=none; b=pSFX9cJ53rgqdpzBre7DpFOYNZrG/c3pyRFTotbRZl6aDdU17M7tXqAjjYt4abTm6NXFKm0UVi5XrxfKQwEKsGJ+lqD6KuhF+MC660/grXV3nnq0ROVe03QiKnbGvR2NHZyeRql5rr4LmIhDXAElzl1/WA281jLMQ2jP6x0T/6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769416065; c=relaxed/simple; bh=Mq588nrNPw+uc5oepjcOMjmGegEoAI+0BQA2zqK9rvc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iV71D7fVIwVq7wQ0wtB6NKQBfbIlb85yxXnQxd+s7Zw3O3QL2VmNDnUSooSJppu23LVQBFV/twsIjOtXh3fOMhD3xcRu9qBia56IHGAtbhGtNAE7WkuUWr7LXDVok81jdGZ+fDFdOdacXVfZd/faZPE33S6X1lktVlAJi8zU20U= 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=dxL7ZT6c; 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="dxL7ZT6c" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 0F3C21A2A50; Mon, 26 Jan 2026 08:27:42 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D731C60717; Mon, 26 Jan 2026 08:27:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 28DA8119A8621; Mon, 26 Jan 2026 09:27:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769416060; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=msjsmNWxtn13jWdt/GBOpxERpRumsKymvRVrflpMg/g=; b=dxL7ZT6cqsi4xh2BWeYfzplsCg5fS2tBVmxFlxY6T0DZl/cajL+14/SCOMK/nqIs0L81NS yGA2fNIq2/C2Dm8QMqbiX1VM11zSYIM60Gx/Cg5qUDJmV62z2sHZsRDzzz1uvzgVnp69ht c2xlEex7JyxBK8FS6xWok09nQzBmS5VF2WRJh8DWe8vSRM4yNjy+gMUtotC0z5o51chELu iH+ecbP4m3lDCBvqciYIofKkVAFAip3meDSSBAY/XZLzMm9bDokPqgsQ/xPjoRp/t2DCFU SNvAgew6w6A+9M/XTiObrWEEKZDY3oly+DlALF0+VPkqWN3MAX6ylJGulufcVQ== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 26 Jan 2026 09:27:30 +0100 Subject: [PATCH net-next v3 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: <20260126-ksz8463-ptp-v3-2-9f092aeb8492@bootlin.com> References: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@bootlin.com> In-Reply-To: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@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 Mon Feb 9 01:47:44 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 533A33126CA; Mon, 26 Jan 2026 08:27:45 +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=1769416067; cv=none; b=ZfbC1v/EBtQVj/cvBxTBG/gmO3LifOmDTU5HW/6zdIoq0WZAfSjpWYtIt3FYe9kx7ewLTc2f0+ZwkNRppuigXg/6UdPv7DvmNRLmu7BZy5JnW/ht5n0ZI1vuQNPAwBpZIvok6OBWlR2Rmm7cstq6eduThiXxuXme6K1mIVpzmsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769416067; c=relaxed/simple; bh=5JRPbX6ZNpbbjxewpLGryuvTwhcPES2z48M948O/Y2Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AUUo1ORuPTmzxuR3NT5I3hZmLbXHJy9lTy8jOw5oMFitNkWpMKXe+KP5XiE18IdWDwdcagNRwHTBjaHgWHXUXcGbcdth5RZeYIMsQwSxE1bjKbrKGqHq+tBLuH7Mf4Lum/YxxD9rP7sI5ZPxwfzNb453rojYso4COs4nr6cKk3A= 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=wM+OeQPa; 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="wM+OeQPa" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 26754C225BB; Mon, 26 Jan 2026 08:27:45 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 9C6F460717; Mon, 26 Jan 2026 08:27:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4453B119A8633; Mon, 26 Jan 2026 09:27:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769416062; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=raSc7l7Hms0kVCTaWY56CLFkcCyEbYi+dFevYnfrWHg=; b=wM+OeQPa+avN/lbZ2UYyxqm6z7qoB6NofnzWGFCBR80bd8T3u6ruHBOg3CtzIJz0xFuSpS 6i5pgn70EBh3RuM2dBHM9Kbq7gC/OIMDEZWvAvHMGQFR/DI/zZdRpzXbsBKA/PlBevO02Q GxZfcYy8x7F1NEzl/PlwvMMSpd5HVCNd/Wl1DtTw+v5AB7nOtXpNGHWdlwb5bgLPDZHEgK Lz2iFDFqy/iUUW6Shk/Vjn+373jb+UfZPSuZpOSgs9yMAuqvHgYWW7NnwI60x/caHCJEWk /4U2Nh4k9kHYrL2tII4Cif2zO9TmpzBbc6FLfuavlhSNINafuZLuQF3iFxYQow== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 26 Jan 2026 09:27:31 +0100 Subject: [PATCH net-next v3 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: <20260126-ksz8463-ptp-v3-3-9f092aeb8492@bootlin.com> References: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@bootlin.com> In-Reply-To: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@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 Mon Feb 9 01:47:44 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 3711E313261 for ; Mon, 26 Jan 2026 08:27:47 +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=1769416070; cv=none; b=pLEFd4GWa8u02pbJpXs30nch0ym9PWurRWl2cUSar+E0rWjh8PhDG6u1Pt/xX6jnwRK3DA9uEBemfnA01h1x0wZENtnt0cKIOJQ9F5kSjZpQ7mctA3PrygG3tpoK5QNxAP1QmWDeJNY6tCz5G/ojj6Cp25AtA5PRpSeKi5McIEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769416070; c=relaxed/simple; bh=aI3Rdxiv6HmUV+sUlKEFr0V8i0Vivmji6NkUUfOXL6M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XiksgsaNQyUov9dJpemj74XJcLoBqRLjXH0TjZbWqY5QqRIUYKXy6yvlDghRMsZOWJ3rYvb4FN5ExgW1hAnCB+g0i869OpaJICB3i7Gu1qCGR+P469bijlsVb240FiTXjjZZQqh8KGgWBhhD7uhcAzWqbA1IPesd8esZI5iiETg= 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=KfZs0Ryt; 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="KfZs0Ryt" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id E53671A2A4F; Mon, 26 Jan 2026 08:27:45 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id AF23E60717; Mon, 26 Jan 2026 08:27:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1135F119A8638; Mon, 26 Jan 2026 09:27:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769416064; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=nPjvyOFoJfYe58hXYPQ6njizsxP54AqOnEDgp4nay2c=; b=KfZs0RytnSFkwz5BkkdCZN4MssyiBQkQhzp9piMJkUN0ItWMUxOX2DHDkalrGFmdlUjWIe QGDipVcMrUHj7DFBls7rlUtqzq4Y6XUtuu8Zmr+TeqeeucLBnT96f6I3X6vnV/SN7ysM8U jPER9EKPhjYVuDX+CdVzM/HxdUKqB6RD1R3kzbYcXvgD1bVnuSqc6LovXZThl1LdG01Vrl qGHqsqKWq5LJDcuiMiuQBAxrqlcxgL9WXg3FUjV7wgVGzhPl/b6Bnslw0wOJ1xvAV3PyjF 03DK+u9UM+WYV5m7eDKYEJwo7baARh+1kXyyGqG5GaCjIY6LRWxKHLmvfvGxaQ== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 26 Jan 2026 09:27:32 +0100 Subject: [PATCH net-next v3 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: <20260126-ksz8463-ptp-v3-4-9f092aeb8492@bootlin.com> References: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@bootlin.com> In-Reply-To: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@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 | 113 ++++++++++++++++++++++++++++= +++- drivers/net/dsa/microchip/ksz_ptp.h | 9 +++ drivers/net/dsa/microchip/ksz_ptp_reg.h | 7 ++ 5 files changed, 161 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..1ab41cc96af9ea3b4c092d7a90a= 6c41fce705a32 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,107 @@ 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; + const struct ksz_dev_ops *ops =3D dev->dev_ops; + 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 +1277,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 Mon Feb 9 01:47:44 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 E9E01312807 for ; Mon, 26 Jan 2026 08:27:48 +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=1769416075; cv=none; b=SvJBygOH6YmYdtWUCeA9QWRMIIzbKMhVaz5bWSoljKBEDqyb6SwX3nmcne6RZC7p8A+jdNFlM6ZuDhsnumPEODFO6KQpvjjEr3b4388zvuQhe6+kMR8msqWm6lkhROIexnu1uWjmjaO4CIJpie4xBYbGPTwYJ4nBcb11ydUZ4q8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769416075; c=relaxed/simple; bh=NXBqTeRrMdmbv9KNJEvENd/g8zIiTw3uvoCmEedoIqM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=isd4zN2w+NTL/zOftyNDL/ye6kE5AOxF/EReMwcBTgWVqDtbQKTnuIwrEocGsAiM8E/OoJJhpX29mOMH+PHHXS1AmiFpKnkUs40I53HrThvhOduwEjGVK6OJ3rcDT1PVCqdIP/tKNVja+hL1yCF29+jR1tbXhqUU/mWleX7HNro= 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=sPYF2eEQ; 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="sPYF2eEQ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id BD6471A2A4E; Mon, 26 Jan 2026 08:27:47 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 91AAE60717; Mon, 26 Jan 2026 08:27:47 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1C4F5119A8643; Mon, 26 Jan 2026 09:27:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769416066; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=mAdxSZE83xUC1VcdJ9laK4kQl5LwI5jSzJL0hyvTGo8=; b=sPYF2eEQftLv9YGwAeJneSuibjdKA6zJYhmcxIc3Hi4DOH1wOBIjtM/qQVOrlvVR0ueRY8 u7HYdLKzvsWMS6aBmXE2NweFknErz9NUiM3UMB8HpnFFVXA+h6SVirBWz/5gCmN3uXzZG3 BUUkxkEDjZtJtG3VUYDvr3/r7pNipasn9bhChLVC7UheZSe5cWwlVA6SFagae71B4REn7K YhiYX5SxMqtixlJLtffbb0DNK1DRDtus2UcGhy8HzqVJYHpvdYu3KYN37KEfE/Qz2wcRr7 LPbi7lcQsEJUzx4AtGONzsKe4zR7Sp+HmymHHwfFs+zNj9SJclscasyJLMy5XQ== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 26 Jan 2026 09:27:33 +0100 Subject: [PATCH net-next v3 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: <20260126-ksz8463-ptp-v3-5-9f092aeb8492@bootlin.com> References: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@bootlin.com> In-Reply-To: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@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 Mon Feb 9 01:47:44 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 949FC3002A9 for ; Mon, 26 Jan 2026 08:27:51 +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=1769416077; cv=none; b=YGViF6QwOrkvZGGpP6761DidigCGQtBCmkEJp5jQ4HpMgDRdIYU70JMor5PnND6fcyJZDwhLwvxA5xACUZiwzvA87wyxlBjtdgWBt8KvAZ6/pWzwpVP1vL85gHdnEoyeQgCrF6cqdEHvsYg+/MEA6UzOBPwtDkb6eAw+s4xnwfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769416077; c=relaxed/simple; bh=c9+1csdERnq6VqZtSUZe4hU4XHbogae+YRUiHHFm5fw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Jt2fvsrTkeolnZ1WuggO9Gqe4Bi49oAZmJU2Pa8lDMPdPmf8FllK+nyDoyVv2svZQ6cMFjky3r2rkjjdUrNjMarsqeh7sHVJt3tky4Oa5pbocVeXmE0xnkRv+xXgwbeI4xI05N5d+hHtxDok8BbFXOrWqBglF1N2mSN+9uhHFhE= 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=OH2PCQtH; 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="OH2PCQtH" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 61CBD4E42295; Mon, 26 Jan 2026 08:27:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 37F3760717; Mon, 26 Jan 2026 08:27:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E0244119A863B; Mon, 26 Jan 2026 09:27:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769416068; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=wlZcPsofQBAS2VnD7y5K6VUGRbgqI5PAGFZ5dErBbds=; b=OH2PCQtHj8d+JaoQjRxRUz4n0Ph8kmWvCkL4keZeoZb0aQ+JZ++WWCceIivKWQETvSiItR uE01anpeDeHxk3sh6pY8ndEZ3zKCpQ7UHMkZwjYzj6BN+a6gjUawQh9/Rm3Z46NWsw2DN3 0xgHgKKiKJobCiWGTSRiziIyPUdR6l52nWiozOaspxmRWMVBkN/3sUg7CuERCi/YeXZu7v jkbz6v6vXCLKxN4GqRk+VKYxbHFSFdRbqG7EfqaVReuxEadkLsmSftFlIOEdqkL80pjD83 MDMzgwXjUurrxQr2TP1oEQQCqRC8ySz2ViYieMnlP+z9FnLlYfOW/rRk5moTQg== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 26 Jan 2026 09:27:34 +0100 Subject: [PATCH net-next v3 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: <20260126-ksz8463-ptp-v3-6-9f092aeb8492@bootlin.com> References: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@bootlin.com> In-Reply-To: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@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 1ab41cc96af9ea3b4c092d7a90a6c41fce705a32..f773989e4d2f72fe7b474ff8965= 09ffd425a87a0 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 Mon Feb 9 01:47:44 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 80D963115B5 for ; Mon, 26 Jan 2026 08:27:53 +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=1769416081; cv=none; b=ohi2xnb/1ehuUZVIOJbW60C+OakspZbiFP2kDBbrfATLwJpRLGk8RvgndFiTII/BOPddLrc4yYDkyWiVySsJmNyvwI4SmsdIC3aDwmnNaFpCNw+jfBJlkAbKXbqK+FX4bqgEes2mX/zs95sQcURTyGZB2T+Hno4H3Ifb4gaGA6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769416081; c=relaxed/simple; bh=F3x7ujt23LH7Hzb/IBaAvxfIn3ywNtT91s3EJRLMZe8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gzctoqLv2ekLv7bkMGnAmAaF9MzcbMFaMTiVDq3CvuIQoJSxUyDUORQ9EuaV9/gIvyQ4IJiyVrnW4Rpj56oitV4AweFrtklR26PTe07JO2/8gwYXXumnOM1Czg6P3W9QDRfm3CIV0yh38/YOUhw9satqM1Y2fcWyWq+c5xPnKVY= 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=QosxL7z7; 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="QosxL7z7" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 4FBC34E42296; Mon, 26 Jan 2026 08:27:52 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 206A660717; Mon, 26 Jan 2026 08:27:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 59509119A8649; Mon, 26 Jan 2026 09:27:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769416070; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=5JUfVn7/HeLWZy5Qd02a6wIWBDQq2NcAA2klS+MsO1s=; b=QosxL7z75al5wbGJj2zei2GJz9GNmiYdHt0xioErGeEQpNWhYxeZiw7XD+tdBSc4oMS0IS iBq5KaxiDPw2Bbg1rwQonxU1BNAUVSbzJxUJmtWmJvrqchcIpXbRq6HICMEmHKwrHvrJxR m4Su4SSDPBQVBL9Fn9p9OQp1M909pc0IXNGbyLV0rzyDvtsOxp+1R5j56FxxkjsornmCNC laBkNn1P6Ea+EYhYmcWHGPXe4qNUBmatHv9+iJlO+jZaHVFddiRwGrTp6/5EClxO83XgNa HN9gVfi3RRgVLyNZNoIrxHylRsMIBA/fWxeAJNvtc/bstpPEZqoWnuwy33nEiQ== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 26 Jan 2026 09:27:35 +0100 Subject: [PATCH net-next v3 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: <20260126-ksz8463-ptp-v3-7-9f092aeb8492@bootlin.com> References: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@bootlin.com> In-Reply-To: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@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 Mon Feb 9 01:47:44 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 5C5D73126C6 for ; Mon, 26 Jan 2026 08:27:55 +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=1769416078; cv=none; b=Oxo/S8a1jpaOnrYZMI/2DNE1DbX3cRep8WEhnoKIzcPPuv9CmMklE/1mZizUEBFmuFTHg+rd7ju78x8nGFVC4FSz6TnCaVL18A5LdYPCmvdpRZdqh6BxDr7+cj9gr46HPNA3Sl9FxbUONXNfv+M9DUxCXnfOuOAg4jETeXv2LpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769416078; c=relaxed/simple; bh=EDzQ7rDJSawXTPUoFy7D5XTYSvtsuvHifE0u6we01U8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nZK5AXFcS50xBrH/q2qLGXDITE+o8RvF4ljoucPSh7mvVu74HE2UnBXiBG74LwaXKYwDyQ0wCsSsjLxeDXIsz5CwPkO7ZK3/zpy56pz5wkGk8fvWhTD1Z36B2YW0cQlul2ZCbDJ3XxWmlDHo5QUhxIKEu4DgvwVtjZY8ZyL3SXI= 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=kCiHW1ir; 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="kCiHW1ir" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 07B951A2A4D; Mon, 26 Jan 2026 08:27:54 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CB6DA60717; Mon, 26 Jan 2026 08:27:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3C142119A8642; Mon, 26 Jan 2026 09:27:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769416072; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=3Bw7U+vIPDS5XmYx0Ca1HEGMhrThFpVkjt4Y6WnDgGU=; b=kCiHW1irzwgCtQ7w6tKbTILfm6ZFkRwabS0Z7rnnw/TnoRrzDjtSALi7y1ooSYRWR2nmAN eD8VmQUf7IqjLJGNK4TuKfBtN35y2vWS6aXgzMPVYBOVQowN5h9YXSa6KAgHayv/DkLKPQ Nz7bD8JnJ4VJgt4F+p/P7isrweoUlknE4WEnfpGIbYPh/w60FVHsk9EhR2LJjTpR4Fl2cM pzTGHRDoOGYDLZ+d30FvP3J1qpz9/AMTtAdmiAk3YB1NKBDMFdwgJ3m1d7rUZWoki3jArV aj6+u4jxRnpuCOYEMBibFHRF+hGK4OYGRe9Ty1qnYJz+4wYi3Tc4FubkIzj4Xw== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 26 Jan 2026 09:27:36 +0100 Subject: [PATCH net-next v3 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: <20260126-ksz8463-ptp-v3-8-9f092aeb8492@bootlin.com> References: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@bootlin.com> In-Reply-To: <20260126-ksz8463-ptp-v3-0-9f092aeb8492@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 f773989e4d2f72fe7b474ff896509ffd425a87a0..1bedf3f87f4b94c130b631dc269= 4938ee5e3f213 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