net: dsa: felix: use phylink_generic_validate()
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 14 Nov 2022 17:07:28 +0000 (19:07 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 16 Nov 2022 04:34:27 +0000 (20:34 -0800)
Drop the custom implementation of phylink_validate() in favor of the
generic one, which requires config->mac_capabilities to be set.

This was used up until now because of the possibility of being paired
with Aquantia PHYs with support for rate matching. The phylink framework
gained generic support for these, and knows to advertise all 10/100/1000
lower speed link modes when our SERDES protocol is 2500base-x
(fixed speed).

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/ocelot/felix.c
drivers/net/dsa/ocelot/felix.h
drivers/net/dsa/ocelot/felix_vsc9959.c
drivers/net/dsa/ocelot/seville_vsc9953.c

index dd3a18cc89dd2beb88e2fc892694326d5ab76761..44e160f32067883120d1122a6811366d8a7840e7 100644 (file)
@@ -1048,21 +1048,14 @@ static void felix_phylink_get_caps(struct dsa_switch *ds, int port,
         */
        config->legacy_pre_march2020 = false;
 
+       config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+                                  MAC_10 | MAC_100 | MAC_1000FD |
+                                  MAC_2500FD;
+
        __set_bit(ocelot->ports[port]->phy_mode,
                  config->supported_interfaces);
 }
 
-static void felix_phylink_validate(struct dsa_switch *ds, int port,
-                                  unsigned long *supported,
-                                  struct phylink_link_state *state)
-{
-       struct ocelot *ocelot = ds->priv;
-       struct felix *felix = ocelot_to_felix(ocelot);
-
-       if (felix->info->phylink_validate)
-               felix->info->phylink_validate(ocelot, port, supported, state);
-}
-
 static struct phylink_pcs *felix_phylink_mac_select_pcs(struct dsa_switch *ds,
                                                        int port,
                                                        phy_interface_t iface)
@@ -2050,7 +2043,6 @@ const struct dsa_switch_ops felix_switch_ops = {
        .get_sset_count                 = felix_get_sset_count,
        .get_ts_info                    = felix_get_ts_info,
        .phylink_get_caps               = felix_phylink_get_caps,
-       .phylink_validate               = felix_phylink_validate,
        .phylink_mac_select_pcs         = felix_phylink_mac_select_pcs,
        .phylink_mac_link_down          = felix_phylink_mac_link_down,
        .phylink_mac_link_up            = felix_phylink_mac_link_up,
index c9c29999c3363cb6719ea203bf7974a4805d81ca..42338116eed01525e715f697448d4234134c7f4d 100644 (file)
@@ -52,9 +52,6 @@ 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);
        int     (*port_setup_tc)(struct dsa_switch *ds, int port,
                                 enum tc_setup_type type, void *type_data);
        void    (*tas_guard_bands_update)(struct ocelot *ocelot, int port);
index 26a35ae322d10317da3def9ba630fbaedabf45c7..b0ae8d6156f6b42dd4026895dc3a7c282e5fd555 100644 (file)
@@ -885,35 +885,6 @@ 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)
-{
-       __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);
-       phylink_set(mask, 1000baseX_Full);
-
-       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);
-       }
-
-       linkmode_and(supported, supported, mask);
-       linkmode_and(state->advertising, state->advertising, mask);
-}
-
 /* Watermark encode
  * Bit 8:   Unit; 0:1, 1:16
  * Bit 7-0: Value to be multiplied with unit
@@ -2588,7 +2559,6 @@ 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,
        .port_modes             = vsc9959_port_modes,
        .port_setup_tc          = vsc9959_port_setup_tc,
        .port_sched_speed_set   = vsc9959_sched_speed_set,
index 7af33b2c685dae0538550fbd2a78e5a67b6bb728..6500c1697dd6127584f52e837ed28edae129a8eb 100644 (file)
@@ -840,32 +840,6 @@ 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)
-{
-       __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);
-       phylink_set(mask, 1000baseX_Full);
-
-       if (state->interface == PHY_INTERFACE_MODE_INTERNAL) {
-               phylink_set(mask, 2500baseT_Full);
-               phylink_set(mask, 2500baseX_Full);
-       }
-
-       linkmode_and(supported, supported, mask);
-       linkmode_and(state->advertising, state->advertising, mask);
-}
-
 /* Watermark encode
  * Bit 9:   Unit; 0:1, 1:16
  * Bit 8-0: Value to be multiplied with unit
@@ -1007,7 +981,6 @@ 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,
        .port_modes             = vsc9953_port_modes,
 };