Skip to contentSkip to conversation

octeontx2-pf: report port connector type in ethtool link ksettings

PATCH Superseded Ratheesh Kannoth 3 participants 7 messages Sep 7 – Sep 8

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Ratheesh Kannoth

author maintainer
#0 lore raw

PATCH v2 1/1 octeontx2-pf: report port connector type in ethtool link ksettings

From: Hariprasad Kelam <[email protected]>

otx2_get_link_ksettings() already fills speed, duplex, autoneg, link modes and FEC from CGX firmware data, but leaves cmd->base.port unset. As a result, ethtool does not show the physical connector type even though the firmware provides it in fwdata.port.

Populate cmd->base.port from rsp->fwdata.port so users can see values such as PORT_TP or PORT_AUI via ethtool.

---
v1 -> v2: Addressed sashiko comments.

	https://lore.kernel.org/netdev/[email protected]/
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +2 -0
index 9bee1b91eeaa..9b4c151b4d7d 100644
@@ -1231,6 +1231,8 @@ static int otx2_get_link_ksettings(struct net_device *netdev,
 				OTX2_MODE_SUPPORTED, cmd);
 	otx2_get_fec_info(rsp->fwdata.supported_fec,
 			  OTX2_MODE_SUPPORTED, cmd);
+
+	cmd->base.port = (u8)rsp->fwdata.port;
 	return 0;
 }
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 25 lines · Ratheesh Kannoth

From: Hariprasad Kelam <[email protected]>

otx2_get_link_ksettings() already fills speed, duplex, autoneg, link modes and FEC from CGX firmware data, but leaves cmd->base.port unset. As a result, ethtool does not show the physical connector type even though the firmware provides it in fwdata.port.

Populate cmd->base.port from rsp->fwdata.port so users can see values such as PORT_TP or PORT_AUI via ethtool.

---
v1 -> v2: Addressed sashiko comments.

	https://lore.kernel.org/netdev/[email protected]/
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +0 -0
index 9bee1b91eeaa..9b4c151b4d7d 100644

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c static int otx2_get_link_ksettings(struct net_device *netdev, · line 1235

Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +2 -0
@@ -1231,6 +1231,8 @@ static int otx2_get_link_ksettings(struct net_device *netdev,
 				OTX2_MODE_SUPPORTED, cmd);
 	otx2_get_fec_info(rsp->fwdata.supported_fec,
 			  OTX2_MODE_SUPPORTED, cmd);
+
+	cmd->base.port = (u8)rsp->fwdata.port;

You should declare identical fields with the same type and avoid silently casting variables.

Thanks

Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +0 -0
 	return 0;
 }
 
Signature · 1 line
2.43.0
author maintainer
#2 lore raw
Quoted 14 lines · Leon Romanovsky

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c static int otx2_get_link_ksettings(struct net_device *netdev, · line 1235

Quoted 9 lines · Ratheesh Kannoth

From: Hariprasad Kelam <[email protected]>

+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +2 -0
@@ -1231,6 +1231,8 @@ static int otx2_get_link_ksettings(struct net_device *netdev,
 				OTX2_MODE_SUPPORTED, cmd);
 	otx2_get_fec_info(rsp->fwdata.supported_fec,
 			  OTX2_MODE_SUPPORTED, cmd);
+
+	cmd->base.port = (u8)rsp->fwdata.port;

You should declare identical fields with the same type and avoid silently casting variables.

Quoted 1 line

Thanks

You are suggesting to split rsp->fwdata.port to u8 port + 7-byte pad ? Currently FW is writing as 64bit.

Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +0 -1
 	return 0;
 }
 
--

2.43.0

#3 lore raw
Quoted 15 lines · Ratheesh Kannoth
Quoted 14 lines · Leon Romanovsky

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c static int otx2_get_link_ksettings(struct net_device *netdev, · line 1235

Quoted 9 lines · Ratheesh Kannoth

From: Hariprasad Kelam <[email protected]>

+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +2 -0
@@ -1231,6 +1231,8 @@ static int otx2_get_link_ksettings(struct net_device *netdev,
 				OTX2_MODE_SUPPORTED, cmd);
 	otx2_get_fec_info(rsp->fwdata.supported_fec,
 			  OTX2_MODE_SUPPORTED, cmd);
+
+	cmd->base.port = (u8)rsp->fwdata.port;

You should declare identical fields with the same type and avoid silently casting variables.

Quoted 2 lines
Quoted 1 line

Thanks

You are suggesting to split rsp->fwdata.port to u8 port + 7-byte pad ?

pad or reserved, something like that.

Thanks

Quoted 10 lines

Currently FW is writing as 64bit.

Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +0 -1
 	return 0;
 }
 
--

2.43.0

maintainer
#4 lore raw
In reply to Ratheesh Kannoth
Quoted 7 lines · On Mon, 7 Sep 2026 09:58:27 +0530 Ratheesh Kannoth wrote:

otx2_get_link_ksettings() already fills speed, duplex, autoneg, link modes and FEC from CGX firmware data, but leaves cmd->base.port unset. As a result, ethtool does not show the physical connector type even though the firmware provides it in fwdata.port.

Populate cmd->base.port from rsp->fwdata.port so users can see values such as PORT_TP or PORT_AUI via ethtool.

I said:

drivers should not blindly pass values between uAPI and the FW.

That means you have to add some explicit validation/translation for each value even if they are numerically identical.

author maintainer
#5 lore raw
Quoted 9 lines · Jakub Kicinski
Quoted 7 lines · On Mon, 7 Sep 2026 09:58:27 +0530 Ratheesh Kannoth wrote:

otx2_get_link_ksettings() already fills speed, duplex, autoneg, link modes and FEC from CGX firmware data, but leaves cmd->base.port unset. As a result, ethtool does not show the physical connector type even though the firmware provides it in fwdata.port.

Populate cmd->base.port from rsp->fwdata.port so users can see values such as PORT_TP or PORT_AUI via ethtool.

Quoted 6 lines

I said:

drivers should not blindly pass values between uAPI and the FW.

That means you have to add some explicit validation/translation for each value even if they are numerically identical.

A field_get() would be OK to satisfy this translation ?

cmd->base.port = FIELD_GET(GENMASK(7, 0), rsp->fwdata.port);

maintainer
#6 lore raw
Quoted 10 lines · On Tue, 8 Sep 2026 08:01:55 +0530 Ratheesh Kannoth wrote:
Quoted 6 lines

I said:

drivers should not blindly pass values between uAPI and the FW.

That means you have to add some explicit validation/translation for each value even if they are numerically identical.

A field_get() would be OK to satisfy this translation ?

cmd->base.port = FIELD_GET(GENMASK(7, 0), rsp->fwdata.port);

switch (fw_value) {
	case X:
	case Y:
		return fw_value;
	default:
		return -EINVAL;
}