netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Heiner Kallweit <hkallweit1@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>, David Miller <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] net: phy: improve pause mode reporting in phy_print_status
Date: Sun, 5 May 2019 10:10:37 -0700	[thread overview]
Message-ID: <65df73ce-9213-2b6a-6894-f68bf54a5f3d@gmail.com> (raw)
In-Reply-To: <1ea97344-6971-44dd-2191-9a8db0d2c10d@gmail.com>



On 5/5/2019 10:03 AM, Heiner Kallweit wrote:
> So far we report symmetric pause only, and we don't consider the local
> pause capabilities. Let's properly consider local and remote
> capabilities, and report also asymmetric pause.

I would go one step further which is to print what is the link state of
RX/TX pause, so something like:

- local RX/TX pause advertisement
- link partnr RX/TX pause advertisement
- RX/TX being enabled for the link (auto-negotiated or manual)

this sort of duplicates what ethtool offers already but arguably so does
printing the link state so this would not be that big of a stretch.

I would make the print be something like:

Link is Up - 1Gb/Full - local pause: rx/tx, lpa pause: rx/tx, link
pause: auto-negotiated
Link is Up - 1Gb/Full - local pause: rx/tx, lpa pause: rx/tx, link
pause: forced off
Link is Up - 1Gb/Full - local pause: rx/tx, lpa pause: rx/tx, link
pause: forced on


Thanks!

> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/net/phy/phy.c | 28 +++++++++++++++++++++++++++-
>  1 file changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 1a146c5c5..e88854292 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -60,6 +60,32 @@ static void phy_link_down(struct phy_device *phydev, bool do_carrier)
>  	phy_led_trigger_change_speed(phydev);
>  }
>  
> +static const char *phy_pause_str(struct phy_device *phydev)
> +{
> +	bool local_pause, local_asym_pause;
> +
> +	if (phydev->autoneg == AUTONEG_DISABLE)
> +		goto no_pause;
> +
> +	local_pause = linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,
> +					phydev->advertising);
> +	local_asym_pause = linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
> +					     phydev->advertising);
> +
> +	if (local_pause && phydev->pause)
> +		return "rx/tx";
> +
> +	if (local_asym_pause && phydev->asym_pause) {
> +		if (local_pause)
> +			return "rx";
> +		if (phydev->pause)
> +			return "tx";
> +	}
> +
> +no_pause:
> +	return "off";
> +}
> +
>  /**
>   * phy_print_status - Convenience function to print out the current phy status
>   * @phydev: the phy_device struct
> @@ -71,7 +97,7 @@ void phy_print_status(struct phy_device *phydev)
>  			"Link is Up - %s/%s - flow control %s\n",
>  			phy_speed_to_str(phydev->speed),
>  			phy_duplex_to_str(phydev->duplex),
> -			phydev->pause ? "rx/tx" : "off");
> +			phy_pause_str(phydev));
>  	} else	{
>  		netdev_info(phydev->attached_dev, "Link is Down\n");
>  	}
> 

-- 
Florian

  reply	other threads:[~2019-05-05 17:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-05 17:03 [PATCH net-next] net: phy: improve pause mode reporting in phy_print_status Heiner Kallweit
2019-05-05 17:10 ` Florian Fainelli [this message]
2019-05-05 17:31   ` Heiner Kallweit
2019-05-05 18:46     ` Florian Fainelli
2019-05-05 19:06       ` Heiner Kallweit
2019-05-05 19:12         ` Florian Fainelli
2019-05-05 19:19           ` Heiner Kallweit
2019-05-07 19:41 ` 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=65df73ce-9213-2b6a-6894-f68bf54a5f3d@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.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 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).