diff mbox series

[RFC,net-next,1/4] net: dsa: ocelot: populate supported_interfaces

Message ID E1nNbgi-00Akie-In@rmk-PC.armlinux.org.uk (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: ocelot: phylink updates | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: linux@armlinux.org.uk
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 75 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Russell King (Oracle) Feb. 25, 2022, 2:35 p.m. UTC
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.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 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(+)

Comments

Vladimir Oltean Feb. 25, 2022, 3:25 p.m. UTC | #1
On Fri, Feb 25, 2022 at 02:35:16PM +0000, Russell King (Oracle) wrote:
> 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.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  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(+)
> 
> diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
> index 9959407fede8..9e05b18940c1 100644
> --- a/drivers/net/dsa/ocelot/felix.c
> +++ b/drivers/net/dsa/ocelot/felix.c
> @@ -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);
> +}

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.

> +
>  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,
> diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h
> index 9395ac119d33..b195e3f4df7f 100644
> --- a/drivers/net/dsa/ocelot/felix.h
> +++ b/drivers/net/dsa/ocelot/felix.h
> @@ -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);
> diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
> index 33f0ceae381d..a1be0e91dde6 100644
> --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
> +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
> @@ -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,
> diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c
> index f2f1608a476c..2db51494b1a9 100644
> --- a/drivers/net/dsa/ocelot/seville_vsc9953.c
> +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c
> @@ -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,
> -- 
> 2.30.2
>
diff mbox series

Patch

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 9959407fede8..9e05b18940c1 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -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,
diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h
index 9395ac119d33..b195e3f4df7f 100644
--- a/drivers/net/dsa/ocelot/felix.h
+++ b/drivers/net/dsa/ocelot/felix.h
@@ -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);
diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index 33f0ceae381d..a1be0e91dde6 100644
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -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,
diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c
index f2f1608a476c..2db51494b1a9 100644
--- a/drivers/net/dsa/ocelot/seville_vsc9953.c
+++ b/drivers/net/dsa/ocelot/seville_vsc9953.c
@@ -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,