netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH net-next 0/3] net: dpaa2: phylink validate implementation updates
@ 2021-11-17 17:02 Russell King (Oracle)
  2021-11-17 17:24 ` [PATCH net-next 1/3] net: dpaa2-mac: populate supported_interfaces member Russell King
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2021-11-17 17:02 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: David S. Miller, Jakub Kicinski, netdev

Hi,

This series converts dpaa2 to fill in the supported_interfaces member
of phylink_config, cleans up the validate() implementation, and then
converts to phylink_generic_validate(). Previous behaviour should be
preserved.

 drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 109 ++++++-----------------
 1 file changed, 26 insertions(+), 83 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] 5+ messages in thread

* [PATCH net-next 1/3] net: dpaa2-mac: populate supported_interfaces member
  2021-11-17 17:02 [PATCH net-next 0/3] net: dpaa2: phylink validate implementation updates Russell King (Oracle)
@ 2021-11-17 17:24 ` Russell King
  2021-11-18 11:40   ` patchwork-bot+netdevbpf
  2021-11-17 17:24 ` [PATCH net-next 2/3] net: dpaa2-mac: remove interface checks in dpaa2_mac_validate() Russell King (Oracle)
  2021-11-17 17:24 ` [PATCH net-next 3/3] net: dpaa2-mac: use phylink_generic_validate() Russell King (Oracle)
  2 siblings, 1 reply; 5+ messages in thread
From: Russell King @ 2021-11-17 17:24 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: David S. Miller, Jakub Kicinski, netdev

Populate the phy interface mode bitmap for the Freescale DPAA2 driver
with interfaces modes supported by the MAC.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index ef8f0a055024..176ce0a03716 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -336,9 +336,30 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 			return err;
 	}
 
+	memset(&mac->phylink_config, 0, sizeof(mac->phylink_config));
 	mac->phylink_config.dev = &net_dev->dev;
 	mac->phylink_config.type = PHYLINK_NETDEV;
 
+	/* We support the current interface mode, and if we have a PCS
+	 * similar interface modes that do not require the PLLs to be
+	 * reconfigured.
+	 */
+	__set_bit(mac->if_mode, mac->phylink_config.supported_interfaces);
+	if (mac->pcs) {
+		switch (mac->if_mode) {
+		case PHY_INTERFACE_MODE_1000BASEX:
+		case PHY_INTERFACE_MODE_SGMII:
+			__set_bit(PHY_INTERFACE_MODE_1000BASEX,
+				  mac->phylink_config.supported_interfaces);
+			__set_bit(PHY_INTERFACE_MODE_SGMII,
+				  mac->phylink_config.supported_interfaces);
+			break;
+
+		default:
+			break;
+		}
+	}
+
 	phylink = phylink_create(&mac->phylink_config,
 				 dpmac_node, mac->if_mode,
 				 &dpaa2_mac_phylink_ops);
-- 
2.30.2


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

* [PATCH net-next 2/3] net: dpaa2-mac: remove interface checks in dpaa2_mac_validate()
  2021-11-17 17:02 [PATCH net-next 0/3] net: dpaa2: phylink validate implementation updates Russell King (Oracle)
  2021-11-17 17:24 ` [PATCH net-next 1/3] net: dpaa2-mac: populate supported_interfaces member Russell King
@ 2021-11-17 17:24 ` Russell King (Oracle)
  2021-11-17 17:24 ` [PATCH net-next 3/3] net: dpaa2-mac: use phylink_generic_validate() Russell King (Oracle)
  2 siblings, 0 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2021-11-17 17:24 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: David S. Miller, Jakub Kicinski, netdev

As phylink checks the interface mode against the supported_interfaces
bitmap, we no longer need to validate the interface mode, nor handle
PHY_INTERFACE_MODE_NA in the validation function. Remove these to
simplify the implementation.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 35 -------------------
 1 file changed, 35 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 176ce0a03716..bcc7fe127d91 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -90,53 +90,18 @@ static int dpaa2_mac_get_if_mode(struct fwnode_handle *dpmac_node,
 	return err;
 }
 
-static bool dpaa2_mac_phy_mode_mismatch(struct dpaa2_mac *mac,
-					phy_interface_t interface)
-{
-	switch (interface) {
-	/* We can switch between SGMII and 1000BASE-X at runtime with
-	 * pcs-lynx
-	 */
-	case PHY_INTERFACE_MODE_SGMII:
-	case PHY_INTERFACE_MODE_1000BASEX:
-		if (mac->pcs &&
-		    (mac->if_mode == PHY_INTERFACE_MODE_SGMII ||
-		     mac->if_mode == PHY_INTERFACE_MODE_1000BASEX))
-			return false;
-		return interface != mac->if_mode;
-
-	case PHY_INTERFACE_MODE_10GBASER:
-	case PHY_INTERFACE_MODE_USXGMII:
-	case PHY_INTERFACE_MODE_QSGMII:
-	case PHY_INTERFACE_MODE_RGMII:
-	case PHY_INTERFACE_MODE_RGMII_ID:
-	case PHY_INTERFACE_MODE_RGMII_RXID:
-	case PHY_INTERFACE_MODE_RGMII_TXID:
-		return (interface != mac->if_mode);
-	default:
-		return true;
-	}
-}
-
 static void dpaa2_mac_validate(struct phylink_config *config,
 			       unsigned long *supported,
 			       struct phylink_link_state *state)
 {
-	struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config);
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
 
-	if (state->interface != PHY_INTERFACE_MODE_NA &&
-	    dpaa2_mac_phy_mode_mismatch(mac, state->interface)) {
-		goto empty_set;
-	}
-
 	phylink_set_port_modes(mask);
 	phylink_set(mask, Autoneg);
 	phylink_set(mask, Pause);
 	phylink_set(mask, Asym_Pause);
 
 	switch (state->interface) {
-	case PHY_INTERFACE_MODE_NA:
 	case PHY_INTERFACE_MODE_10GBASER:
 	case PHY_INTERFACE_MODE_USXGMII:
 		phylink_set_10g_modes(mask);
-- 
2.30.2


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

* [PATCH net-next 3/3] net: dpaa2-mac: use phylink_generic_validate()
  2021-11-17 17:02 [PATCH net-next 0/3] net: dpaa2: phylink validate implementation updates Russell King (Oracle)
  2021-11-17 17:24 ` [PATCH net-next 1/3] net: dpaa2-mac: populate supported_interfaces member Russell King
  2021-11-17 17:24 ` [PATCH net-next 2/3] net: dpaa2-mac: remove interface checks in dpaa2_mac_validate() Russell King (Oracle)
@ 2021-11-17 17:24 ` Russell King (Oracle)
  2 siblings, 0 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2021-11-17 17:24 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: David S. Miller, Jakub Kicinski, netdev

DPAA2 has no special behaviour in its validation implementation, so can
be switched to phylink_generic_validate().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 53 ++-----------------
 1 file changed, 5 insertions(+), 48 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index bcc7fe127d91..34b2a73c347f 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -90,53 +90,6 @@ static int dpaa2_mac_get_if_mode(struct fwnode_handle *dpmac_node,
 	return err;
 }
 
-static void dpaa2_mac_validate(struct phylink_config *config,
-			       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);
-
-	switch (state->interface) {
-	case PHY_INTERFACE_MODE_10GBASER:
-	case PHY_INTERFACE_MODE_USXGMII:
-		phylink_set_10g_modes(mask);
-		if (state->interface == PHY_INTERFACE_MODE_10GBASER)
-			break;
-		phylink_set(mask, 5000baseT_Full);
-		phylink_set(mask, 2500baseT_Full);
-		fallthrough;
-	case PHY_INTERFACE_MODE_SGMII:
-	case PHY_INTERFACE_MODE_QSGMII:
-	case PHY_INTERFACE_MODE_1000BASEX:
-	case PHY_INTERFACE_MODE_RGMII:
-	case PHY_INTERFACE_MODE_RGMII_ID:
-	case PHY_INTERFACE_MODE_RGMII_RXID:
-	case PHY_INTERFACE_MODE_RGMII_TXID:
-		phylink_set(mask, 1000baseX_Full);
-		phylink_set(mask, 1000baseT_Full);
-		if (state->interface == PHY_INTERFACE_MODE_1000BASEX)
-			break;
-		phylink_set(mask, 100baseT_Full);
-		phylink_set(mask, 10baseT_Full);
-		break;
-	default:
-		goto empty_set;
-	}
-
-	linkmode_and(supported, supported, mask);
-	linkmode_and(state->advertising, state->advertising, mask);
-
-	return;
-
-empty_set:
-	linkmode_zero(supported);
-}
-
 static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
 			     const struct phylink_link_state *state)
 {
@@ -208,7 +161,7 @@ static void dpaa2_mac_link_down(struct phylink_config *config,
 }
 
 static const struct phylink_mac_ops dpaa2_mac_phylink_ops = {
-	.validate = dpaa2_mac_validate,
+	.validate = phylink_generic_validate,
 	.mac_config = dpaa2_mac_config,
 	.mac_link_up = dpaa2_mac_link_up,
 	.mac_link_down = dpaa2_mac_link_down,
@@ -305,6 +258,10 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 	mac->phylink_config.dev = &net_dev->dev;
 	mac->phylink_config.type = PHYLINK_NETDEV;
 
+	mac->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE |
+		MAC_10FD | MAC_100FD | MAC_1000FD | MAC_2500FD | MAC_5000FD |
+		MAC_10000FD;
+
 	/* We support the current interface mode, and if we have a PCS
 	 * similar interface modes that do not require the PLLs to be
 	 * reconfigured.
-- 
2.30.2


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

* Re: [PATCH net-next 1/3] net: dpaa2-mac: populate supported_interfaces member
  2021-11-17 17:24 ` [PATCH net-next 1/3] net: dpaa2-mac: populate supported_interfaces member Russell King
@ 2021-11-18 11:40   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-11-18 11:40 UTC (permalink / raw)
  To: Russell King; +Cc: ioana.ciornei, davem, kuba, netdev

Hello:

This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed, 17 Nov 2021 17:24:02 +0000 you wrote:
> Populate the phy interface mode bitmap for the Freescale DPAA2 driver
> with interfaces modes supported by the MAC.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 21 +++++++++++++++++++
>  1 file changed, 21 insertions(+)

Here is the summary with links:
  - [net-next,1/3] net: dpaa2-mac: populate supported_interfaces member
    https://git.kernel.org/netdev/net-next/c/15d0b14cec1c
  - [net-next,2/3] net: dpaa2-mac: remove interface checks in dpaa2_mac_validate()
    https://git.kernel.org/netdev/net-next/c/22de481d23c9
  - [net-next,3/3] net: dpaa2-mac: use phylink_generic_validate()
    https://git.kernel.org/netdev/net-next/c/6d386f661326

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] 5+ messages in thread

end of thread, other threads:[~2021-11-18 11:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-17 17:02 [PATCH net-next 0/3] net: dpaa2: phylink validate implementation updates Russell King (Oracle)
2021-11-17 17:24 ` [PATCH net-next 1/3] net: dpaa2-mac: populate supported_interfaces member Russell King
2021-11-18 11:40   ` patchwork-bot+netdevbpf
2021-11-17 17:24 ` [PATCH net-next 2/3] net: dpaa2-mac: remove interface checks in dpaa2_mac_validate() Russell King (Oracle)
2021-11-17 17:24 ` [PATCH net-next 3/3] net: dpaa2-mac: use phylink_generic_validate() Russell King (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).