From: Andrew Lunn <andrew@lunn.ch>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Michal Kubecek <mkubecek@suse.cz>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jiri Pirko <jiri@resnulli.us>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Arun Ramadoss <arun.ramadoss@microchip.com>,
Woojung.Huh@microchip.com, kernel@pengutronix.de,
netdev@vger.kernel.org, UNGLinuxDriver@microchip.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v1 1/1] ethtool: netlink: do not return SQI value if link is down
Date: Thu, 4 Jul 2024 16:01:31 +0200 [thread overview]
Message-ID: <dbfa3bc1-fff0-4dc7-a9f2-6cd304d4eaf8@lunn.ch> (raw)
In-Reply-To: <20240704054007.969557-1-o.rempel@pengutronix.de>
On Thu, Jul 04, 2024 at 07:40:07AM +0200, Oleksij Rempel wrote:
> Do not attach SQI value if link is down. "SQI values are only valid if link-up
> condition is present" per OpenAlliance specification of 100Base-T1
> Interoperability Test suite [1]. The same rule would apply for other link
> types.
>
> [1] https://opensig.org/automotive-ethernet-specifications/#
>
> Fixes: 8066021915924 ("ethtool: provide UAPI for PHY Signal Quality Index (SQI)")
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
> net/ethtool/linkstate.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/net/ethtool/linkstate.c b/net/ethtool/linkstate.c
> index b2de2108b356a..370ae628b13a4 100644
> --- a/net/ethtool/linkstate.c
> +++ b/net/ethtool/linkstate.c
> @@ -37,6 +37,8 @@ static int linkstate_get_sqi(struct net_device *dev)
> mutex_lock(&phydev->lock);
> if (!phydev->drv || !phydev->drv->get_sqi)
> ret = -EOPNOTSUPP;
> + else if (!phydev->link)
> + ret = -ENETDOWN;
> else
> ret = phydev->drv->get_sqi(phydev);
> mutex_unlock(&phydev->lock);
> @@ -55,6 +57,8 @@ static int linkstate_get_sqi_max(struct net_device *dev)
> mutex_lock(&phydev->lock);
> if (!phydev->drv || !phydev->drv->get_sqi_max)
> ret = -EOPNOTSUPP;
> + else if (!phydev->link)
> + ret = -ENETDOWN;
> else
> ret = phydev->drv->get_sqi_max(phydev);
> mutex_unlock(&phydev->lock);
I guess this part is optional. I think i've always seen hard coded
values. But this is O.K.
> @@ -93,12 +97,12 @@ static int linkstate_prepare_data(const struct ethnl_req_info *req_base,
> data->link = __ethtool_get_link(dev);
>
> ret = linkstate_get_sqi(dev);
> - if (ret < 0 && ret != -EOPNOTSUPP)
> + if (ret < 0 && ret != -EOPNOTSUPP && ret != -ENETDOWN)
> goto out;
> data->sqi = ret;
So data->sqi becomes -ENETDOWN
> - if (data->sqi != -EOPNOTSUPP &&
> + if (data->sqi != -EOPNOTSUPP && data->sqi != -ENETDOWN &&
> nla_put_u32(skb, ETHTOOL_A_LINKSTATE_SQI, data->sqi))
> return -EMSGSIZE;
Thinking about the old code, if the driver returned something other
than -EOPNOTSUPP, it looks like the error code would make it to user
space. Is ethtool/iproute2 setup to correctly handle this? If it is,
maybe pass the -ENETDOWN to user space?
Andrew
next prev parent reply other threads:[~2024-07-04 14:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 5:40 Oleksij Rempel
2024-07-04 14:01 ` Andrew Lunn [this message]
2024-07-05 7:05 ` Oleksij Rempel
2024-07-08 13:29 ` Andrew Lunn
2024-07-06 1:00 ` Jakub Kicinski
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=dbfa3bc1-fff0-4dc7-a9f2-6cd304d4eaf8@lunn.ch \
--to=andrew@lunn.ch \
--cc=UNGLinuxDriver@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=arun.ramadoss@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@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
all inboxes | Powered by JetHome®