2020-09-15 18:26:23

by Dan Murphy

[permalink] [raw]
Subject: [PATCH net-next 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: [ 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 <[email protected]>
---
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


2020-09-15 20:14:14

by Andrew Lunn

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

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

2020-09-15 22:11:08

by Andrew Lunn

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

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

2020-09-15 23:28:12

by Dan Murphy

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

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

2020-09-15 23:32:32

by Dan Murphy

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

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

2020-09-17 15:17:04

by Dan Murphy

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

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
>