From: Heiner Kallweit <hkallweit1@gmail.com>
To: Vladimir Oltean <olteanv@gmail.com>,
Julia Lawall <julia.lawall@inria.fr>
Cc: netdev <netdev@vger.kernel.org>, Joe Perches <joe@perches.com>,
Russell King - ARM Linux admin <linux@armlinux.org.uk>,
Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: question about drivers/net/dsa/sja1105/sja1105_main.c
Date: Fri, 3 Apr 2020 23:02:44 +0200 [thread overview]
Message-ID: <7fc8f8d5-285a-9ec0-23c5-c867347c4feb@gmail.com> (raw)
In-Reply-To: <CA+h21hrP-0Tdpqje-xbPHmh+v+zndsFyxaEfadMwdAHY+9QK+g@mail.gmail.com>
On 03.04.2020 16:36, Vladimir Oltean wrote:
> Hi Julia,
>
> On Fri, 3 Apr 2020 at 16:46, Julia Lawall <julia.lawall@inria.fr> wrote:
>>
>> Hello,
>>
>> The function sja1105_static_config_reload in sja1105_main.c contains the
>> code:
>>
>> if (!an_enabled) {
>> int speed = SPEED_UNKNOWN;
>>
>> if (bmcr & BMCR_SPEED1000)
>> speed = SPEED_1000;
>> else if (bmcr & BMCR_SPEED100)
>> speed = SPEED_100;
>> else if (bmcr & BMCR_SPEED10)
>> speed = SPEED_10;
>>
>> sja1105_sgmii_pcs_force_speed(priv, speed);
>> }
>>
>> The last test bmcr & BMCR_SPEED10 does not look correct, because according
>> to include/uapi/linux/mii.h, BMCR_SPEED10 is 0. What should be done
>> instead?
>>
It's right that this is not correct. You can check genphy_read_status_fixed()
for how it's done there.
>> thanks,
>> julia
>
> Thanks for pointing out, you raise a good point.
> Correct usage would be:
>
> include/uapi/linux/mii.h:
> #define BMCR_SPEED_MASK 0x2040
>
> drivers/net/dsa/sja1105/sja1105_main.c:
> int speed = SPEED_UNKNOWN;
>
> if (bmcr & BMCR_SPEED_MASK == BMCR_SPEED1000)
> speed = SPEED_1000;
> else if (bmcr & BMCR_SPEED_MASK == BMCR_SPEED100)
> speed = SPEED_100;
> else if (bmcr & BMCR_SPEED_MASK == BMCR_SPEED10)
> speed = SPEED_10;
>
> but the BMCR_SPEED_MASK doesn't exist, it looks like. I believe that
> is because drivers (or the PHY library) don't typically need to read
> the speed from the MII_BMCR register, they just need to write it. If
> the PHY library maintainers think there is any value in defining
> BMCR_SPEED_MASK as part of the UAPI, we can do that. Otherwise, the
> definition can be restricted to drivers/net/dsa/sja1105/sja1105.h.
>
> Thanks,
> -Vladimir
>
next prev parent reply other threads:[~2020-04-03 21:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-03 13:46 question about drivers/net/dsa/sja1105/sja1105_main.c Julia Lawall
2020-04-03 14:36 ` Vladimir Oltean
2020-04-03 21:02 ` Heiner Kallweit [this message]
2020-04-03 21:10 ` Joe Perches
2020-04-04 8:37 ` Vladimir Oltean
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=7fc8f8d5-285a-9ec0-23c5-c867347c4feb@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=joe@perches.com \
--cc=julia.lawall@inria.fr \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
/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