From: Sean Anderson <sean.anderson@seco.com>
To: Antoine Tenart <atenart@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org
Cc: Claudiu Beznea <claudiu.beznea@microchip.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Russell King <linux@armlinux.org.uk>
Subject: Re: [PATCH v3 2/2] net: macb: Clean up macb_validate
Date: Thu, 14 Oct 2021 12:01:25 -0400 [thread overview]
Message-ID: <08913b53-0960-d8f4-9209-51a059b62fa2@seco.com> (raw)
In-Reply-To: <163411375475.451779.17785363770684815611@kwain>
On 10/13/21 4:29 AM, Antoine Tenart wrote:
> Quoting Sean Anderson (2021-10-12 21:46:44)
>> + /* There are three major types of interfaces we support:
>> + * - (R)MII supporting 10/100 Mbit/s
>> + * - GMII, RGMII, and SGMII supporting 10/100/1000 Mbit/s
>> + * - 10GBASER supporting 10 Gbit/s only
>> + * Because GMII and MII both support 10/100, GMII falls through to MII.
>> + *
>> + * If we can't support an interface mode, we just clear the supported
>> + * mask and return. The major complication is that if we get
>> + * PHY_INTERFACE_MODE_NA, we must return all modes we support. Because
>> + * of this, NA starts at the top of the switch and falls all the way to
>> + * the bottom, and doesn't return early if we don't support a
>> + * particular mode.
>> + */
>> + switch (state->interface) {
>> + case PHY_INTERFACE_MODE_NA:
>> + case PHY_INTERFACE_MODE_10GBASER:
>> + if (bp->caps & MACB_CAPS_HIGH_SPEED &&
>> + bp->caps & MACB_CAPS_PCS &&
>> + bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE) {
>> + phylink_set_10g_modes(mask);
>> + phylink_set(mask, 10000baseKR_Full);
>> + } else if (one) {
>> + bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
>> + return;
>> + }
>> + if (one)
>> + break;
>
> This can go in the first if block.
OK.
>> + fallthrough;
>> + case PHY_INTERFACE_MODE_GMII:
>> + case PHY_INTERFACE_MODE_RGMII:
>> + case PHY_INTERFACE_MODE_RGMII_ID:
>> + case PHY_INTERFACE_MODE_RGMII_RXID:
>> + case PHY_INTERFACE_MODE_RGMII_TXID:
>> + case PHY_INTERFACE_MODE_SGMII:
>> + if (macb_is_gem(bp)) {
>> + if (bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE) {
>
> Is not having MACB_CAPS_GIGABIT_MODE_AVAILABLE acceptable here, or
> should the two above checks be merged?
As I understand it, macb_is_gem does not imply GIGABIT_MODE. I'm not
sure if GIGABIT_MODE implies macb_is_gem. The logic here is mostly to
match that in prepare()/config(). From what I can gather, all accesses
to GEM registers are protected by macb_is_gem.
--Sean
>> + phylink_set(mask, 1000baseT_Full);
>> + phylink_set(mask, 1000baseX_Full);
>> + if (!(bp->caps & MACB_CAPS_NO_GIGABIT_HALF))
>> + phylink_set(mask, 1000baseT_Half);
>> + }
>> + } else if (one) {
>> + bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
>> + return;
>> + }
>> + fallthrough;
>> + case PHY_INTERFACE_MODE_MII:
>> + case PHY_INTERFACE_MODE_RMII:
>> + phylink_set(mask, 10baseT_Half);
>> + phylink_set(mask, 10baseT_Full);
>> + phylink_set(mask, 100baseT_Half);
>> + phylink_set(mask, 100baseT_Full);
>> + break;
>> + default:
>> bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
>> return;
>> }
>
> (For readability, it's not for me to decide in the end).
>
> Thanks,
> Antoine
>
prev parent reply other threads:[~2021-10-14 16:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 19:46 [PATCH v3 1/2] net: macb: Allow SGMII only if we are a GEM in mac_validate Sean Anderson
2021-10-12 19:46 ` [PATCH v3 2/2] net: macb: Clean up macb_validate Sean Anderson
2021-10-13 8:29 ` Antoine Tenart
2021-10-14 16:01 ` Sean Anderson [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=08913b53-0960-d8f4-9209-51a059b62fa2@seco.com \
--to=sean.anderson@seco.com \
--cc=atenart@kernel.org \
--cc=claudiu.beznea@microchip.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.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