diff mbox series

[v2,3/3] netlink: add LINKSTATE SQI support

Message ID 20200528115414.11516-4-o.rempel@pengutronix.de
State Superseded
Delegated to: John Linville
Headers show
Series Add support for SQI and master-slave | expand

Commit Message

Oleksij Rempel May 28, 2020, 11:54 a.m. UTC
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 <o.rempel@pengutronix.de>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 netlink/desc-ethtool.c |  2 ++
 netlink/settings.c     | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

Comments

Michal Kubecek June 7, 2020, 8:24 p.m. UTC | #1
On Thu, May 28, 2020 at 01:54:14PM +0200, Oleksij Rempel wrote:
> 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 <o.rempel@pengutronix.de>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

Reviewed-by: Michal Kubecek <mkubecek@suse.cz>

> ---
>  netlink/desc-ethtool.c |  2 ++
>  netlink/settings.c     | 16 ++++++++++++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/netlink/desc-ethtool.c b/netlink/desc-ethtool.c
> index b0a793c..8f4c36b 100644
> --- a/netlink/desc-ethtool.c
> +++ b/netlink/desc-ethtool.c
> @@ -93,6 +93,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 851de15..cd4b9a7 100644
> --- a/netlink/settings.c
> +++ b/netlink/settings.c
> @@ -638,6 +638,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;
>  }
>  
> -- 
> 2.26.2
>
diff mbox series

Patch

diff --git a/netlink/desc-ethtool.c b/netlink/desc-ethtool.c
index b0a793c..8f4c36b 100644
--- a/netlink/desc-ethtool.c
+++ b/netlink/desc-ethtool.c
@@ -93,6 +93,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 851de15..cd4b9a7 100644
--- a/netlink/settings.c
+++ b/netlink/settings.c
@@ -638,6 +638,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;
 }