netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ethtool v2] Improve error message when SFP module is missing
@ 2020-12-02 17:22 Baruch Siach
  2020-12-02 17:23 ` Andrew Lunn
  2020-12-06 18:40 ` Michal Kubecek
  0 siblings, 2 replies; 3+ messages in thread
From: Baruch Siach @ 2020-12-02 17:22 UTC (permalink / raw)
  To: Michal Kubecek; +Cc: netdev, Andrew Lunn, Baruch Siach

ETHTOOL_GMODULEINFO request success indicates that SFP cage is present.
Failure of ETHTOOL_GMODULEEEPROM is most likely because SFP module is
not plugged in. Add an indication to the user as to what might be the
reason for the failure.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
v2: Limit message to likely errno values (Andrew Lunn)
---
 ethtool.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ethtool.c b/ethtool.c
index 1d9067e774af..63b3a095eded 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4855,7 +4855,11 @@ static int do_getmodule(struct cmd_context *ctx)
 	eeprom->offset = geeprom_offset;
 	err = send_ioctl(ctx, eeprom);
 	if (err < 0) {
+		int saved_errno = errno;
 		perror("Cannot get Module EEPROM data");
+		if (saved_errno == ENODEV || saved_errno == EIO ||
+				saved_errno == ENXIO)
+			fprintf(stderr, "SFP module not in cage?\n");
 		free(eeprom);
 		return 1;
 	}
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH ethtool v2] Improve error message when SFP module is missing
  2020-12-02 17:22 [PATCH ethtool v2] Improve error message when SFP module is missing Baruch Siach
@ 2020-12-02 17:23 ` Andrew Lunn
  2020-12-06 18:40 ` Michal Kubecek
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2020-12-02 17:23 UTC (permalink / raw)
  To: Baruch Siach; +Cc: Michal Kubecek, netdev

On Wed, Dec 02, 2020 at 07:22:14PM +0200, Baruch Siach wrote:
> ETHTOOL_GMODULEINFO request success indicates that SFP cage is present.
> Failure of ETHTOOL_GMODULEEEPROM is most likely because SFP module is
> not plugged in. Add an indication to the user as to what might be the
> reason for the failure.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>

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

    Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH ethtool v2] Improve error message when SFP module is missing
  2020-12-02 17:22 [PATCH ethtool v2] Improve error message when SFP module is missing Baruch Siach
  2020-12-02 17:23 ` Andrew Lunn
@ 2020-12-06 18:40 ` Michal Kubecek
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Kubecek @ 2020-12-06 18:40 UTC (permalink / raw)
  To: Baruch Siach; +Cc: netdev, Andrew Lunn

[-- Attachment #1: Type: text/plain, Size: 1149 bytes --]

On Wed, Dec 02, 2020 at 07:22:14PM +0200, Baruch Siach wrote:
> ETHTOOL_GMODULEINFO request success indicates that SFP cage is present.
> Failure of ETHTOOL_GMODULEEEPROM is most likely because SFP module is
> not plugged in. Add an indication to the user as to what might be the
> reason for the failure.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>

Applied (with minor whitespace formatting cleanup), thank you.

Michal

> ---
> v2: Limit message to likely errno values (Andrew Lunn)
> ---
>  ethtool.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/ethtool.c b/ethtool.c
> index 1d9067e774af..63b3a095eded 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -4855,7 +4855,11 @@ static int do_getmodule(struct cmd_context *ctx)
>  	eeprom->offset = geeprom_offset;
>  	err = send_ioctl(ctx, eeprom);
>  	if (err < 0) {
> +		int saved_errno = errno;
>  		perror("Cannot get Module EEPROM data");
> +		if (saved_errno == ENODEV || saved_errno == EIO ||
> +				saved_errno == ENXIO)
> +			fprintf(stderr, "SFP module not in cage?\n");
>  		free(eeprom);
>  		return 1;
>  	}
> -- 
> 2.29.2
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-06 18:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02 17:22 [PATCH ethtool v2] Improve error message when SFP module is missing Baruch Siach
2020-12-02 17:23 ` Andrew Lunn
2020-12-06 18:40 ` Michal Kubecek

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).