[net-next PatchV3] Octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields

Hariprasad Kelam posted 1 patch 2 months, 1 week ago
.../marvell/octeontx2/nic/otx2_ethtool.c      | 24 +++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
[net-next PatchV3] Octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
Posted by Hariprasad Kelam 2 months, 1 week ago
The Octeontx2/CN10k netdev drivers access a shared firmware structure
to obtain link configuration details, such as supported and advertised
link modes. This patch adds support to display the same.

ethtool eth1
Settings for eth1:
    Supported ports: [ ]
    Supported link modes:  10000baseCR/Full
	                   10000baseSR/Full
                           10000baseLR/Full
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Supported FEC modes: None
    Advertised link modes: Not reported
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Advertised FEC modes: None
    Speed: 10000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown
    Current message level: 0x00000000 (0)
    Link detected: yes

Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
---
V3 * Fix port types in firmware 

V2 * Add validation for 'port' parameter
    include full output of ethtool ethx

 .../marvell/octeontx2/nic/otx2_ethtool.c      | 24 +++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index 998c734ff839..95a7aa2b6b69 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -1184,11 +1184,13 @@ static void otx2_get_link_mode_info(u64 link_mode_bmap,
 	}
 
 	if (req_mode == OTX2_MODE_ADVERTISED)
-		linkmode_copy(link_ksettings->link_modes.advertising,
-			      otx2_link_modes);
+		linkmode_or(link_ksettings->link_modes.advertising,
+			    link_ksettings->link_modes.advertising,
+			    otx2_link_modes);
 	else
-		linkmode_copy(link_ksettings->link_modes.supported,
-			      otx2_link_modes);
+		linkmode_or(link_ksettings->link_modes.supported,
+			    link_ksettings->link_modes.supported,
+			    otx2_link_modes);
 }
 
 static int otx2_get_link_ksettings(struct net_device *netdev,
@@ -1209,6 +1211,10 @@ static int otx2_get_link_ksettings(struct net_device *netdev,
 		ethtool_link_ksettings_add_link_mode(cmd,
 						     supported,
 						     Autoneg);
+	if (rsp->fwdata.advertised_an)
+		ethtool_link_ksettings_add_link_mode(cmd,
+						     advertising,
+						     Autoneg);
 
 	otx2_get_link_mode_info(rsp->fwdata.advertised_link_modes,
 				OTX2_MODE_ADVERTISED, cmd);
@@ -1218,6 +1224,16 @@ 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);
+
+	switch (rsp->fwdata.port) {
+	case PORT_TP:
+	case PORT_FIBRE:
+		cmd->base.port = rsp->fwdata.port;
+		break;
+	default:
+		cmd->base.port = PORT_NONE;
+	}
+
 	return 0;
 }
 
-- 
2.34.1
Re: [net-next PatchV3] Octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
Posted by Jakub Kicinski 2 months, 1 week ago
On Thu, 24 Jul 2025 15:40:57 +0530 Hariprasad Kelam wrote:
>     Supported link modes:  10000baseCR/Full
> 	                   10000baseSR/Full
>                            10000baseLR/Full

>     Speed: 10000Mb/s
>     Duplex: Full
>     Port: Twisted Pair

How can you have twisted pair with those link modes.
Twisted pair is 10000baseT/Full.
If the link mode is CR the correct port type is PORT_DA.
-- 
pw-bot: cr
Re: [net-next PatchV3] Octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
Posted by Simon Horman 2 months, 1 week ago
On Thu, Jul 24, 2025 at 03:40:57PM +0530, Hariprasad Kelam wrote:
> The Octeontx2/CN10k netdev drivers access a shared firmware structure
> to obtain link configuration details, such as supported and advertised
> link modes. This patch adds support to display the same.
> 
> ethtool eth1
> Settings for eth1:
>     Supported ports: [ ]
>     Supported link modes:  10000baseCR/Full
> 	                   10000baseSR/Full
>                            10000baseLR/Full
>     Supported pause frame use: No
>     Supports auto-negotiation: Yes
>     Supported FEC modes: None
>     Advertised link modes: Not reported
>     Advertised pause frame use: No
>     Advertised auto-negotiation: Yes
>     Advertised FEC modes: None
>     Speed: 10000Mb/s
>     Duplex: Full
>     Port: Twisted Pair
>     PHYAD: 0
>     Transceiver: internal
>     Auto-negotiation: on
>     MDI-X: Unknown
>     Current message level: 0x00000000 (0)
>     Link detected: yes
> 
> Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
> ---
> V3 * Fix port types in firmware 
> 
> V2 * Add validation for 'port' parameter
>     include full output of ethtool ethx

Thanks, I believe this addresses Jakub's review of v2.

Reviewed-by: Simon Horman <horms@kernel.org>