octeontx2-pf: report port connector type in ethtool link ksettings
Ratheesh Kannoth
maintainerPATCH 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
@@ -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
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 leavescmd->base.portunset. As a result, ethtool does not show the physical connector type even though the firmware provides it in fwdata.port.Populate
cmd->base.portfromrsp->fwdata.portso users can see values such asPORT_TPorPORT_AUIvia ethtool.Signed-off-by Hariprasad Kelam <[email protected]>Signed-off-by Ratheesh Kannoth <[email protected]>---
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
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
-0return 0 ; }Signature · 1 line
2.43.0
Ratheesh Kannoth
maintainerQuoted 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.cdrivers/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
-1return 0 ; } --2.43.0
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.cdrivers/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.portto 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
-1return 0 ; } --2.43.0
Jakub Kicinski
maintainerQuoted 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 leavescmd->base.portunset. As a result, ethtool does not show the physical connector type even though the firmware provides it in fwdata.port.Populate
cmd->base.portfromrsp->fwdata.portso users can see values such asPORT_TPorPORT_AUIvia 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.
Ratheesh Kannoth
maintainerQuoted 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 leavescmd->base.portunset. As a result, ethtool does not show the physical connector type even though the firmware provides it in fwdata.port.Populate
cmd->base.portfromrsp->fwdata.portso users can see values such asPORT_TPorPORT_AUIvia 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);
Jakub Kicinski
maintainerQuoted 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;
}