Skip to contentSkip to conversation

ice: improve port representor naming scheme

PATCH New Marcin Szycik 2 participants 5 messages Mar 28, 2022 – May 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ice: improve port representor naming scheme

This patchset adds support for systemd defined naming scheme for port representors, as well as re-enables displaying PCI bus-info in ethtool.

bus-info information has previously been removed from ethtool for port representors, as a workaround for a bug in lshw tool, where the tool would sometimes display wrong descriptions for port representors/PF. Now the bug has been fixed in lshw tool [1].

Removing the workaround can be considered a regression (user might be running an older, unpatched version of lshw) (see [2] for discussion). However, calling SET_NETDEV_DEV also produces the same effect as removing the workaround, i.e. lshw is able to access PCI bus-info (this time not via ethtool, but in some other way) and the bug can occur.

Adding SET_NETDEV_DEV is important, as it greatly improves netdev naming -
- port representors are named based on PF name. Currently port representors are named "ethX", which might be confusing, especially when spawning VFs on multiple PFs. Furthermore, it's currently harder to determine to which PF does a particular port representor belong, as bus-info is not shown in ethtool.

Consider the following three cases:

Case 1: current code - driver workaround in place, no SET_NETDEV_DEV, lshw with or without fix. Port representors are not displayed because they don't have bus-info (the workaround), PFs are labelled correctly:

$ sudo ./lshw -c net -businfo
Bus info          Device      Class          Description
========================================================
pci at 0000:02:00.0  ens6f0      network        Ethernet Controller E810-XXV for SFP <-- PF
pci at 0000:02:00.1  ens6f1      network        Ethernet Controller E810-XXV for SFP
pci at 0000:02:01.0  ens6f0v0    network        Ethernet Adaptive Virtual Function <-- VF
pci at 0000:02:01.1  ens6f0v1    network        Ethernet Adaptive Virtual Function
...

Case 2: driver workaround in place, SET_NETDEV_DEV, no lshw fix. Port representors have predictable names. lshw is able to get bus-info because of SET_NETDEV_DEV and netdevs CAN be mislabelled:

$ sudo ./lshw -c net -businfo
Bus info          Device           Class          Description
=============================================================
pci at 0000:02:00.0  ens6f0npf0vf60   network        Ethernet Controller E810-XXV for SFP <-- mislabelled port representor
pci at 0000:02:00.1  ens6f1           network        Ethernet Controller E810-XXV for SFP
pci at 0000:02:01.0  ens6f0v0         network        Ethernet Adaptive Virtual Function
pci at 0000:02:01.1  ens6f0v1         network        Ethernet Adaptive Virtual Function
...
pci at 0000:02:00.0  ens6f0npf0vf26   network        Ethernet interface
pci at 0000:02:00.0  ens6f0           network        Ethernet interface <-- mislabelled PF
pci at 0000:02:00.0  ens6f0npf0vf81   network        Ethernet interface
...
$ sudo ethtool -i ens6f0npf0vf60
driver: ice
...
bus-info:
...

Output of lshw would be the same with workaround removed; it does not change the fact that lshw labels netdevs incorrectly, while at the same time it prevents ethtool from displaying potentially useful data (bus-info).

Case 3: workaround removed, SET_NETDEV_DEV, lshw fix:

$ sudo ./lshw -c net -businfo
Bus info          Device           Class          Description
=============================================================
pci at 0000:02:00.0  ens6f0npf0vf73   network        Ethernet Controller E810-XXV for SFP
pci at 0000:02:00.1  ens6f1           network        Ethernet Controller E810-XXV for SFP
pci at 0000:02:01.0  ens6f0v0         network        Ethernet Adaptive Virtual Function
pci at 0000:02:01.1  ens6f0v1         network        Ethernet Adaptive Virtual Function
...
pci at 0000:02:00.0  ens6f0npf0vf5    network        Ethernet Controller E810-XXV for SFP
pci at 0000:02:00.0  ens6f0           network        Ethernet Controller E810-XXV for SFP
pci at 0000:02:00.0  ens6f0npf0vf60   network        Ethernet Controller E810-XXV for SFP
...
$ sudo ethtool -i ens6f0npf0vf73
driver: ice
...
bus-info: 0000:02:00.0
...

In this case poort representors have predictable names, netdevs are not mislabelled in lshw, and bus-info is shown in ethtool.

[1] https://ezix.org/src/pkg/lshw/commit/9bf4e4c9c1
[2] https://patchwork.ozlabs.org/project/intel-wired-lan/patch/[email protected]

Marcin Szycik (1):
Revert "ice: Hide bus-info in ethtool for PRs in switchdev mode"

Michal Swiatkowski (1):
ice: link representors to PCI device

 drivers/net/ethernet/intel/ice/ice_ethtool.c | 8 +++-----
 drivers/net/ethernet/intel/ice/ice_repr.c    | 1 +
 2 files changed, 4 insertions(+), 5 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/2 ice: link representors to PCI device

From: Michal Swiatkowski <[email protected]>

Link port representors to parent PCI device to benefit from systemd defined naming scheme.

Example from ip tool:
- without linking:
eth0 ...
- with linking:
eth0 ...
altname enp24s0f0npf0vf0

The port representor name is being shown in altname, because the name is longer than IFNAMSIZ (16) limit. Altname can be used in ip tool.

---
 drivers/net/ethernet/intel/ice/ice_repr.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/ice/ice_repr.c +1 -0
index 848f2adea563..78ee82511329 100644
@@ -333,6 +333,7 @@ static int ice_repr_add(struct ice_vf *vf)
 	repr->netdev->min_mtu = ETH_MIN_MTU;
 	repr->netdev->max_mtu = ICE_MAX_MTU;
 
+	SET_NETDEV_DEV(repr->netdev, ice_pf_to_dev(vf->pf));
 	err = ice_repr_reg_netdev(repr->netdev);
 	if (err)
 		goto err_netdev;
Signature · 1 line
2.35.1
#2 lore raw

PATCH 1/2 ice: link representors to PCI device

Quoted 4 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Marcin Szycik
Sent: Monday, March 28, 2022 8:28 PM

To: [email protected]

Quoted 15 lines

Subject: [Intel-wired-lan] [PATCH net-next 1/2] ice: link representors to PCI device

From: Michal Swiatkowski <[email protected]>

Link port representors to parent PCI device to benefit from systemd defined naming scheme.

Example from ip tool:
- without linking:
eth0 ...
- with linking:
eth0 ...
altname enp24s0f0npf0vf0

Quoted 8 lines

The port representor name is being shown in altname, because the name is longer than IFNAMSIZ (16) limit. Altname can be used in ip tool.

---
drivers/net/ethernet/intel/ice/ice_repr.c | 1 +

1 file changed, 1 insertion(+)
#3 lore raw

PATCH 2/2 Revert "ice: Hide bus-info in ethtool for PRs in switchdev mode"

In reply to Marcin Szycik

This reverts commit bfaaba99e680bf82bf2cbf69866c3f37434ff766.

Commit bfaaba99e680 ("ice: Hide bus-info in ethtool for PRs in switchdev mode") was a workaround for lshw tool displaying incorrect descriptions for port representors and PF in switchdev mode. Now the issue has been fixed in the lshw tool itself [1].

Removing the workaround can be considered a regression, as the user might be running older, unpatched lshw version. However, another important change (ice: link representors to PCI device, which improves port representor netdev naming with SET_NETDEV_DEV) also causes the same "regression" as removing the workaround, i.e. unpatched lshw is able to access bus-info information (this time not via ethtool) and the bug can occur. Therefore, the workaround no longer prevents the bug and can be removed.

[1] https://ezix.org/src/pkg/lshw/commit/9bf4e4c9c1

---
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +3 -5
index 24cda7e1f916..476bd1c83c87 100644
@@ -190,19 +190,17 @@ __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;
 }
 
Signature · 1 line
2.35.1
#4 lore raw

PATCH 2/2 Revert "ice: Hide bus-info in ethtool for PRs in switchdev mode"

Quoted 4 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Marcin Szycik
Sent: Monday, March 28, 2022 8:28 PM

To: [email protected]

Quoted 19 lines

Subject: [Intel-wired-lan] [PATCH net-next 2/2] Revert "ice: Hide bus-info in ethtool for PRs in switchdev mode"

This reverts commit bfaaba99e680bf82bf2cbf69866c3f37434ff766.

Commit bfaaba99e680 ("ice: Hide bus-info in ethtool for PRs in switchdev mode") was a workaround for lshw tool displaying incorrect descriptions for port representors and PF in switchdev mode. Now the issue has been fixed in the lshw tool itself [1].

Removing the workaround can be considered a regression, as the user might be running older, unpatched lshw version. However, another important change
(ice: link representors to PCI device, which improves port representor netdev naming with SET_NETDEV_DEV) also causes the same "regression" as removing the workaround, i.e. unpatched lshw is able to access bus-info information (this time not via ethtool) and the bug can occur. Therefore, the workaround no longer prevents the bug and can be removed.

Quoted 7 lines

[1] https://ezix.org/src/pkg/lshw/commit/9bf4e4c9c1

---
drivers/net/ethernet/intel/ice/ice_ethtool.c | 8 +++-----

1 file changed, 3 insertions(+), 5 deletions(-)