From: Lukasz Stelmach <l.stelmach@samsung.com>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: "Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Bartłomiej Żolnierkiewicz" <b.zolnierkie@samsung.com>,
"Marek Szyprowski" <m.szyprowski@samsung.com>
Subject: Re: [PATCH] net: phy: Prevent reporting advertised modes when autoneg is off
Date: Thu, 15 Oct 2020 01:37:37 +0200 [thread overview]
Message-ID: <dleftj8sc8751a.fsf%l.stelmach@samsung.com> (raw)
In-Reply-To: <20201014220434.GR1551@shell.armlinux.org.uk> (Russell King's message of "Wed, 14 Oct 2020 23:04:34 +0100")
[-- Attachment #1: Type: text/plain, Size: 4636 bytes --]
It was <2020-10-14 śro 23:04>, when Russell King - ARM Linux admin wrote:
> On Wed, Oct 14, 2020 at 04:39:47PM +0200, Lukasz Stelmach wrote:
>> It was <2020-10-14 śro 14:32>, when Russell King - ARM Linux admin wrote:
>> > In any case, the mii.c code does fill in the advertising mask even
>> > when autoneg is disabled, because, rightly or wrongly, the advertising
>> > mask contains more than just the link modes, it includes the
>> > interface(s) as well. Your change means phylib no longer reports the
>> > interface modes which is at odds with the mii.c code.
>>
>> I am afraid you are wrong. There is a rather big if()[1], which
>> depending on AN beeing enabled fills more or less information. Yes this
>> if() looks like it has been yanked from mii_ethtool_gset(). When
>> advertising is converted and copied to cmd->link_modes.advertising at
>> the end of mii_ethtool_get_link_ksettings() it is 0[2] if autonegotiation
>> is disabled.
>>
>> [1]
>> https://protect2.fireeye.com/v1/url?k=d1d33944-8c07852c-d1d2b20b-0cc47a3356b2-cede44db8a43e7c3&q=1&e=d1dea895-d1df-46b9-8413-ac329b0bbfa7&u=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv5.9%2Fsource%2Fdrivers%2Fnet%2Fmii.c%23L174
>> [2]
>> https://protect2.fireeye.com/v1/url?k=c840e942-9594552a-c841620d-0cc47a3356b2-510c0749446ea7df&q=1&e=d1dea895-d1df-46b9-8413-ac329b0bbfa7&u=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv5.9%2Fsource%2Fdrivers%2Fnet%2Fmii.c%23L215
>
> I'm very sorry, but I have to disagree. I'll quote the code here:
>
> advertising = ADVERTISED_TP | ADVERTISED_MII;
>
> // This is your big if()
> if (bmcr & BMCR_ANENABLE) {
> advertising |= ADVERTISED_Autoneg;
> ...
> } else {
> ...
> }
>
> ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
> advertising);
>
> So, when AN is disabled, we still end up with TP and MII in the
> advertised link modes. I call TP and MII "interface modes" above
> to separate them from the "link modes" that describe the speed and
> duplex etc.
Yes.
> Note that only lp_advertising is zeroed in the "else" clause of
> the above "if" statement - advertising remains as-is with TP and MII
> set.
Yes.
> Your patch, on the other hand, merely avoids setting anything in
> cmd->link_modes.advertising, which means we do not end up with the
> "interface modes".
>
> I hope that this helps you see my point.
Yes.
Thanks.
tl;dr: v2 is coming.
Let's take a look at what ethtool prints. With AN enabled
--8<---------------cut here---------------start------------->8---
Settings for enx00249b14f06e:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes
[...]
Link detected: yes
--8<---------------cut here---------------end--------------->8---
with AN disabled
--8<---------------cut here---------------start------------->8---
Settings for enx00249b14f06e:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
[...]
Link detected: yes
--8<---------------cut here---------------end--------------->8---
The driver is ax88179_178a which calls mii_ethtool_get_link_ksettings()
The first line that differs is "Advertised link modes". Apparently[1]
ethtool does not consider ADVERTISED_TP and ADVERTISED_MII as
interesting modes. Indeed I should add an else clause to clear
cmd->link_modes.advertising (and lp_advertising) and set only
ETHTOOL_LINK_MODE_TP_BIT and ETHTOOL_LINK_MODE_MII_BIT.
[1] https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/tree/ethtool.c?h=v5.8#n656
--
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
prev parent reply other threads:[~2020-10-14 23:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20201014125655eucas1p129ba3322a72b17a19a533e7a2890ff88@eucas1p1.samsung.com>
2020-10-14 12:56 ` Łukasz Stelmach
2020-10-14 13:32 ` Russell King - ARM Linux admin
[not found] ` <CGME20201014144018eucas1p101424a57f5bf63eabb3dc24177551dff@eucas1p1.samsung.com>
2020-10-14 14:39 ` Lukasz Stelmach
2020-10-14 22:04 ` Russell King - ARM Linux admin
[not found] ` <CGME20201014233749eucas1p239bd9b81aca3ddaa1d589ffeed930a08@eucas1p2.samsung.com>
2020-10-14 23:37 ` Lukasz Stelmach [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dleftj8sc8751a.fsf%l.stelmach@samsung.com \
--to=l.stelmach@samsung.com \
--cc=andrew@lunn.ch \
--cc=b.zolnierkie@samsung.com \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=m.szyprowski@samsung.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®