netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next 03/10] net: add linkmode helper for setting flow control advertisement
Date: Sat, 15 Feb 2020 19:56:32 +0100	[thread overview]
Message-ID: <20200215185632.GT31084@lunn.ch> (raw)
In-Reply-To: <E1j2zhE-0003XA-E4@rmk-PC.armlinux.org.uk>

On Sat, Feb 15, 2020 at 03:49:32PM +0000, Russell King wrote:
> Add a linkmode helper to set the flow control advertisement in an
> ethtool linkmode mask according to the tx/rx capabilities. This
> implementation is moved from phylib, and documented with an
> analysis of its shortcomings.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/net/phy/linkmode.c   | 51 ++++++++++++++++++++++++++++++++++++
>  drivers/net/phy/phy_device.c | 17 +-----------
>  include/linux/linkmode.h     |  2 ++
>  3 files changed, 54 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/phy/linkmode.c b/drivers/net/phy/linkmode.c
> index 969918795228..f60560fe3499 100644
> --- a/drivers/net/phy/linkmode.c
> +++ b/drivers/net/phy/linkmode.c
> @@ -42,3 +42,54 @@ void linkmode_resolve_pause(const unsigned long *local_adv,
>  	}
>  }
>  EXPORT_SYMBOL_GPL(linkmode_resolve_pause);
> +
> +/**
> + * linkmode_set_pause - set the pause mode advertisement
> + * @advertisement: advertisement in ethtool format
> + * @tx: boolean from ethtool struct ethtool_pauseparam tx_pause member
> + * @rx: boolean from ethtool struct ethtool_pauseparam rx_pause member
> + *
> + * Configure the advertised Pause and Asym_Pause bits according to the
> + * capabilities of provided in @tx and @rx.
> + *
> + * We convert as follows:
> + *  tx rx  Pause AsymDir
> + *  0  0   0     0
> + *  0  1   1     1
> + *  1  0   0     1
> + *  1  1   1     0
> + *
> + * Note: this translation from ethtool tx/rx notation to the advertisement
> + * is actually very problematical. Here are some examples:
> + *
> + * For tx=0 rx=1, meaning transmit is unsupported, receive is supported:
> + *
> + *  Local device  Link partner
> + *  Pause AsymDir Pause AsymDir Result
> + *    1     1       1     0     TX + RX - but we have no TX support.
> + *    1     1       0     1	Only this gives RX only
> + *
> + * For tx=1 rx=1, meaning we have the capability to transmit and receive
> + * pause frames:
> + *
> + *  Local device  Link partner
> + *  Pause AsymDir Pause AsymDir Result
> + *    1     0       0     1     Disabled - but since we do support tx and rx,
> + *				this should resolve to RX only.
> + *
> + * Hence, asking for:
> + *  rx=1 tx=0 gives Pause+AsymDir advertisement, but we may end up
> + *            resolving to tx+rx pause or only rx pause depending on
> + *            the partners advertisement.
> + *  rx=0 tx=1 gives AsymDir only, which will only give tx pause if
> + *            the partners advertisement allows it.
> + *  rx=1 tx=1 gives Pause only, which will only allow tx+rx pause
> + *            if the other end also advertises Pause.
> + */

It is good to document this.

With the change to netlink ethtool, we have the option to change the
interface to user space, or at least, easily add another way for
userspace to configure things. Maybe you can think of a better API?

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

  reply	other threads:[~2020-02-15 18:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-15 15:48 [PATCH net-next 00/10] Pause updates for phylib and phylink Russell King - ARM Linux admin
2020-02-15 15:49 ` [PATCH net-next 02/10] net: add helpers to resolve negotiated flow control Russell King
2020-02-15 18:49   ` Andrew Lunn
2020-02-15 23:18     ` Russell King - ARM Linux admin
2020-02-15 15:49 ` [PATCH net-next 03/10] net: add linkmode helper for setting flow control advertisement Russell King
2020-02-15 18:56   ` Andrew Lunn [this message]
2020-02-15 23:54     ` Russell King - ARM Linux admin
2020-02-15 15:49 ` [PATCH net-next 04/10] net: phylink: remove pause mode ethtool setting for fixed links Russell King
2020-02-15 18:57   ` Andrew Lunn
2020-02-15 15:49 ` [PATCH net-next 05/10] net: phylink: ensure manual flow control is selected appropriately Russell King
2020-02-15 19:00   ` Andrew Lunn
2020-02-15 15:49 ` [PATCH net-next 06/10] net: phylink: use phylib resolved flow control modes Russell King
2020-02-15 15:49 ` [PATCH net-next 07/10] net: phylink: resolve fixed link flow control Russell King
2020-02-15 19:02   ` Andrew Lunn
2020-02-15 15:49 ` [PATCH net-next 08/10] net: phylink: allow ethtool -A to change flow control advertisement Russell King
2020-02-15 19:04   ` Andrew Lunn
2020-02-15 15:50 ` [PATCH net-next 09/10] net: phylink: improve initial mac configuration Russell King
2020-02-15 19:06   ` Andrew Lunn
2020-02-15 15:50 ` [PATCH net-next 10/10] net: phylink: clarify flow control settings in documentation Russell King
2020-02-15 19:08   ` Andrew Lunn
2020-02-15 21:11 ` [PATCH net-next 00/10] Pause updates for phylib and phylink Florian Fainelli
2020-02-16  0:00   ` Russell King - ARM Linux admin
2020-02-15 23:57 ` [PATCH net-next 01/10] net: linkmode: make linkmode_test_bit() take const pointer Russell King
2020-02-17  3:40 ` [PATCH net-next 00/10] Pause updates for phylib and phylink David Miller

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=20200215185632.GT31084@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    /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).