netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, ioana.ciornei@nxp.com
Subject: Re: [PATCH net-next] dpaa2-eth: Add pause frame support
Date: Fri, 23 Aug 2019 18:30:37 +0200	[thread overview]
Message-ID: <20190823163037.GA19727@lunn.ch> (raw)
In-Reply-To: <1566573579-9940-1-git-send-email-ruxandra.radulescu@nxp.com>

> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
> @@ -78,29 +78,20 @@ static int
>  dpaa2_eth_get_link_ksettings(struct net_device *net_dev,
>  			     struct ethtool_link_ksettings *link_settings)
>  {
> -	struct dpni_link_state state = {0};
> -	int err = 0;
>  	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
>  
> -	err = dpni_get_link_state(priv->mc_io, 0, priv->mc_token, &state);
> -	if (err) {
> -		netdev_err(net_dev, "ERROR %d getting link state\n", err);
> -		goto out;
> -	}
> -
>  	/* At the moment, we have no way of interrogating the DPMAC
>  	 * from the DPNI side - and for that matter there may exist
>  	 * no DPMAC at all. So for now we just don't report anything
>  	 * beyond the DPNI attributes.
>  	 */
> -	if (state.options & DPNI_LINK_OPT_AUTONEG)
> +	if (priv->link_state.options & DPNI_LINK_OPT_AUTONEG)
>  		link_settings->base.autoneg = AUTONEG_ENABLE;
> -	if (!(state.options & DPNI_LINK_OPT_HALF_DUPLEX))
> +	if (!(priv->link_state.options & DPNI_LINK_OPT_HALF_DUPLEX))
>  		link_settings->base.duplex = DUPLEX_FULL;
> -	link_settings->base.speed = state.rate;
> +	link_settings->base.speed = priv->link_state.rate;
>  
> -out:
> -	return err;
> +	return 0;

Hi Ioana

I think this patch can be broken up a bit, to help review.

It looks like this change to report state via priv->link_state should
be a separate patch. I think this change can be made without the pause
changes. That then makes the pause changes themselves simpler.

> +static void dpaa2_eth_get_pauseparam(struct net_device *net_dev,
> +				     struct ethtool_pauseparam *pause)
> +{
> +	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
> +	u64 link_options = priv->link_state.options;
> +
> +	pause->rx_pause = !!(link_options & DPNI_LINK_OPT_PAUSE);
> +	pause->tx_pause = pause->rx_pause ^
> +			  !!(link_options & DPNI_LINK_OPT_ASYM_PAUSE);

Since you don't support auto-neg, you should set pause->autoneg to
false. It probably already is set to false, by a memset, but setting
it explicitly is a form of documentation, this hardware only supports
forced pause configuration.

> +}
> +
> +static int dpaa2_eth_set_pauseparam(struct net_device *net_dev,
> +				    struct ethtool_pauseparam *pause)
> +{
> +	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
> +	struct dpni_link_cfg cfg = {0};
> +	int err;
> +
> +	if (!dpaa2_eth_has_pause_support(priv)) {
> +		netdev_info(net_dev, "No pause frame support for DPNI version < %d.%d\n",
> +			    DPNI_PAUSE_VER_MAJOR, DPNI_PAUSE_VER_MINOR);
> +		return -EOPNOTSUPP;
> +	}
> +
> +	if (pause->autoneg)
> +		netdev_err(net_dev, "Pause frame autoneg not supported\n");

And here you should return -EOPNOTSUPP. No need for an netdev_err. It
is not an error, you simply don't support it.

There is also the issue of what is the PHY doing? It would not be good
if the MAC is configured one way, but the PHY is advertising something
else. So it appears you have no control over the PHY. But i assume you
know what the PHY is actually doing? Does it advertise pause/asym
pause?

It might be, to keep things consistent, we only accept pause
configuration when auto-neg in general is disabled.

   Andrew

  reply	other threads:[~2019-08-23 16:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23 15:19 [PATCH net-next] dpaa2-eth: Add pause frame support Ioana Radulescu
2019-08-23 16:30 ` Andrew Lunn [this message]
2019-08-26 13:00   ` Ioana Ciocoi Radulescu

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=20190823163037.GA19727@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=ioana.ciornei@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=ruxandra.radulescu@nxp.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;
as well as URLs for NNTP newsgroup(s).