From nobody Mon Jun 8 21:47:06 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 001CB3B9949; Tue, 26 May 2026 09:47: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=1779788871; cv=none; b=AVb16ing40X3gzOh6lw9L0lqouGMWLIlZWXvKLDmn4YyVC4GSiCi9sCVqGGllIUReg5jkYAna7ViaUfvFjMnoRHKSkxfSyVrPxiOZvG7jGIDme52CY2N5G8UCJKtnMU8pH8wFsrDbHYuZITWsiuJwiY7Dn6MFA6USltG1QQ140I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779788871; c=relaxed/simple; bh=vet+8LUw9CMHJCl4uCcWV2+acL0io+HppB8DCWwMYSI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YDIV1gOmYVwHk1p63+ZX96MPQQDVzSgabXomeeDQYGnnsvZ30PTSXgTKSiSit+iuUBf8ROvkzvsiCTanOYqAUkLysi3gVzPC2rL4JahcwIEdIUFOd2TfG0oxUveY8LVr5+5I+N7Nqx3QJ5JG+TvnA973sZeAjPqOLBi6rOxMy9E= 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=eUZV8Rb3; 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="eUZV8Rb3" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 733BD1A36D4; Tue, 26 May 2026 09:47:42 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 468BA60732; Tue, 26 May 2026 09:47:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B97B11088858A; Tue, 26 May 2026 11:47:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1779788861; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=/K9/ZTUYEm7hgptnRygC7Z1Qmu1Q/ZK2rVMEioKNYGM=; b=eUZV8Rb3hYs4R80fck3UyLCiqktJCsoy21b9h4aO0MledhzwuCI8eNlV+LrRZ5PCr6oPhZ didGMf+PU4bpr2W5jO4t5UB/dieDUzDdSMk/8sFnbt9LThAD5qIIgPkOUkxPhfEZ+Bb8Cu 5twNtBZ+HTrGRJtS+npHyYgxXHXjMrhkn4EcgIrtkfAGARHH8JXejeP0Ezn0D6ewdgcl4u XQu1E7JJZtwBHMRGIj15SjJwXm89/W3HC6j6Ek5r852nbJV+G2f6maUTDkr96yI4fsFn0K JI/RsOa72ZpB1oF8B8HiRg3C/F/PZ9EH7/0Ki4Xh+zJYQEjY8Ph/OyS9l3ZwwA== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 26 May 2026 11:47:27 +0200 Subject: [PATCH net-next 1/9] net: dsa: microchip: remove useless common cls_flower_{add/del} operations 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: <20260526-clean-ksz-3rd-v1-1-5b63e732149a@bootlin.com> References: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> In-Reply-To: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , Tristram Ha , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 All the KSZ switches share a common implementation of the cls_flower_{add/del} operations. These common implementations return ksz9477-specific implementations for the KSZ9477 family and -EOPNOTSUPP for the others. -EOPNOTSUPP is already returned by the DSA core when the operation isn't implemented. Remove the common implementations. Directly link the ksz9477_cls_flower_{add/del}() to the KSZ9477 callback. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 6 ----- drivers/net/dsa/microchip/ksz9477.c | 4 +-- drivers/net/dsa/microchip/ksz_common.c | 42 ----------------------------= ---- drivers/net/dsa/microchip/ksz_common.h | 4 --- drivers/net/dsa/microchip/lan937x_main.c | 2 -- 5 files changed, 2 insertions(+), 56 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index 0f84b2e7d25d..db08874eb025 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -2462,8 +2462,6 @@ const struct dsa_switch_ops ksz8463_switch_ops =3D { .port_hwtstamp_set =3D ksz_hwtstamp_set, .port_txtstamp =3D ksz_port_txtstamp, .port_rxtstamp =3D ksz_port_rxtstamp, - .cls_flower_add =3D ksz_cls_flower_add, - .cls_flower_del =3D ksz_cls_flower_del, .port_setup_tc =3D ksz_setup_tc, .support_eee =3D ksz_support_eee, .set_mac_eee =3D ksz_set_mac_eee, @@ -2522,8 +2520,6 @@ const struct dsa_switch_ops ksz87xx_switch_ops =3D { .port_hwtstamp_set =3D ksz_hwtstamp_set, .port_txtstamp =3D ksz_port_txtstamp, .port_rxtstamp =3D ksz_port_rxtstamp, - .cls_flower_add =3D ksz_cls_flower_add, - .cls_flower_del =3D ksz_cls_flower_del, .port_setup_tc =3D ksz_setup_tc, .support_eee =3D ksz_support_eee, .set_mac_eee =3D ksz_set_mac_eee, @@ -2582,8 +2578,6 @@ const struct dsa_switch_ops ksz88xx_switch_ops =3D { .port_hwtstamp_set =3D ksz_hwtstamp_set, .port_txtstamp =3D ksz_port_txtstamp, .port_rxtstamp =3D ksz_port_rxtstamp, - .cls_flower_add =3D ksz_cls_flower_add, - .cls_flower_del =3D ksz_cls_flower_del, .port_setup_tc =3D ksz_setup_tc, .support_eee =3D ksz_support_eee, .set_mac_eee =3D ksz_set_mac_eee, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchi= p/ksz9477.c index c1395322e54b..c18bad08a508 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1996,8 +1996,8 @@ const struct dsa_switch_ops ksz9477_switch_ops =3D { .port_hwtstamp_set =3D ksz_hwtstamp_set, .port_txtstamp =3D ksz_port_txtstamp, .port_rxtstamp =3D ksz_port_rxtstamp, - .cls_flower_add =3D ksz_cls_flower_add, - .cls_flower_del =3D ksz_cls_flower_del, + .cls_flower_add =3D ksz9477_cls_flower_add, + .cls_flower_del =3D ksz9477_cls_flower_del, .port_setup_tc =3D ksz_setup_tc, .support_eee =3D ksz_support_eee, .set_mac_eee =3D ksz_set_mac_eee, diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 57c8abfe0147..81d3ec88e436 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3373,48 +3373,6 @@ static int ksz_switch_detect(struct ksz_device *dev) return 0; } =20 -int ksz_cls_flower_add(struct dsa_switch *ds, int port, - struct flow_cls_offload *cls, bool ingress) -{ - struct ksz_device *dev =3D ds->priv; - - switch (dev->chip_id) { - case KSZ8563_CHIP_ID: - case KSZ8567_CHIP_ID: - case KSZ9477_CHIP_ID: - case KSZ9563_CHIP_ID: - case KSZ9567_CHIP_ID: - case KSZ9893_CHIP_ID: - case KSZ9896_CHIP_ID: - case KSZ9897_CHIP_ID: - case LAN9646_CHIP_ID: - return ksz9477_cls_flower_add(ds, port, cls, ingress); - } - - return -EOPNOTSUPP; -} - -int ksz_cls_flower_del(struct dsa_switch *ds, int port, - struct flow_cls_offload *cls, bool ingress) -{ - struct ksz_device *dev =3D ds->priv; - - switch (dev->chip_id) { - case KSZ8563_CHIP_ID: - case KSZ8567_CHIP_ID: - case KSZ9477_CHIP_ID: - case KSZ9563_CHIP_ID: - case KSZ9567_CHIP_ID: - case KSZ9893_CHIP_ID: - case KSZ9896_CHIP_ID: - case KSZ9897_CHIP_ID: - case LAN9646_CHIP_ID: - return ksz9477_cls_flower_del(ds, port, cls, ingress); - } - - return -EOPNOTSUPP; -} - /* Bandwidth is calculated by idle slope/transmission speed. Then the Band= width * is converted to Hex-decimal using the successive multiplication method.= On * every step, integer part is taken and decimal part is carry forwarded. diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index b67038cf1bd0..da62c1658aa8 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -483,10 +483,6 @@ bool ksz_support_eee(struct dsa_switch *ds, int port); int ksz_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e); =20 -int ksz_cls_flower_add(struct dsa_switch *ds, int port, - struct flow_cls_offload *cls, bool ingress); -int ksz_cls_flower_del(struct dsa_switch *ds, int port, - struct flow_cls_offload *cls, bool ingress); int ksz_setup_tc(struct dsa_switch *ds, int port, enum tc_setup_type type, void *type_data); =20 diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index 536153886f7b..731737fd58d1 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -890,8 +890,6 @@ const struct dsa_switch_ops lan937x_switch_ops =3D { .port_hwtstamp_set =3D ksz_hwtstamp_set, .port_txtstamp =3D ksz_port_txtstamp, .port_rxtstamp =3D ksz_port_rxtstamp, - .cls_flower_add =3D ksz_cls_flower_add, - .cls_flower_del =3D ksz_cls_flower_del, .port_setup_tc =3D ksz_setup_tc, .support_eee =3D ksz_support_eee, .set_mac_eee =3D ksz_set_mac_eee, --=20 2.54.0 From nobody Mon Jun 8 21:47:06 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 9B56930C371 for ; Tue, 26 May 2026 09:47: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=1779788867; cv=none; b=ZSYTOcev0fqMuuPjcDXd4oRFCK8v9s+835ZZOiXX63+ZThfDJpugJ5DbGHQxkNFjGPmEJmTivOm1xIdN4i5Rx4f4PsPNCv17SqC7iBHzN/INhn8850rGXTXvHDwtGmQJ4F9vwrypzA23AJPliyRjikRdENpqbuFcEYi0tYfh2pE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779788867; c=relaxed/simple; bh=fEHEwXEoUDYte5vxo2ruOxaYtP9IzusrpbVVL0dP9qo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LS58PH2KfiXBy/S2s+R8y/bfTXo0Iik4EiUkKbuKYXtpc7bRS3EWxqkoxMQVNX/mg1IoFn23RQhgEbCTSaPM8jp4dLUXz87oOhvwlwnnV1BqDgUn3BYHTAQoPQL7DHulaLj5UVdRI/Yz9nF0HFBrdYHCImSsYIA/X7mO5VAefjs= 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=Dwr73jFb; 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="Dwr73jFb" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id AB3A9C79AB6; Tue, 26 May 2026 09:47:43 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 61CB160732; Tue, 26 May 2026 09:47:44 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id ADE3A10888582; Tue, 26 May 2026 11:47:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1779788863; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=BBtWvn1cViKIlEYxRrtV8pMaWvcQuKsWUQfn4agDogc=; b=Dwr73jFbqIIbWCJirU3xBBR/tlxxm34ROraVcEsYebGe/j8Z4U3yUas78iog0zme/Qvgcp NN5P1BL8oQrZzqFNvHvuVCJ9pfqT1kvLWxjx/BHbpci9RkaXWaAqBd471rF0nUDBdJaR2M BY2GFov5nBzWe/qg6uUJRzOjINBggOkcjTn+QoYi04g6S5WZrayHGFeEIrRdftmGaa8+Qa J3FKq5MyULtRiCqbDiT5NgxvzNqBoGiKvAW7iukBfrMvfx5zdv7FjV3PpK7a/j1Ycq/hiE ExkhzDjBglZKxxaB4ShDv1T1QRZa+NbbcOvc6lP6LrjMzLp6kznD0sOP0cqRQQ== From: Bastien Curutchet Date: Tue, 26 May 2026 11:47:28 +0200 Subject: [PATCH net-next 2/9] net: dsa: microchip: remove VLAN operations 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: <20260526-clean-ksz-3rd-v1-2-5b63e732149a@bootlin.com> References: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> In-Reply-To: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , Tristram Ha , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" , Vladimir Oltean X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 From: Vladimir Oltean KSZ8463 uses the common KSZ8 implementation for its VLAN operations. This implementation returns -ENOTSUPP for the KSZ8463 case, which is pointless. Remove the VLAN operations from the ksz8463_switch_ops so the core can directly return -ENOTSUPP. Signed-off-by: Vladimir Oltean Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index db08874eb025..93e0b3f60448 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -1477,7 +1477,7 @@ static int ksz8_port_vlan_filtering(struct dsa_switch= *ds, int port, bool flag, { struct ksz_device *dev =3D ds->priv; =20 - if (ksz_is_ksz88x3(dev) || ksz_is_ksz8463(dev)) + if (ksz_is_ksz88x3(dev)) return -ENOTSUPP; =20 /* Discard packets with VID not enabled on the switch */ @@ -1514,7 +1514,7 @@ static int ksz8_port_vlan_add(struct dsa_switch *ds, = int port, u16 data, new_pvid =3D 0; u8 fid, member, valid; =20 - if (ksz_is_ksz88x3(dev) || ksz_is_ksz8463(dev)) + if (ksz_is_ksz88x3(dev)) return -ENOTSUPP; =20 /* If a VLAN is added with untagged flag different from the @@ -1584,7 +1584,7 @@ static int ksz8_port_vlan_del(struct dsa_switch *ds, = int port, u8 fid, member, valid; u16 data, pvid; =20 - if (ksz_is_ksz88x3(dev) || ksz_is_ksz8463(dev)) + if (ksz_is_ksz88x3(dev)) return -ENOTSUPP; =20 ksz_pread16(dev, port, REG_PORT_CTRL_VID, &pvid); @@ -2439,9 +2439,6 @@ const struct dsa_switch_ops ksz8463_switch_ops =3D { .port_pre_bridge_flags =3D ksz_port_pre_bridge_flags, .port_bridge_flags =3D ksz_port_bridge_flags, .port_fast_age =3D ksz8_flush_dyn_mac_table, - .port_vlan_filtering =3D ksz8_port_vlan_filtering, - .port_vlan_add =3D ksz8_port_vlan_add, - .port_vlan_del =3D ksz8_port_vlan_del, .port_fdb_dump =3D ksz8_fdb_dump, .port_fdb_add =3D ksz8_fdb_add, .port_fdb_del =3D ksz8_fdb_del, --=20 2.54.0 From nobody Mon Jun 8 21:47:06 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 0FD163DC84E for ; Tue, 26 May 2026 09:47:52 +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=1779788874; cv=none; b=Ff+p3ABlUgI8z+ge8O9lS42orD5yribZo6HaXuMh07TaZfTObIJeMjGZI94fjPn72BNubgqLxkkpVuOchkExFRRPcfLtBJNXeAYL2PlIM6OpqGfM4XSHKiz4dKDHGmmTz7gyBS75dIvKHR3d+afwx9c+2iqAwaBVfYWMp57AYGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779788874; c=relaxed/simple; bh=/chFbqe/d9fGsKte/GmNLYtFYgRf7dD52fg9DqrYvzU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JraCU7Guq7QyPQK32l0vK1G5BFSI9yuoEMc8Zo9FXhWlBvtZBLbUsqJA5E/boJmpaAHq3zifvxzV/X8DVfT4ks/H0pzoNaFLjyz9MdSAostQbio3rq8+8hrXS8lLSJDQVVutgCqJ1M++Tq2HP1dgqV7s1w9YlzyUlP9+inlDhVc= 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=cFFmFgDO; 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="cFFmFgDO" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 637714E42D0C; Tue, 26 May 2026 09:47:46 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 35F3760732; Tue, 26 May 2026 09:47:46 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id AFF4210888589; Tue, 26 May 2026 11:47:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1779788865; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=vzYaQ5yu63Jc3ORXyaAHobEcTOkRNZZ3zA5L1lbh9OM=; b=cFFmFgDOKknGbxOq4itLQRmbLoUz0AAquKTtfyjuOfHie/7hICNz4tt7TFJ9Ai3cRIXE2j e3Q+EagOrM5VG+s53BVvlN+Z1nAh33teIqd6C2Rxr3TpYv5TSEvds47x9rxr2wDkOh54A1 Gg2e151AkqzlG/Ch6wj1hXa27Hao98jAqDdZQcPzu1Y7/yu7NgfmK3WF6EJNfVQAJOZaLv 7XTN5eIUGg7jK81vov2aZw3wkZvl+teJFcwxpdyYdNxpIqIj2DxMtt5Udn1xPsD7IbvYBx YHGqErC/6T3yyScdl/d1TaHFE0ZQX0hv7f8Z++Wn8XvW2k4zCsceJiLri08flw== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 26 May 2026 11:47:29 +0200 Subject: [PATCH net-next 3/9] net: dsa: microchip: implement get_phy_flags only if needed 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: <20260526-clean-ksz-3rd-v1-3-5b63e732149a@bootlin.com> References: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> In-Reply-To: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , Tristram Ha , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The common ksz_get_phy_flags() is used by all the switches to implement the optional .get_phy_flags DSA operation. It always returns 0 except for KSZ88X3 switches where an errata has to be handled. Make ksz_get_phy_flags() ksz88xx-specific. Remove the get_phy_flags implementation for the switches that don't need it. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 22 +++++++++++++++++++--- drivers/net/dsa/microchip/ksz9477.c | 1 - drivers/net/dsa/microchip/ksz_common.c | 18 ------------------ drivers/net/dsa/microchip/ksz_common.h | 2 -- drivers/net/dsa/microchip/lan937x_main.c | 1 - 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index 93e0b3f60448..98cf7239057d 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -2272,6 +2272,24 @@ static int ksz8463_phy_write16(struct dsa_switch *ds= , int addr, int reg, u16 val return 0; } =20 +static u32 ksz88xx_get_phy_flags(struct dsa_switch *ds, int port) +{ + struct ksz_device *dev =3D ds->priv; + + switch (dev->chip_id) { + case KSZ88X3_CHIP_ID: + /* Silicon Errata Sheet (DS80000830A): + * Port 1 does not work with LinkMD Cable-Testing. + * Port 1 does not respond to received PAUSE control frames. + */ + if (!port) + return MICREL_KSZ8_P1_ERRATA; + break; + } + + return 0; +} + static int ksz8_switch_init(struct ksz_device *dev) { dev->cpu_port =3D fls(dev->info->cpu_ports) - 1; @@ -2419,7 +2437,6 @@ const struct ksz_dev_ops ksz88xx_dev_ops =3D { const struct dsa_switch_ops ksz8463_switch_ops =3D { .get_tag_protocol =3D ksz8463_get_tag_protocol, .connect_tag_protocol =3D ksz8463_connect_tag_protocol, - .get_phy_flags =3D ksz_get_phy_flags, .setup =3D ksz8_setup, .teardown =3D ksz_teardown, .phy_read =3D ksz8463_phy_read16, @@ -2474,7 +2491,6 @@ const struct dsa_switch_ops ksz8463_switch_ops =3D { const struct dsa_switch_ops ksz87xx_switch_ops =3D { .get_tag_protocol =3D ksz87xx_get_tag_protocol, .connect_tag_protocol =3D ksz87xx_connect_tag_protocol, - .get_phy_flags =3D ksz_get_phy_flags, .setup =3D ksz8_setup, .teardown =3D ksz_teardown, .phy_read =3D ksz8_phy_read16, @@ -2532,7 +2548,7 @@ const struct dsa_switch_ops ksz87xx_switch_ops =3D { const struct dsa_switch_ops ksz88xx_switch_ops =3D { .get_tag_protocol =3D ksz88xx_get_tag_protocol, .connect_tag_protocol =3D ksz88xx_connect_tag_protocol, - .get_phy_flags =3D ksz_get_phy_flags, + .get_phy_flags =3D ksz88xx_get_phy_flags, .setup =3D ksz8_setup, .teardown =3D ksz_teardown, .phy_read =3D ksz8_phy_read16, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchi= p/ksz9477.c index c18bad08a508..a39541d29ad5 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1952,7 +1952,6 @@ const struct ksz_dev_ops ksz9477_dev_ops =3D { const struct dsa_switch_ops ksz9477_switch_ops =3D { .get_tag_protocol =3D ksz9477_get_tag_protocol, .connect_tag_protocol =3D ksz9477_connect_tag_protocol, - .get_phy_flags =3D ksz_get_phy_flags, .setup =3D ksz9477_setup, .teardown =3D ksz_teardown, .phy_read =3D ksz9477_phy_read16, diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 81d3ec88e436..5fb151fbf4f3 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2838,24 +2838,6 @@ void ksz_init_mib_timer(struct ksz_device *dev) } } =20 -u32 ksz_get_phy_flags(struct dsa_switch *ds, int port) -{ - struct ksz_device *dev =3D ds->priv; - - switch (dev->chip_id) { - case KSZ88X3_CHIP_ID: - /* Silicon Errata Sheet (DS80000830A): - * Port 1 does not work with LinkMD Cable-Testing. - * Port 1 does not respond to received PAUSE control frames. - */ - if (!port) - return MICREL_KSZ8_P1_ERRATA; - break; - } - - return 0; -} - void ksz_phylink_mac_link_down(struct phylink_config *config, unsigned int mode, phy_interface_t interface) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index da62c1658aa8..804912fdd2db 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -440,8 +440,6 @@ void ksz_switch_macaddr_put(struct dsa_switch *ds); void ksz_switch_shutdown(struct ksz_device *dev); int ksz_handle_wake_reason(struct ksz_device *dev, int port); =20 -u32 ksz_get_phy_flags(struct dsa_switch *ds, int port); - int ksz_sset_count(struct dsa_switch *ds, int port, int sset); void ksz_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *buf); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index 731737fd58d1..57e289637193 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -846,7 +846,6 @@ const struct ksz_dev_ops lan937x_dev_ops =3D { const struct dsa_switch_ops lan937x_switch_ops =3D { .get_tag_protocol =3D lan937x_get_tag_protocol, .connect_tag_protocol =3D lan937x_connect_tag_protocol, - .get_phy_flags =3D ksz_get_phy_flags, .setup =3D lan937x_setup, .teardown =3D ksz_teardown, .phy_read =3D lan937x_phy_read16, --=20 2.54.0 From nobody Mon Jun 8 21:47:06 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 B2DFF3DA5B2 for ; Tue, 26 May 2026 09:47:49 +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=1779788871; cv=none; b=A4NlFQGB0pjeq9lMbTOYElekK03lkEbb8CHDvqAFWh1t+N+6cT+9GU3igow4uaWJJGy01Z1aRNhN3Y0m/VuwanNRiAYL8DYcTZRkP+8pm40KHKFNfn/blf6gcH2bjpXkJAf724Ng31w7fV0DQMzaWSMozZ+Prw01Kftx4IUQgF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779788871; c=relaxed/simple; bh=VTK07zuWvuXLGuNFl/CVuX9HM50QZx01yYMzA7qKsuk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sULqaQY6ZWdxPUDSY2VnlXKa/GV9Al+00is7SVUkN/gu3xlStPv9TO7Wf6ahOBQlM7WH4/EvX/d2TEYZfsZEvQOfmOJYj3IhWZ31nkiCn667zn6Ec4rD6ssOLUO9pWWdR6yjg5V64A2Uonxdyc4cUEJLSytdggEUQaYdcqC8Tmc= 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=L/pAI8Oz; 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="L/pAI8Oz" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id DF532C79AB4; Tue, 26 May 2026 09:47:47 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 9784D60732; Tue, 26 May 2026 09:47:48 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 76B0D1088858A; Tue, 26 May 2026 11:47:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1779788867; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=W5I520zCD5y1iYXl8IK7VlXE/m8EK+QkgDqIt4zWqBM=; b=L/pAI8OzTo7HwejTjTMFEPYGV3qJM2tvvhTTIqPDIUl3utJCdGoT3GtaDwACzLHHlWJSTX 3Vln8X/AexS+7nV6URajjlLcpmCkTwwKAURmmYnpV1GUnXWATs7VA6i1b+3EnPvSQpIeLZ cWdrX0/TKT48BFlSFZXhlnh5a9rUFD2SrNMRBLlTdiFTlYmU8S8nZhRlx8q4bWjjfX/sAO Sr5ImMzFZ5eWIILMvxvOjKZqbjBHGG1WB8Kw3f+HLNSwJDkkot51JvTy3nEOXXsNynvcGX HwPz57R0a3HAvuZlExIOtBrEXJ24tHqd8cZ93mVtteIQQeEyI/3VN4H/PY8pBg== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 26 May 2026 11:47:30 +0200 Subject: [PATCH net-next 4/9] net: dsa: microchip: remove setup_rgmii_delay() KSZ operation 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: <20260526-clean-ksz-3rd-v1-4-5b63e732149a@bootlin.com> References: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> In-Reply-To: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , Tristram Ha , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 setup_rgmii_delay() operation is only used once during the common phylink MAC configuration. Only the lan937x switch implements this setup_rgmii_delay(). Remove the setup_rgmii_delay operation from ksz_dev_ops. Implement a lan937x-specific phylink MAC configuration that does this RGMII delay setup. Export ksz_set_xmii since it's needed by the lan937x implementation. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_common.c | 6 +----- drivers/net/dsa/microchip/ksz_common.h | 2 +- drivers/net/dsa/microchip/lan937x_main.c | 29 +++++++++++++++++++++++++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 5fb151fbf4f3..d6511fcebcf2 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3127,8 +3127,7 @@ int ksz_set_mac_eee(struct dsa_switch *ds, int port, return 0; } =20 -static void ksz_set_xmii(struct ksz_device *dev, int port, - phy_interface_t interface) +void ksz_set_xmii(struct ksz_device *dev, int port, phy_interface_t interf= ace) { const u8 *bitval =3D dev->info->xmii_ctrl1; struct ksz_port *p =3D &dev->ports[port]; @@ -3233,9 +3232,6 @@ void ksz_phylink_mac_config(struct phylink_config *co= nfig, } =20 ksz_set_xmii(dev, port, state->interface); - - if (dev->dev_ops->setup_rgmii_delay) - dev->dev_ops->setup_rgmii_delay(dev, port); } =20 bool ksz_get_gbit(struct ksz_device *dev, int port) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index 804912fdd2db..ab08c98ed257 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -410,7 +410,6 @@ struct ksz_dev_ops { u8 data); void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze); void (*port_init_cnt)(struct ksz_device *dev, int port); - void (*setup_rgmii_delay)(struct ksz_device *dev, int port); int (*tc_cbs_set_cinc)(struct ksz_device *dev, int port, u32 val); int (*init)(struct ksz_device *dev); }; @@ -468,6 +467,7 @@ void ksz_phylink_get_caps(struct dsa_switch *ds, int po= rt, void ksz_phylink_mac_disable_tx_lpi(struct phylink_config *config); int ksz_phylink_mac_enable_tx_lpi(struct phylink_config *config, u32 timer, bool tx_clock_stop); +void ksz_set_xmii(struct ksz_device *dev, int port, phy_interface_t interf= ace); void ksz_phylink_mac_config(struct phylink_config *config, unsigned int mode, const struct phylink_link_state *state); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index 57e289637193..f8f220242f7a 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -643,6 +643,32 @@ static void lan937x_setup_rgmii_delay(struct ksz_devic= e *dev, int port) } } =20 +static void lan937x_phylink_mac_config(struct phylink_config *config, + unsigned int mode, + const struct phylink_link_state *state) +{ + struct dsa_port *dp =3D dsa_phylink_to_port(config); + struct ksz_device *dev =3D dp->ds->priv; + int port =3D dp->index; + + /* Internal PHYs */ + if (dev->info->internal_phy[port]) + return; + + /* No need to configure XMII control register when using SGMII. */ + if (ksz_is_sgmii_port(dev, port)) + return; + + if (phylink_autoneg_inband(mode)) { + dev_err(dev->dev, "In-band AN not supported!\n"); + return; + } + + ksz_set_xmii(dev, port, state->interface); + + lan937x_setup_rgmii_delay(dev, port); +} + static int lan937x_tc_cbs_set_cinc(struct ksz_device *dev, int port, u32 v= al) { return ksz_pwrite32(dev, port, REG_PORT_MTI_CREDIT_INCREMENT, val); @@ -821,7 +847,7 @@ static int lan937x_connect_tag_protocol(struct dsa_swit= ch *ds, } =20 const struct phylink_mac_ops lan937x_phylink_mac_ops =3D { - .mac_config =3D ksz_phylink_mac_config, + .mac_config =3D lan937x_phylink_mac_config, .mac_link_down =3D ksz_phylink_mac_link_down, .mac_link_up =3D ksz9477_phylink_mac_link_up, .mac_disable_tx_lpi =3D ksz_phylink_mac_disable_tx_lpi, @@ -838,7 +864,6 @@ const struct ksz_dev_ops lan937x_dev_ops =3D { .r_mib_stat64 =3D ksz_r_mib_stats64, .freeze_mib =3D ksz9477_freeze_mib, .port_init_cnt =3D ksz9477_port_init_cnt, - .setup_rgmii_delay =3D lan937x_setup_rgmii_delay, .tc_cbs_set_cinc =3D lan937x_tc_cbs_set_cinc, .init =3D lan937x_switch_init, }; --=20 2.54.0 From nobody Mon Jun 8 21:47:06 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 074DD3DB658; Tue, 26 May 2026 09:47:51 +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=1779788873; cv=none; b=Nxnh4YfcaSy+nrhAWkenrcZ04HcHGt7r0PXvm6wEAk4P8pnjdkZxB73LeWx46ZfH2Hn8PsdjYFePy/9HCh9EqVEvow3LvmwDxpGaQYAkPjmHgvNfjhT4FpSD4SRywu2UctySb1Yq/lk/hI9UTra/Z8OPCwpWyS2u3GjG5w6zkBI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779788873; c=relaxed/simple; bh=vgv+HBrXp8+fLCMfSEFfB3zZxws4BkQdT6goxXUHjy4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eXwJ7hRHmT8lsyOatGUB2bWxeusWJM/E86DUOPLQ1nkSDB3Lniv25RKtPRS4HpZ6sza7sUDpNKCw4+2SxmRsIjzmTyXASCXk1YzcRc0xApI0jH0xFrdMSw3NGihFXZS1s7AEjDxGGeoqMHriIqmmLgQQAcNMMMzq3Ay3te3Wghs= 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=I6n9GHtZ; 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="I6n9GHtZ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 783B11A36D8; Tue, 26 May 2026 09:47:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4B67960732; Tue, 26 May 2026 09:47:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B1D0710888582; Tue, 26 May 2026 11:47:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1779788869; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=dKO1xS8jIVdj/J9VfLrYaDU87m2Qrkpv+lORKi93T+I=; b=I6n9GHtZLGQPhmDRt/C/lSPl3dAycqTN0YAGZs5L/eM/h+g5F8zPSD0ElT0E+i6B8kt4bw obqzDsbGXBPxhhmNPDZjyqERuBIhWWUTr+ANe1RffGxDB4HCTZH6U+0zexms8kLWgg3G6b WGkdan+ZJLukPx2j/fmViM2F6JRmMcFni8n044Vbbv5ATugVipNqtzDj2ytiRzPWcxATqs e6T5P32wptVyOrKMPdh3NUc8oyLEIiShhemuYs/CI6/wT9gFwjWljvC6xF6K6PbeXtWahr rwzLxQM+3aPzAiFV6hKtBsQe0Y28+WPQNq0w/ugnLxlf5WEh6xxzDzmPdUGQ+A== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 26 May 2026 11:47:31 +0200 Subject: [PATCH net-next 5/9] net: dsa: microchip: implement .support_eee() only if needed 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: <20260526-clean-ksz-3rd-v1-5-5b63e732149a@bootlin.com> References: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> In-Reply-To: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , Tristram Ha , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The .support_eee() operation is optional. Yet, it is implemented by the KSZ switches through a common functon that reports false for every chip except for KSZ8563, KSZ9563 and KSZ9893 from the KSZ9477 family. Remove the implementation from the switches that don't support EEE. Implement instead a ksz9477-specific suppor_eee for these three supported switches. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 3 -- drivers/net/dsa/microchip/ksz9477.c | 50 +++++++++++++++++++++++++++- drivers/net/dsa/microchip/ksz_common.c | 57 ----------------------------= ---- drivers/net/dsa/microchip/ksz_common.h | 1 - drivers/net/dsa/microchip/lan937x_main.c | 1 - 5 files changed, 49 insertions(+), 63 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index 98cf7239057d..f297aa03f42a 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -2477,7 +2477,6 @@ const struct dsa_switch_ops ksz8463_switch_ops =3D { .port_txtstamp =3D ksz_port_txtstamp, .port_rxtstamp =3D ksz_port_rxtstamp, .port_setup_tc =3D ksz_setup_tc, - .support_eee =3D ksz_support_eee, .set_mac_eee =3D ksz_set_mac_eee, .port_get_default_prio =3D ksz_port_get_default_prio, .port_set_default_prio =3D ksz_port_set_default_prio, @@ -2534,7 +2533,6 @@ const struct dsa_switch_ops ksz87xx_switch_ops =3D { .port_txtstamp =3D ksz_port_txtstamp, .port_rxtstamp =3D ksz_port_rxtstamp, .port_setup_tc =3D ksz_setup_tc, - .support_eee =3D ksz_support_eee, .set_mac_eee =3D ksz_set_mac_eee, .port_get_default_prio =3D ksz_port_get_default_prio, .port_set_default_prio =3D ksz_port_set_default_prio, @@ -2592,7 +2590,6 @@ const struct dsa_switch_ops ksz88xx_switch_ops =3D { .port_txtstamp =3D ksz_port_txtstamp, .port_rxtstamp =3D ksz_port_rxtstamp, .port_setup_tc =3D ksz_setup_tc, - .support_eee =3D ksz_support_eee, .set_mac_eee =3D ksz_set_mac_eee, .port_get_default_prio =3D ksz_port_get_default_prio, .port_set_default_prio =3D ksz_port_set_default_prio, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchi= p/ksz9477.c index a39541d29ad5..e0b3724a7558 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1909,6 +1909,54 @@ void ksz9477_phylink_mac_link_up(struct phylink_conf= ig *config, ksz9477_duplex_flowctrl(dev, port, duplex, tx_pause, rx_pause); } =20 +/** + * ksz9477_support_eee - Determine Energy Efficient Ethernet (EEE) support= for a + * port + * @ds: Pointer to the DSA switch structure + * @port: Port number to check + * + * This function also documents devices where EEE was initially advertised= but + * later withdrawn due to reliability issues, as described in official err= ata + * documents. These devices are explicitly listed to record known limitati= ons, + * even if there is no technical necessity for runtime checks. + * + * Returns: true if the internal PHY on the given port supports fully + * operational EEE, false otherwise. + */ +static bool ksz9477_support_eee(struct dsa_switch *ds, int port) +{ + struct ksz_device *dev =3D ds->priv; + + if (!dev->info->internal_phy[port]) + return false; + + switch (dev->chip_id) { + case KSZ8563_CHIP_ID: + case KSZ9563_CHIP_ID: + case KSZ9893_CHIP_ID: + return true; + default: + /* KSZ8567R Errata DS80000752C Module 4 */ + /* KSZ9477S Errata DS80000754A Module 4 */ + /* KSZ9567S Errata DS80000756A Module 4 */ + /* KSZ9896C Errata DS80000757A Module 3 */ + /* KSZ9897R Errata DS80000758C Module 4 */ + /* Energy Efficient Ethernet (EEE) feature select must be + * manually disabled + * The EEE feature is enabled by default, but it is not fully + * operational. It must be manually disabled through register + * controls. If not disabled, the PHY ports can auto-negotiate + * to enable EEE, and this feature can cause link drops when + * linked to another device supporting EEE. + * + * The same item appears in the errata for all switches above. + */ + break; + } + + return false; +} + static struct phylink_pcs * ksz9477_phylink_mac_select_pcs(struct phylink_config *config, phy_interface_t interface) @@ -1998,7 +2046,7 @@ const struct dsa_switch_ops ksz9477_switch_ops =3D { .cls_flower_add =3D ksz9477_cls_flower_add, .cls_flower_del =3D ksz9477_cls_flower_del, .port_setup_tc =3D ksz_setup_tc, - .support_eee =3D ksz_support_eee, + .support_eee =3D ksz9477_support_eee, .set_mac_eee =3D ksz_set_mac_eee, .port_get_default_prio =3D ksz_port_get_default_prio, .port_set_default_prio =3D ksz_port_set_default_prio, diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index d6511fcebcf2..475886b8c255 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3052,63 +3052,6 @@ int ksz_max_mtu(struct dsa_switch *ds, int port) return -EOPNOTSUPP; } =20 -/** - * ksz_support_eee - Determine Energy Efficient Ethernet (EEE) support for= a - * port - * @ds: Pointer to the DSA switch structure - * @port: Port number to check - * - * This function also documents devices where EEE was initially advertised= but - * later withdrawn due to reliability issues, as described in official err= ata - * documents. These devices are explicitly listed to record known limitati= ons, - * even if there is no technical necessity for runtime checks. - * - * Returns: true if the internal PHY on the given port supports fully - * operational EEE, false otherwise. - */ -bool ksz_support_eee(struct dsa_switch *ds, int port) -{ - struct ksz_device *dev =3D ds->priv; - - if (!dev->info->internal_phy[port]) - return false; - - switch (dev->chip_id) { - case KSZ8563_CHIP_ID: - case KSZ9563_CHIP_ID: - case KSZ9893_CHIP_ID: - return true; - case KSZ8567_CHIP_ID: - /* KSZ8567R Errata DS80000752C Module 4 */ - case KSZ8765_CHIP_ID: - case KSZ8794_CHIP_ID: - case KSZ8795_CHIP_ID: - /* KSZ879x/KSZ877x/KSZ876x Errata DS80000687C Module 2 */ - case KSZ9477_CHIP_ID: - /* KSZ9477S Errata DS80000754A Module 4 */ - case KSZ9567_CHIP_ID: - /* KSZ9567S Errata DS80000756A Module 4 */ - case KSZ9896_CHIP_ID: - /* KSZ9896C Errata DS80000757A Module 3 */ - case KSZ9897_CHIP_ID: - case LAN9646_CHIP_ID: - /* KSZ9897R Errata DS80000758C Module 4 */ - /* Energy Efficient Ethernet (EEE) feature select must be - * manually disabled - * The EEE feature is enabled by default, but it is not fully - * operational. It must be manually disabled through register - * controls. If not disabled, the PHY ports can auto-negotiate - * to enable EEE, and this feature can cause link drops when - * linked to another device supporting EEE. - * - * The same item appears in the errata for all switches above. - */ - break; - } - - return false; -} - int ksz_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e) { diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index ab08c98ed257..33cb2c44004b 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -477,7 +477,6 @@ void ksz_phylink_mac_link_down(struct phylink_config *c= onfig, =20 int ksz_max_mtu(struct dsa_switch *ds, int port); =20 -bool ksz_support_eee(struct dsa_switch *ds, int port); int ksz_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e); =20 diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index f8f220242f7a..4cbbcf7993c9 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -915,7 +915,6 @@ const struct dsa_switch_ops lan937x_switch_ops =3D { .port_txtstamp =3D ksz_port_txtstamp, .port_rxtstamp =3D ksz_port_rxtstamp, .port_setup_tc =3D ksz_setup_tc, - .support_eee =3D ksz_support_eee, .set_mac_eee =3D ksz_set_mac_eee, .port_get_default_prio =3D ksz_port_get_default_prio, .port_set_default_prio =3D ksz_port_set_default_prio, --=20 2.54.0 From nobody Mon Jun 8 21:47:06 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 B29FD3DD505; Tue, 26 May 2026 09:47:53 +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=1779788875; cv=none; b=MnLFXwnE5/VnFh1ifZ1niKbBKvSlMMNn8Ra4f/bX2tiGpjVHuK5cZzHzundTv79W6zCRictLQ6xZvAaMUb7VqsYFopgoYNlCN4vHo9Nh2oavJqyFoLBGi7hBgsSFgiWqmLUxjjkLjuBFXAUCINVIG41Mbt12c2jZE+dELyaEGxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779788875; c=relaxed/simple; bh=a9/vrEBXQRpufAVt4JV1I3s8sy9rvKKOF9CiOIUxd6U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WYjwcJZM8q6+qBwceH/KeYKl01lOi2b0Qkyl0l1j/r3Zz0lkGRXdwWpWGM8bmf2ql1kVXql+hw8QZ+0XhAiSk5nrp5KdiPtijBahKRDRb5khSpckFnEuAJuC5gpW90esiqOszQwZLrQGqoii0OPwkhq6GxiNCKVb99vNP/dbC9M= 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=aVEhiEJX; 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="aVEhiEJX" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id D0356C79AB4; Tue, 26 May 2026 09:47:51 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8702B60732; Tue, 26 May 2026 09:47:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 95E3010888590; Tue, 26 May 2026 11:47:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1779788871; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=usnJdPNe1BK3Qj7++ffkt4Udbt3lsVQDDSepaOcUG/k=; b=aVEhiEJXvRJIaXyoMYWR9ILQlNHWhe9I0qLpxZerojOiq/pd/m+ZNPjYdsSpvsDLRxyWiT 0SWUM7E9RmF2NKTjRAD1KOxzNd7imR3z8LkbuRlg5I62TwJWZnQMLIVtDlvo1649Twpg2k 0NzIoOH2Crdg8fVPMy2HJjyZFWZTrPByNYVZcOw4s4c4ZkEzka2G4oOYo9yg6Jfycpy47Q usm38PswVHF0DfT4J3pnUCX6wNcaG8G6oXEU2Z34dq8WyfuuZZ+woJJqWWjyT7BpHZHrtn kRusyNUYsMlgtSEM3J5ycK2rHByMwnkl0HvK5pWkGpXCL0MhOlhPw75v7WINig== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 26 May 2026 11:47:32 +0200 Subject: [PATCH net-next 6/9] net: dsa: microchip: implement .{get/set}_wol only if needed 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: <20260526-clean-ksz-3rd-v1-6-5b63e732149a@bootlin.com> References: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> In-Reply-To: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , Tristram Ha , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 All the KSZ switches use common {get/set}_wol operations while only the ksz9477 and the ksz87xx families really support it. These operations are optional so there is no point implementing them to return -EOPNOTSUPP. Remove the {get/set}_wol callbacks from the switch operations for the ksz88xx, the ksz8463 and the lan937x families. Remove the family check from the common {get/set}_wol implementation. Note that is_ksz9477() is only true for the KSZ9477 so this change will also add WoL support for the other switches using the ksz9477_switch_ops. I checked their datasheet, they implement the same PME_WOL registers, at the same addresses, so this should go fine. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 4 ---- drivers/net/dsa/microchip/ksz_common.c | 9 ++------- drivers/net/dsa/microchip/lan937x_main.c | 2 -- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index f297aa03f42a..38549dfdce7c 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -2467,8 +2467,6 @@ const struct dsa_switch_ops ksz8463_switch_ops =3D { .get_pause_stats =3D ksz_get_pause_stats, .port_change_mtu =3D ksz8_change_mtu, .port_max_mtu =3D ksz_max_mtu, - .get_wol =3D ksz_get_wol, - .set_wol =3D ksz_set_wol, .suspend =3D ksz_suspend, .resume =3D ksz_resume, .get_ts_info =3D ksz_get_ts_info, @@ -2580,8 +2578,6 @@ const struct dsa_switch_ops ksz88xx_switch_ops =3D { .get_pause_stats =3D ksz_get_pause_stats, .port_change_mtu =3D ksz8_change_mtu, .port_max_mtu =3D ksz_max_mtu, - .get_wol =3D ksz_get_wol, - .set_wol =3D ksz_set_wol, .suspend =3D ksz_suspend, .resume =3D ksz_resume, .get_ts_info =3D ksz_get_ts_info, diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 475886b8c255..2d0150b37a40 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3745,9 +3745,6 @@ void ksz_get_wol(struct dsa_switch *ds, int port, u8 pme_ctrl; int ret; =20 - if (!is_ksz9477(dev) && !ksz_is_ksz87xx(dev)) - return; - if (!dev->wakeup_source) return; =20 @@ -3798,9 +3795,6 @@ int ksz_set_wol(struct dsa_switch *ds, int port, if (wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC)) return -EINVAL; =20 - if (!is_ksz9477(dev) && !ksz_is_ksz87xx(dev)) - return -EOPNOTSUPP; - if (!dev->wakeup_source) return -EOPNOTSUPP; =20 @@ -3913,7 +3907,8 @@ int ksz_port_set_mac_address(struct dsa_switch *ds, i= nt port, */ wol.wolopts =3D 0; =20 - ksz_get_wol(ds, dp->index, &wol); + if (ds->ops->get_wol) + ds->ops->get_wol(ds, dp->index, &wol); if (wol.wolopts & WAKE_MAGIC) { dev_err(ds->dev, "Cannot change MAC address on port %d with active Wake on Magic Packet\= n", diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index 4cbbcf7993c9..5e55f92fb0d4 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -905,8 +905,6 @@ const struct dsa_switch_ops lan937x_switch_ops =3D { .get_pause_stats =3D ksz_get_pause_stats, .port_change_mtu =3D lan937x_change_mtu, .port_max_mtu =3D ksz_max_mtu, - .get_wol =3D ksz_get_wol, - .set_wol =3D ksz_set_wol, .suspend =3D ksz_suspend, .resume =3D ksz_resume, .get_ts_info =3D ksz_get_ts_info, --=20 2.54.0 From nobody Mon Jun 8 21:47:06 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 E961F3DD878 for ; Tue, 26 May 2026 09:47: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=1779788878; cv=none; b=AdNYWnwrhW7FLf7nQgNAlqkbbVqQoBmHirRkhs4u6FXoAESZRT8xCOLSCTg+T4ZcoGFTGOmK+jZi6NKxUm25Pb1svjoZ/U42Dj7D4BOwck0S/apdg7EiGGZPSLAJ6snFKIX9fESfl7Vlc0FnvA4adh33QXc1JkxoVg2lkePcS8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779788878; c=relaxed/simple; bh=RqhqUlgIRJ/4gPO45gh/czQrI5Q7huTR9VldIjIQCvk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YuvggFP40ERzbh6F8gdkqhe7TTd7X12TI1ZaRqpcO7DC8LsgZpWmOhCtj4GRJMY98sHVvMrTvryEWpGthOg9RUJWDHybqyv5lM1PnX9d7lEajVSLd7+XMSc0ol5xriGINKE8B3zOQ7ryFy26VyFDx5rJH3S2DQcjyYATkPXE1uo= 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=NYdPvv9I; 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="NYdPvv9I" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 9CFAE1A36D5; Tue, 26 May 2026 09:47:54 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 70F2E60732; Tue, 26 May 2026 09:47:54 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id ABBAC1088858A; Tue, 26 May 2026 11:47:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1779788873; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=+ArWhabM5naZBAFFkEbpc6/MSZbc2R5Fy5iytBo+VLU=; b=NYdPvv9IX7aEsIuoJ2n54B7NwhE/T3efDW7odciwV2W4H71n8gU2C3jaUud3xzqZP4pJul 0kcj+gi3GDtLxCZAEjYnomyLMp2vW74xosi082LzbeRXTbPa8Q1K81V+1cUcq43NDVd9Y8 s8DwIOZbJiEyy59cjYm2f/6W/HrofGJPEMEVgdIo84cVd963b416OA7pNe14rwfNg1xQvz clLMaC3JYmOZ7y+d3HiFnTRoopLY9yeitZ0QqnquSYXmIXKsc+nfY2xYJZXtbXKSZGkICp zJcEGZs89qGSU5Mf3RNSnpmvfCgDXozMTBjpAhOB4BqlPusSCQcRE0ctD0h9Bw== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 26 May 2026 11:47:33 +0200 Subject: [PATCH net-next 7/9] net: dsa: microchip: implement port_hsr_join for KSZ9477 only 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: <20260526-clean-ksz-3rd-v1-7-5b63e732149a@bootlin.com> References: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> In-Reply-To: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , Tristram Ha , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 All switches implement the optional .port_hsr_join operation while only the KSZ9477 truly supports it. Remove the common port_hsr_join implementation. Replace it with a specific implementation for the KSZ9477 case. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 6 --- drivers/net/dsa/microchip/ksz9477.c | 64 ++++++++++++++++++++++++++++= -- drivers/net/dsa/microchip/ksz9477.h | 2 - drivers/net/dsa/microchip/ksz_common.c | 67 ----------------------------= ---- drivers/net/dsa/microchip/ksz_common.h | 4 -- drivers/net/dsa/microchip/lan937x_main.c | 2 - 6 files changed, 60 insertions(+), 85 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index 38549dfdce7c..bea66183238e 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -2448,8 +2448,6 @@ const struct dsa_switch_ops ksz8463_switch_ops =3D { .get_sset_count =3D ksz_sset_count, .port_bridge_join =3D ksz_port_bridge_join, .port_bridge_leave =3D ksz_port_bridge_leave, - .port_hsr_join =3D ksz_hsr_join, - .port_hsr_leave =3D ksz_hsr_leave, .port_set_mac_address =3D ksz_port_set_mac_address, .port_stp_state_set =3D ksz_port_stp_state_set, .port_teardown =3D ksz_port_teardown, @@ -2499,8 +2497,6 @@ const struct dsa_switch_ops ksz87xx_switch_ops =3D { .get_sset_count =3D ksz_sset_count, .port_bridge_join =3D ksz_port_bridge_join, .port_bridge_leave =3D ksz_port_bridge_leave, - .port_hsr_join =3D ksz_hsr_join, - .port_hsr_leave =3D ksz_hsr_leave, .port_set_mac_address =3D ksz_port_set_mac_address, .port_stp_state_set =3D ksz_port_stp_state_set, .port_teardown =3D ksz_port_teardown, @@ -2556,8 +2552,6 @@ const struct dsa_switch_ops ksz88xx_switch_ops =3D { .get_sset_count =3D ksz_sset_count, .port_bridge_join =3D ksz_port_bridge_join, .port_bridge_leave =3D ksz_port_bridge_leave, - .port_hsr_join =3D ksz_hsr_join, - .port_hsr_leave =3D ksz_hsr_leave, .port_set_mac_address =3D ksz_port_set_mac_address, .port_stp_state_set =3D ksz_port_stp_state_set, .port_teardown =3D ksz_port_teardown, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchi= p/ksz9477.c index e0b3724a7558..d7903814a2a5 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -1707,12 +1708,51 @@ static int ksz9477_tc_cbs_set_cinc(struct ksz_devic= e *dev, int port, u32 val) */ #define KSZ9477_SUPPORTED_HSR_FEATURES (NETIF_F_HW_HSR_DUP | NETIF_F_HW_HS= R_FWD) =20 -void ksz9477_hsr_join(struct dsa_switch *ds, int port, struct net_device *= hsr) +static int ksz9477_hsr_join(struct dsa_switch *ds, int port, + struct net_device *hsr, + struct netlink_ext_ack *extack) { struct ksz_device *dev =3D ds->priv; struct net_device *user; struct dsa_port *hsr_dp; u8 data, hsr_ports =3D 0; + enum hsr_version ver; + int ret; + + ret =3D hsr_get_version(hsr, &ver); + if (ret) + return ret; + + if (dev->chip_id !=3D KSZ9477_CHIP_ID) { + NL_SET_ERR_MSG_MOD(extack, "Chip does not support HSR offload"); + return -EOPNOTSUPP; + } + + /* KSZ9477 can support HW offloading of only 1 HSR device */ + if (dev->hsr_dev && hsr !=3D dev->hsr_dev) { + NL_SET_ERR_MSG_MOD(extack, "Offload supported for a single HSR"); + return -EOPNOTSUPP; + } + + /* KSZ9477 only supports HSR v0 and v1 */ + if (!(ver =3D=3D HSR_V0 || ver =3D=3D HSR_V1)) { + NL_SET_ERR_MSG_MOD(extack, "Only HSR v0 and v1 supported"); + return -EOPNOTSUPP; + } + + /* KSZ9477 can only perform HSR offloading for up to two ports */ + if (hweight8(dev->hsr_ports) >=3D 2) { + NL_SET_ERR_MSG_MOD(extack, + "Cannot offload more than two ports - using software HSR"); + return -EOPNOTSUPP; + } + + /* Self MAC address filtering, to avoid frames traversing + * the HSR ring more than once. + */ + ret =3D ksz_switch_macaddr_get(ds, port, extack); + if (ret) + return ret; =20 /* Program which port(s) shall support HSR */ ksz_rmw32(dev, REG_HSR_PORT_MAP__4, BIT(port), BIT(port)); @@ -1744,12 +1784,20 @@ void ksz9477_hsr_join(struct dsa_switch *ds, int po= rt, struct net_device *hsr) /* Setup HW supported features for lan HSR ports */ user =3D dsa_to_port(ds, port)->user; user->features |=3D KSZ9477_SUPPORTED_HSR_FEATURES; + + dev->hsr_dev =3D hsr; + dev->hsr_ports |=3D BIT(port); + + return 0; } =20 -void ksz9477_hsr_leave(struct dsa_switch *ds, int port, struct net_device = *hsr) +static int ksz9477_hsr_leave(struct dsa_switch *ds, int port, + struct net_device *hsr) { struct ksz_device *dev =3D ds->priv; =20 + WARN_ON(dev->chip_id !=3D KSZ9477_CHIP_ID); + /* Clear port HSR support */ ksz_rmw32(dev, REG_HSR_PORT_MAP__4, BIT(port), 0); =20 @@ -1758,6 +1806,14 @@ void ksz9477_hsr_leave(struct dsa_switch *ds, int po= rt, struct net_device *hsr) =20 /* Disable per port self-address filtering */ ksz_port_cfg(dev, port, REG_PORT_LUE_CTRL, PORT_SRC_ADDR_FILTER, false); + + dev->hsr_ports &=3D ~BIT(port); + if (!dev->hsr_ports) + dev->hsr_dev =3D NULL; + + ksz_switch_macaddr_put(ds); + + return 0; } =20 static int ksz9477_switch_init(struct ksz_device *dev) @@ -2012,8 +2068,8 @@ const struct dsa_switch_ops ksz9477_switch_ops =3D { .get_sset_count =3D ksz_sset_count, .port_bridge_join =3D ksz_port_bridge_join, .port_bridge_leave =3D ksz_port_bridge_leave, - .port_hsr_join =3D ksz_hsr_join, - .port_hsr_leave =3D ksz_hsr_leave, + .port_hsr_join =3D ksz9477_hsr_join, + .port_hsr_leave =3D ksz9477_hsr_leave, .port_set_mac_address =3D ksz_port_set_mac_address, .port_stp_state_set =3D ksz_port_stp_state_set, .port_teardown =3D ksz_port_teardown, diff --git a/drivers/net/dsa/microchip/ksz9477.h b/drivers/net/dsa/microchi= p/ksz9477.h index 599db0a6ba2e..92a1d889224d 100644 --- a/drivers/net/dsa/microchip/ksz9477.h +++ b/drivers/net/dsa/microchip/ksz9477.h @@ -45,8 +45,6 @@ int ksz9477_mdb_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb, struct dsa_db db); int ksz9477_enable_stp_addr(struct ksz_device *dev); void ksz9477_port_queue_split(struct ksz_device *dev, int port); -void ksz9477_hsr_join(struct dsa_switch *ds, int port, struct net_device *= hsr); -void ksz9477_hsr_leave(struct dsa_switch *ds, int port, struct net_device = *hsr); =20 int ksz9477_port_acl_init(struct ksz_device *dev, int port); void ksz9477_port_acl_free(struct ksz_device *dev, int port); diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 2d0150b37a40..404399737cea 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -4043,72 +4042,6 @@ void ksz_switch_macaddr_put(struct dsa_switch *ds) kfree(switch_macaddr); } =20 -int ksz_hsr_join(struct dsa_switch *ds, int port, struct net_device *hsr, - struct netlink_ext_ack *extack) -{ - struct ksz_device *dev =3D ds->priv; - enum hsr_version ver; - int ret; - - ret =3D hsr_get_version(hsr, &ver); - if (ret) - return ret; - - if (dev->chip_id !=3D KSZ9477_CHIP_ID) { - NL_SET_ERR_MSG_MOD(extack, "Chip does not support HSR offload"); - return -EOPNOTSUPP; - } - - /* KSZ9477 can support HW offloading of only 1 HSR device */ - if (dev->hsr_dev && hsr !=3D dev->hsr_dev) { - NL_SET_ERR_MSG_MOD(extack, "Offload supported for a single HSR"); - return -EOPNOTSUPP; - } - - /* KSZ9477 only supports HSR v0 and v1 */ - if (!(ver =3D=3D HSR_V0 || ver =3D=3D HSR_V1)) { - NL_SET_ERR_MSG_MOD(extack, "Only HSR v0 and v1 supported"); - return -EOPNOTSUPP; - } - - /* KSZ9477 can only perform HSR offloading for up to two ports */ - if (hweight8(dev->hsr_ports) >=3D 2) { - NL_SET_ERR_MSG_MOD(extack, - "Cannot offload more than two ports - using software HSR"); - return -EOPNOTSUPP; - } - - /* Self MAC address filtering, to avoid frames traversing - * the HSR ring more than once. - */ - ret =3D ksz_switch_macaddr_get(ds, port, extack); - if (ret) - return ret; - - ksz9477_hsr_join(ds, port, hsr); - dev->hsr_dev =3D hsr; - dev->hsr_ports |=3D BIT(port); - - return 0; -} - -int ksz_hsr_leave(struct dsa_switch *ds, int port, - struct net_device *hsr) -{ - struct ksz_device *dev =3D ds->priv; - - WARN_ON(dev->chip_id !=3D KSZ9477_CHIP_ID); - - ksz9477_hsr_leave(ds, port, hsr); - dev->hsr_ports &=3D ~BIT(port); - if (!dev->hsr_ports) - dev->hsr_dev =3D NULL; - - ksz_switch_macaddr_put(ds); - - return 0; -} - int ksz_suspend(struct dsa_switch *ds) { struct ksz_device *dev =3D ds->priv; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index 33cb2c44004b..c8f9ac6c3a38 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -489,10 +489,6 @@ int ksz_set_wol(struct dsa_switch *ds, int port, struct ethtool_wolinfo *wol); int ksz_port_set_mac_address(struct dsa_switch *ds, int port, const unsigned char *addr); -int ksz_hsr_join(struct dsa_switch *ds, int port, struct net_device *hsr, - struct netlink_ext_ack *extack); -int ksz_hsr_leave(struct dsa_switch *ds, int port, - struct net_device *hsr); =20 int ksz_suspend(struct dsa_switch *ds); int ksz_resume(struct dsa_switch *ds); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index 5e55f92fb0d4..742b919ae4df 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -883,8 +883,6 @@ const struct dsa_switch_ops lan937x_switch_ops =3D { .get_sset_count =3D ksz_sset_count, .port_bridge_join =3D ksz_port_bridge_join, .port_bridge_leave =3D ksz_port_bridge_leave, - .port_hsr_join =3D ksz_hsr_join, - .port_hsr_leave =3D ksz_hsr_leave, .port_set_mac_address =3D ksz_port_set_mac_address, .port_stp_state_set =3D ksz_port_stp_state_set, .port_teardown =3D ksz_port_teardown, --=20 2.54.0 From nobody Mon Jun 8 21:47:06 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 389093DE433 for ; Tue, 26 May 2026 09:47:57 +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=1779788881; cv=none; b=KWq+kJFLCpAXg9n8goGqYh90SQi5Rxur4Cpe2c8rCEJv4TUuSi3kwr30q88Ng9I0fJrbOg5tCm7KQCqwiuqdKtcMbpNXcTkcFdsORhSuiwMZm6pR/1Rt0gbTvTBEpShyue9SHFWInAog3dxLc0pbGFo6BzEgPp2W9PxJ4r4bpTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779788881; c=relaxed/simple; bh=hzRu9sY1TexaOQYaEXbujNtRV7bArS5rlfB7GNAN8Kc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dKvDXgGM45I5+9jj0OmWWTTPS1uRG9giZscXCqkg5X0SV2SVGi1kjg3GVIwDvu8dJx2NRRSJWb+UMc/ji9u5KasWmlyITSgzJxAKZ1yJZODioFxV74V1zm231TsT4CQYqaOHAzd1IMsYSnvLZzSEJdoIxLiVCX2SrUF+J+gegh8= 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=127YGpCF; 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="127YGpCF" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 75430C79AB4; Tue, 26 May 2026 09:47:55 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2C27B60732; Tue, 26 May 2026 09:47:56 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9D42710888582; Tue, 26 May 2026 11:47:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1779788875; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=nHWkjNMpqsqTnSKiOm8i7Nm0HYKAvN1ZNA2K3QcMkbo=; b=127YGpCFUWQlfirVvSc3f+axLVo2v9OBZWqUlcNPu9xs3Xct67fVO3MFMLBlXiy/80eodn tf19sgH9GOVJbEhwn/POViPLttz+hEOcadsoyTWsRK06SuHszttonkgP313zoMsD6Be5SJ zU5A51P8/i0fPBJGNCuPCKg/0vSxYxrtejTwU5Szf72C0LbAyasysmhcoquALrV8LqgEt4 4EnyZVjJftmON1eHOe9zf6xiL+/1AdWl5IvtpDN0eDCIlk7U4cd+4qQ+AvCOoT0PZx8bK7 ZQCujPYVKQtrB7AxcBqw+lhRBIdfSccmUBYr4yn8+BDjoWiVyzhWqbrMNIg2+w== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 26 May 2026 11:47:34 +0200 Subject: [PATCH net-next 8/9] net: dsa: microchip: implement lan937x-specific MDIO registration 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: <20260526-clean-ksz-3rd-v1-8-5b63e732149a@bootlin.com> References: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> In-Reply-To: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , Tristram Ha , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 All the switches use a common mdio_register() function that uses two ksz_dev_ops callbacks (.mdio_bus_preinit() and .create_phy_addr_map()) to handle the lan937x specific case. These two callbacks are used only at this place in the code. Implement a new lan937x-specific MDIO registration functions that uses these two lan937x-specific functions. The lan937x bindings don't have any 'interrupts' property so this lan937x_mdio_register() doesn't call ksz_irq_phy_setup(). Expose the common ksz_*_mdio_{read/write} functions so they can be used in lan937x.c Remove the callbacks from ksz_dev_ops. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_common.c | 30 +++------- drivers/net/dsa/microchip/ksz_common.h | 42 ++------------ drivers/net/dsa/microchip/lan937x_main.c | 99 ++++++++++++++++++++++++++++= +++- 3 files changed, 110 insertions(+), 61 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 404399737cea..708dddf2c6cf 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2256,7 +2256,7 @@ static void ksz_update_port_member(struct ksz_device = *dev, int port) dev->dev_ops->cfg_port_member(dev, port, port_member | cpu_port); } =20 -static int ksz_sw_mdio_read(struct mii_bus *bus, int addr, int regnum) +int ksz_sw_mdio_read(struct mii_bus *bus, int addr, int regnum) { struct ksz_device *dev =3D bus->priv; struct dsa_switch *ds =3D dev->ds; @@ -2264,8 +2264,7 @@ static int ksz_sw_mdio_read(struct mii_bus *bus, int = addr, int regnum) return ds->ops->phy_read(ds, addr, regnum); } =20 -static int ksz_sw_mdio_write(struct mii_bus *bus, int addr, int regnum, - u16 val) +int ksz_sw_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val) { struct ksz_device *dev =3D bus->priv; struct dsa_switch *ds =3D dev->ds; @@ -2286,7 +2285,7 @@ static int ksz_sw_mdio_write(struct mii_bus *bus, int= addr, int regnum, * * Return: Value of the PHY register, or a negative error code on failure. */ -static int ksz_parent_mdio_read(struct mii_bus *bus, int addr, int regnum) +int ksz_parent_mdio_read(struct mii_bus *bus, int addr, int regnum) { struct ksz_device *dev =3D bus->priv; =20 @@ -2306,8 +2305,7 @@ static int ksz_parent_mdio_read(struct mii_bus *bus, = int addr, int regnum) * * Return: 0 on success, or a negative error code on failure. */ -static int ksz_parent_mdio_write(struct mii_bus *bus, int addr, int regnum, - u16 val) +int ksz_parent_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 v= al) { struct ksz_device *dev =3D bus->priv; =20 @@ -2415,8 +2413,8 @@ static void ksz_irq_phy_free(struct ksz_device *dev) * * Return: 0 on success, or a negative error code on failure. */ -static int ksz_parse_dt_phy_config(struct ksz_device *dev, struct mii_bus = *bus, - struct device_node *mdio_np) +int ksz_parse_dt_phy_config(struct ksz_device *dev, struct mii_bus *bus, + struct device_node *mdio_np) { struct device_node *phy_node, *phy_parent_node; bool phys_are_valid =3D true; @@ -2519,20 +2517,8 @@ int ksz_mdio_register(struct ksz_device *dev) goto put_mdio_node; } =20 - if (dev->dev_ops->mdio_bus_preinit) { - ret =3D dev->dev_ops->mdio_bus_preinit(dev, !!parent_bus); - if (ret) - goto put_mdio_node; - } - - if (dev->dev_ops->create_phy_addr_map) { - ret =3D dev->dev_ops->create_phy_addr_map(dev, !!parent_bus); - if (ret) - goto put_mdio_node; - } else { - for (i =3D 0; i < dev->info->port_cnt; i++) - dev->phy_addr_map[i] =3D i; - } + for (i =3D 0; i < dev->info->port_cnt; i++) + dev->phy_addr_map[i] =3D i; =20 bus->priv =3D dev; if (parent_bus) { diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index c8f9ac6c3a38..a7fc23ced38c 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -362,42 +362,6 @@ struct ksz_dev_ops { u32 (*get_port_addr)(int port, int offset); void (*cfg_port_member)(struct ksz_device *dev, int port, u8 member); =20 - /** - * @mdio_bus_preinit: Function pointer to pre-initialize the MDIO bus - * for accessing PHYs. - * @dev: Pointer to device structure. - * @side_mdio: Boolean indicating if the PHYs are accessed over a side - * MDIO bus. - * - * This function pointer is used to configure the MDIO bus for PHY - * access before initiating regular PHY operations. It enables either - * SPI/I2C or side MDIO access modes by unlocking necessary registers - * and setting up access permissions for the selected mode. - * - * Return: - * - 0 on success. - * - Negative error code on failure. - */ - int (*mdio_bus_preinit)(struct ksz_device *dev, bool side_mdio); - - /** - * @create_phy_addr_map: Function pointer to create a port-to-PHY - * address map. - * @dev: Pointer to device structure. - * @side_mdio: Boolean indicating if the PHYs are accessed over a side - * MDIO bus. - * - * This function pointer is responsible for mapping switch ports to PHY - * addresses according to the configured access mode (SPI or side MDIO) - * and the device=E2=80=99s strap configuration. The mapping setup may va= ry - * depending on the chip variant and configuration. Ensures the correct - * address mapping for PHY communication. - * - * Return: - * - 0 on success. - * - Negative error code on failure (e.g., invalid configuration). - */ - int (*create_phy_addr_map)(struct ksz_device *dev, bool side_mdio); void (*r_mib_cnt)(struct ksz_device *dev, int port, u16 addr, u64 *cnt); void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr, @@ -493,6 +457,12 @@ int ksz_port_set_mac_address(struct dsa_switch *ds, in= t port, int ksz_suspend(struct dsa_switch *ds); int ksz_resume(struct dsa_switch *ds); =20 +int ksz_parse_dt_phy_config(struct ksz_device *dev, struct mii_bus *bus, + struct device_node *mdio_np); +int ksz_sw_mdio_read(struct mii_bus *bus, int addr, int regnum); +int ksz_sw_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val); +int ksz_parent_mdio_read(struct mii_bus *bus, int addr, int regnum); +int ksz_parent_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 v= al); int ksz_mdio_register(struct ksz_device *dev); int ksz_pirq_setup(struct ksz_device *dev, u8 p); int ksz_girq_setup(struct ksz_device *dev); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index 742b919ae4df..73ad99dac72d 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -681,6 +682,100 @@ static int lan937x_switch_init(struct ksz_device *dev) return 0; } =20 +/** + * lan937x_mdio_register - Register and configure the MDIO bus for the LAN= 937x. + * @dev: Pointer to the KSZ device structure. + * + * This function sets up and registers an MDIO bus for a LAN937x switch, + * allowing access to its internal PHYs. If the device supports side MDIO, + * the function will configure the external MDIO controller specified by t= he + * "mdio-parent-bus" device tree property to directly manage internal PHYs. + * Otherwise, SPI or I2C access is set up for PHY access. + * + * Return: 0 on success, or a negative error code on failure. + */ +static int lan937x_mdio_register(struct ksz_device *dev) +{ + struct device_node *parent_bus_node; + struct mii_bus *parent_bus =3D NULL; + struct dsa_switch *ds =3D dev->ds; + struct device_node *mdio_np; + struct mii_bus *bus; + int ret; + + mdio_np =3D of_get_child_by_name(dev->dev->of_node, "mdio"); + if (!mdio_np) + return 0; + + parent_bus_node =3D of_parse_phandle(mdio_np, "mdio-parent-bus", 0); + if (parent_bus_node && !dev->info->phy_side_mdio_supported) { + dev_err(dev->dev, "Side MDIO bus is not supported for this HW, ignoring = 'mdio-parent-bus' property.\n"); + ret =3D -EINVAL; + + goto put_mdio_node; + } else if (parent_bus_node) { + parent_bus =3D of_mdio_find_bus(parent_bus_node); + if (!parent_bus) { + ret =3D -EPROBE_DEFER; + + goto put_mdio_node; + } + + dev->parent_mdio_bus =3D parent_bus; + } + + bus =3D devm_mdiobus_alloc(ds->dev); + if (!bus) { + ret =3D -ENOMEM; + goto put_mdio_node; + } + + ret =3D lan937x_mdio_bus_preinit(dev, !!parent_bus); + if (ret) + goto put_mdio_node; + + ret =3D lan937x_create_phy_addr_map(dev, !!parent_bus); + if (ret) + goto put_mdio_node; + + bus->priv =3D dev; + if (parent_bus) { + bus->read =3D ksz_parent_mdio_read; + bus->write =3D ksz_parent_mdio_write; + bus->name =3D "KSZ side MDIO"; + snprintf(bus->id, MII_BUS_ID_SIZE, "ksz-side-mdio-%d", + ds->index); + } else { + bus->read =3D ksz_sw_mdio_read; + bus->write =3D ksz_sw_mdio_write; + bus->name =3D "ksz user smi"; + if (ds->dst->index !=3D 0) + snprintf(bus->id, MII_BUS_ID_SIZE, "SMI-%d-%d", ds->dst->index, ds->ind= ex); + else + snprintf(bus->id, MII_BUS_ID_SIZE, "SMI-%d", ds->index); + } + + ret =3D ksz_parse_dt_phy_config(dev, bus, mdio_np); + if (ret) + goto put_mdio_node; + + ds->phys_mii_mask =3D bus->phy_mask; + bus->parent =3D ds->dev; + + ds->user_mii_bus =3D bus; + + ret =3D devm_of_mdiobus_register(ds->dev, bus, mdio_np); + if (ret) + dev_err(ds->dev, "unable to register MDIO bus %s\n", + bus->id); + +put_mdio_node: + of_node_put(mdio_np); + of_node_put(parent_bus_node); + + return ret; +} + static int lan937x_setup(struct dsa_switch *ds) { struct ksz_device *dev =3D ds->priv; @@ -794,7 +889,7 @@ static int lan937x_setup(struct dsa_switch *ds) goto port_release; } =20 - ret =3D ksz_mdio_register(dev); + ret =3D lan937x_mdio_register(dev); if (ret < 0) { dev_err(dev->dev, "failed to register the mdio"); goto out_ptp_clock_unregister; @@ -857,8 +952,6 @@ const struct phylink_mac_ops lan937x_phylink_mac_ops = =3D { const struct ksz_dev_ops lan937x_dev_ops =3D { .get_port_addr =3D ksz9477_get_port_addr, .cfg_port_member =3D ksz9477_cfg_port_member, - .mdio_bus_preinit =3D lan937x_mdio_bus_preinit, - .create_phy_addr_map =3D lan937x_create_phy_addr_map, .r_mib_cnt =3D ksz9477_r_mib_cnt, .r_mib_pkt =3D ksz9477_r_mib_pkt, .r_mib_stat64 =3D ksz_r_mib_stats64, --=20 2.54.0 From nobody Mon Jun 8 21:47:06 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 A14523DF003 for ; Tue, 26 May 2026 09:48:00 +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=1779788885; cv=none; b=ZG7Ar5CDssnC/oTU8TcQtuNECusVf/vTYJ2wVF1EG9rbCIg7jnpqcl3jXsvxBCOr5SCi+dLkTLzHSpg2FtLFsv3uac5sve6fE5cWATE0GmsFkkmUP/SgyrT4jjZLt99X2tUkUmufCH6HAAhSu3mGyB7E1Ms+qdKNBGyv2dmjd4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779788885; c=relaxed/simple; bh=TJAsHonXH7rQdWgbjJwmPvFrpTQNxpZnfdHNYkOvLBc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TNwa0PGNIPUQqH5zGYlkCFKdsskB/2xNZFWT/7CqB7usKsMKtMiPp2AoRQ5mcCUYtV+SY1y4fG1/MKWHo5rPC1OJAN9g0XWoxlQhDZ4RY/orac0enbNdIgavbEN1M448LhKOKHR9rP5WWCAVqHsCck5i6cVdHfTxHFSERO7TOIw= 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=Ce7/Zz/F; 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="Ce7/Zz/F" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 2F2AD4E42D0E; Tue, 26 May 2026 09:47:58 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 030AD60732; Tue, 26 May 2026 09:47:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7699210888589; Tue, 26 May 2026 11:47:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1779788877; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=iilN8KF8C83AesyPJyQQ0xVeNXqiT5pjrbqiZCp3vjs=; b=Ce7/Zz/F/3FzQzfOWLzwZn3NuDGiOd6kf5rBKPMu2RebOvYCd6nN6h2qb3Il22oD0Ua5mz TwK9qW+6qZJGheMu//2cxhYEJ4IcRMYgWT9pl+kXl5LOmzAtnXWSgpTdaxAZLhdsvXDex/ 4CGX+kaj9CAMkKdH28u+1F3IUeTz+2Md0u7b0zqndqmM5E5RMT7VyY7UzRuUnwUsNGVAPf pV3EyX/hlEQcdH6E+6r5QvaKNWxV/clE5vBd8KTBf5rwSVzDX9G8ARxlPYH6nhjej8jkSJ 20pruq4Rny+3WiMu0HWscQk7Sn+CZo2pTxdIY7i5G/jg1HLcHPwb1H6uKkKI5A== From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 26 May 2026 11:47:35 +0200 Subject: [PATCH net-next 9/9] net: dsa: microchip: implement port_teardown only if needed 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: <20260526-clean-ksz-3rd-v1-9-5b63e732149a@bootlin.com> References: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> In-Reply-To: <20260526-clean-ksz-3rd-v1-0-5b63e732149a@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , Tristram Ha , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The port_teardown() operation is optional. Yet, it is implemented by all the KSZ switches through a common function that doesn't do anything for the switches that aren't part of the ksz9477 family Remove the implementation from the switches that don't need it. Implement instead a ksz9477-specific port_teardown. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 3 --- drivers/net/dsa/microchip/ksz9477.c | 10 +++++++++- drivers/net/dsa/microchip/ksz_common.c | 19 ------------------- drivers/net/dsa/microchip/ksz_common.h | 1 - drivers/net/dsa/microchip/lan937x_main.c | 1 - 5 files changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index bea66183238e..e5d4ade0b29a 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -2450,7 +2450,6 @@ const struct dsa_switch_ops ksz8463_switch_ops =3D { .port_bridge_leave =3D ksz_port_bridge_leave, .port_set_mac_address =3D ksz_port_set_mac_address, .port_stp_state_set =3D ksz_port_stp_state_set, - .port_teardown =3D ksz_port_teardown, .port_pre_bridge_flags =3D ksz_port_pre_bridge_flags, .port_bridge_flags =3D ksz_port_bridge_flags, .port_fast_age =3D ksz8_flush_dyn_mac_table, @@ -2499,7 +2498,6 @@ const struct dsa_switch_ops ksz87xx_switch_ops =3D { .port_bridge_leave =3D ksz_port_bridge_leave, .port_set_mac_address =3D ksz_port_set_mac_address, .port_stp_state_set =3D ksz_port_stp_state_set, - .port_teardown =3D ksz_port_teardown, .port_pre_bridge_flags =3D ksz_port_pre_bridge_flags, .port_bridge_flags =3D ksz_port_bridge_flags, .port_fast_age =3D ksz8_flush_dyn_mac_table, @@ -2554,7 +2552,6 @@ const struct dsa_switch_ops ksz88xx_switch_ops =3D { .port_bridge_leave =3D ksz_port_bridge_leave, .port_set_mac_address =3D ksz_port_set_mac_address, .port_stp_state_set =3D ksz_port_stp_state_set, - .port_teardown =3D ksz_port_teardown, .port_pre_bridge_flags =3D ksz_port_pre_bridge_flags, .port_bridge_flags =3D ksz_port_bridge_flags, .port_fast_age =3D ksz8_flush_dyn_mac_table, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchi= p/ksz9477.c index d7903814a2a5..c2220afd7466 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1940,6 +1940,14 @@ static void ksz9477_duplex_flowctrl(struct ksz_devic= e *dev, int port, int duplex ksz_prmw8(dev, port, regs[P_XMII_CTRL_0], mask, val); } =20 +static void ksz9477_port_teardown(struct dsa_switch *ds, int port) +{ + struct ksz_device *dev =3D ds->priv; + + if (dsa_is_user_port(ds, port)) + ksz9477_port_acl_free(dev, port); +} + void ksz9477_phylink_mac_link_up(struct phylink_config *config, struct phy_device *phydev, unsigned int mode, @@ -2072,7 +2080,7 @@ const struct dsa_switch_ops ksz9477_switch_ops =3D { .port_hsr_leave =3D ksz9477_hsr_leave, .port_set_mac_address =3D ksz_port_set_mac_address, .port_stp_state_set =3D ksz_port_stp_state_set, - .port_teardown =3D ksz_port_teardown, + .port_teardown =3D ksz9477_port_teardown, .port_pre_bridge_flags =3D ksz_port_pre_bridge_flags, .port_bridge_flags =3D ksz_port_bridge_flags, .port_fast_age =3D ksz9477_flush_dyn_mac_table, diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 708dddf2c6cf..3f5b1c4e7169 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2953,25 +2953,6 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, i= nt port, u8 state) ksz_update_port_member(dev, port); } =20 -void ksz_port_teardown(struct dsa_switch *ds, int port) -{ - struct ksz_device *dev =3D ds->priv; - - switch (dev->chip_id) { - case KSZ8563_CHIP_ID: - case KSZ8567_CHIP_ID: - case KSZ9477_CHIP_ID: - case KSZ9563_CHIP_ID: - case KSZ9567_CHIP_ID: - case KSZ9893_CHIP_ID: - case KSZ9896_CHIP_ID: - case KSZ9897_CHIP_ID: - case LAN9646_CHIP_ID: - if (dsa_is_user_port(ds, port)) - ksz9477_port_acl_free(dev, port); - } -} - int ksz_port_pre_bridge_flags(struct dsa_switch *ds, int port, struct switchdev_brport_flags flags, struct netlink_ext_ack *extack) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index a7fc23ced38c..80cb4265dbdc 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -387,7 +387,6 @@ int ksz_switch_suspend(struct device *dev); int ksz_switch_resume(struct device *dev); =20 void ksz_teardown(struct dsa_switch *ds); -void ksz_port_teardown(struct dsa_switch *ds, int port); =20 void ksz_init_mib_timer(struct ksz_device *dev); bool ksz_is_port_mac_global_usable(struct dsa_switch *ds, int port); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index 73ad99dac72d..084ee811f6e2 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -978,7 +978,6 @@ const struct dsa_switch_ops lan937x_switch_ops =3D { .port_bridge_leave =3D ksz_port_bridge_leave, .port_set_mac_address =3D ksz_port_set_mac_address, .port_stp_state_set =3D ksz_port_stp_state_set, - .port_teardown =3D ksz_port_teardown, .port_pre_bridge_flags =3D ksz_port_pre_bridge_flags, .port_bridge_flags =3D ksz_port_bridge_flags, .port_fast_age =3D ksz9477_flush_dyn_mac_table, --=20 2.54.0