diff mbox series

[net-next] ice: Hide bus-info in ethtool for PRs in switchdev mode

Message ID 20211026155624.17106-1-marcin.szycik@linux.intel.com
State Accepted
Delegated to: Anthony Nguyen
Headers show
Series [net-next] ice: Hide bus-info in ethtool for PRs in switchdev mode | expand

Commit Message

Marcin Szycik Oct. 26, 2021, 3:56 p.m. UTC
Disable showing bus-info information for port representors in switchdev
mode. This fixes a bug that caused displaying wrong netdev descriptions in
lshw tool - one port representor displayed PF branding string, and in turn
one PF displayed a "generic" description. The bug occurs when many devices
show the same bus-info in ethtool, which was the case in switchdev mode (PF
and its port representors displayed the same bus-info). The bug occurs only
if a port representor netdev appears before PF netdev in /proc/net/dev.

In the examples below:
ens6fX is PF
ens6fXvY is VF
ethX is port representor
One irrelevant column was removed from output

Before:
$ sudo lshw -c net -businfo
Bus info          Device      Description
=========================================
pci@0000:02:00.0  eth102       Ethernet Controller E810-XXV for SFP
pci@0000:02:00.1  ens6f1       Ethernet Controller E810-XXV for SFP
pci@0000:02:01.0  ens6f0v0     Ethernet Adaptive Virtual Function
pci@0000:02:01.1  ens6f0v1     Ethernet Adaptive Virtual Function
pci@0000:02:01.2  ens6f0v2     Ethernet Adaptive Virtual Function
pci@0000:02:00.0  ens6f0       Ethernet interface

Notice that eth102 and ens6f0 have the same bus-info and their descriptions
are swapped.

After:
$ sudo lshw -c net -businfo
Bus info          Device      Description
=========================================
pci@0000:02:00.0  ens6f0      Ethernet Controller E810-XXV for SFP
pci@0000:02:00.1  ens6f1      Ethernet Controller E810-XXV for SFP
pci@0000:02:01.0  ens6f0v0    Ethernet Adaptive Virtual Function
pci@0000:02:01.1  ens6f0v1    Ethernet Adaptive Virtual Function
pci@0000:02:01.2  ens6f0v2    Ethernet Adaptive Virtual Function

Fixes: 7aae80cef7ba ("ice: add port representor ethtool ops and stats")
Signed-off-by: Marcin Szycik <marcin.szycik@linux.intel.com>
---
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Penigalapati, Sandeep Oct. 29, 2021, 12:34 p.m. UTC | #1
>-----Original Message-----
>From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
>Marcin Szycik
>Sent: Tuesday, October 26, 2021 9:26 PM
>To: intel-wired-lan@lists.osuosl.org
>Subject: [Intel-wired-lan] [PATCH net-next] ice: Hide bus-info in ethtool for PRs
>in switchdev mode
>
>Disable showing bus-info information for port representors in switchdev
>mode. This fixes a bug that caused displaying wrong netdev descriptions in
>lshw tool - one port representor displayed PF branding string, and in turn one
>PF displayed a "generic" description. The bug occurs when many devices show
>the same bus-info in ethtool, which was the case in switchdev mode (PF and
>its port representors displayed the same bus-info). The bug occurs only if a
>port representor netdev appears before PF netdev in /proc/net/dev.
>
>In the examples below:
>ens6fX is PF
>ens6fXvY is VF
>ethX is port representor
>One irrelevant column was removed from output
>
>Before:
>$ sudo lshw -c net -businfo
>Bus info          Device      Description
>=========================================
>pci@0000:02:00.0  eth102       Ethernet Controller E810-XXV for SFP
>pci@0000:02:00.1  ens6f1       Ethernet Controller E810-XXV for SFP
>pci@0000:02:01.0  ens6f0v0     Ethernet Adaptive Virtual Function
>pci@0000:02:01.1  ens6f0v1     Ethernet Adaptive Virtual Function
>pci@0000:02:01.2  ens6f0v2     Ethernet Adaptive Virtual Function
>pci@0000:02:00.0  ens6f0       Ethernet interface
>
>Notice that eth102 and ens6f0 have the same bus-info and their descriptions
>are swapped.
>
>After:
>$ sudo lshw -c net -businfo
>Bus info          Device      Description
>=========================================
>pci@0000:02:00.0  ens6f0      Ethernet Controller E810-XXV for SFP
>pci@0000:02:00.1  ens6f1      Ethernet Controller E810-XXV for SFP
>pci@0000:02:01.0  ens6f0v0    Ethernet Adaptive Virtual Function
>pci@0000:02:01.1  ens6f0v1    Ethernet Adaptive Virtual Function
>pci@0000:02:01.2  ens6f0v2    Ethernet Adaptive Virtual Function
>
>Fixes: 7aae80cef7ba ("ice: add port representor ethtool ops and stats")
>Signed-off-by: Marcin Szycik <marcin.szycik@linux.intel.com>
>---
> drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
Tested-by: Sandeep Penigalapati <sandeep.penigalapati@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
index 870d02adcfe8..dfbba64e691c 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -189,18 +189,19 @@  __ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo,
 	snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
 		 "%x.%02x 0x%x %d.%d.%d", nvm->major, nvm->minor,
 		 nvm->eetrack, orom->major, orom->build, orom->patch);
-
-	strscpy(drvinfo->bus_info, pci_name(pf->pdev),
-		sizeof(drvinfo->bus_info));
 }
 
 static void
 ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
 {
 	struct ice_netdev_priv *np = netdev_priv(netdev);
+	struct ice_pf *pf = np->vsi->back;
 
 	__ice_get_drvinfo(netdev, drvinfo, np->vsi);
 
+	strscpy(drvinfo->bus_info, pci_name(pf->pdev),
+		sizeof(drvinfo->bus_info));
+
 	drvinfo->n_priv_flags = ICE_PRIV_FLAG_ARRAY_SIZE;
 }