From patchwork Tue May 26 08:29:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 218556 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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 6F6A9C433DF for ; Tue, 26 May 2020 08:30:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CA7C2071A for ; Tue, 26 May 2020 08:30:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731518AbgEZIaF (ORCPT ); Tue, 26 May 2020 04:30:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728467AbgEZIaE (ORCPT ); Tue, 26 May 2020 04:30:04 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3141DC03E97E for ; Tue, 26 May 2020 01:30:04 -0700 (PDT) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jdUy7-0000e8-RB; Tue, 26 May 2020 10:29:51 +0200 Received: from ore by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1jdUy0-0007Jc-3k; Tue, 26 May 2020 10:29:44 +0200 From: Oleksij Rempel To: Andrew Lunn , "David S. Miller" , Florian Fainelli , Heiner Kallweit , Jakub Kicinski , Jonathan Corbet , Michal Kubecek , "John W. Linville" Cc: Oleksij Rempel , David Jander , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Russell King , mkl@pengutronix.de, Marek Vasut , Christian Herber , Amit Cohen , Petr Machata Subject: [PATCH ethtool v1] netlink: add LINKSTATE SQI support Date: Tue, 26 May 2020 10:29:42 +0200 Message-Id: <20200526082942.28073-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some PHYs provide Signal Quality Index (SQI) if the link is in active state. This information can help to diagnose cable and system design related issues. Signed-off-by: Oleksij Rempel --- netlink/desc-ethtool.c | 2 ++ netlink/settings.c | 16 ++++++++++++++++ uapi/linux/ethtool_netlink.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/netlink/desc-ethtool.c b/netlink/desc-ethtool.c index 76c6f13..f4559ea 100644 --- a/netlink/desc-ethtool.c +++ b/netlink/desc-ethtool.c @@ -91,6 +91,8 @@ static const struct pretty_nla_desc __linkstate_desc[] = { NLATTR_DESC_INVALID(ETHTOOL_A_LINKSTATE_UNSPEC), NLATTR_DESC_NESTED(ETHTOOL_A_LINKSTATE_HEADER, header), NLATTR_DESC_BOOL(ETHTOOL_A_LINKSTATE_LINK), + NLATTR_DESC_U32(ETHTOOL_A_LINKSTATE_SQI), + NLATTR_DESC_U32(ETHTOOL_A_LINKSTATE_SQI_MAX), }; static const struct pretty_nla_desc __debug_desc[] = { diff --git a/netlink/settings.c b/netlink/settings.c index 8be5a22..a6b2fba 100644 --- a/netlink/settings.c +++ b/netlink/settings.c @@ -604,6 +604,22 @@ int linkstate_reply_cb(const struct nlmsghdr *nlhdr, void *data) printf("\tLink detected: %s\n", val ? "yes" : "no"); } + if (tb[ETHTOOL_A_LINKSTATE_SQI]) { + uint32_t val = mnl_attr_get_u32(tb[ETHTOOL_A_LINKSTATE_SQI]); + + print_banner(nlctx); + printf("\tSQI: %u", val); + + if (tb[ETHTOOL_A_LINKSTATE_SQI_MAX]) { + uint32_t max; + + max = mnl_attr_get_u32(tb[ETHTOOL_A_LINKSTATE_SQI_MAX]); + printf("/%u\n", max); + } else { + printf("\n"); + } + } + return MNL_CB_OK; } diff --git a/uapi/linux/ethtool_netlink.h b/uapi/linux/ethtool_netlink.h index ad6d3a0..98e236c 100644 --- a/uapi/linux/ethtool_netlink.h +++ b/uapi/linux/ethtool_netlink.h @@ -197,6 +197,8 @@ enum { ETHTOOL_A_LINKSTATE_UNSPEC, ETHTOOL_A_LINKSTATE_HEADER, /* nest - _A_HEADER_* */ ETHTOOL_A_LINKSTATE_LINK, /* u8 */ + ETHTOOL_A_LINKSTATE_SQI, /* u32 */ + ETHTOOL_A_LINKSTATE_SQI_MAX, /* u32 */ /* add new constants above here */ __ETHTOOL_A_LINKSTATE_CNT,