linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] 100base Fx link modes
@ 2020-09-15 18:17 Dan Murphy
  2020-09-15 18:17 ` [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries Dan Murphy
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Dan Murphy @ 2020-09-15 18:17 UTC (permalink / raw)
  To: davem, andrew, f.fainelli, hkallweit1
  Cc: mkubecek, netdev, linux-kernel, Dan Murphy

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(-)

-- 
2.28.0


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

* [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries
  2020-09-15 18:17 [PATCH net-next 0/3] 100base Fx link modes Dan Murphy
@ 2020-09-15 18:17 ` Dan Murphy
  2020-09-15 20:10   ` Andrew Lunn
  2020-09-15 20:21   ` Andrew Lunn
  2020-09-15 18:17 ` [PATCH net-next 2/3] net: dp83869: Add ability to advertise Fiber connection Dan Murphy
  2020-09-15 18:17 ` [PATCH net-next 3/3] net: phy: dp83822: Update the fiber advertisement for speed Dan Murphy
  2 siblings, 2 replies; 13+ messages in thread
From: Dan Murphy @ 2020-09-15 18:17 UTC (permalink / raw)
  To: davem, andrew, f.fainelli, hkallweit1
  Cc: mkubecek, netdev, linux-kernel, Dan Murphy

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

$ ethtool eth0
        Supported ports: [ TP    MII     FIBRE ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                100baseFX/Half 100baseFX/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: No
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                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

Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 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(-)

diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index ff8e14b01eeb..de5b869139d7 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -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		),
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index b4f2d134e713..9ca87bc73c44 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -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
 };
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index ed19573fccd7..24036e3055a1 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -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);
 
diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c
index 7044a2853886..29dcd675b65a 100644
--- a/net/ethtool/linkmodes.c
+++ b/net/ethtool/linkmodes.c
@@ -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
-- 
2.28.0


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

* [PATCH net-next 2/3] net: dp83869: Add ability to advertise Fiber connection
  2020-09-15 18:17 [PATCH net-next 0/3] 100base Fx link modes Dan Murphy
  2020-09-15 18:17 ` [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries Dan Murphy
@ 2020-09-15 18:17 ` Dan Murphy
  2020-09-15 20:17   ` Andrew Lunn
  2020-09-15 18:17 ` [PATCH net-next 3/3] net: phy: dp83822: Update the fiber advertisement for speed Dan Murphy
  2 siblings, 1 reply; 13+ messages in thread
From: Dan Murphy @ 2020-09-15 18:17 UTC (permalink / raw)
  To: davem, andrew, f.fainelli, hkallweit1
  Cc: mkubecek, netdev, linux-kernel, 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.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 drivers/net/phy/dp83869.c | 73 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c
index 6b98d74b5102..81899bc99add 100644
--- a/drivers/net/phy/dp83869.c
+++ b/drivers/net/phy/dp83869.c
@@ -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,
-- 
2.28.0


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

* [PATCH net-next 3/3] net: phy: dp83822: Update the fiber advertisement for speed
  2020-09-15 18:17 [PATCH net-next 0/3] 100base Fx link modes Dan Murphy
  2020-09-15 18:17 ` [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries Dan Murphy
  2020-09-15 18:17 ` [PATCH net-next 2/3] net: dp83869: Add ability to advertise Fiber connection Dan Murphy
@ 2020-09-15 18:17 ` Dan Murphy
  2 siblings, 0 replies; 13+ messages in thread
From: Dan Murphy @ 2020-09-15 18:17 UTC (permalink / raw)
  To: davem, andrew, f.fainelli, hkallweit1
  Cc: mkubecek, netdev, linux-kernel, Dan Murphy

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

Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 drivers/net/phy/dp83822.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
index 732c8bec7452..c162c9551bd1 100644
--- a/drivers/net/phy/dp83822.c
+++ b/drivers/net/phy/dp83822.c
@@ -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);
-- 
2.28.0


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

* Re: [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries
  2020-09-15 18:17 ` [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries Dan Murphy
@ 2020-09-15 20:10   ` Andrew Lunn
  2020-09-15 23:26     ` Dan Murphy
  2020-09-15 20:21   ` Andrew Lunn
  1 sibling, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2020-09-15 20:10 UTC (permalink / raw)
  To: Dan Murphy; +Cc: davem, f.fainelli, hkallweit1, mkubecek, netdev, linux-kernel

On Tue, Sep 15, 2020 at 01:17:06PM -0500, Dan Murphy wrote:
> @@ -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		),

Hi Dan

Does 100baseFX_Half make an sense? My understanding of 802.3 section
26 is that it is always a pair, not a single fibre where you might
need CSMA/CD?

   Andrew

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

* Re: [PATCH net-next 2/3] net: dp83869: Add ability to advertise Fiber connection
  2020-09-15 18:17 ` [PATCH net-next 2/3] net: dp83869: Add ability to advertise Fiber connection Dan Murphy
@ 2020-09-15 20:17   ` Andrew Lunn
  2020-09-16 20:54     ` Dan Murphy
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2020-09-15 20:17 UTC (permalink / raw)
  To: Dan Murphy; +Cc: davem, f.fainelli, hkallweit1, mkubecek, netdev, linux-kernel

> +		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 */

Hi Dan

If it does not support auto neg, how do you decide to do half duplex?
I don't see any code here which allows the user to configure it.

  Andrew

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

* Re: [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries
  2020-09-15 18:17 ` [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries Dan Murphy
  2020-09-15 20:10   ` Andrew Lunn
@ 2020-09-15 20:21   ` Andrew Lunn
  2020-09-15 23:29     ` Dan Murphy
  1 sibling, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2020-09-15 20:21 UTC (permalink / raw)
  To: Dan Murphy; +Cc: davem, f.fainelli, hkallweit1, mkubecek, netdev, linux-kernel

On Tue, Sep 15, 2020 at 01:17:06PM -0500, Dan Murphy wrote:
> Add entries for the 100base-FX full and half duplex supported modes.
> 
> $ ethtool eth0
>         Supported ports: [ TP    MII     FIBRE ]
>         Supported link modes:   10baseT/Half 10baseT/Full
>                                 100baseT/Half 100baseT/Full
>                                 100baseFX/Half 100baseFX/Full
>         Supported pause frame use: Symmetric Receive-only
>         Supports auto-negotiation: No
>         Supported FEC modes: Not reported
>         Advertised link modes:  10baseT/Half 10baseT/Full
>                                 100baseT/Half 100baseT/Full
>                                 100baseFX/Half 100baseFX/Full

I thought this PHY could not switch between TP and Fibre. It has a
strap which decides? So i would expect the supported modes to be
either BaseT or BaseFX. Not both. Same for Advertised?

       Andrew

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

* Re: [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries
  2020-09-15 20:10   ` Andrew Lunn
@ 2020-09-15 23:26     ` Dan Murphy
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Murphy @ 2020-09-15 23:26 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: davem, f.fainelli, hkallweit1, mkubecek, netdev, linux-kernel

Andrew

On 9/15/20 3:10 PM, Andrew Lunn wrote:
> On Tue, Sep 15, 2020 at 01:17:06PM -0500, Dan Murphy wrote:
>> @@ -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		),
> Hi Dan
>
> Does 100baseFX_Half make an sense? My understanding of 802.3 section
> 26 is that it is always a pair, not a single fibre where you might
> need CSMA/CD?

I actually questioned that too and looked it up

I found these and thought they could be viable

http://www.certiology.com/tech-terms/network/100base-fx.html

"The 100Base-FX can be used in a maximum length of 412 meters if being 
used in

half-duplex connections or as 2 kilometer lengths in the case of 
full-duplex transmissions over optical fiber."

https://www.cnet.com/products/half-duplex-100basefx-interface-pb7/

Of course I never have seen one myself

Dan


>     Andrew

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

* Re: [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries
  2020-09-15 20:21   ` Andrew Lunn
@ 2020-09-15 23:29     ` Dan Murphy
  2020-09-17 15:03       ` Dan Murphy
  0 siblings, 1 reply; 13+ messages in thread
From: Dan Murphy @ 2020-09-15 23:29 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: davem, f.fainelli, hkallweit1, mkubecek, netdev, linux-kernel

Andrew

On 9/15/20 3:21 PM, Andrew Lunn wrote:
> On Tue, Sep 15, 2020 at 01:17:06PM -0500, Dan Murphy wrote:
>> Add entries for the 100base-FX full and half duplex supported modes.
>>
>> $ ethtool eth0
>>          Supported ports: [ TP    MII     FIBRE ]
>>          Supported link modes:   10baseT/Half 10baseT/Full
>>                                  100baseT/Half 100baseT/Full
>>                                  100baseFX/Half 100baseFX/Full
>>          Supported pause frame use: Symmetric Receive-only
>>          Supports auto-negotiation: No
>>          Supported FEC modes: Not reported
>>          Advertised link modes:  10baseT/Half 10baseT/Full
>>                                  100baseT/Half 100baseT/Full
>>                                  100baseFX/Half 100baseFX/Full
> I thought this PHY could not switch between TP and Fibre. It has a
> strap which decides? So i would expect the supported modes to be
> either BaseT or BaseFX. Not both. Same for Advertised?
>
>         Andrew

I found that the phy-device was setting all these bits in phy_init in 
features_init.

My first pass was to clear all these bits as well because the PHY was 
still advertising these modes.

But you are right this PHY cannot switch without strapping.

I can clear these bits.

Dan


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

* Re: [PATCH net-next 2/3] net: dp83869: Add ability to advertise Fiber connection
  2020-09-15 20:17   ` Andrew Lunn
@ 2020-09-16 20:54     ` Dan Murphy
  2020-09-16 22:13       ` Andrew Lunn
  0 siblings, 1 reply; 13+ messages in thread
From: Dan Murphy @ 2020-09-16 20:54 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: davem, f.fainelli, hkallweit1, mkubecek, netdev, linux-kernel

Andrew

On 9/15/20 3:17 PM, Andrew Lunn wrote:
>> +		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 */
> Hi Dan
>
> If it does not support auto neg, how do you decide to do half duplex?
> I don't see any code here which allows the user to configure it.

Ethtool has the provisions to set the duplex and speed right?.

The only call back I see which is valid is config_aneg which would still 
require a user space tool to set the needed link modes.

I could implement the config_aneg to call genphy_setup_forced if auto 
neg is disabled but that function just writes the BMCR which is already 
updated and if auto neg is enabled it would just call 
genphy_check_and_restart_aneg.

I verified the ethtool path with the DP83822 by reading the BMCR and 
ethtool displayed the correct advertisement

root@am335x-evm:~# ethtool -s eth0 speed 100 duplex full
root@am335x-evm:~# ethtool eth0
Settings for eth0:
         Supported ports: [ TP MII FIBRE ]
         Supported link modes:   10baseT/Half 10baseT/Full
                                 100baseT/Half 100baseT/Full
         Supported pause frame use: Symmetric Receive-only
         Supports auto-negotiation: No
         Supported FEC modes: Not reported
         Advertised link modes:  100baseT/Full

<snip>

root@am335x-evm:~# ethtool -s eth0 speed 10 duplex half
root@am335x-evm:~# ethtool eth0
Settings for eth0:
         Supported ports: [ TP MII FIBRE ]
         Supported link modes:   10baseT/Half 10baseT/Full
                                 100baseT/Half 100baseT/Full
         Supported pause frame use: Symmetric Receive-only
         Supports auto-negotiation: No
         Supported FEC modes: Not reported
         Advertised link modes:  10baseT/Half

root@am335x-evm:~# ./mdio-test g eth0 0
0x0000
root@am335x-evm:~# ethtool -s eth0 speed 100 duplex full
root@am335x-evm:~# ./mdio-test g eth0 0
0x2100
root@am335x-evm:~# ethtool -s eth0 speed 10 duplex half
root@am335x-evm:~# ./mdio-test g eth0 0
0x0000
root@am335x-evm:~# ethtool -s eth0 speed 10 duplex full
root@am335x-evm:~# ./mdio-test g eth0 0
0x0100
root@am335x-evm:~# ethtool eth0
Settings for eth0:
         Supported ports: [ TP MII FIBRE ]
         Supported link modes:   10baseT/Half 10baseT/Full
                                 100baseT/Half 100baseT/Full
         Supported pause frame use: Symmetric Receive-only
         Supports auto-negotiation: No
         Supported FEC modes: Not reported
         Advertised link modes:  10baseT/Full

Dan



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

* Re: [PATCH net-next 2/3] net: dp83869: Add ability to advertise Fiber connection
  2020-09-16 20:54     ` Dan Murphy
@ 2020-09-16 22:13       ` Andrew Lunn
  2020-09-17 14:57         ` Dan Murphy
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2020-09-16 22:13 UTC (permalink / raw)
  To: Dan Murphy; +Cc: davem, f.fainelli, hkallweit1, mkubecek, netdev, linux-kernel

On Wed, Sep 16, 2020 at 03:54:34PM -0500, Dan Murphy wrote:
> Andrew
> 
> On 9/15/20 3:17 PM, Andrew Lunn wrote:
> > > +		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 */
> > Hi Dan
> > 
> > If it does not support auto neg, how do you decide to do half duplex?
> > I don't see any code here which allows the user to configure it.
> 
> Ethtool has the provisions to set the duplex and speed right?.

What i'm getting at is you say you support
ETHTOOL_LINK_MODE_100baseFX_Full_BIT &
ETHTOOL_LINK_MODE_100baseFX_Half_BIT. If there is no auto neg in FX
mode, i'm questioning how these two different modes code be used? I'm
guessing the PHY defaults to ETHTOOL_LINK_MODE_100baseFX_Full_BIT? How
does the user set it to ETHTOOL_LINK_MODE_100baseFX_Half_BIT?

> The only call back I see which is valid is config_aneg which would still
> require a user space tool to set the needed link modes.

Correct. Maybe all you need to do is point me at the code in the
driver which actually sets the PHY into half duplex in FX mode when
the user asks for it. Is it just clearing BMCR_FULLDPLX?

    Andrew
 

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

* Re: [PATCH net-next 2/3] net: dp83869: Add ability to advertise Fiber connection
  2020-09-16 22:13       ` Andrew Lunn
@ 2020-09-17 14:57         ` Dan Murphy
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Murphy @ 2020-09-17 14:57 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: davem, f.fainelli, hkallweit1, mkubecek, netdev, linux-kernel

Andrew

On 9/16/20 5:13 PM, Andrew Lunn wrote:
> On Wed, Sep 16, 2020 at 03:54:34PM -0500, Dan Murphy wrote:
>> Andrew
>>
>> On 9/15/20 3:17 PM, Andrew Lunn wrote:
>>>> +		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 */
>>> Hi Dan
>>>
>>> If it does not support auto neg, how do you decide to do half duplex?
>>> I don't see any code here which allows the user to configure it.
>> Ethtool has the provisions to set the duplex and speed right?.
> What i'm getting at is you say you support
> ETHTOOL_LINK_MODE_100baseFX_Full_BIT &
> ETHTOOL_LINK_MODE_100baseFX_Half_BIT. If there is no auto neg in FX
> mode, i'm questioning how these two different modes code be used? I'm
> guessing the PHY defaults to ETHTOOL_LINK_MODE_100baseFX_Full_BIT? How
> does the user set it to ETHTOOL_LINK_MODE_100baseFX_Half_BIT?

The user can use ethtool to set the speed and duplex. And ethtool uses 
the IOCTLs to configure the device.

So if the user creates their own HAL then they can use those IOCTLs as well.

The data sheet indicates

"In fiber mode, the speed is not
decided through auto-negotiation. Both sides of the link must be 
configured to the same operating speed."

>
>> The only call back I see which is valid is config_aneg which would still
>> require a user space tool to set the needed link modes.
> Correct. Maybe all you need to do is point me at the code in the
> driver which actually sets the PHY into half duplex in FX mode when
> the user asks for it. Is it just clearing BMCR_FULLDPLX?

Here is the full flow when setting the speed and duplex mode from the 
Ethtool or when the IOCTL's are called to update the PHY

phy_ethtool_ksettings_set updates the phydev->speed and phydev->duplex

Since Auto Neg is disabled the call to genphy_setup_forced is done in 
the __genphy_config_aneg in phy_device.

genphy_setup_forced updates the BMCR with the updated values.

So IMO there is no need to populate the config_aneg call back to

root@am335x-evm:~# ./ethtool -s eth0 speed 10 duplex half
[   92.098491] phy_ethtool_ksettings_set
[   92.102247] phy_ethtool_ksettings_set: speed 10 duplex 0
[   92.107755] phy_sanitize_settings
[   92.111085] phy_config_aneg
[   92.113930] genphy_config_aneg
[   92.116997] __genphy_config_aneg
[   92.120237] genphy_setup_forced
[   92.123419] genphy_setup_forced: Update the BMCR
root@am335x-evm:~# ./ethtool -s eth0 speed 100 duplex full
[  102.693105] phy_ethtool_ksettings_set
[  102.697029] phy_ethtool_ksettings_set: speed 100 duplex 1
[  102.702462] phy_sanitize_settings
[  102.705892] phy_config_aneg
[  102.708702] genphy_config_aneg
[  102.711770] __genphy_config_aneg
[  102.715051] genphy_setup_forced
[  102.718209] genphy_setup_forced: Update the BMCR

I am hoping this answers your question.

Dan


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

* Re: [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries
  2020-09-15 23:29     ` Dan Murphy
@ 2020-09-17 15:03       ` Dan Murphy
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Murphy @ 2020-09-17 15:03 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: davem, f.fainelli, hkallweit1, mkubecek, netdev, linux-kernel

Andrew

On 9/15/20 6:29 PM, Dan Murphy wrote:
> Andrew
>
> On 9/15/20 3:21 PM, Andrew Lunn wrote:
>> On Tue, Sep 15, 2020 at 01:17:06PM -0500, Dan Murphy wrote:
>>> Add entries for the 100base-FX full and half duplex supported modes.
>>>
>>> $ ethtool eth0
>>>          Supported ports: [ TP    MII     FIBRE ]
>>>          Supported link modes:   10baseT/Half 10baseT/Full
>>>                                  100baseT/Half 100baseT/Full
>>>                                  100baseFX/Half 100baseFX/Full
>>>          Supported pause frame use: Symmetric Receive-only
>>>          Supports auto-negotiation: No
>>>          Supported FEC modes: Not reported
>>>          Advertised link modes:  10baseT/Half 10baseT/Full
>>>                                  100baseT/Half 100baseT/Full
>>>                                  100baseFX/Half 100baseFX/Full
>> I thought this PHY could not switch between TP and Fibre. It has a
>> strap which decides? So i would expect the supported modes to be
>> either BaseT or BaseFX. Not both. Same for Advertised?
>>
>>         Andrew
>
> I found that the phy-device was setting all these bits in phy_init in 
> features_init.
>
> My first pass was to clear all these bits as well because the PHY was 
> still advertising these modes.
>
> But you are right this PHY cannot switch without strapping.
>
> I can clear these bits.

I re-read your reply and this is just an example.  This patch really has 
nothing to do with any PHY as it is just adding in the new link modes.

Unless you comment wanted me to remove the TP and advertised modes from 
the example in the commit message?

Dan


>
> Dan
>

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

end of thread, other threads:[~2020-09-17 19:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 18:17 [PATCH net-next 0/3] 100base Fx link modes Dan Murphy
2020-09-15 18:17 ` [PATCH net-next 1/3] ethtool: Add 100base-FX link mode entries Dan Murphy
2020-09-15 20:10   ` Andrew Lunn
2020-09-15 23:26     ` Dan Murphy
2020-09-15 20:21   ` Andrew Lunn
2020-09-15 23:29     ` Dan Murphy
2020-09-17 15:03       ` Dan Murphy
2020-09-15 18:17 ` [PATCH net-next 2/3] net: dp83869: Add ability to advertise Fiber connection Dan Murphy
2020-09-15 20:17   ` Andrew Lunn
2020-09-16 20:54     ` Dan Murphy
2020-09-16 22:13       ` Andrew Lunn
2020-09-17 14:57         ` Dan Murphy
2020-09-15 18:17 ` [PATCH net-next 3/3] net: phy: dp83822: Update the fiber advertisement for speed Dan Murphy

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).