netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
@ 2025-05-13  6:13 Hariprasad Kelam
  2025-05-13 10:55 ` Hariprasad Kelam
  0 siblings, 1 reply; 5+ messages in thread
From: Hariprasad Kelam @ 2025-05-13  6:13 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Hariprasad Kelam, Sunil Goutham, Linu Cherian, Geetha sowjanya,
	Jerin Jacob, Subbaraya Sundeep, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Bharat Bhushan

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>
---
 drivers/net/ethernet/marvell/octeontx2/af/mbox.h          | 4 +++-
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 5 +++++
 2 files changed, 8 insertions(+), 1 deletion(-)

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 010385b29988..d49d76eabc07 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -1190,6 +1190,7 @@ static int otx2_get_link_ksettings(struct net_device *netdev,
 	cmd->base.duplex  = pfvf->linfo.full_duplex;
 	cmd->base.speed   = pfvf->linfo.speed;
 	cmd->base.autoneg = pfvf->linfo.an;
+	cmd->base.port    = rsp->fwdata.port;
 
 	rsp = otx2_get_fwdata(pfvf);
 	if (IS_ERR(rsp))
@@ -1199,6 +1200,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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
  2025-05-13  6:13 Hariprasad Kelam
@ 2025-05-13 10:55 ` Hariprasad Kelam
  0 siblings, 0 replies; 5+ messages in thread
From: Hariprasad Kelam @ 2025-05-13 10:55 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
	Subbaraya Sundeep, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Bharat Bhushan

On 2025-05-13 at 11:43:51, Hariprasad Kelam (hkelam@marvell.com) wrote:

Please ignore this patch, accidentally submitted old version

> 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>
> ---
>  drivers/net/ethernet/marvell/octeontx2/af/mbox.h          | 4 +++-
>  drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 5 +++++
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> 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 010385b29988..d49d76eabc07 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
> @@ -1190,6 +1190,7 @@ static int otx2_get_link_ksettings(struct net_device *netdev,
>  	cmd->base.duplex  = pfvf->linfo.full_duplex;
>  	cmd->base.speed   = pfvf->linfo.speed;
>  	cmd->base.autoneg = pfvf->linfo.an;
> +	cmd->base.port    = rsp->fwdata.port;
>  
>  	rsp = otx2_get_fwdata(pfvf);
>  	if (IS_ERR(rsp))
> @@ -1199,6 +1200,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);
> -- 
> 2.34.1
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
@ 2025-05-19 11:23 Hariprasad Kelam
  2025-05-20 23:50 ` Jakub Kicinski
  0 siblings, 1 reply; 5+ messages in thread
From: Hariprasad Kelam @ 2025-05-19 11:23 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Hariprasad Kelam, Sunil Goutham, Linu Cherian, Geetha sowjanya,
	Jerin Jacob, Subbaraya Sundeep, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Bharat Bhushan

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
  2025-05-19 11:23 [net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields Hariprasad Kelam
@ 2025-05-20 23:50 ` Jakub Kicinski
  2025-05-22 11:11   ` Hariprasad Kelam
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2025-05-20 23:50 UTC (permalink / raw)
  To: Hariprasad Kelam
  Cc: netdev, linux-kernel, Sunil Goutham, Linu Cherian,
	Geetha sowjanya, Jerin Jacob, Subbaraya Sundeep, Andrew Lunn,
	David S. Miller, Eric Dumazet, Paolo Abeni, Bharat Bhushan

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
  2025-05-20 23:50 ` Jakub Kicinski
@ 2025-05-22 11:11   ` Hariprasad Kelam
  0 siblings, 0 replies; 5+ messages in thread
From: Hariprasad Kelam @ 2025-05-22 11:11 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: netdev, linux-kernel, Sunil Goutham, Linu Cherian,
	Geetha sowjanya, Jerin Jacob, Subbaraya Sundeep, Andrew Lunn,
	David S. Miller, Eric Dumazet, Paolo Abeni, Bharat Bhushan

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-05-22 11:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-19 11:23 [net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields Hariprasad Kelam
2025-05-20 23:50 ` Jakub Kicinski
2025-05-22 11:11   ` Hariprasad Kelam
  -- strict thread matches above, loose matches on Subject: below --
2025-05-13  6:13 Hariprasad Kelam
2025-05-13 10:55 ` Hariprasad Kelam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).