[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230923134904.3627402-8-vladimir.oltean@nxp.com>
Date: Sat, 23 Sep 2023 16:48:56 +0300
From: Vladimir Oltean <vladimir.oltean@....com>
To: netdev@...r.kernel.org,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-phy@...ts.infradead.org
Cc: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
Heiner Kallweit <hkallweit1@...il.com>,
Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Madalin Bucur <madalin.bucur@....com>,
Ioana Ciornei <ioana.ciornei@....com>,
Camelia Groza <camelia.groza@....com>,
Li Yang <leoyang.li@....com>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor@...nel.org>,
Sean Anderson <sean.anderson@...o.com>,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
Vinod Koul <vkoul@...nel.org>,
Kishon Vijay Abraham I <kishon@...nel.org>
Subject: [RFC PATCH v2 net-next 07/15] net: phylink: centralize phy_interface_mode_is_8023z() && phylink_autoneg_inband() checks
In a future change, we will extend the PHY interface modes for which
phylink allows the PCS to handle autoneg. Group the existing occurences
into a common phylink_pcs_handles_an().
Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
v1->v2: patch is new
drivers/net/phy/phylink.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 0d7354955d62..548130d77302 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1107,12 +1107,17 @@ static void phylink_mac_config(struct phylink *pl,
pl->mac_ops->mac_config(pl->config, pl->cur_link_an_mode, &st);
}
+static bool phylink_pcs_handles_an(phy_interface_t iface, unsigned int mode)
+{
+ return phy_interface_mode_is_8023z(iface) && phylink_autoneg_inband(mode);
+}
+
static void phylink_pcs_an_restart(struct phylink *pl)
{
if (pl->pcs && linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
pl->link_config.advertising) &&
- phy_interface_mode_is_8023z(pl->link_config.interface) &&
- phylink_autoneg_inband(pl->cur_link_an_mode))
+ phylink_pcs_handles_an(pl->link_config.interface,
+ pl->cur_link_an_mode))
pl->pcs->ops->pcs_an_restart(pl->pcs);
}
@@ -1716,8 +1721,8 @@ EXPORT_SYMBOL_GPL(phylink_destroy);
bool phylink_expects_phy(struct phylink *pl)
{
if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
- (pl->cfg_link_an_mode == MLO_AN_INBAND &&
- phy_interface_mode_is_8023z(pl->link_config.interface)))
+ phylink_pcs_handles_an(pl->link_config.interface,
+ pl->cfg_link_an_mode))
return false;
return true;
}
@@ -1852,8 +1857,8 @@ static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy,
phy_interface_t interface)
{
if (WARN_ON(pl->cfg_link_an_mode == MLO_AN_FIXED ||
- (pl->cfg_link_an_mode == MLO_AN_INBAND &&
- phy_interface_mode_is_8023z(interface) && !pl->sfp_bus)))
+ (phylink_pcs_handles_an(interface, pl->cfg_link_an_mode) &&
+ !pl->sfp_bus)))
return -EINVAL;
if (pl->phydev)
@@ -1937,10 +1942,11 @@ int phylink_fwnode_phy_connect(struct phylink *pl,
struct phy_device *phy_dev;
int ret;
- /* Fixed links and 802.3z are handled without needing a PHY */
+ /* Fixed links and the modes where the PCS can handle autoneg with the
+ * far end do not need a PHY.
+ */
if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
- (pl->cfg_link_an_mode == MLO_AN_INBAND &&
- phy_interface_mode_is_8023z(pl->link_interface)))
+ phylink_pcs_handles_an(pl->link_interface, pl->cfg_link_an_mode))
return 0;
phy_fwnode = fwnode_get_phy_node(fwnode);
--
2.34.1
Powered by blists - more mailing lists