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

Hariprasad Kelam posted 1 patch 7 months ago
There is a newer version of this series
.../net/ethernet/marvell/octeontx2/af/mbox.h    |  4 +++-
.../marvell/octeontx2/nic/otx2_ethtool.c        | 17 +++++++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)
[net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
Posted by Hariprasad Kelam 7 months 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 updates the shared firmware data to include additional
fields like 'Autonegotiation' and 'Port type'.

example output:
  ethtool ethx
	 Advertised auto-negotiation: Yes
	 Port: Twisted Pair

Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
---
 .../net/ethernet/marvell/octeontx2/af/mbox.h    |  4 +++-
 .../marvell/octeontx2/nic/otx2_ethtool.c        | 17 +++++++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 005ca8a056c0..4a305c183987 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -652,7 +652,9 @@ struct cgx_lmac_fwdata_s {
 	/* Only applicable if SFP/QSFP slot is present */
 	struct sfp_eeprom_s sfp_eeprom;
 	struct phy_s phy;
-#define LMAC_FWDATA_RESERVED_MEM 1021
+	u64 advertised_an:1;
+	u64 port;
+#define LMAC_FWDATA_RESERVED_MEM 1019
 	u64 reserved[LMAC_FWDATA_RESERVED_MEM];
 };
 
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index 45b8c9230184..0ae39cd7d842 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -1174,11 +1174,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,
@@ -1200,6 +1202,11 @@ static int otx2_get_link_ksettings(struct net_device *netdev,
 						     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);
 	otx2_get_fec_info(rsp->fwdata.advertised_fec,
@@ -1208,6 +1215,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 = rsp->fwdata.port;
 	return 0;
 }
 
-- 
2.34.1
Re: [net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
Posted by Jakub Kicinski 7 months ago
On Mon, 19 May 2025 16:53:33 +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 updates the shared firmware data to include additional
> fields like 'Autonegotiation' and 'Port type'.
> 
> example output:
>   ethtool ethx
> 	 Advertised auto-negotiation: Yes
> 	 Port: Twisted Pair

Can you add the real output without trimming please?

> +	cmd->base.port = rsp->fwdata.port;

Do you validate somewhere this value is within the legitimate values
from kernel uAPI?
-- 
pw-bot: cr
Re: [net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
Posted by Hariprasad Kelam 7 months ago
On 2025-05-21 at 05:20:19, Jakub Kicinski (kuba@kernel.org) wrote:
> On Mon, 19 May 2025 16:53:33 +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 updates the shared firmware data to include additional
> > fields like 'Autonegotiation' and 'Port type'.
> > 
> > example output:
> >   ethtool ethx
> > 	 Advertised auto-negotiation: Yes
> > 	 Port: Twisted Pair
> 
> Can you add the real output without trimming please?
  Ack
> 
> > +	cmd->base.port = rsp->fwdata.port;
> 
> Do you validate somewhere this value is within the legitimate values
> from kernel uAPI?
  No, missed adding validation.
  Will address this in next version.