Skip to contentSkip to conversation

net/mlx5: fix hypervisor detection in VLAN workaround

PATCH Superseded Viacheslav Ovsiienko 5 participants 8 messages Dec 3, 2024 – Jun 10, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix hypervisor detection in VLAN workaround

The mlx5 PMD provides a specific workaround for the VMware ESXi hypervisor, enabling on-demand routing configuration to virtual machines. This workaround activates when the device type is a Virtual Function and either an ESXi hypervisor is detected or the hypervisor type is unknown.

For non-x86 architectures the function rte_hypervisor_get() consistently returns an unknown type, which triggers the workaround automatically without any actual needs. If there are VLAN support requirements, this can lead to failures in inserting default control flows.

Do not trigger the workaround for unknown hypervisor type in non-x86 environments.

Fixes dfedf3e3f9d2 ("net/mlx5: add workaround for VLAN in virtual machine")
---
 drivers/net/mlx5/linux/mlx5_vlan_os.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/mlx5/linux/mlx5_vlan_os.c +2 -0
index 81611a8d3f..017953d5cc 100644
@@ -112,7 +112,9 @@ mlx5_vlan_vmwa_init(struct rte_eth_dev *dev, uint32_t ifindex)
 	/* Check whether there is desired virtual environment */
 	hv_type = rte_hypervisor_get();
 	switch (hv_type) {
+#if defined(RTE_ARCH_X86) || defined(RTE_ARCH_X86_64)
 	case RTE_HYPERVISOR_UNKNOWN:
+#endif
 	case RTE_HYPERVISOR_VMWARE:
 		/*
 		 * The "white list" of configurations
Signature · 1 line
2.34.1
#1 lore raw
Quoted 5 lines · On Tue, 3 Dec 2024 18:22:00 +0200 Viacheslav Ovsiienko…
drivers/net/mlx5/linux/mlx5_vlan_os.c +0 -0
index 81611a8d3f..017953d5cc 100644

drivers/net/mlx5/linux/mlx5_vlan_os.c mlx5_vlan_vmwa_init(struct rte_eth_dev *dev, uint32_t ifindex) · line 120

Quoted 9 lines
drivers/net/mlx5/linux/mlx5_vlan_os.c +2 -0
@@ -112,7 +112,9 @@ mlx5_vlan_vmwa_init(struct rte_eth_dev *dev, uint32_t ifindex)
 	/* Check whether there is desired virtual environment */
 	hv_type = rte_hypervisor_get();
 	switch (hv_type) {
+#if defined(RTE_ARCH_X86) || defined(RTE_ARCH_X86_64)
 	case RTE_HYPERVISOR_UNKNOWN:
+#endif
 	case RTE_HYPERVISOR_VMWARE:
 		/*
 		 * The "white list" of configurations

Could you fix that comment as well?
We got rid of all use of "whitelist" in DPDK, looks like this one got missed.

#2 lore raw

PATCH v2 1/1 net/mlx5: fix hypervisor detection in VLAN workaround

In reply to Viacheslav Ovsiienko

The mlx5 PMD provides a specific workaround for the VMware ESXi hypervisor, enabling on-demand routing configuration to virtual machines. This workaround activates when the device type is a Virtual Function and either an ESXi hypervisor is detected or the hypervisor type is unknown.

For non-x86 architectures the function rte_hypervisor_get() consistently returns an unknown type, which triggers the workaround automatically without any actual needs. If there are VLAN support requirements, this can lead to failures in inserting default control flows.

Do not trigger the workaround for unknown hypervisor type in non-x86 environments.

Fixes dfedf3e3f9d2 ("net/mlx5: add workaround for VLAN in virtual machine")

--
v2: updated cooments to remove "white list"

---
 drivers/net/mlx5/linux/mlx5_vlan_os.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/mlx5/linux/mlx5_vlan_os.c +5 -5
index 81611a8d3f..353484de3f 100644
@@ -112,16 +112,16 @@ mlx5_vlan_vmwa_init(struct rte_eth_dev *dev, uint32_t ifindex)
 	/* Check whether there is desired virtual environment */
 	hv_type = rte_hypervisor_get();
 	switch (hv_type) {
+#if defined(RTE_ARCH_X86) || defined(RTE_ARCH_X86_64)
+	/* Always misdetected on ARM archs, let's ignore this */
 	case RTE_HYPERVISOR_UNKNOWN:
+#endif
 	case RTE_HYPERVISOR_VMWARE:
-		/*
-		 * The "white list" of configurations
-		 * to engage the workaround.
-		 */
+		/* The list of configurations to engage the workaround. */
 		break;
 	default:
 		/*
-		 * The configuration is not found in the "white list".
+		 * The configuration is not found in the list.
 		 * We should not engage the VLAN workaround.
 		 */
 		return NULL;
Signature · 1 line
2.34.1
#3 lore raw

06/12/2024 15:26, Viacheslav Ovsiienko:

Quoted 6 lines

The mlx5 PMD provides a specific workaround for the VMware ESXi hypervisor, enabling on-demand routing configuration to virtual machines. This workaround activates when the device type is a Virtual Function and either an ESXi hypervisor is detected or the hypervisor type is unknown.

Quoted 8 lines

For non-x86 architectures the function rte_hypervisor_get() consistently returns an unknown type, which triggers the workaround automatically without any actual needs. If there are VLAN support requirements, this can lead to failures in inserting default control flows.

Do not trigger the workaround for unknown hypervisor type in non-x86 environments.

It would be a lot better to fix rte_hypervisor_get(). I suggest starting with the read of /sys/class/dmi/id/

#4 lore raw
Quoted 13 lines · On Thu, 12 Dec 2024 11:52:51 +0100 Thomas Monjalon <[email protected]> wrote:

06/12/2024 15:26, Viacheslav Ovsiienko:

Quoted 12 lines

The mlx5 PMD provides a specific workaround for the VMware ESXi hypervisor, enabling on-demand routing configuration to virtual machines. This workaround activates when the device type is a Virtual Function and either an ESXi hypervisor is detected or the hypervisor type is unknown.

For non-x86 architectures the function rte_hypervisor_get() consistently returns an unknown type, which triggers the workaround automatically without any actual needs. If there are VLAN support requirements, this can lead to failures in inserting default control flows.

Quoted 5 lines
Quoted 2 lines

Do not trigger the workaround for unknown hypervisor type in non-x86 environments.

It would be a lot better to fix rte_hypervisor_get(). I suggest starting with the read of /sys/class/dmi/id/

The common heuristic is what is in the lscpu utility.
https://github.com/util-linux/util-linux/sys-utils/lscpu-virt.c

Doing all this right is complex.

PS: it should also detect Xen and others even though DPDK doesn' support it.

#5 lore raw

12/12/2024 18:27, Stephen Hemminger:

Quoted 22 lines
Quoted 13 lines · On Thu, 12 Dec 2024 11:52:51 +0100 Thomas Monjalon <[email protected]> wrote:

06/12/2024 15:26, Viacheslav Ovsiienko:

Quoted 12 lines

The mlx5 PMD provides a specific workaround for the VMware ESXi hypervisor, enabling on-demand routing configuration to virtual machines. This workaround activates when the device type is a Virtual Function and either an ESXi hypervisor is detected or the hypervisor type is unknown.

For non-x86 architectures the function rte_hypervisor_get() consistently returns an unknown type, which triggers the workaround automatically without any actual needs. If there are VLAN support requirements, this can lead to failures in inserting default control flows.

Quoted 5 lines
Quoted 2 lines

Do not trigger the workaround for unknown hypervisor type in non-x86 environments.

It would be a lot better to fix rte_hypervisor_get(). I suggest starting with the read of /sys/class/dmi/id/

Quoted 6 lines

The common heuristic is what is in the lscpu utility.
https://github.com/util-linux/util-linux/sys-utils/lscpu-virt.c

Doing all this right is complex.

PS: it should also detect Xen and others even though DPDK doesn' support it.

I don't think we need to detect all.
Currently we have a very limited implementation, using only CPUID on x86.

Acked-by on v2 1/1
#6 lore raw
In reply to Viacheslav Ovsiienko

Hi,

Since it is only a WA and no need to consider all archs or CPU types, LGTM so far.

Quoted 66 lines

-----Original Message-----
From: Viacheslav Ovsiienko <[email protected]>
Sent: Friday, December 6, 2024 10:26 PM
To: [email protected]
Cc: Raslan Darawsheh <[email protected]>; Matan Azrad <[email protected]>; Suanming Mou <[email protected]>; [email protected]
Subject: [PATCH v2] net/mlx5: fix hypervisor detection in VLAN workaround

External email: Use caution opening links or attachments

The mlx5 PMD provides a specific workaround for the VMware ESXi hypervisor, enabling on-demand routing configuration to virtual machines. This workaround activates when the device type is a Virtual Function and either an ESXi hypervisor is detected or the hypervisor type is unknown.

For non-x86 architectures the function rte_hypervisor_get() consistently returns an unknown type, which triggers the workaround automatically without any actual needs. If there are VLAN support requirements, this can lead to failures in inserting default control flows.

Do not trigger the workaround for unknown hypervisor type in non-x86 environments.

Fixes dfedf3e3f9d2 ("net/mlx5: add workaround for VLAN in virtual

machine")
Cc: [email protected]

--
v2: updated cooments to remove "white list"

---
 drivers/net/mlx5/linux/mlx5_vlan_os.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/mlx5/linux/mlx5_vlan_os.c +6 -6
index 81611a8d3f..353484de3f 100644
@@ -112,16 +112,16 @@ mlx5_vlan_vmwa_init(struct rte_eth_dev *dev,
 uint32_t ifindex)
        /* Check whether there is desired virtual environment */
        hv_type = rte_hypervisor_get();
        switch (hv_type) {
+#if defined(RTE_ARCH_X86) || defined(RTE_ARCH_X86_64)
+       /* Always misdetected on ARM archs, let's ignore this */
        case RTE_HYPERVISOR_UNKNOWN:
+#endif
        case RTE_HYPERVISOR_VMWARE:
-               /*
-                * The "white list" of configurations
-                * to engage the workaround.
-                */
+               /* The list of configurations to engage the workaround.
+ */
                break;
        default:
                /*
-                * The configuration is not found in the "white list".
+                * The configuration is not found in the list.
                 * We should not engage the VLAN workaround.
                 */
                return NULL;
--
Quoted 1 line

2.34.1

#7 lore raw
In reply to Viacheslav Ovsiienko

Hi,

Quoted 12 lines · Viacheslav Ovsiienko

The mlx5 PMD provides a specific workaround for the VMware ESXi hypervisor, enabling on-demand routing configuration to virtual machines. This workaround activates when the device type is a Virtual Function and either an ESXi hypervisor is detected or the hypervisor type is unknown.

For non-x86 architectures the function rte_hypervisor_get() consistently returns an unknown type, which triggers the workaround automatically without any actual needs. If there are VLAN support requirements, this can lead to failures in inserting default control flows.

Quoted 8 lines

Do not trigger the workaround for unknown hypervisor type in non-x86 environments.

Fixes dfedf3e3f9d2 ("net/mlx5: add workaround for VLAN in virtual machine")

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh