diff mbox series

[ethtool] Improve error message when SFP module is missing

Message ID 4267a91b40ef4dff755c4476757e2b17f48dbf57.1606802961.git.baruch@tkos.co.il
State New
Headers show
Series [ethtool] Improve error message when SFP module is missing | expand

Commit Message

Baruch Siach Dec. 1, 2020, 6:09 a.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>
---
 ethtool.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andrew Lunn Dec. 1, 2020, 6:36 p.m. UTC | #1
On Tue, Dec 01, 2020 at 08:09:21AM +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>
> ---
>  ethtool.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/ethtool.c b/ethtool.c
> index 1d9067e774af..6d785f830ffa 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -4856,6 +4856,7 @@ static int do_getmodule(struct cmd_context *ctx)
>  	err = send_ioctl(ctx, eeprom);
>  	if (err < 0) {
>  		perror("Cannot get Module EEPROM data");
> +		fprintf(stderr, "SFP module not in cage?\n");

I wonder if this should be limited to ENODEV and EIO? ENOMEM or
EINVAL is probably not going to be fixed by inserting a module.

       Andrew
diff mbox series

Patch

diff --git a/ethtool.c b/ethtool.c
index 1d9067e774af..6d785f830ffa 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4856,6 +4856,7 @@  static int do_getmodule(struct cmd_context *ctx)
 	err = send_ioctl(ctx, eeprom);
 	if (err < 0) {
 		perror("Cannot get Module EEPROM data");
+		fprintf(stderr, "SFP module not in cage?\n");
 		free(eeprom);
 		return 1;
 	}