From patchwork Wed Dec 2 17:22:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 11946495 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C7A7C71156 for ; Wed, 2 Dec 2020 17:23:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3C1522253 for ; Wed, 2 Dec 2020 17:23:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389202AbgLBRXH (ORCPT ); Wed, 2 Dec 2020 12:23:07 -0500 Received: from guitar.tcltek.co.il ([192.115.133.116]:51084 "EHLO mx.tkos.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389091AbgLBRXG (ORCPT ); Wed, 2 Dec 2020 12:23:06 -0500 Received: from tarshish.tkos.co.il (unknown [10.0.8.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx.tkos.co.il (Postfix) with ESMTPS id 129DC44048F; Wed, 2 Dec 2020 19:22:23 +0200 (IST) From: Baruch Siach To: Michal Kubecek Cc: netdev@vger.kernel.org, Andrew Lunn , Baruch Siach Subject: [PATCH ethtool v2] Improve error message when SFP module is missing Date: Wed, 2 Dec 2020 19:22:14 +0200 Message-Id: <19fb6da036b04a465398f5b053b029ea04179aba.1606929734.git.baruch@tkos.co.il> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: mkubecek+ethtool@suse.cz 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 Reviewed-by: Andrew Lunn --- 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; }