All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/5] net: dsa: convert two drivers to phylink_generic_validate()
@ 2021-11-30 13:09 Russell King (Oracle)
  2021-11-30 13:09 ` [PATCH net-next 1/5] net: dsa: consolidate phylink creation Russell King (Oracle)
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Russell King (Oracle) @ 2021-11-30 13:09 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, David S. Miller, Florian Fainelli, Hauke Mehrtens,
	Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot, Vladimir Oltean

Hi,

The following series comes from the RFC series posted last Thursday
adding support for phylink_generic_validate() to DSA.

Patches 1 to 3 update core DSA code to allow drivers to be converted,
and patches 4 and 5 convert hellcreek and lantiq to use this (both of
which received reviewed-by from their maintainers.) As the rest have
yet to be reviewed by their maintainers, they are not included here.

Patch 1 had a request to change the formatting of it; I have not done
so as I believe a patch should do one change and one change only -
reformatting it is a separate change that should be in its own patch.
However, as patch 2 gets rid of the reason for reformatting it, it
would be pointless, and pure noise to include such an intermediary
patch.

Instead, I have swapped the order of patches 2 and 3 from the RFC
series.

 drivers/net/dsa/hirschmann/hellcreek.c |  24 ++++---
 drivers/net/dsa/lantiq_gswip.c         | 120 +++++++++++----------------------
 include/net/dsa.h                      |   4 +-
 net/dsa/dsa_priv.h                     |   2 +-
 net/dsa/port.c                         |  48 ++++++++-----
 net/dsa/slave.c                        |  19 +-----
 6 files changed, 88 insertions(+), 129 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH net-next 1/5] net: dsa: consolidate phylink creation
  2021-11-30 13:09 [PATCH net-next 0/5] net: dsa: convert two drivers to phylink_generic_validate() Russell King (Oracle)
@ 2021-11-30 13:09 ` Russell King (Oracle)
  2021-11-30 15:41   ` Marek Behún
  2021-11-30 15:43   ` Andrew Lunn
  2021-11-30 13:10 ` [PATCH net-next 2/5] net: dsa: replace phylink_get_interfaces() with phylink_get_caps() Russell King (Oracle)
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 13+ messages in thread
From: Russell King (Oracle) @ 2021-11-30 13:09 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, David S. Miller, Florian Fainelli, Hauke Mehrtens,
	Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot, Vladimir Oltean

The code in port.c and slave.c creating the phylink instance is very
similar - let's consolidate this into a single function.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 net/dsa/dsa_priv.h |  2 +-
 net/dsa/port.c     | 44 ++++++++++++++++++++++++++++----------------
 net/dsa/slave.c    | 19 +++----------------
 3 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index a5c9bc7b66c6..3fb2c37c9b88 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -258,13 +258,13 @@ int dsa_port_mrp_add_ring_role(const struct dsa_port *dp,
 			       const struct switchdev_obj_ring_role_mrp *mrp);
 int dsa_port_mrp_del_ring_role(const struct dsa_port *dp,
 			       const struct switchdev_obj_ring_role_mrp *mrp);
+int dsa_port_phylink_create(struct dsa_port *dp);
 int dsa_port_link_register_of(struct dsa_port *dp);
 void dsa_port_link_unregister_of(struct dsa_port *dp);
 int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr);
 void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr);
 int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast);
 void dsa_port_tag_8021q_vlan_del(struct dsa_port *dp, u16 vid, bool broadcast);
-extern const struct phylink_mac_ops dsa_port_phylink_mac_ops;
 
 static inline bool dsa_port_offloads_bridge_port(struct dsa_port *dp,
 						 const struct net_device *dev)
diff --git a/net/dsa/port.c b/net/dsa/port.c
index f6f12ad2b525..eaa66114924b 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -1072,7 +1072,7 @@ static void dsa_port_phylink_mac_link_up(struct phylink_config *config,
 				     speed, duplex, tx_pause, rx_pause);
 }
 
-const struct phylink_mac_ops dsa_port_phylink_mac_ops = {
+static const struct phylink_mac_ops dsa_port_phylink_mac_ops = {
 	.validate = dsa_port_phylink_validate,
 	.mac_pcs_get_state = dsa_port_phylink_mac_pcs_get_state,
 	.mac_config = dsa_port_phylink_mac_config,
@@ -1081,6 +1081,30 @@ const struct phylink_mac_ops dsa_port_phylink_mac_ops = {
 	.mac_link_up = dsa_port_phylink_mac_link_up,
 };
 
+int dsa_port_phylink_create(struct dsa_port *dp)
+{
+	struct dsa_switch *ds = dp->ds;
+	phy_interface_t mode;
+	int err;
+
+	err = of_get_phy_mode(dp->dn, &mode);
+	if (err)
+		mode = PHY_INTERFACE_MODE_NA;
+
+	if (ds->ops->phylink_get_interfaces)
+		ds->ops->phylink_get_interfaces(ds, dp->index,
+					dp->pl_config.supported_interfaces);
+
+	dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn),
+				mode, &dsa_port_phylink_mac_ops);
+	if (IS_ERR(dp->pl)) {
+		pr_err("error creating PHYLINK: %ld\n", PTR_ERR(dp->pl));
+		return PTR_ERR(dp->pl);
+	}
+
+	return 0;
+}
+
 static int dsa_port_setup_phy_of(struct dsa_port *dp, bool enable)
 {
 	struct dsa_switch *ds = dp->ds;
@@ -1157,27 +1181,15 @@ static int dsa_port_phylink_register(struct dsa_port *dp)
 {
 	struct dsa_switch *ds = dp->ds;
 	struct device_node *port_dn = dp->dn;
-	phy_interface_t mode;
 	int err;
 
-	err = of_get_phy_mode(port_dn, &mode);
-	if (err)
-		mode = PHY_INTERFACE_MODE_NA;
-
 	dp->pl_config.dev = ds->dev;
 	dp->pl_config.type = PHYLINK_DEV;
 	dp->pl_config.pcs_poll = ds->pcs_poll;
 
-	if (ds->ops->phylink_get_interfaces)
-		ds->ops->phylink_get_interfaces(ds, dp->index,
-					dp->pl_config.supported_interfaces);
-
-	dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn),
-				mode, &dsa_port_phylink_mac_ops);
-	if (IS_ERR(dp->pl)) {
-		pr_err("error creating PHYLINK: %ld\n", PTR_ERR(dp->pl));
-		return PTR_ERR(dp->pl);
-	}
+	err = dsa_port_phylink_create(dp);
+	if (err)
+		return err;
 
 	err = phylink_of_phy_connect(dp->pl, port_dn, 0);
 	if (err && err != -ENODEV) {
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index ad61f6bc8886..33b54eadc641 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1851,14 +1851,9 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
 	struct dsa_port *dp = dsa_slave_to_port(slave_dev);
 	struct device_node *port_dn = dp->dn;
 	struct dsa_switch *ds = dp->ds;
-	phy_interface_t mode;
 	u32 phy_flags = 0;
 	int ret;
 
-	ret = of_get_phy_mode(port_dn, &mode);
-	if (ret)
-		mode = PHY_INTERFACE_MODE_NA;
-
 	dp->pl_config.dev = &slave_dev->dev;
 	dp->pl_config.type = PHYLINK_NETDEV;
 
@@ -1871,17 +1866,9 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
 		dp->pl_config.poll_fixed_state = true;
 	}
 
-	if (ds->ops->phylink_get_interfaces)
-		ds->ops->phylink_get_interfaces(ds, dp->index,
-					dp->pl_config.supported_interfaces);
-
-	dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn), mode,
-				&dsa_port_phylink_mac_ops);
-	if (IS_ERR(dp->pl)) {
-		netdev_err(slave_dev,
-			   "error creating PHYLINK: %ld\n", PTR_ERR(dp->pl));
-		return PTR_ERR(dp->pl);
-	}
+	ret = dsa_port_phylink_create(dp);
+	if (ret)
+		return ret;
 
 	if (ds->ops->get_phy_flags)
 		phy_flags = ds->ops->get_phy_flags(ds, dp->index);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 2/5] net: dsa: replace phylink_get_interfaces() with phylink_get_caps()
  2021-11-30 13:09 [PATCH net-next 0/5] net: dsa: convert two drivers to phylink_generic_validate() Russell King (Oracle)
  2021-11-30 13:09 ` [PATCH net-next 1/5] net: dsa: consolidate phylink creation Russell King (Oracle)
@ 2021-11-30 13:10 ` Russell King (Oracle)
  2021-11-30 15:42   ` Marek Behún
  2021-11-30 15:48   ` Andrew Lunn
  2021-11-30 13:10 ` [PATCH net-next 3/5] net: dsa: support use of phylink_generic_validate() Russell King (Oracle)
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 13+ messages in thread
From: Russell King (Oracle) @ 2021-11-30 13:10 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, David S. Miller, Florian Fainelli, Hauke Mehrtens,
	Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot, Vladimir Oltean

Phylink needs slightly more information than phylink_get_interfaces()
allows us to get from the DSA drivers - we need the MAC capabilities.
Replace the phylink_get_interfaces() method with phylink_get_caps() to
allow DSA drivers to fill in the phylink_config MAC capabilities field
as well.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 include/net/dsa.h | 4 ++--
 net/dsa/port.c    | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index eff5c44ba377..8ca9d50cbbc2 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -645,8 +645,8 @@ struct dsa_switch_ops {
 	/*
 	 * PHYLINK integration
 	 */
-	void	(*phylink_get_interfaces)(struct dsa_switch *ds, int port,
-					  unsigned long *supported_interfaces);
+	void	(*phylink_get_caps)(struct dsa_switch *ds, int port,
+				    struct phylink_config *config);
 	void	(*phylink_validate)(struct dsa_switch *ds, int port,
 				    unsigned long *supported,
 				    struct phylink_link_state *state);
diff --git a/net/dsa/port.c b/net/dsa/port.c
index eaa66114924b..ef0acf005f8f 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -1091,9 +1091,8 @@ int dsa_port_phylink_create(struct dsa_port *dp)
 	if (err)
 		mode = PHY_INTERFACE_MODE_NA;
 
-	if (ds->ops->phylink_get_interfaces)
-		ds->ops->phylink_get_interfaces(ds, dp->index,
-					dp->pl_config.supported_interfaces);
+	if (ds->ops->phylink_get_caps)
+		ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config);
 
 	dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn),
 				mode, &dsa_port_phylink_mac_ops);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 3/5] net: dsa: support use of phylink_generic_validate()
  2021-11-30 13:09 [PATCH net-next 0/5] net: dsa: convert two drivers to phylink_generic_validate() Russell King (Oracle)
  2021-11-30 13:09 ` [PATCH net-next 1/5] net: dsa: consolidate phylink creation Russell King (Oracle)
  2021-11-30 13:10 ` [PATCH net-next 2/5] net: dsa: replace phylink_get_interfaces() with phylink_get_caps() Russell King (Oracle)
@ 2021-11-30 13:10 ` Russell King (Oracle)
  2021-11-30 15:43   ` Marek Behún
  2021-11-30 15:49   ` Andrew Lunn
  2021-11-30 13:10 ` [PATCH net-next 4/5] net: dsa: hellcreek: convert to phylink_generic_validate() Russell King (Oracle)
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 13+ messages in thread
From: Russell King (Oracle) @ 2021-11-30 13:10 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, David S. Miller, Florian Fainelli, Hauke Mehrtens,
	Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot, Vladimir Oltean

Support the use of phylink_generic_validate() when there is no
phylink_validate method given in the DSA switch operations and
mac_capabilities have been set in the phylink_config structure by the
DSA switch driver.

This gives DSA switch drivers the option to use this if they provide
the supported_interfaces and mac_capabilities, while still giving them
an option to override the default implementation if necessary.

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 net/dsa/port.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/dsa/port.c b/net/dsa/port.c
index ef0acf005f8f..6d5ebe61280b 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -981,8 +981,11 @@ static void dsa_port_phylink_validate(struct phylink_config *config,
 	struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
 	struct dsa_switch *ds = dp->ds;
 
-	if (!ds->ops->phylink_validate)
+	if (!ds->ops->phylink_validate) {
+		if (config->mac_capabilities)
+			phylink_generic_validate(config, supported, state);
 		return;
+	}
 
 	ds->ops->phylink_validate(ds, dp->index, supported, state);
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 4/5] net: dsa: hellcreek: convert to phylink_generic_validate()
  2021-11-30 13:09 [PATCH net-next 0/5] net: dsa: convert two drivers to phylink_generic_validate() Russell King (Oracle)
                   ` (2 preceding siblings ...)
  2021-11-30 13:10 ` [PATCH net-next 3/5] net: dsa: support use of phylink_generic_validate() Russell King (Oracle)
@ 2021-11-30 13:10 ` Russell King (Oracle)
  2021-11-30 13:10 ` [PATCH net-next 5/5] net: dsa: lantiq: " Russell King (Oracle)
  2021-12-02  3:20 ` [PATCH net-next 0/5] net: dsa: convert two drivers " patchwork-bot+netdevbpf
  5 siblings, 0 replies; 13+ messages in thread
From: Russell King (Oracle) @ 2021-11-30 13:10 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, David S. Miller, Florian Fainelli, Hauke Mehrtens,
	Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot, Vladimir Oltean

Populate the supported interfaces and MAC capabilities for the
hellcreek DSA switch and remove the old validate implementation to
allow DSA to use phylink_generic_validate() for this switch driver.

The switch actually only supports MII and RGMII, but as phylib defaults
to GMII, we need to include this interface mode to keep existing DT
working.

Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
Tested-by: Kurt Kanzenbach <kurt@linutronix.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/dsa/hirschmann/hellcreek.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c
index 4e0b53d94b52..86839b43011b 100644
--- a/drivers/net/dsa/hirschmann/hellcreek.c
+++ b/drivers/net/dsa/hirschmann/hellcreek.c
@@ -1384,14 +1384,19 @@ static void hellcreek_teardown(struct dsa_switch *ds)
 	dsa_devlink_resources_unregister(ds);
 }
 
-static void hellcreek_phylink_validate(struct dsa_switch *ds, int port,
-				       unsigned long *supported,
-				       struct phylink_link_state *state)
+static void hellcreek_phylink_get_caps(struct dsa_switch *ds, int port,
+				       struct phylink_config *config)
 {
-	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
 	struct hellcreek *hellcreek = ds->priv;
 
-	dev_dbg(hellcreek->dev, "Phylink validate for port %d\n", port);
+	__set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces);
+	__set_bit(PHY_INTERFACE_MODE_RGMII, config->supported_interfaces);
+
+	/* Include GMII - the hardware does not support this interface
+	 * mode, but it's the default interface mode for phylib, so we
+	 * need it for compatibility with existing DT.
+	 */
+	__set_bit(PHY_INTERFACE_MODE_GMII, config->supported_interfaces);
 
 	/* The MAC settings are a hardware configuration option and cannot be
 	 * changed at run time or by strapping. Therefore the attached PHYs
@@ -1399,12 +1404,9 @@ static void hellcreek_phylink_validate(struct dsa_switch *ds, int port,
 	 * by the hardware.
 	 */
 	if (hellcreek->pdata->is_100_mbits)
-		phylink_set(mask, 100baseT_Full);
+		config->mac_capabilities = MAC_100FD;
 	else
-		phylink_set(mask, 1000baseT_Full);
-
-	linkmode_and(supported, supported, mask);
-	linkmode_and(state->advertising, state->advertising, mask);
+		config->mac_capabilities = MAC_1000FD;
 }
 
 static int
@@ -1755,7 +1757,7 @@ static const struct dsa_switch_ops hellcreek_ds_ops = {
 	.get_strings	       = hellcreek_get_strings,
 	.get_tag_protocol      = hellcreek_get_tag_protocol,
 	.get_ts_info	       = hellcreek_get_ts_info,
-	.phylink_validate      = hellcreek_phylink_validate,
+	.phylink_get_caps      = hellcreek_phylink_get_caps,
 	.port_bridge_flags     = hellcreek_bridge_flags,
 	.port_bridge_join      = hellcreek_port_bridge_join,
 	.port_bridge_leave     = hellcreek_port_bridge_leave,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 5/5] net: dsa: lantiq: convert to phylink_generic_validate()
  2021-11-30 13:09 [PATCH net-next 0/5] net: dsa: convert two drivers to phylink_generic_validate() Russell King (Oracle)
                   ` (3 preceding siblings ...)
  2021-11-30 13:10 ` [PATCH net-next 4/5] net: dsa: hellcreek: convert to phylink_generic_validate() Russell King (Oracle)
@ 2021-11-30 13:10 ` Russell King (Oracle)
  2021-12-02  3:20 ` [PATCH net-next 0/5] net: dsa: convert two drivers " patchwork-bot+netdevbpf
  5 siblings, 0 replies; 13+ messages in thread
From: Russell King (Oracle) @ 2021-11-30 13:10 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, David S. Miller, Florian Fainelli, Hauke Mehrtens,
	Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot, Vladimir Oltean

Populate the supported interfaces and MAC capabilities for the Lantiq
DSA switches and remove the old validate implementation to allow DSA to
use phylink_generic_validate() for this switch driver.

The exclusion of Gigabit linkmodes for MII, Reverse MII and Reduced MII
links is handled within phylink_generic_validate() in phylink, so there
is no need to make them conditional on the interface mode in the driver.

Reviewed-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/dsa/lantiq_gswip.c | 120 +++++++++++----------------------
 1 file changed, 38 insertions(+), 82 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 7056d98d8177..583af774e1bd 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -1438,114 +1438,70 @@ static int gswip_port_fdb_dump(struct dsa_switch *ds, int port,
 	return 0;
 }
 
-static void gswip_phylink_set_capab(unsigned long *supported,
-				    struct phylink_link_state *state)
-{
-	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
-
-	/* Allow all the expected bits */
-	phylink_set(mask, Autoneg);
-	phylink_set_port_modes(mask);
-	phylink_set(mask, Pause);
-	phylink_set(mask, Asym_Pause);
-
-	/* With the exclusion of MII, Reverse MII and Reduced MII, we
-	 * support Gigabit, including Half duplex
-	 */
-	if (state->interface != PHY_INTERFACE_MODE_MII &&
-	    state->interface != PHY_INTERFACE_MODE_REVMII &&
-	    state->interface != PHY_INTERFACE_MODE_RMII) {
-		phylink_set(mask, 1000baseT_Full);
-		phylink_set(mask, 1000baseT_Half);
-	}
-
-	phylink_set(mask, 10baseT_Half);
-	phylink_set(mask, 10baseT_Full);
-	phylink_set(mask, 100baseT_Half);
-	phylink_set(mask, 100baseT_Full);
-
-	linkmode_and(supported, supported, mask);
-	linkmode_and(state->advertising, state->advertising, mask);
-}
-
-static void gswip_xrx200_phylink_validate(struct dsa_switch *ds, int port,
-					  unsigned long *supported,
-					  struct phylink_link_state *state)
+static void gswip_xrx200_phylink_get_caps(struct dsa_switch *ds, int port,
+					  struct phylink_config *config)
 {
 	switch (port) {
 	case 0:
 	case 1:
-		if (!phy_interface_mode_is_rgmii(state->interface) &&
-		    state->interface != PHY_INTERFACE_MODE_MII &&
-		    state->interface != PHY_INTERFACE_MODE_REVMII &&
-		    state->interface != PHY_INTERFACE_MODE_RMII)
-			goto unsupported;
+		phy_interface_set_rgmii(config->supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_MII,
+			  config->supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_REVMII,
+			  config->supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_RMII,
+			  config->supported_interfaces);
 		break;
+
 	case 2:
 	case 3:
 	case 4:
-		if (state->interface != PHY_INTERFACE_MODE_INTERNAL)
-			goto unsupported;
+		__set_bit(PHY_INTERFACE_MODE_INTERNAL,
+			  config->supported_interfaces);
 		break;
+
 	case 5:
-		if (!phy_interface_mode_is_rgmii(state->interface) &&
-		    state->interface != PHY_INTERFACE_MODE_INTERNAL)
-			goto unsupported;
+		phy_interface_set_rgmii(config->supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_INTERNAL,
+			  config->supported_interfaces);
 		break;
-	default:
-		linkmode_zero(supported);
-		dev_err(ds->dev, "Unsupported port: %i\n", port);
-		return;
 	}
 
-	gswip_phylink_set_capab(supported, state);
-
-	return;
-
-unsupported:
-	linkmode_zero(supported);
-	dev_err(ds->dev, "Unsupported interface '%s' for port %d\n",
-		phy_modes(state->interface), port);
+	config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+		MAC_10 | MAC_100 | MAC_1000;
 }
 
-static void gswip_xrx300_phylink_validate(struct dsa_switch *ds, int port,
-					  unsigned long *supported,
-					  struct phylink_link_state *state)
+static void gswip_xrx300_phylink_get_caps(struct dsa_switch *ds, int port,
+					  struct phylink_config *config)
 {
 	switch (port) {
 	case 0:
-		if (!phy_interface_mode_is_rgmii(state->interface) &&
-		    state->interface != PHY_INTERFACE_MODE_GMII &&
-		    state->interface != PHY_INTERFACE_MODE_RMII)
-			goto unsupported;
+		phy_interface_set_rgmii(config->supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_GMII,
+			  config->supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_RMII,
+			  config->supported_interfaces);
 		break;
+
 	case 1:
 	case 2:
 	case 3:
 	case 4:
-		if (state->interface != PHY_INTERFACE_MODE_INTERNAL)
-			goto unsupported;
+		__set_bit(PHY_INTERFACE_MODE_INTERNAL,
+			  config->supported_interfaces);
 		break;
+
 	case 5:
-		if (!phy_interface_mode_is_rgmii(state->interface) &&
-		    state->interface != PHY_INTERFACE_MODE_INTERNAL &&
-		    state->interface != PHY_INTERFACE_MODE_RMII)
-			goto unsupported;
+		phy_interface_set_rgmii(config->supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_INTERNAL,
+			  config->supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_RMII,
+			  config->supported_interfaces);
 		break;
-	default:
-		linkmode_zero(supported);
-		dev_err(ds->dev, "Unsupported port: %i\n", port);
-		return;
 	}
 
-	gswip_phylink_set_capab(supported, state);
-
-	return;
-
-unsupported:
-	linkmode_zero(supported);
-	dev_err(ds->dev, "Unsupported interface '%s' for port %d\n",
-		phy_modes(state->interface), port);
+	config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+		MAC_10 | MAC_100 | MAC_1000;
 }
 
 static void gswip_port_set_link(struct gswip_priv *priv, int port, bool link)
@@ -1827,7 +1783,7 @@ static const struct dsa_switch_ops gswip_xrx200_switch_ops = {
 	.port_fdb_add		= gswip_port_fdb_add,
 	.port_fdb_del		= gswip_port_fdb_del,
 	.port_fdb_dump		= gswip_port_fdb_dump,
-	.phylink_validate	= gswip_xrx200_phylink_validate,
+	.phylink_get_caps	= gswip_xrx200_phylink_get_caps,
 	.phylink_mac_config	= gswip_phylink_mac_config,
 	.phylink_mac_link_down	= gswip_phylink_mac_link_down,
 	.phylink_mac_link_up	= gswip_phylink_mac_link_up,
@@ -1851,7 +1807,7 @@ static const struct dsa_switch_ops gswip_xrx300_switch_ops = {
 	.port_fdb_add		= gswip_port_fdb_add,
 	.port_fdb_del		= gswip_port_fdb_del,
 	.port_fdb_dump		= gswip_port_fdb_dump,
-	.phylink_validate	= gswip_xrx300_phylink_validate,
+	.phylink_get_caps	= gswip_xrx300_phylink_get_caps,
 	.phylink_mac_config	= gswip_phylink_mac_config,
 	.phylink_mac_link_down	= gswip_phylink_mac_link_down,
 	.phylink_mac_link_up	= gswip_phylink_mac_link_up,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 1/5] net: dsa: consolidate phylink creation
  2021-11-30 13:09 ` [PATCH net-next 1/5] net: dsa: consolidate phylink creation Russell King (Oracle)
@ 2021-11-30 15:41   ` Marek Behún
  2021-11-30 15:43   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Marek Behún @ 2021-11-30 15:41 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: netdev, Andrew Lunn, David S. Miller, Florian Fainelli,
	Hauke Mehrtens, Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot,
	Vladimir Oltean

On Tue, 30 Nov 2021 13:09:55 +0000
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> wrote:

> The code in port.c and slave.c creating the phylink instance is very
> similar - let's consolidate this into a single function.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---

Reviewed-by: Marek Behún <kabel@kernel.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 2/5] net: dsa: replace phylink_get_interfaces() with phylink_get_caps()
  2021-11-30 13:10 ` [PATCH net-next 2/5] net: dsa: replace phylink_get_interfaces() with phylink_get_caps() Russell King (Oracle)
@ 2021-11-30 15:42   ` Marek Behún
  2021-11-30 15:48   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Marek Behún @ 2021-11-30 15:42 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: netdev, Andrew Lunn, David S. Miller, Florian Fainelli,
	Hauke Mehrtens, Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot,
	Vladimir Oltean

On Tue, 30 Nov 2021 13:10:01 +0000
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> wrote:

> Phylink needs slightly more information than phylink_get_interfaces()
> allows us to get from the DSA drivers - we need the MAC capabilities.
> Replace the phylink_get_interfaces() method with phylink_get_caps() to
> allow DSA drivers to fill in the phylink_config MAC capabilities field
> as well.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Marek Behún <kabel@kernel.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 1/5] net: dsa: consolidate phylink creation
  2021-11-30 13:09 ` [PATCH net-next 1/5] net: dsa: consolidate phylink creation Russell King (Oracle)
  2021-11-30 15:41   ` Marek Behún
@ 2021-11-30 15:43   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2021-11-30 15:43 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: netdev, David S. Miller, Florian Fainelli, Hauke Mehrtens,
	Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot, Vladimir Oltean

On Tue, Nov 30, 2021 at 01:09:55PM +0000, Russell King (Oracle) wrote:
> The code in port.c and slave.c creating the phylink instance is very
> similar - let's consolidate this into a single function.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 3/5] net: dsa: support use of phylink_generic_validate()
  2021-11-30 13:10 ` [PATCH net-next 3/5] net: dsa: support use of phylink_generic_validate() Russell King (Oracle)
@ 2021-11-30 15:43   ` Marek Behún
  2021-11-30 15:49   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Marek Behún @ 2021-11-30 15:43 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: netdev, Andrew Lunn, David S. Miller, Florian Fainelli,
	Hauke Mehrtens, Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot,
	Vladimir Oltean

On Tue, 30 Nov 2021 13:10:06 +0000
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> wrote:

> Support the use of phylink_generic_validate() when there is no
> phylink_validate method given in the DSA switch operations and
> mac_capabilities have been set in the phylink_config structure by the
> DSA switch driver.
> 
> This gives DSA switch drivers the option to use this if they provide
> the supported_interfaces and mac_capabilities, while still giving them
> an option to override the default implementation if necessary.
> 
> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Marek Behún <kabel@kernel.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 2/5] net: dsa: replace phylink_get_interfaces() with phylink_get_caps()
  2021-11-30 13:10 ` [PATCH net-next 2/5] net: dsa: replace phylink_get_interfaces() with phylink_get_caps() Russell King (Oracle)
  2021-11-30 15:42   ` Marek Behún
@ 2021-11-30 15:48   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2021-11-30 15:48 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: netdev, David S. Miller, Florian Fainelli, Hauke Mehrtens,
	Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot, Vladimir Oltean

On Tue, Nov 30, 2021 at 01:10:01PM +0000, Russell King (Oracle) wrote:
> Phylink needs slightly more information than phylink_get_interfaces()
> allows us to get from the DSA drivers - we need the MAC capabilities.
> Replace the phylink_get_interfaces() method with phylink_get_caps() to
> allow DSA drivers to fill in the phylink_config MAC capabilities field
> as well.

It would of been nice to say that phylink_get_interfaces() is
currently unused, and so this change does not break anything. I think
that was a discussion with the RFC?

But the code itself looks good.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 3/5] net: dsa: support use of phylink_generic_validate()
  2021-11-30 13:10 ` [PATCH net-next 3/5] net: dsa: support use of phylink_generic_validate() Russell King (Oracle)
  2021-11-30 15:43   ` Marek Behún
@ 2021-11-30 15:49   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2021-11-30 15:49 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: netdev, David S. Miller, Florian Fainelli, Hauke Mehrtens,
	Jakub Kicinski, Kurt Kanzenbach, Vivien Didelot, Vladimir Oltean

On Tue, Nov 30, 2021 at 01:10:06PM +0000, Russell King (Oracle) wrote:
> Support the use of phylink_generic_validate() when there is no
> phylink_validate method given in the DSA switch operations and
> mac_capabilities have been set in the phylink_config structure by the
> DSA switch driver.
> 
> This gives DSA switch drivers the option to use this if they provide
> the supported_interfaces and mac_capabilities, while still giving them
> an option to override the default implementation if necessary.
> 
> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 0/5] net: dsa: convert two drivers to phylink_generic_validate()
  2021-11-30 13:09 [PATCH net-next 0/5] net: dsa: convert two drivers to phylink_generic_validate() Russell King (Oracle)
                   ` (4 preceding siblings ...)
  2021-11-30 13:10 ` [PATCH net-next 5/5] net: dsa: lantiq: " Russell King (Oracle)
@ 2021-12-02  3:20 ` patchwork-bot+netdevbpf
  5 siblings, 0 replies; 13+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-02  3:20 UTC (permalink / raw)
  To: Russell King
  Cc: netdev, andrew, davem, f.fainelli, hauke, kuba, kurt,
	vivien.didelot, olteanv

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 30 Nov 2021 13:09:29 +0000 you wrote:
> Hi,
> 
> The following series comes from the RFC series posted last Thursday
> adding support for phylink_generic_validate() to DSA.
> 
> Patches 1 to 3 update core DSA code to allow drivers to be converted,
> and patches 4 and 5 convert hellcreek and lantiq to use this (both of
> which received reviewed-by from their maintainers.) As the rest have
> yet to be reviewed by their maintainers, they are not included here.
> 
> [...]

Here is the summary with links:
  - [net-next,1/5] net: dsa: consolidate phylink creation
    https://git.kernel.org/netdev/net-next/c/21bd64bd717d
  - [net-next,2/5] net: dsa: replace phylink_get_interfaces() with phylink_get_caps()
    https://git.kernel.org/netdev/net-next/c/072eea6c22b2
  - [net-next,3/5] net: dsa: support use of phylink_generic_validate()
    https://git.kernel.org/netdev/net-next/c/5938bce4b6e2
  - [net-next,4/5] net: dsa: hellcreek: convert to phylink_generic_validate()
    https://git.kernel.org/netdev/net-next/c/1c9e7fd2a579
  - [net-next,5/5] net: dsa: lantiq: convert to phylink_generic_validate()
    https://git.kernel.org/netdev/net-next/c/a2279b08c7f4

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-12-02  3:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 13:09 [PATCH net-next 0/5] net: dsa: convert two drivers to phylink_generic_validate() Russell King (Oracle)
2021-11-30 13:09 ` [PATCH net-next 1/5] net: dsa: consolidate phylink creation Russell King (Oracle)
2021-11-30 15:41   ` Marek Behún
2021-11-30 15:43   ` Andrew Lunn
2021-11-30 13:10 ` [PATCH net-next 2/5] net: dsa: replace phylink_get_interfaces() with phylink_get_caps() Russell King (Oracle)
2021-11-30 15:42   ` Marek Behún
2021-11-30 15:48   ` Andrew Lunn
2021-11-30 13:10 ` [PATCH net-next 3/5] net: dsa: support use of phylink_generic_validate() Russell King (Oracle)
2021-11-30 15:43   ` Marek Behún
2021-11-30 15:49   ` Andrew Lunn
2021-11-30 13:10 ` [PATCH net-next 4/5] net: dsa: hellcreek: convert to phylink_generic_validate() Russell King (Oracle)
2021-11-30 13:10 ` [PATCH net-next 5/5] net: dsa: lantiq: " Russell King (Oracle)
2021-12-02  3:20 ` [PATCH net-next 0/5] net: dsa: convert two drivers " patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.