All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net-next] net: enetc: kill PHY-less mode for PFs
@ 2022-05-11  9:42 Vladimir Oltean
  2022-05-11  9:53 ` Claudiu Manoil
  2022-05-12  9:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Oltean @ 2022-05-11  9:42 UTC (permalink / raw)
  To: netdev
  Cc: Jakub Kicinski, David S. Miller, Paolo Abeni, Eric Dumazet,
	Claudiu Manoil, Michael Walle

Right now, a PHY-less port (no phy-mode, no fixed-link, no phy-handle)
doesn't register with phylink, but calls netif_carrier_on() from
enetc_start().

This makes sense for a VF, but for a PF, this is braindead, because we
never call enetc_mac_enable() so the MAC is left inoperational.
Furthermore, commit 71b77a7a27a3 ("enetc: Migrate to PHYLINK and
PCS_LYNX") put the nail in the coffin because it removed the initial
netif_carrier_off() call done right after register_netdev().

Without that call, netif_carrier_on() does not call
linkwatch_fire_event(), so the operstate remains IF_OPER_UNKNOWN.

Just deny the broken configuration by requiring that a phy-mode is
present, and always register a PF with phylink.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
v1->v2: fix of_get_phy_mode() error path in enetc_pf_probe()

 .../net/ethernet/freescale/enetc/enetc_pf.c   | 24 +++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index 7cccdf54359f..c4a0e836d4f0 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -1105,8 +1105,7 @@ static int enetc_phylink_create(struct enetc_ndev_priv *priv,
 
 static void enetc_phylink_destroy(struct enetc_ndev_priv *priv)
 {
-	if (priv->phylink)
-		phylink_destroy(priv->phylink);
+	phylink_destroy(priv->phylink);
 }
 
 /* Initialize the entire shared memory for the flow steering entries
@@ -1273,16 +1272,20 @@ static int enetc_pf_probe(struct pci_dev *pdev,
 		goto err_alloc_msix;
 	}
 
-	if (!of_get_phy_mode(node, &pf->if_mode)) {
-		err = enetc_mdiobus_create(pf, node);
-		if (err)
-			goto err_mdiobus_create;
-
-		err = enetc_phylink_create(priv, node);
-		if (err)
-			goto err_phylink_create;
+	err = of_get_phy_mode(node, &pf->if_mode);
+	if (err) {
+		dev_err(&pdev->dev, "Failed to read PHY mode\n");
+		goto err_phy_mode;
 	}
 
+	err = enetc_mdiobus_create(pf, node);
+	if (err)
+		goto err_mdiobus_create;
+
+	err = enetc_phylink_create(priv, node);
+	if (err)
+		goto err_phylink_create;
+
 	err = register_netdev(ndev);
 	if (err)
 		goto err_reg_netdev;
@@ -1294,6 +1297,7 @@ static int enetc_pf_probe(struct pci_dev *pdev,
 err_phylink_create:
 	enetc_mdiobus_destroy(pf);
 err_mdiobus_create:
+err_phy_mode:
 	enetc_free_msix(priv);
 err_config_si:
 err_alloc_msix:
-- 
2.25.1


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

* RE: [PATCH v2 net-next] net: enetc: kill PHY-less mode for PFs
  2022-05-11  9:42 [PATCH v2 net-next] net: enetc: kill PHY-less mode for PFs Vladimir Oltean
@ 2022-05-11  9:53 ` Claudiu Manoil
  2022-05-12  9:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Claudiu Manoil @ 2022-05-11  9:53 UTC (permalink / raw)
  To: Vladimir Oltean, netdev
  Cc: Jakub Kicinski, David S. Miller, Paolo Abeni, Eric Dumazet,
	Michael Walle

> -----Original Message-----
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> Sent: Wednesday, May 11, 2022 12:42 PM
> To: netdev@vger.kernel.org
[...]
> Subject: [PATCH v2 net-next] net: enetc: kill PHY-less mode for PFs
> 
[...]
> 
> Just deny the broken configuration by requiring that a phy-mode is
> present, and always register a PF with phylink.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> v1->v2: fix of_get_phy_mode() error path in enetc_pf_probe()
> 

Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>

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

* Re: [PATCH v2 net-next] net: enetc: kill PHY-less mode for PFs
  2022-05-11  9:42 [PATCH v2 net-next] net: enetc: kill PHY-less mode for PFs Vladimir Oltean
  2022-05-11  9:53 ` Claudiu Manoil
@ 2022-05-12  9:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-12  9:30 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: netdev, kuba, davem, pabeni, edumazet, claudiu.manoil, michael

Hello:

This patch was applied to netdev/net-next.git (master)
by Paolo Abeni <pabeni@redhat.com>:

On Wed, 11 May 2022 12:42:00 +0300 you wrote:
> Right now, a PHY-less port (no phy-mode, no fixed-link, no phy-handle)
> doesn't register with phylink, but calls netif_carrier_on() from
> enetc_start().
> 
> This makes sense for a VF, but for a PF, this is braindead, because we
> never call enetc_mac_enable() so the MAC is left inoperational.
> Furthermore, commit 71b77a7a27a3 ("enetc: Migrate to PHYLINK and
> PCS_LYNX") put the nail in the coffin because it removed the initial
> netif_carrier_off() call done right after register_netdev().
> 
> [...]

Here is the summary with links:
  - [v2,net-next] net: enetc: kill PHY-less mode for PFs
    https://git.kernel.org/netdev/net-next/c/0f84d403b8e5

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

end of thread, other threads:[~2022-05-12  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  9:42 [PATCH v2 net-next] net: enetc: kill PHY-less mode for PFs Vladimir Oltean
2022-05-11  9:53 ` Claudiu Manoil
2022-05-12  9:30 ` 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.