Skip to contentSkip to conversation

100base Fx link modes

PATCH In review Dan Murphy 4 participants 11 messages Sep 18, 2020 – Sep 19, 2020

Subsystems (4)
lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

v2 cover 100base Fx link modes

Hello

As per patch https://lore.kernel.org/patchwork/patch/1300241/ the link modes for 100base FX full and half duplex modes did not exist. Adding these link modes to the core and ethtool allow devices like the DP83822, DP83869 and Broadcomm PHYs to properly advertise the correct mode for Fiber 100Mbps.

Corresponding user land ethtool patches are available but rely on these patches to be applied first.

Dan

Dan Murphy (3):
ethtool: Add 100base-FX link mode entries
net: dp83869: Add ability to advertise Fiber connection
net: phy: dp83822: Update the fiber advertisement for speed

 drivers/net/phy/dp83822.c    | 13 +++++--
 drivers/net/phy/dp83869.c    | 73 ++++++++++++++++++++++++++++++++++++
 drivers/net/phy/phy-core.c   |  4 +-
 include/uapi/linux/ethtool.h |  2 +
 net/ethtool/common.c         |  2 +
 net/ethtool/linkmodes.c      |  2 +
 6 files changed, 92 insertions(+), 4 deletions(-)
Signature · 1 line
2.28.0
author
#1 lore raw

PATCH v2 1/3 ethtool: Add 100base-FX link mode entries

Add entries for the 100base-FX full and half duplex supported modes.

$ ethtool eth0
        Supported ports: [ FIBRE ]
        Supported link modes:  100baseFX/Half 100baseFX/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: No
        Supported FEC modes: Not reported
        Advertised link modes: 100baseFX/Half 100baseFX/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: 100Mb/s
        Duplex: Full
        Auto-negotiation: off
        Port: MII
        PHYAD: 1
        Transceiver: external
        Supports Wake-on: gs
        Wake-on: d
        SecureOn password: 00:00:00:00:00:00
        Current message level: 0x00000000 (0)

Link detected: yes

---

v2 - Updated ethtool example in the commit message no other functional changes

 drivers/net/phy/phy-core.c   | 4 +++-
 include/uapi/linux/ethtool.h | 2 ++
 net/ethtool/common.c         | 2 ++
 net/ethtool/linkmodes.c      | 2 ++
 4 files changed, 9 insertions(+), 1 deletion(-)
drivers/net/phy/phy-core.c +3 -1
index ff8e14b01eeb..de5b869139d7 100644
@@ -8,7 +8,7 @@
 
 const char *phy_speed_to_str(int speed)
 {
-	BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 90,
+	BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 92,
 		"Enum ethtool_link_mode_bit_indices and phylib are out of sync. "
 		"If a speed or mode has been added please update phy_speed_to_str "
 		"and the PHY settings array.\n");
@@ -160,6 +160,8 @@ static const struct phy_setting settings[] = {
 	PHY_SETTING(    100, FULL,    100baseT_Full		),
 	PHY_SETTING(    100, FULL,    100baseT1_Full		),
 	PHY_SETTING(    100, HALF,    100baseT_Half		),
+	PHY_SETTING(    100, HALF,    100baseFX_Half		),
+	PHY_SETTING(    100, FULL,    100baseFX_Full		),
 	/* 10M */
 	PHY_SETTING(     10, FULL,     10baseT_Full		),
 	PHY_SETTING(     10, HALF,     10baseT_Half		),
include/uapi/linux/ethtool.h +2 -0
index b4f2d134e713..9ca87bc73c44 100644
@@ -1617,6 +1617,8 @@ enum ethtool_link_mode_bit_indices {
 	ETHTOOL_LINK_MODE_400000baseLR4_ER4_FR4_Full_BIT = 87,
 	ETHTOOL_LINK_MODE_400000baseDR4_Full_BIT	 = 88,
 	ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT	 = 89,
+	ETHTOOL_LINK_MODE_100baseFX_Half_BIT		 = 90,
+	ETHTOOL_LINK_MODE_100baseFX_Full_BIT		 = 91,
 	/* must be last entry */
 	__ETHTOOL_LINK_MODE_MASK_NBITS
 };
net/ethtool/common.c +2 -0
index ed19573fccd7..24036e3055a1 100644
@@ -192,6 +192,8 @@ const char link_mode_names[][ETH_GSTRING_LEN] = {
 	__DEFINE_LINK_MODE_NAME(400000, LR4_ER4_FR4, Full),
 	__DEFINE_LINK_MODE_NAME(400000, DR4, Full),
 	__DEFINE_LINK_MODE_NAME(400000, CR4, Full),
+	__DEFINE_LINK_MODE_NAME(100, FX, Half),
+	__DEFINE_LINK_MODE_NAME(100, FX, Full),
 };
 static_assert(ARRAY_SIZE(link_mode_names) == __ETHTOOL_LINK_MODE_MASK_NBITS);
 
net/ethtool/linkmodes.c +2 -0
index 7044a2853886..29dcd675b65a 100644
@@ -272,6 +272,8 @@ static const struct link_mode_info link_mode_params[] = {
 	__DEFINE_LINK_MODE_PARAMS(400000, LR4_ER4_FR4, Full),
 	__DEFINE_LINK_MODE_PARAMS(400000, DR4, Full),
 	__DEFINE_LINK_MODE_PARAMS(400000, CR4, Full),
+	__DEFINE_LINK_MODE_PARAMS(100, FX, Half),
+	__DEFINE_LINK_MODE_PARAMS(100, FX, Full),
 };
 
 static const struct nla_policy
Signature · 1 line
2.28.0
maintainer Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH net-next v2 1/3] ethtool: Add 100base-FX link mode entries

Quoted 23 lines · Dan Murphy

Add entries for the 100base-FX full and half duplex supported modes.

$ ethtool eth0
        Supported ports: [ FIBRE ]
        Supported link modes:  100baseFX/Half 100baseFX/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: No
        Supported FEC modes: Not reported
        Advertised link modes: 100baseFX/Half 100baseFX/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: 100Mb/s
        Duplex: Full
        Auto-negotiation: off
        Port: MII
        PHYAD: 1
        Transceiver: external
        Supports Wake-on: gs
        Wake-on: d
        SecureOn password: 00:00:00:00:00:00
        Current message level: 0x00000000 (0)
Quoted 3 lines

Link detected: yes

Andrew

Reviewed-by on v2 1/3
#3 lore raw

Re: [PATCH net-next v2 1/3] ethtool: Add 100base-FX link mode entries

In reply to Dan Murphy
Quoted 23 lines · Dan Murphy

Add entries for the 100base-FX full and half duplex supported modes.

$ ethtool eth0
         Supported ports: [ FIBRE ]
         Supported link modes:  100baseFX/Half 100baseFX/Full
         Supported pause frame use: Symmetric Receive-only
         Supports auto-negotiation: No
         Supported FEC modes: Not reported
         Advertised link modes: 100baseFX/Half 100baseFX/Full
         Advertised pause frame use: No
         Advertised auto-negotiation: No
         Advertised FEC modes: Not reported
         Speed: 100Mb/s
         Duplex: Full
         Auto-negotiation: off
         Port: MII
         PHYAD: 1
         Transceiver: external
         Supports Wake-on: gs
         Wake-on: d
         SecureOn password: 00:00:00:00:00:00
         Current message level: 0x00000000 (0)
Quoted 3 lines

Link detected: yes

Signature · 1 line
Florian
author
#4 lore raw

PATCH v2 2/3 net: dp83869: Add ability to advertise Fiber connection

In reply to Dan Murphy

Add the ability to advertise the Fiber connection if the strap or the op-mode is configured for 100Base-FX.

Auto negotiation is not supported on this PHY when in fiber mode.

---
 drivers/net/phy/dp83869.c | 73 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)
drivers/net/phy/dp83869.c +73 -0
index 6b98d74b5102..81899bc99add 100644
@@ -52,6 +52,10 @@
 					 BMCR_FULLDPLX | \
 					 BMCR_SPEED1000)
 
+#define MII_DP83869_FIBER_ADVERTISE    (ADVERTISED_FIBRE | \
+					ADVERTISED_Pause | \
+					ADVERTISED_Asym_Pause)
+
 /* This is the same bit mask as the BMCR so re-use the BMCR default */
 #define DP83869_FX_CTRL_DEFAULT	MII_DP83869_BMCR_DEFAULT
 
@@ -118,6 +122,28 @@ struct dp83869_private {
 	int mode;
 };
 
+static int dp83869_read_status(struct phy_device *phydev)
+{
+	struct dp83869_private *dp83869 = phydev->priv;
+	int ret;
+
+	ret = genphy_read_status(phydev);
+	if (ret)
+		return ret;
+
+	if (linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->supported)) {
+		if (phydev->link) {
+			if (dp83869->mode == DP83869_RGMII_100_BASE)
+				phydev->speed = SPEED_100;
+		} else {
+			phydev->speed = SPEED_UNKNOWN;
+			phydev->duplex = DUPLEX_UNKNOWN;
+		}
+	}
+
+	return 0;
+}
+
 static int dp83869_ack_interrupt(struct phy_device *phydev)
 {
 	int err = phy_read(phydev, MII_DP83869_ISR);
@@ -295,6 +321,51 @@ static int dp83869_configure_rgmii(struct phy_device *phydev,
 	return ret;
 }
 
+static int dp83869_configure_fiber(struct phy_device *phydev,
+				   struct dp83869_private *dp83869)
+{
+	int bmcr;
+	int ret;
+
+	/* Only allow advertising what this PHY supports */
+	linkmode_and(phydev->advertising, phydev->advertising,
+		     phydev->supported);
+
+	linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->supported);
+	linkmode_set_bit(ADVERTISED_FIBRE, phydev->advertising);
+
+	if (dp83869->mode == DP83869_RGMII_1000_BASE) {
+		linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT,
+				 phydev->supported);
+	} else {
+		linkmode_set_bit(ETHTOOL_LINK_MODE_100baseFX_Full_BIT,
+				 phydev->supported);
+		linkmode_set_bit(ETHTOOL_LINK_MODE_100baseFX_Half_BIT,
+				 phydev->supported);
+
+		/* Auto neg is not supported in 100base FX mode */
+		bmcr = phy_read(phydev, MII_BMCR);
+		if (bmcr < 0)
+			return bmcr;
+
+		phydev->autoneg = AUTONEG_DISABLE;
+		linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported);
+		linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->advertising);
+
+		if (bmcr & BMCR_ANENABLE) {
+			ret =  phy_modify(phydev, MII_BMCR, BMCR_ANENABLE, 0);
+			if (ret < 0)
+				return ret;
+		}
+	}
+
+	/* Update advertising from supported */
+	linkmode_or(phydev->advertising, phydev->advertising,
+		    phydev->supported);
+
+	return 0;
+}
+
 static int dp83869_configure_mode(struct phy_device *phydev,
 				  struct dp83869_private *dp83869)
 {
@@ -384,6 +455,7 @@ static int dp83869_configure_mode(struct phy_device *phydev,
 		break;
 	case DP83869_RGMII_1000_BASE:
 	case DP83869_RGMII_100_BASE:
+		ret = dp83869_configure_fiber(phydev, dp83869);
 		break;
 	default:
 		return -EINVAL;
@@ -494,6 +566,7 @@ static struct phy_driver dp83869_driver[] = {
 		/* IRQ related */
 		.ack_interrupt	= dp83869_ack_interrupt,
 		.config_intr	= dp83869_config_intr,
+		.read_status	= dp83869_read_status,
 
 		.suspend	= genphy_suspend,
 		.resume		= genphy_resume,
Signature · 1 line
2.28.0
maintainer Reviewed-by on v2 2/3
#5 lore raw

Re: [PATCH net-next v2 2/3] net: dp83869: Add ability to advertise Fiber connection

Quoted 6 lines · Dan Murphy

Add the ability to advertise the Fiber connection if the strap or the op-mode is configured for 100Base-FX.

Auto negotiation is not supported on this PHY when in fiber mode.

Andrew

Reviewed-by on v2 2/3
#6 lore raw

Re: [PATCH net-next v2 2/3] net: dp83869: Add ability to advertise Fiber connection

In reply to Dan Murphy
Quoted 6 lines · Dan Murphy

Add the ability to advertise the Fiber connection if the strap or the op-mode is configured for 100Base-FX.

Auto negotiation is not supported on this PHY when in fiber mode.

Signature · 1 line
Florian
author
#7 lore raw

PATCH v2 3/3 net: phy: dp83822: Update the fiber advertisement for speed

In reply to Dan Murphy

Update the fiber advertisement for speed and duplex modes with the 100base-FX full and half linkmode entries.

---
 drivers/net/phy/dp83822.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/phy/dp83822.c +10 -3
index 732c8bec7452..c162c9551bd1 100644
@@ -110,9 +110,8 @@
 #define DP83822_RX_ER_SHIFT	8
 
 #define MII_DP83822_FIBER_ADVERTISE    (ADVERTISED_TP | ADVERTISED_MII | \
-					ADVERTISED_FIBRE | ADVERTISED_BNC |  \
-					ADVERTISED_Pause | ADVERTISED_Asym_Pause | \
-					ADVERTISED_100baseT_Full)
+					ADVERTISED_FIBRE | \
+					ADVERTISED_Pause | ADVERTISED_Asym_Pause)
 
 struct dp83822_private {
 	bool fx_signal_det_low;
@@ -406,6 +405,14 @@ static int dp83822_config_init(struct phy_device *phydev)
 				 phydev->supported);
 		linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT,
 				 phydev->advertising);
+		linkmode_set_bit(ETHTOOL_LINK_MODE_100baseFX_Full_BIT,
+				 phydev->supported);
+		linkmode_set_bit(ETHTOOL_LINK_MODE_100baseFX_Half_BIT,
+				 phydev->supported);
+		linkmode_set_bit(ETHTOOL_LINK_MODE_100baseFX_Full_BIT,
+				 phydev->advertising);
+		linkmode_set_bit(ETHTOOL_LINK_MODE_100baseFX_Half_BIT,
+				 phydev->advertising);
 
 		/* Auto neg is not supported in fiber mode */
 		bmcr = phy_read(phydev, MII_BMCR);
Signature · 1 line
2.28.0
maintainer
#10 lore raw
In reply to Dan Murphy

From: Dan Murphy <[email protected]>
Date: Fri, 18 Sep 2020 14:14:50 -0500

Quoted 7 lines

As per patch https://lore.kernel.org/patchwork/patch/1300241/ the link modes for 100base FX full and half duplex modes did not exist. Adding these link modes to the core and ethtool allow devices like the DP83822, DP83869 and Broadcomm PHYs to properly advertise the correct mode for Fiber 100Mbps.

Corresponding user land ethtool patches are available but rely on these patches to be applied first.

Series applied, thank you.