From: Paolo Abeni <pabeni@redhat.com>
To: "Bastien Curutchet (Schneider Electric)"
<bastien.curutchet@bootlin.com>,
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>,
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>,
"Tristram Ha" <tristram.ha@microchip.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 4/9] net: dsa: microchip: remove setup_rgmii_delay() KSZ operation
Date: Mon, 1 Jun 2026 10:49:23 +0200 [thread overview]
Message-ID: <27937ce7-ec1c-4aab-9061-cedcf4f89d12@redhat.com> (raw)
In-Reply-To: <20260526-clean-ksz-3rd-v1-4-5b63e732149a@bootlin.com>
On 5/26/26 11:47 AM, Bastien Curutchet (Schneider Electric) wrote:
> 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) <bastien.curutchet@bootlin.com>
> ---
> 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/microchip/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;
> }
>
> -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 interface)
> {
> const u8 *bitval = dev->info->xmii_ctrl1;
> struct ksz_port *p = &dev->ports[port];
> @@ -3233,9 +3232,6 @@ void ksz_phylink_mac_config(struct phylink_config *config,
> }
>
> ksz_set_xmii(dev, port, state->interface);
> -
> - if (dev->dev_ops->setup_rgmii_delay)
> - dev->dev_ops->setup_rgmii_delay(dev, port);
> }
>
> bool ksz_get_gbit(struct ksz_device *dev, int port)
> diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/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 port,
> 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 interface);
> 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/microchip/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_device *dev, int port)
> }
> }
>
> +static void lan937x_phylink_mac_config(struct phylink_config *config,
> + unsigned int mode,
> + const struct phylink_link_state *state)
> +{
> + struct dsa_port *dp = dsa_phylink_to_port(config);
> + struct ksz_device *dev = dp->ds->priv;
> + int port = 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);
I think you can avoid some code duplication with something alike the
following:
- factor out of ksz_phylink_mac_config() a __ksz_phylink_mac_config(),
helper, with the latter doing all the work and returning true when
actually calling ksz_set_xmii()
- implement lan937x_phylink_mac_config() on top of
__ksz_phylink_mac_config():
if (__ksz_phylink_mac_config())
lan937x_setup_rgmii_delay(dev, port);
/P
next prev parent reply other threads:[~2026-06-01 8:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 9:47 [PATCH net-next 0/9] net: dsa: microchip: remove unnecessary dsa_switch_ops callbacks Bastien Curutchet (Schneider Electric)
2026-05-26 9:47 ` [PATCH net-next 1/9] net: dsa: microchip: remove useless common cls_flower_{add/del} operations Bastien Curutchet (Schneider Electric)
2026-05-26 9:47 ` [PATCH net-next 2/9] net: dsa: microchip: remove VLAN operations for ksz8463 Bastien Curutchet
2026-05-26 9:47 ` [PATCH net-next 3/9] net: dsa: microchip: implement get_phy_flags only if needed Bastien Curutchet (Schneider Electric)
2026-05-26 9:47 ` [PATCH net-next 4/9] net: dsa: microchip: remove setup_rgmii_delay() KSZ operation Bastien Curutchet (Schneider Electric)
2026-06-01 8:49 ` Paolo Abeni [this message]
2026-06-02 12:15 ` Bastien Curutchet
2026-05-26 9:47 ` [PATCH net-next 5/9] net: dsa: microchip: implement .support_eee() only if needed Bastien Curutchet (Schneider Electric)
2026-06-01 8:55 ` Paolo Abeni
2026-06-02 12:21 ` Bastien Curutchet
2026-05-26 9:47 ` [PATCH net-next 6/9] net: dsa: microchip: implement .{get/set}_wol " Bastien Curutchet (Schneider Electric)
2026-06-01 8:59 ` Paolo Abeni
2026-06-02 12:34 ` Bastien Curutchet
2026-05-26 9:47 ` [PATCH net-next 7/9] net: dsa: microchip: implement port_hsr_join for KSZ9477 only Bastien Curutchet (Schneider Electric)
2026-06-01 9:03 ` Paolo Abeni
2026-06-02 12:35 ` Bastien Curutchet
2026-06-02 14:06 ` Bastien Curutchet
2026-05-26 9:47 ` [PATCH net-next 8/9] net: dsa: microchip: implement lan937x-specific MDIO registration Bastien Curutchet (Schneider Electric)
2026-05-26 9:47 ` [PATCH net-next 9/9] net: dsa: microchip: implement port_teardown only if needed 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=27937ce7-ec1c-4aab-9061-cedcf4f89d12@redhat.com \
--to=pabeni@redhat.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=bastien.curutchet@bootlin.com \
--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=pascal.eberhard@se.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tristram.ha@microchip.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
Powered by JetHome