All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steen Hegelund <steen.hegelund@microchip.com>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Lars Povlsen <lars.povlsen@microchip.com>,
	Bjarni Jonasson <bjarni.jonasson@microchip.com>,
	Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Microsemi List <microsemi@lists.bootlin.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH 2/3] net: sparx5: Add Sparx5 switchdev driver
Date: Mon, 30 Nov 2020 15:15:56 +0100	[thread overview]
Message-ID: <20201130141556.o4vg32lr4uykwxmu@mchp-dev-shegelun> (raw)
In-Reply-To: <20201129105245.GG1605@shell.armlinux.org.uk>

On 29.11.2020 10:52, Russell King - ARM Linux admin wrote:
>EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
>On Sat, Nov 28, 2020 at 10:28:28PM +0000, Russell King - ARM Linux admin wrote:
>> On Sat, Nov 28, 2020 at 08:06:16PM +0100, Andrew Lunn wrote:
>> > > +static void sparx5_phylink_mac_config(struct phylink_config *config,
>> > > +                               unsigned int mode,
>> > > +                               const struct phylink_link_state *state)
>> > > +{
>> > > + struct sparx5_port *port = netdev_priv(to_net_dev(config->dev));
>> > > + struct sparx5_port_config conf;
>> > > + int err = 0;
>> > > +
>> > > + conf = port->conf;
>> > > + conf.autoneg = state->an_enabled;
>> > > + conf.pause = state->pause;
>> > > + conf.duplex = state->duplex;
>> > > + conf.power_down = false;
>> > > + conf.portmode = state->interface;
>> > > +
>> > > + if (state->speed == SPEED_UNKNOWN) {
>> > > +         /* When a SFP is plugged in we use capabilities to
>> > > +          * default to the highest supported speed
>> > > +          */
>> >
>> > This looks suspicious.
>>
>> Yes, it looks highly suspicious. The fact that
>> sparx5_phylink_mac_link_up() is empty, and sparx5_phylink_mac_config()
>> does all the work suggests that this was developed before the phylink
>> re-organisation, and this code hasn't been updated for it.
>>
>> Any new code for the kernel really ought to be updated for the new
>> phylink methodology before it is accepted.
>>
>> Looking at sparx5_port_config(), it also seems to use
>> PHY_INTERFACE_MODE_1000BASEX for both 1000BASE-X and 2500BASE-X. All
>> very well for the driver to do that internally, but it's confusing
>> when it comes to reviewing this stuff, especially when people outside
>> of the driver (such as myself) reviewing it need to understand what's
>> going on with the configuration.
>

Hi Russell,

>There are other issues too.
>
>Looking at sparx5_get_1000basex_status(), we have:
>
> +       status->link = DEV2G5_PCS1G_LINK_STATUS_LINK_STATUS_GET(value) |
> +                      DEV2G5_PCS1G_LINK_STATUS_SYNC_STATUS_GET(value);
>

>Why is the link status the logical OR of these?

Oops: It should have been AND. Well spotted.

>
> +                       if ((lp_abil >> 8) & 1) /* symmetric pause */
> +                               status->pause = MLO_PAUSE_RX | MLO_PAUSE_TX;
> +                       if (lp_abil & (1 << 7)) /* asymmetric pause */
> +                               status->pause |= MLO_PAUSE_RX;
>
>is actually wrong, and I see I need to improve the documentation for
>mac_pcs_get_state(). The intention in the documentation was concerning
>hardware that indicated the _resolved_ status of pause modes. It was
>not intended that drivers resolve the pause modes themselves.
>
>Even so, the above is still wrong; it takes no account of what is being
>advertised at the local end. If one looks at the implementation in
>phylink_decode_c37_word(), one will notice there is code to deal with
>this.
>
>I think we ought to make phylink_decode_c37_word() and
>phylink_decode_sgmii_word() public functions, and then this driver can
>use these helpers to decode the link partner advertisement to the
>phylink state.

Should I remove the current implementation and use something like what
is in phylink_decode_c37_word() and phylink_decode_sgmii_word() in the
meantime?

>
>Does the driver need to provide an ethtool .get_link function? That
>seems to bypass phylink. Why can't ethtool_op_get_link() be used?

I think that I tried that earlier, but ran into problems.  I better
revisit this, and try out your suggestion.

>
>I think if ethtool_op_get_link() is used, we then have just one caller
>for sparx5_get_port_status(), which means "struct sparx5_port_status"
>can be eliminated and the code cleaned up to use the phylink decoding
>helpers.
>
>--
>RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
>FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

Thanks for your comments.

BR
Steen

---------------------------------------
Steen Hegelund
steen.hegelund@microchip.com

  parent reply	other threads:[~2020-11-30 14:17 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27 13:33 [RFC PATCH 0/3] net: Adding the Sparx5 Switch Driver Steen Hegelund
2020-11-27 13:33 ` [RFC PATCH 1/3] dt-bindings: net: sparx5: Add sparx5-switch bindings Steen Hegelund
2020-11-27 13:33   ` Steen Hegelund
2020-11-27 17:00   ` Andrew Lunn
2020-11-27 17:00     ` Andrew Lunn
2020-11-30 13:09     ` Steen Hegelund
2020-11-30 13:09       ` Steen Hegelund
2020-11-30 14:05       ` Andrew Lunn
2020-11-30 14:05         ` Andrew Lunn
2020-11-30 15:33         ` Steen Hegelund
2020-11-30 15:33           ` Steen Hegelund
2020-11-27 13:33 ` [RFC PATCH 2/3] net: sparx5: Add Sparx5 switchdev driver Steen Hegelund
2020-11-27 17:15   ` Andrew Lunn
2020-11-30 13:13     ` Steen Hegelund
2020-12-07 13:33       ` Jiri Pirko
2020-11-28 18:45   ` Andrew Lunn
2020-11-30 13:17     ` Steen Hegelund
2020-11-28 19:03   ` Andrew Lunn
2020-11-30 13:28     ` Steen Hegelund
2020-11-30 15:34       ` Andrew Lunn
2020-11-28 19:06   ` Andrew Lunn
2020-11-28 19:37     ` Russell King - ARM Linux admin
2020-11-28 20:07       ` Alexandre Belloni
2020-11-28 20:21         ` Andrew Lunn
2020-11-28 22:28     ` Russell King - ARM Linux admin
2020-11-29 10:52       ` Russell King - ARM Linux admin
2020-11-29 11:28         ` Russell King - ARM Linux admin
2020-11-30 14:39           ` Steen Hegelund
2020-11-30 14:54             ` Russell King - ARM Linux admin
2020-11-29 11:30         ` Russell King - ARM Linux admin
2020-11-30 14:30           ` Steen Hegelund
2020-11-30 14:50             ` Russell King - ARM Linux admin
2020-11-30 14:15         ` Steen Hegelund [this message]
2020-11-30 14:52           ` Russell King - ARM Linux admin
2020-11-30 14:10       ` Steen Hegelund
2020-11-28 19:24   ` Andrew Lunn
2020-12-01 11:11     ` Lars Povlsen
2020-11-29 17:16   ` Andrew Lunn
2020-11-30 13:33     ` Steen Hegelund
2020-11-29 17:26   ` Andrew Lunn
2020-11-30 13:31     ` Steen Hegelund
2020-11-29 17:35   ` Andrew Lunn
2020-11-30 14:42     ` Steen Hegelund
2020-11-27 13:33 ` [RFC PATCH 3/3] arm64: dts: sparx5: Add the Sparx5 switch node Steen Hegelund
2020-11-27 13:33   ` Steen Hegelund

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=20201130141556.o4vg32lr4uykwxmu@mchp-dev-shegelun \
    --to=steen.hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=bjarni.jonasson@microchip.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=lars.povlsen@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=masahiroy@kernel.org \
    --cc=microsemi@lists.bootlin.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.