Skip to contentSkip to conversation

Fix condition for showing MDI-X status

PATCH Superseded [email protected] 3 participants 7 messages Oct 27, 2021 – Oct 28, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Fix condition for showing MDI-X status

From: Bastian Germann <[email protected]>

Currently there is a filter for showing the MDI-X info. It is only presented for twisted pair ports, which suppresses the info, e.g., for MII. I found that issue running ethtool on a br53 switch port.

Despite the enum names, I cannot find documentation on the MDIX fields only being valid for twisted pair ports -- if they are present, they should be valid. But maybe I am mistaken.

Additionally, fix a duplicate condition.

Bastian Germann (2):
netlink: settings: Correct duplicate condition
netlink: settings: Drop port filter for MDI-X

 netlink/settings.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 netlink: settings: Correct duplicate condition

From: Bastian Germann <[email protected]>

tb's fields ETHTOOL_A_LINKINFO_TP_MDIX and ETHTOOL_A_LINKINFO_TP_MDIX_CTRL are used in this case. The condition is duplicate for the former. Fix that.

---
 netlink/settings.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
netlink/settings.c +1 -1
index 6d10a07..c4f5d61 100644
@@ -560,7 +560,7 @@ int linkinfo_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 		print_enum(names_transceiver, ARRAY_SIZE(names_transceiver),
 			   val, "Transceiver");
 	}
-	if (tb[ETHTOOL_A_LINKINFO_TP_MDIX] && tb[ETHTOOL_A_LINKINFO_TP_MDIX] &&
+	if (tb[ETHTOOL_A_LINKINFO_TP_MDIX] && tb[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] &&
 	    port == PORT_TP) {
 		uint8_t mdix = mnl_attr_get_u8(tb[ETHTOOL_A_LINKINFO_TP_MDIX]);
 		uint8_t mdix_ctrl =
Signature · 1 line
2.30.2
#3 lore raw

PATCH 2/2 netlink: settings: Drop port filter for MDI-X

In reply to [email protected]

From: Bastian Germann <[email protected]>

The port == PORT_TP condition on printing linkinfo's MDI-X field prevents ethtool from printing that info even if it is present and valid, e.g. with the port being MII and still having that info.

---
 netlink/settings.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
netlink/settings.c +1 -2
index c4f5d61..4da251b 100644
@@ -560,8 +560,7 @@ int linkinfo_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 		print_enum(names_transceiver, ARRAY_SIZE(names_transceiver),
 			   val, "Transceiver");
 	}
-	if (tb[ETHTOOL_A_LINKINFO_TP_MDIX] && tb[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] &&
-	    port == PORT_TP) {
+	if (tb[ETHTOOL_A_LINKINFO_TP_MDIX] && tb[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL]) {
 		uint8_t mdix = mnl_attr_get_u8(tb[ETHTOOL_A_LINKINFO_TP_MDIX]);
 		uint8_t mdix_ctrl =
 			mnl_attr_get_u8(tb[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL]);
Signature · 1 line
2.30.2
#4 lore raw

Re: [PATCH ethtool 2/2] netlink: settings: Drop port filter for MDI-X

Quoted 16 lines · On Wed, Oct 27, 2021 at 08:11:40PM +0200, [email protected] wrote:

From: Bastian Germann <[email protected]>

The port == PORT_TP condition on printing linkinfo's MDI-X field prevents ethtool from printing that info even if it is present and valid, e.g. with the port being MII and still having that info.

---
 netlink/settings.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
netlink/settings.c +0 -0
index c4f5d61..4da251b 100644

netlink/settings.c int linkinfo_reply_cb(const struct nlmsghdr *nlhdr, void *data) · line 566

Quoted 9 lines
netlink/settings.c +1 -2
@@ -560,8 +560,7 @@ int linkinfo_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 		print_enum(names_transceiver, ARRAY_SIZE(names_transceiver),
 			   val, "Transceiver");
 	}
-	if (tb[ETHTOOL_A_LINKINFO_TP_MDIX] && tb[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] &&
-	    port == PORT_TP) {
+	if (tb[ETHTOOL_A_LINKINFO_TP_MDIX] && tb[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL]) {
 		uint8_t mdix = mnl_attr_get_u8(tb[ETHTOOL_A_LINKINFO_TP_MDIX]);
 		uint8_t mdix_ctrl =
 			mnl_attr_get_u8(tb[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL]);

It's a bit more complicated, I'm afraid. With current kernel code, both ETHTOOL_A_LINKINFO_TP_MDIX and ETHTOOL_A_LINKINFO_TP_MDIX_CTRL will be always present in kernel reply so that we would always show something. Also, the same condition is also used in ioctl code path and we should try to keep the output consistent between ioctl and netlink.

How about replacing "port == PORT_TP" with

  (port == TP || mdix != ETH_TP_MDI_INVALID || mdix_ctrl != ETH_TP_MDI_INVALID)

in both code path and probably moving the check into dump_mdix()?

We could (and perhaps should) also modify kernel code to omit ETHTOOL_A_LINKINFO_TP_MDIX or ETHTOOL_A_LINKINFO_TP_MDIX_CTRL if the value is ETH_TP_MDI_INVALID but ethtool would still have to check for both options (absence and ETH_TP_MDI_INVALID value) to preserve compatibility with older kernels.

Michal

Acked-by on v1 1/2
#2 lore raw

Re: [PATCH ethtool 1/2] netlink: settings: Correct duplicate condition

In reply to [email protected]
Quoted 15 lines · On Wed, Oct 27, 2021 at 08:11:39PM +0200, [email protected] wrote:

From: Bastian Germann <[email protected]>

tb's fields ETHTOOL_A_LINKINFO_TP_MDIX and ETHTOOL_A_LINKINFO_TP_MDIX_CTRL are used in this case. The condition is duplicate for the former. Fix that.

---
 netlink/settings.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
netlink/settings.c +0 -0
index 6d10a07..c4f5d61 100644

netlink/settings.c int linkinfo_reply_cb(const struct nlmsghdr *nlhdr, void *data) · line 566

Quoted 8 lines
netlink/settings.c +1 -1
@@ -560,7 +560,7 @@ int linkinfo_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 		print_enum(names_transceiver, ARRAY_SIZE(names_transceiver),
 			   val, "Transceiver");
 	}
-	if (tb[ETHTOOL_A_LINKINFO_TP_MDIX] && tb[ETHTOOL_A_LINKINFO_TP_MDIX] &&
+	if (tb[ETHTOOL_A_LINKINFO_TP_MDIX] && tb[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] &&
 	    port == PORT_TP) {
 		uint8_t mdix = mnl_attr_get_u8(tb[ETHTOOL_A_LINKINFO_TP_MDIX]);
 		uint8_t mdix_ctrl =
Fixes 10cc3ea337d1 ("netlink: partial netlink handler for gset (no option)")
#5 lore raw

Re: [PATCH ethtool 2/2] netlink: settings: Drop port filter for MDI-X

In reply to Michal Kubecek
Quoted 5 lines · Michal Kubecek

How about replacing "port == PORT_TP" with

  (port == TP || mdix != ETH_TP_MDI_INVALID || mdix_ctrl != ETH_TP_MDI_INVALID)

in both code path and probably moving the check into dump_mdix()?

Looking at the code again, we cannot move the check into dump_mdix() easily as decision if print_banner(nlctx) should be called depends on its result.

Michal

#6 lore raw
In reply to [email protected]

Hi Bastian

Quoted 1 line

I found that issue running ethtool on a br53 switch port.

Is this on the user ports? With copper PHYs? Did you try fixing the driver so it actually sets TP?

Quoted 3 lines

Despite the enum names, I cannot find documentation on the MDIX fields only being valid for twisted pair ports -- if they are present, they should be valid. But maybe I am mistaken.

I'm not sure that is true. I've never seen an SFP module that can swap around the two fibres if they happen to be the wrong way around. And it makes no sense for BNC based cheapernet, if that actually still exists anywhere.

Andrew