net: dsa: microchip: bypass dev_ops for phylink_get_caps()

ksz_phylink_get_caps() is a bit different from other generic methods.
It has a dev_ops->get_caps() call in the middle of the function, and it
does other stuff before (set some supported_interfaces) and after (set
lpi_interfaces from supported_interfaces).

Whereas the dev_ops->get_caps() methods set mac_capabilities and
(optionally) logically OR the supported_interfaces with that of the PCS.

The idea is that this can be expressed simpler, and avoid a indirect
function call to dev_ops->get_caps(). If we tail-call the common
ksz_phylink_get_caps() from individual phylink_get_caps() methods, we do
reorder the settings, but in an inconsequential way (the transfer from
supported_interfaces to lpi_interfaces still sees a complete list of the
supported_interfaces).
Remove the no longer used get_caps() callbacl the ksz_dev_ops.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Link: https://patch.msgid.link/20260512-clean-ksz-2nd-series-v1-7-c00f6ce037fa@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Vladimir Oltean 2026-05-12 15:06:29 +02:00 committed by Jakub Kicinski
parent 5973ddcc17
commit 82e5193a4e
5 changed files with 22 additions and 20 deletions

View File

@ -1995,9 +1995,11 @@ static int ksz8_setup(struct dsa_switch *ds)
return ret;
}
static void ksz8_get_caps(struct ksz_device *dev, int port,
struct phylink_config *config)
static void ksz8_phylink_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config)
{
struct ksz_device *dev = ds->priv;
config->mac_capabilities = MAC_10 | MAC_100;
/* Silicon Errata Sheet (DS80000830A):
@ -2011,6 +2013,8 @@ static void ksz8_get_caps(struct ksz_device *dev, int port,
/* Asym pause is not supported on KSZ8863 and KSZ8873 */
if (!ksz_is_ksz88x3(dev))
config->mac_capabilities |= MAC_ASYM_PAUSE;
ksz_phylink_get_caps(ds, port, config);
}
static u32 ksz8_get_port_addr(int port, int offset)
@ -2218,7 +2222,6 @@ const struct ksz_dev_ops ksz8463_dev_ops = {
.r_mib_stat64 = ksz88xx_r_mib_stats64,
.freeze_mib = ksz8_freeze_mib,
.port_init_cnt = ksz8_port_init_cnt,
.get_caps = ksz8_get_caps,
.config_cpu_port = ksz8_config_cpu_port,
.enable_stp_addr = ksz8_enable_stp_addr,
.reset = ksz8_reset_switch,
@ -2238,7 +2241,6 @@ const struct ksz_dev_ops ksz87xx_dev_ops = {
.r_mib_stat64 = ksz_r_mib_stats64,
.freeze_mib = ksz8_freeze_mib,
.port_init_cnt = ksz8_port_init_cnt,
.get_caps = ksz8_get_caps,
.config_cpu_port = ksz8_config_cpu_port,
.enable_stp_addr = ksz8_enable_stp_addr,
.reset = ksz8_reset_switch,
@ -2261,7 +2263,6 @@ const struct ksz_dev_ops ksz88xx_dev_ops = {
.r_mib_stat64 = ksz88xx_r_mib_stats64,
.freeze_mib = ksz8_freeze_mib,
.port_init_cnt = ksz8_port_init_cnt,
.get_caps = ksz8_get_caps,
.config_cpu_port = ksz8_config_cpu_port,
.enable_stp_addr = ksz8_enable_stp_addr,
.reset = ksz8_reset_switch,
@ -2280,7 +2281,7 @@ const struct dsa_switch_ops ksz8463_switch_ops = {
.teardown = ksz_teardown,
.phy_read = ksz_phy_read16,
.phy_write = ksz_phy_write16,
.phylink_get_caps = ksz_phylink_get_caps,
.phylink_get_caps = ksz8_phylink_get_caps,
.port_setup = ksz_port_setup,
.get_strings = ksz_get_strings,
.get_ethtool_stats = ksz_get_ethtool_stats,
@ -2340,7 +2341,7 @@ const struct dsa_switch_ops ksz87xx_switch_ops = {
.teardown = ksz_teardown,
.phy_read = ksz_phy_read16,
.phy_write = ksz_phy_write16,
.phylink_get_caps = ksz_phylink_get_caps,
.phylink_get_caps = ksz8_phylink_get_caps,
.port_setup = ksz_port_setup,
.get_strings = ksz_get_strings,
.get_ethtool_stats = ksz_get_ethtool_stats,
@ -2400,7 +2401,7 @@ const struct dsa_switch_ops ksz88xx_switch_ops = {
.teardown = ksz_teardown,
.phy_read = ksz_phy_read16,
.phy_write = ksz_phy_write16,
.phylink_get_caps = ksz_phylink_get_caps,
.phylink_get_caps = ksz8_phylink_get_caps,
.port_setup = ksz_port_setup,
.get_strings = ksz_get_strings,
.get_ethtool_stats = ksz_get_ethtool_stats,

View File

@ -1165,9 +1165,11 @@ static phy_interface_t ksz9477_get_interface(struct ksz_device *dev, int port)
return interface;
}
static void ksz9477_get_caps(struct ksz_device *dev, int port,
struct phylink_config *config)
static void ksz9477_phylink_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config)
{
struct ksz_device *dev = ds->priv;
config->mac_capabilities = MAC_10 | MAC_100 | MAC_ASYM_PAUSE |
MAC_SYM_PAUSE;
@ -1181,6 +1183,8 @@ static void ksz9477_get_caps(struct ksz_device *dev, int port,
config->supported_interfaces,
p->pcs->supported_interfaces);
}
ksz_phylink_get_caps(ds, port, config);
}
static int ksz9477_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)
@ -1791,7 +1795,6 @@ const struct ksz_dev_ops ksz9477_dev_ops = {
.r_mib_stat64 = ksz_r_mib_stats64,
.freeze_mib = ksz9477_freeze_mib,
.port_init_cnt = ksz9477_port_init_cnt,
.get_caps = ksz9477_get_caps,
.pme_write8 = ksz_write8,
.pme_pread8 = ksz_pread8,
.pme_pwrite8 = ksz_pwrite8,
@ -1812,7 +1815,7 @@ const struct dsa_switch_ops ksz9477_switch_ops = {
.teardown = ksz_teardown,
.phy_read = ksz_phy_read16,
.phy_write = ksz_phy_write16,
.phylink_get_caps = ksz_phylink_get_caps,
.phylink_get_caps = ksz9477_phylink_get_caps,
.port_setup = ksz_port_setup,
.set_ageing_time = ksz9477_set_ageing_time,
.get_strings = ksz_get_strings,

View File

@ -1995,9 +1995,6 @@ void ksz_phylink_get_caps(struct dsa_switch *ds, int port,
config->supported_interfaces);
}
if (dev->dev_ops->get_caps)
dev->dev_ops->get_caps(dev, port, config);
if (ds->ops->support_eee && ds->ops->support_eee(ds, port)) {
memcpy(config->lpi_interfaces, config->supported_interfaces,
sizeof(config->lpi_interfaces));

View File

@ -408,8 +408,6 @@ struct ksz_dev_ops {
void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr,
u64 *dropped, u64 *cnt);
void (*r_mib_stat64)(struct ksz_device *dev, int port);
void (*get_caps)(struct ksz_device *dev, int port,
struct phylink_config *config);
int (*pme_write8)(struct ksz_device *dev, u32 reg, u8 value);
int (*pme_pread8)(struct ksz_device *dev, int port, int offset,
u8 *data);

View File

@ -575,9 +575,11 @@ static void lan937x_set_rgmii_rx_delay(struct ksz_device *dev, int port)
lan937x_set_tune_adj(dev, port, REG_PORT_XMII_CTRL_4, val);
}
static void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
static void lan937x_phylink_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config)
{
struct ksz_device *dev = ds->priv;
config->mac_capabilities = MAC_100FD;
if (dev->info->supports_rgmii[port]) {
@ -588,6 +590,8 @@ static void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
config->mac_capabilities |= MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
MAC_100HD | MAC_10;
}
ksz_phylink_get_caps(ds, port, config);
}
static void lan937x_setup_rgmii_delay(struct ksz_device *dev, int port)
@ -713,7 +717,6 @@ const struct ksz_dev_ops lan937x_dev_ops = {
.r_mib_stat64 = ksz_r_mib_stats64,
.freeze_mib = ksz9477_freeze_mib,
.port_init_cnt = ksz9477_port_init_cnt,
.get_caps = lan937x_phylink_get_caps,
.setup_rgmii_delay = lan937x_setup_rgmii_delay,
.config_cpu_port = lan937x_config_cpu_port,
.tc_cbs_set_cinc = lan937x_tc_cbs_set_cinc,
@ -731,7 +734,7 @@ const struct dsa_switch_ops lan937x_switch_ops = {
.teardown = ksz_teardown,
.phy_read = ksz_phy_read16,
.phy_write = ksz_phy_write16,
.phylink_get_caps = ksz_phylink_get_caps,
.phylink_get_caps = lan937x_phylink_get_caps,
.port_setup = ksz_port_setup,
.set_ageing_time = lan937x_set_ageing_time,
.get_strings = ksz_get_strings,