From 7d384dc3e28afd432b6ce219a699c0f02003e899 Mon Sep 17 00:00:00 2001 From: "Russell King (Oracle)" Date: Sat, 18 Jun 2022 20:24:13 +0100 Subject: net: dsa: ocelot: use phylink_validate_mask_caps() Signed-off-by: Russell King (Oracle) --- drivers/net/dsa/ocelot/felix.c | 9 +++++++-- drivers/net/dsa/ocelot/felix.h | 4 +--- drivers/net/dsa/ocelot/felix_vsc9959.c | 29 +++++++---------------------- drivers/net/dsa/ocelot/seville_vsc9953.c | 30 ++++++++---------------------- 4 files changed, 23 insertions(+), 49 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 187893678f66..84cfaf163f0e 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -999,9 +999,14 @@ static void felix_phylink_validate(struct dsa_switch *ds, int port, { struct ocelot *ocelot = ds->priv; struct felix *felix = ocelot_to_felix(ocelot); + unsigned long caps; - if (felix->info->phylink_validate) - felix->info->phylink_validate(ocelot, port, supported, state); + if (!felix->info->phylink_caps) + return; + + caps = felix->info->phylink_caps(state->interface); + + phylink_validate_mask_caps(supported, state, caps); } static struct phylink_pcs *felix_phylink_mac_select_pcs(struct dsa_switch *ds, diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h index f083b06fdfe9..8ad21d4a4a7b 100644 --- a/drivers/net/dsa/ocelot/felix.h +++ b/drivers/net/dsa/ocelot/felix.h @@ -48,9 +48,7 @@ struct felix_info { int (*mdio_bus_alloc)(struct ocelot *ocelot); void (*mdio_bus_free)(struct ocelot *ocelot); - void (*phylink_validate)(struct ocelot *ocelot, int port, - unsigned long *supported, - struct phylink_link_state *state); + unsigned long (*phylink_caps)(phy_interface_t interface); int (*port_setup_tc)(struct dsa_switch *ds, int port, enum tc_setup_type type, void *type_data); void (*port_sched_speed_set)(struct ocelot *ocelot, int port, diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 52a8566071ed..303d30e92f12 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -956,32 +956,17 @@ static int vsc9959_reset(struct ocelot *ocelot) return 0; } -static void vsc9959_phylink_validate(struct ocelot *ocelot, int port, - unsigned long *supported, - struct phylink_link_state *state) +static unsigned long vsc9959_phylink_caps(phy_interface_t interface) { - __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; - - phylink_set_port_modes(mask); - phylink_set(mask, Autoneg); - phylink_set(mask, Pause); - phylink_set(mask, Asym_Pause); - phylink_set(mask, 10baseT_Half); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Half); - phylink_set(mask, 100baseT_Full); - phylink_set(mask, 1000baseT_Half); - phylink_set(mask, 1000baseT_Full); + unsigned long caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | + MAC_10 | MAC_100 | MAC_1000; if (state->interface == PHY_INTERFACE_MODE_INTERNAL || state->interface == PHY_INTERFACE_MODE_2500BASEX || - state->interface == PHY_INTERFACE_MODE_USXGMII) { - phylink_set(mask, 2500baseT_Full); - phylink_set(mask, 2500baseX_Full); - } + state->interface == PHY_INTERFACE_MODE_USXGMII) + caps |= MAC_2500FD; - linkmode_and(supported, supported, mask); - linkmode_and(state->advertising, state->advertising, mask); + return caps; } /* Watermark encode @@ -2229,7 +2214,7 @@ static const struct felix_info felix_info_vsc9959 = { .ptp_caps = &vsc9959_ptp_caps, .mdio_bus_alloc = vsc9959_mdio_bus_alloc, .mdio_bus_free = vsc9959_mdio_bus_free, - .phylink_validate = vsc9959_phylink_validate, + .phylink_caps = vsc9959_phylink_caps, .port_modes = vsc9959_port_modes, .port_setup_tc = vsc9959_port_setup_tc, .port_sched_speed_set = vsc9959_sched_speed_set, diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index 68ef8f111bbe..a7d4045aa66f 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -931,29 +931,15 @@ static int vsc9953_reset(struct ocelot *ocelot) return 0; } -static void vsc9953_phylink_validate(struct ocelot *ocelot, int port, - unsigned long *supported, - struct phylink_link_state *state) +static unsigned long vsc9953_phylink_caps(phy_interface_t interface) { - __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; - - phylink_set_port_modes(mask); - phylink_set(mask, Autoneg); - phylink_set(mask, Pause); - phylink_set(mask, Asym_Pause); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 10baseT_Half); - phylink_set(mask, 100baseT_Full); - phylink_set(mask, 100baseT_Half); - phylink_set(mask, 1000baseT_Full); - - if (state->interface == PHY_INTERFACE_MODE_INTERNAL) { - phylink_set(mask, 2500baseT_Full); - phylink_set(mask, 2500baseX_Full); - } + unsigned long caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | + MAC_10 | MAC_100 | MAC_1000FD; + + if (interface == PHY_INTERFACE_MODE_INTERNAL) + caps |= MAC_2500FD; - linkmode_and(supported, supported, mask); - linkmode_and(state->advertising, state->advertising, mask); + return caps; } /* Watermark encode @@ -1097,7 +1083,7 @@ static const struct felix_info seville_info_vsc9953 = { .num_tx_queues = OCELOT_NUM_TC, .mdio_bus_alloc = vsc9953_mdio_bus_alloc, .mdio_bus_free = vsc9953_mdio_bus_free, - .phylink_validate = vsc9953_phylink_validate, + .phylink_caps = vsc9953_phylink_caps, .port_modes = vsc9953_port_modes, .init_regmap = ocelot_regmap_init, }; -- cgit