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

Hariprasad Kelam posted 1 patch 9 months ago
There is a newer version of this series
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(-)
[net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
Posted by Hariprasad Kelam 9 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>
---
 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
Re: [net-next] octeontx2-pf: ethtool: Display "Autoneg" and "Port" fields
Posted by Hariprasad Kelam 8 months, 4 weeks ago
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
> 
>