diff mbox series

[ethtool,v2] Improve error message when SFP module is missing

Message ID 19fb6da036b04a465398f5b053b029ea04179aba.1606929734.git.baruch@tkos.co.il
State New
Headers show
Series [ethtool,v2] Improve error message when SFP module is missing | expand

Commit Message

Baruch Siach Dec. 2, 2020, 5:22 p.m. UTC
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(+)

Comments

Andrew Lunn Dec. 2, 2020, 5:23 p.m. UTC | #1
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
Michal Kubecek Dec. 6, 2020, 6:40 p.m. UTC | #2
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

>
diff mbox series

Patch

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;
 	}