From: Bastien Curutchet <bastien.curutchet@bootlin.com>
To: Woojung Huh <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Russell King <linux@armlinux.org.uk>
Cc: "Pascal Eberhard" <pascal.eberhard@se.com>,
"Miquèl Raynal" <miquel.raynal@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Bastien Curutchet (Schneider Electric)"
<bastien.curutchet@bootlin.com>,
"Vladimir Oltean" <vladimir.oltean@nxp.com>
Subject: [PATCH net-next 01/10] net: dsa: microchip: split ksz8_change_mtu()
Date: Thu, 02 Jul 2026 11:07:23 +0200 [thread overview]
Message-ID: <20260702-clean-ksz-4th-v1-1-93441e695fa4@bootlin.com> (raw)
In-Reply-To: <20260702-clean-ksz-4th-v1-0-93441e695fa4@bootlin.com>
From: Vladimir Oltean <vladimir.oltean@nxp.com>
Even among the ksz8 family, there are big differences in the MTU change
procedure between KSZ87xx and KSZ88xx (KSZ8463 is like KSZ88xx here).
Since we have 3 separate dsa_switch_ops for what constitutes "KSZ8", we
can split those procedures into separate functions.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
---
drivers/net/dsa/microchip/ksz8.c | 49 ++++++++++++++++------------------------
1 file changed, 19 insertions(+), 30 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c
index 586916570a84..c351179f6a60 100644
--- a/drivers/net/dsa/microchip/ksz8.c
+++ b/drivers/net/dsa/microchip/ksz8.c
@@ -158,10 +158,17 @@ static int ksz8_reset_switch(struct ksz_device *dev)
return 0;
}
-static int ksz8863_change_mtu(struct ksz_device *dev, int frame_size)
+static int ksz88xx_change_mtu(struct dsa_switch *ds, int port, int mtu)
{
+ struct ksz_device *dev = ds->priv;
+ int frame_size;
u8 ctrl2 = 0;
+ if (!dsa_is_cpu_port(dev->ds, port))
+ return 0;
+
+ frame_size = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
+
if (frame_size <= KSZ8_LEGAL_PACKET_SIZE)
ctrl2 |= KSZ8863_LEGAL_PACKET_ENABLE;
else if (frame_size > KSZ8863_NORMAL_PACKET_SIZE)
@@ -171,11 +178,18 @@ static int ksz8863_change_mtu(struct ksz_device *dev, int frame_size)
KSZ8863_HUGE_PACKET_ENABLE, ctrl2);
}
-static int ksz8795_change_mtu(struct ksz_device *dev, int frame_size)
+static int ksz87xx_change_mtu(struct dsa_switch *ds, int port, int mtu)
{
+ struct ksz_device *dev = ds->priv;
u8 ctrl1 = 0, ctrl2 = 0;
+ u16 frame_size;
int ret;
+ if (!dsa_is_cpu_port(dev->ds, port))
+ return 0;
+
+ frame_size = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
+
if (frame_size > KSZ8_LEGAL_PACKET_SIZE)
ctrl2 |= SW_LEGAL_PACKET_DISABLE;
if (frame_size > KSZ8863_NORMAL_PACKET_SIZE)
@@ -188,31 +202,6 @@ static int ksz8795_change_mtu(struct ksz_device *dev, int frame_size)
return ksz_rmw8(dev, REG_SW_CTRL_2, SW_LEGAL_PACKET_DISABLE, ctrl2);
}
-static int ksz8_change_mtu(struct dsa_switch *ds, int port, int mtu)
-{
- struct ksz_device *dev = ds->priv;
- u16 frame_size;
-
- if (!dsa_is_cpu_port(dev->ds, port))
- return 0;
-
- frame_size = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
-
- switch (dev->chip_id) {
- case KSZ8795_CHIP_ID:
- case KSZ8794_CHIP_ID:
- case KSZ8765_CHIP_ID:
- return ksz8795_change_mtu(dev, frame_size);
- case KSZ8463_CHIP_ID:
- case KSZ88X3_CHIP_ID:
- case KSZ8864_CHIP_ID:
- case KSZ8895_CHIP_ID:
- return ksz8863_change_mtu(dev, frame_size);
- }
-
- return -EOPNOTSUPP;
-}
-
static int ksz8_port_queue_split(struct ksz_device *dev, int port, int queues)
{
u8 mask_4q, mask_2q;
@@ -2551,7 +2540,7 @@ const struct dsa_switch_ops ksz8463_switch_ops = {
.port_mirror_del = ksz8_port_mirror_del,
.get_stats64 = ksz_get_stats64,
.get_pause_stats = ksz_get_pause_stats,
- .port_change_mtu = ksz8_change_mtu,
+ .port_change_mtu = ksz88xx_change_mtu,
.port_max_mtu = ksz_max_mtu,
.suspend = ksz_suspend,
.resume = ksz_resume,
@@ -2601,7 +2590,7 @@ const struct dsa_switch_ops ksz87xx_switch_ops = {
.port_mirror_del = ksz8_port_mirror_del,
.get_stats64 = ksz_get_stats64,
.get_pause_stats = ksz_get_pause_stats,
- .port_change_mtu = ksz8_change_mtu,
+ .port_change_mtu = ksz87xx_change_mtu,
.port_max_mtu = ksz_max_mtu,
.suspend = ksz_suspend,
.resume = ksz_resume,
@@ -2652,7 +2641,7 @@ const struct dsa_switch_ops ksz88xx_switch_ops = {
.port_mirror_del = ksz8_port_mirror_del,
.get_stats64 = ksz_get_stats64,
.get_pause_stats = ksz_get_pause_stats,
- .port_change_mtu = ksz8_change_mtu,
+ .port_change_mtu = ksz88xx_change_mtu,
.port_max_mtu = ksz_max_mtu,
.get_wol = ksz_get_wol,
.set_wol = ksz_set_wol,
--
2.54.0
next prev parent reply other threads:[~2026-07-02 9:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 9:07 [PATCH net-next 00/10] net: dsa: microchip: move non-common function out of ksz_common.c Bastien Curutchet
2026-07-02 9:07 ` Bastien Curutchet [this message]
2026-07-02 9:07 ` [PATCH net-next 02/10] net: dsa: microchip: split port_max_mtu() implementation Bastien Curutchet
2026-07-02 9:07 ` [PATCH net-next 03/10] net: dsa: microchip: make ksz_is_port_mac_global_usable() static Bastien Curutchet (Schneider Electric)
2026-07-02 9:07 ` [PATCH net-next 04/10] net: dsa: microchip: move ksz88xx stats handling in ksz8.c Bastien Curutchet (Schneider Electric)
2026-07-02 9:07 ` [PATCH net-next 05/10] net: dsa: microchip: move ksz_get_gbit() and ksz_get_xmii() to ksz9477.c Bastien Curutchet (Schneider Electric)
2026-07-02 9:07 ` [PATCH net-next 06/10] net: dsa: microchip: move KSZ9477 errata handling " Bastien Curutchet (Schneider Electric)
2026-07-02 9:07 ` [PATCH net-next 07/10] net: dsa: microchip: handle KSZ8-specific tc setup in ksz8.c Bastien Curutchet (Schneider Electric)
2026-07-02 9:07 ` [PATCH net-next 08/10] net: dsa: microchip: move ksz9477_set_default_prio_queue_mapping() to ksz9477.c Bastien Curutchet (Schneider Electric)
2026-07-02 9:07 ` [PATCH net-next 09/10] net: dsa: microchip: rename ksz9477_drive_strength_write() Bastien Curutchet (Schneider Electric)
2026-07-02 9:07 ` [PATCH net-next 10/10] net: dsa: microchip: move the drive strength config out of the common section Bastien Curutchet (Schneider Electric)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260702-clean-ksz-4th-v1-1-93441e695fa4@bootlin.com \
--to=bastien.curutchet@bootlin.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=pascal.eberhard@se.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vladimir.oltean@nxp.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox