net: dsa: ocelot: phylink updates
Subsystems (4)
cover net: dsa: ocelot: phylink updates
Hi,
This series updates the Ocelot DSA driver for some of the recent phylink changes. Specifically, we fill in the supported_interfaces fields, convert to mac_select_pcs and mark the driver as non-legacy. We do not convert to phylink_generic_validate() as Ocelot has special support for its rate adapting PCS which makes the generic validate method unsuitable for this driver.
The three changes mentioned above are implemented in their own separate patches with one additional cleanup:
1) Populate the supported_interfaces bitmap
2) Remove the now unnecessary interface checks in the validate methods
3) Convert from phylink_set_pcs() to .mac_select_pcs.
4) Mark the driver as non-legacy
Thanks.
drivers/net/dsa/ocelot/felix.c | 31 +++++++++++++++++++++++++------ drivers/net/dsa/ocelot/felix.h | 2 ++ drivers/net/dsa/ocelot/felix_vsc9959.c | 16 ++++++++++------ drivers/net/dsa/ocelot/seville_vsc9953.c | 16 ++++++++++------ 4 files changed, 47 insertions(+), 18 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
RFC PATCH 1/4 net: dsa: ocelot: populate supported_interfaces
Populate the supported interfaces bitmap for the Ocelot DSA switches.
The felix_vsc9959 and seville_vsc9953 sub-drivers only supports a single interface mode, defined by ocelot_port->phy_mode, so we indicate only this interface mode to phylink.
--- drivers/net/dsa/ocelot/felix.c | 11 +++++++++++ drivers/net/dsa/ocelot/felix.h | 2 ++ drivers/net/dsa/ocelot/felix_vsc9959.c | 10 ++++++++++ drivers/net/dsa/ocelot/seville_vsc9953.c | 10 ++++++++++ 4 files changed, 33 insertions(+)
drivers/net/dsa/ocelot/felix.c +11 -0
@@ -778,6 +778,16 @@ static int felix_vlan_del(struct dsa_switch *ds, int port,return ocelot_vlan_del (ocelot, port, vlan->vid); } +static void felix_phylink_get_caps (struct dsa_switch *ds,int port, +struct phylink_config *config) +{ +struct ocelot *ocelot = ds->priv; +struct felix *felix =ocelot_to_felix (ocelot); + +if (felix->info->phylink_get_caps) + felix->info->phylink_get_caps (ocelot, port, config); +} +static void felix_phylink_validate (struct dsa_switch *ds,int port,unsigned long *supported,struct phylink_link_state *state)
@@ -1587,6 +1597,7 @@ const struct dsa_switch_ops felix_switch_ops = { .get_ethtool_stats = felix_get_ethtool_stats, .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_config = felix_phylink_mac_config, .phylink_mac_link_down = felix_phylink_mac_link_down,
drivers/net/dsa/ocelot/felix.h +2 -0
@@ -41,6 +41,8 @@ struct felix_info {int (*mdio_bus_alloc)(struct ocelot *ocelot);void (*mdio_bus_free)(struct ocelot *ocelot); +void (*phylink_get_caps)(struct ocelot *ocelot,int port, +struct phylink_config *config);void (*phylink_validate)(struct ocelot *ocelot,int port,unsigned long *supported,struct phylink_link_state *state);
drivers/net/dsa/ocelot/felix_vsc9959.c +10 -0
@@ -940,6 +940,15 @@ static int vsc9959_reset(struct ocelot *ocelot)return 0 ; } +static void vsc9959_phylink_get_caps (struct ocelot *ocelot,int port, +struct phylink_config *config) +{ +struct ocelot_port *ocelot_port = ocelot->ports[port]; + +__set_bit (ocelot_port->phy_mode, + config->supported_interfaces); +} +static void vsc9959_phylink_validate (struct ocelot *ocelot,int port,unsigned long *supported,struct phylink_link_state *state)
@@ -2237,6 +2246,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_get_caps = vsc9959_phylink_get_caps, .phylink_validate = vsc9959_phylink_validate, .prevalidate_phy_mode = vsc9959_prevalidate_phy_mode, .port_setup_tc = vsc9959_port_setup_tc,
drivers/net/dsa/ocelot/seville_vsc9953.c +10 -0
@@ -913,6 +913,15 @@ static int vsc9953_reset(struct ocelot *ocelot)return 0 ; } +static void vsc9953_phylink_get_caps (struct ocelot *ocelot,int port, +struct phylink_config *config) +{ +struct ocelot_port *ocelot_port = ocelot->ports[port]; + +__set_bit (ocelot_port->phy_mode, + config->supported_interfaces); +} +static void vsc9953_phylink_validate (struct ocelot *ocelot,int port,unsigned long *supported,struct phylink_link_state *state)
@@ -1105,6 +1114,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_get_caps = vsc9953_phylink_get_caps, .phylink_validate = vsc9953_phylink_validate, .prevalidate_phy_mode = vsc9953_prevalidate_phy_mode, .init_regmap = ocelot_regmap_init,
Signature · 1 line
2.30.2
RFC PATCH 2/4 net: dsa: ocelot: remove interface checks
In reply to Russell King (Oracle)When the supported interfaces bitmap is populated, phylink will itself check that the interface mode is present in this bitmap. Drivers no longer need to perform this check themselves. Remove these checks.
--- drivers/net/dsa/ocelot/felix_vsc9959.c | 6 ------ drivers/net/dsa/ocelot/seville_vsc9953.c | 6 ------ 2 files changed, 12 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +0 -6
@@ -956,12 +956,6 @@ static void vsc9959_phylink_validate(struct ocelot *ocelot, int port,struct ocelot_port *ocelot_port = ocelot->ports[port];__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; -if (state->interface !=PHY_INTERFACE_MODE_NA && - state->interface != ocelot_port->phy_mode) { -linkmode_zero (supported); -return ; - } -phylink_set_port_modes (mask);phylink_set (mask, Autoneg);phylink_set (mask, Pause);
drivers/net/dsa/ocelot/seville_vsc9953.c +0 -6
@@ -929,12 +929,6 @@ static void vsc9953_phylink_validate(struct ocelot *ocelot, int port,struct ocelot_port *ocelot_port = ocelot->ports[port];__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; -if (state->interface !=PHY_INTERFACE_MODE_NA && - state->interface != ocelot_port->phy_mode) { -linkmode_zero (supported); -return ; - } -phylink_set_port_modes (mask);phylink_set (mask, Autoneg);phylink_set (mask, Pause);
Signature · 1 line
2.30.2
RFC PATCH 3/4 net: dsa: ocelot: convert to mac_select_pcs()
In reply to Russell King (Oracle)Convert the PCS selection to use mac_select_pcs, which allows the PCS to perform any validation it needs, and removes the need to set the PCS in the mac_config() callback, delving into the higher DSA levels to do so.
--- drivers/net/dsa/ocelot/felix.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/dsa/ocelot/felix.c +8 -6
@@ -799,16 +799,18 @@ static void felix_phylink_validate(struct dsa_switch *ds, int port, felix->info->phylink_validate (ocelot, port, supported, state); } -static void felix_phylink_mac_config (struct dsa_switch *ds,int port, -unsigned int link_an_mode, -const struct phylink_link_state *state) +static struct phylink_pcs *felix_phylink_mac_select_pcs (struct dsa_switch *ds, +int port, +phy_interface_t iface) {struct ocelot *ocelot = ds->priv;struct felix *felix =ocelot_to_felix (ocelot); -struct dsa_port *dp =dsa_to_port (ds, port); +struct phylink_pcs *pcs =NULL ;if (felix->pcs && felix->pcs[port]) -phylink_set_pcs (dp->pl, felix->pcs[port]); + pcs = felix->pcs[port]; + +return pcs; } static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
@@ -1599,7 +1601,7 @@ const struct dsa_switch_ops felix_switch_ops = { .get_ts_info = felix_get_ts_info, .phylink_get_caps = felix_phylink_get_caps, .phylink_validate = felix_phylink_validate, - .phylink_mac_config = felix_phylink_mac_config, + .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, .port_fast_age = felix_port_fast_age,
Signature · 1 line
2.30.2
RFC PATCH 4/4 net: dsa: ocelot: mark as non-legacy
In reply to Russell King (Oracle)The ocelot DSA driver does not make use of the speed, duplex, pause or advertisement in its phylink_mac_config() implementation, so it can be marked as a non-legacy driver.
--- drivers/net/dsa/ocelot/felix.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/dsa/ocelot/felix.c +6 -0
@@ -784,6 +784,12 @@ static void felix_phylink_get_caps(struct dsa_switch *ds, int port,struct ocelot *ocelot = ds->priv;struct felix *felix =ocelot_to_felix (ocelot); +/* This driver does not make use of the speed, duplex, pause or the +* advertisement in its mac_config, so it is safe to mark this driver +* as non-legacy. +*/ + config->legacy_pre_march2020 = false; +if (felix->info->phylink_get_caps) felix->info->phylink_get_caps (ocelot, port, config); }
Signature · 1 line
2.30.2
Re: [PATCH RFC net-next 2/4] net: dsa: ocelot: remove interface checks
In reply to Russell King (Oracle)Quoted 5 lines · Russell King (Oracle)
When the supported interfaces bitmap is populated, phylink will itself check that the interface mode is present in this bitmap. Drivers no longer need to perform this check themselves. Remove these checks.
Signed-off-by Russell King (Oracle) <[email protected]>
Sorry, just realised I should've deleted "ocelot_port" here as well, for some reason my build testing didn't find that. Please assume that I've deleted it (I've updated the patch locally.) Thanks.
Quoted 43 lines
--- drivers/net/dsa/ocelot/felix_vsc9959.c | 6 ------ drivers/net/dsa/ocelot/seville_vsc9953.c | 6 ------ 2 files changed, 12 deletions(-)drivers/net/dsa/ocelot/felix_vsc9959.c +0
-6@@ -956,12 +956,6 @@ static void vsc9959_phylink_validate(struct ocelot *ocelot, int port,struct ocelot_port *ocelot_port = ocelot->ports[port];__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; -if (state->interface !=PHY_INTERFACE_MODE_NA && - state->interface != ocelot_port->phy_mode) { -linkmode_zero (supported); -return ; - } -phylink_set_port_modes (mask);phylink_set (mask, Autoneg);phylink_set (mask, Pause);drivers/net/dsa/ocelot/seville_vsc9953.c +0
-6@@ -929,12 +929,6 @@ static void vsc9953_phylink_validate(struct ocelot *ocelot, int port,struct ocelot_port *ocelot_port = ocelot->ports[port];__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; -if (state->interface !=PHY_INTERFACE_MODE_NA && - state->interface != ocelot_port->phy_mode) { -linkmode_zero (supported); -return ; - } -phylink_set_port_modes (mask);phylink_set (mask, Autoneg);phylink_set (mask, Pause);Signature · 1 line
2.30.2
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Vladimir Oltean
maintainerRe: [PATCH RFC net-next 1/4] net: dsa: ocelot: populate supported_interfaces
In reply to Russell King (Oracle)Quoted 21 lines · Russell King (Oracle)
Populate the supported interfaces bitmap for the Ocelot DSA switches.
The
felix_vsc9959andseville_vsc9953sub-drivers only supports a single interface mode, defined byocelot_port->phy_mode, so we indicate only this interface mode to phylink.Signed-off-by Russell King (Oracle) <[email protected]>--- drivers/net/dsa/ocelot/felix.c | 11 +++++++++++ drivers/net/dsa/ocelot/felix.h | 2 ++ drivers/net/dsa/ocelot/felix_vsc9959.c | 10 ++++++++++ drivers/net/dsa/ocelot/seville_vsc9953.c | 10 ++++++++++ 4 files changed, 33 insertions(+)drivers/net/dsa/ocelot/felix.c +0
-0@@ -778,6 +778,16 @@ static int felix_vlan_del(struct dsa_switch *ds, int port,return ocelot_vlan_del (ocelot, port, vlan->vid); }
drivers/net/dsa/ocelot/felix.c static int felix_vlan_del(struct dsa_switch *ds, int port, · line 789
Quoted 10 lines
drivers/net/dsa/ocelot/felix.c +9
-0+static void felix_phylink_get_caps (struct dsa_switch *ds,int port, +struct phylink_config *config) +{ +struct ocelot *ocelot = ds->priv; +struct felix *felix =ocelot_to_felix (ocelot); + +if (felix->info->phylink_get_caps) + felix->info->phylink_get_caps (ocelot, port, config); +}
Up until the end the implementations for vsc9953 and vsc9959 remain identical, so please remove felix->info->phylink_get_caps and keep a common implementation for both.
Quoted 84 lines
drivers/net/dsa/ocelot/felix.c +2
-0+static void felix_phylink_validate (struct dsa_switch *ds,int port,unsigned long *supported,struct phylink_link_state *state)@@ -1587,6 +1597,7 @@ const struct dsa_switch_ops felix_switch_ops = { .get_ethtool_stats = felix_get_ethtool_stats, .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_config = felix_phylink_mac_config, .phylink_mac_link_down = felix_phylink_mac_link_down,drivers/net/dsa/ocelot/felix.h +2
-0@@ -41,6 +41,8 @@ struct felix_info {int (*mdio_bus_alloc)(struct ocelot *ocelot);void (*mdio_bus_free)(struct ocelot *ocelot); +void (*phylink_get_caps)(struct ocelot *ocelot,int port, +struct phylink_config *config);void (*phylink_validate)(struct ocelot *ocelot,int port,unsigned long *supported,struct phylink_link_state *state);drivers/net/dsa/ocelot/felix_vsc9959.c +10
-0@@ -940,6 +940,15 @@ static int vsc9959_reset(struct ocelot *ocelot)return 0 ; } +static void vsc9959_phylink_get_caps (struct ocelot *ocelot,int port, +struct phylink_config *config) +{ +struct ocelot_port *ocelot_port = ocelot->ports[port]; + +__set_bit (ocelot_port->phy_mode, + config->supported_interfaces); +} +static void vsc9959_phylink_validate (struct ocelot *ocelot,int port,unsigned long *supported,struct phylink_link_state *state)@@ -2237,6 +2246,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_get_caps = vsc9959_phylink_get_caps, .phylink_validate = vsc9959_phylink_validate, .prevalidate_phy_mode = vsc9959_prevalidate_phy_mode, .port_setup_tc = vsc9959_port_setup_tc,drivers/net/dsa/ocelot/seville_vsc9953.c +10
-0@@ -913,6 +913,15 @@ static int vsc9953_reset(struct ocelot *ocelot)return 0 ; } +static void vsc9953_phylink_get_caps (struct ocelot *ocelot,int port, +struct phylink_config *config) +{ +struct ocelot_port *ocelot_port = ocelot->ports[port]; + +__set_bit (ocelot_port->phy_mode, + config->supported_interfaces); +} +static void vsc9953_phylink_validate (struct ocelot *ocelot,int port,unsigned long *supported,struct phylink_link_state *state)@@ -1105,6 +1114,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_get_caps = vsc9953_phylink_get_caps, .phylink_validate = vsc9953_phylink_validate, .prevalidate_phy_mode = vsc9953_prevalidate_phy_mode, .init_regmap = ocelot_regmap_init,Signature · 1 line
2.30.2
Re: [PATCH RFC net-next 2/4] net: dsa: ocelot: remove interface checks
In reply to Russell King (Oracle)Quoted 6 lines · Russell King (Oracle)
When the supported interfaces bitmap is populated, phylink will itself check that the interface mode is present in this bitmap. Drivers no longer need to perform this check themselves. Remove these checks.
Signed-off-by Russell King (Oracle) <[email protected]>---
Quoted 41 lines
drivers/net/dsa/ocelot/felix_vsc9959.c | 6 ------ drivers/net/dsa/ocelot/seville_vsc9953.c | 6 ------ 2 files changed, 12 deletions(-)drivers/net/dsa/ocelot/felix_vsc9959.c +0
-6@@ -956,12 +956,6 @@ static void vsc9959_phylink_validate(struct ocelot *ocelot, int port,struct ocelot_port *ocelot_port = ocelot->ports[port];__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; -if (state->interface !=PHY_INTERFACE_MODE_NA && - state->interface != ocelot_port->phy_mode) { -linkmode_zero (supported); -return ; - } -phylink_set_port_modes (mask);phylink_set (mask, Autoneg);phylink_set (mask, Pause);drivers/net/dsa/ocelot/seville_vsc9953.c +0
-6@@ -929,12 +929,6 @@ static void vsc9953_phylink_validate(struct ocelot *ocelot, int port,struct ocelot_port *ocelot_port = ocelot->ports[port];__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; -if (state->interface !=PHY_INTERFACE_MODE_NA && - state->interface != ocelot_port->phy_mode) { -linkmode_zero (supported); -return ; - } -phylink_set_port_modes (mask);phylink_set (mask, Autoneg);phylink_set (mask, Pause);Signature · 1 line
2.30.2
Re: [PATCH RFC net-next 3/4] net: dsa: ocelot: convert to mac_select_pcs()
In reply to Russell King (Oracle)Quoted 7 lines · Russell King (Oracle)
Convert the PCS selection to use
mac_select_pcs, which allows the PCS to perform any validation it needs, and removes the need to set the PCS in themac_config()callback, delving into the higher DSA levels to do so.Signed-off-by Russell King (Oracle) <[email protected]>---
Re: [PATCH RFC net-next 4/4] net: dsa: ocelot: mark as non-legacy
In reply to Russell King (Oracle)Quoted 6 lines · Russell King (Oracle)
The ocelot DSA driver does not make use of the speed, duplex, pause or advertisement in its
phylink_mac_config()implementation, so it can be marked as a non-legacy driver.Signed-off-by Russell King (Oracle) <[email protected]>---
Re: [PATCH RFC net-next 4/4] net: dsa: ocelot: mark as non-legacy
Quoted 10 lines · Vladimir Oltean
Quoted 6 lines · Russell King (Oracle)
The ocelot DSA driver does not make use of the speed, duplex, pause or advertisement in its
phylink_mac_config()implementation, so it can be marked as a non-legacy driver.Signed-off-by Russell King (Oracle) <[email protected]>---
Reviewed-by Vladimir Oltean <[email protected]>Tested-by Vladimir Oltean <[email protected]>
Hi Vladimir,
Shall I assume the tested-by applies to patch 2 and 3 as well?
Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Vladimir Oltean
maintainerRe: [PATCH RFC net-next 4/4] net: dsa: ocelot: mark as non-legacy
Quoted 9 lines · Russell King (Oracle)
Quoted 8 lines · Vladimir Oltean
Quoted 6 lines · Russell King (Oracle)
The ocelot DSA driver does not make use of the speed, duplex, pause or advertisement in its
phylink_mac_config()implementation, so it can be marked as a non-legacy driver.Signed-off-by Russell King (Oracle) <[email protected]>---
Quoted 8 lines
Quoted 2 lines
Reviewed-by Vladimir Oltean <[email protected]>Tested-by Vladimir Oltean <[email protected]>Hi Vladimir,
Shall I assume the tested-by applies to patch 2 and 3 as well?
Thanks.
Yes.