Skip to contentSkip to conversation

net/virtio: fix uninitialized duplex mode

PATCH Applied Chenbo Xia 2 participants 3 messages Jul 27, 2021 – Jul 28, 2021 Network drivers

lore
Share & tools
lore

Chenbo Xia

author
#0 lore raw

PATCH 1/1 net/virtio: fix uninitialized duplex mode

When virtio front-end initializes, the duplex mode should be set unknown before reading any duplex mode information from configuration space. This patch fixes the issue that duplex mode is by default set to zero, which equals ETH_LINK_HALF_DUPLEX. This will lead to duplex mode being half duplex when fron-end does not have the feature named VIRTIO_NET_F_SPEED_DUPLEX.

Fixes 1357b4b36246 ("net/virtio: support Virtio link speed feature")
---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_ethdev.c +1 -0
index 72d3dda71f..9061db4e41 100644
@@ -1901,6 +1901,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret < 0)
 		return ret;
 	hw->speed = speed;
+	hw->duplex = DUPLEX_UNKNOWN;
 
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("virtio",
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Chenbo Xia

When virtio front-end initializes, the duplex mode should be set unknown before reading any duplex mode information from configuration space. This patch fixes the issue that duplex mode is by default set to zero, which equals ETH_LINK_HALF_DUPLEX. This will lead to duplex mode being half duplex when fron-end does not have the feature named VIRTIO_NET_F_SPEED_DUPLEX.

Fixes 1357b4b36246 ("net/virtio: support Virtio link speed feature")
---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 72d3dda71f..9061db4e41 100644

drivers/net/virtio/virtio_ethdev.c eth_virtio_dev_init(struct rte_eth_dev *eth_dev) · line 1907

Quoted 7 lines
drivers/net/virtio/virtio_ethdev.c +1 -0
@@ -1901,6 +1901,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret < 0)
 		return ret;
 	hw->speed = speed;
+	hw->duplex = DUPLEX_UNKNOWN;
 
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("virtio",

Thanks,
Maxime

author Applied
#2 lore raw
In reply to Chenbo Xia
Quoted 36 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenbo Xia
Sent: Tuesday, July 27, 2021 1:15 PM
To: [email protected]
Cc: [email protected]; [email protected]
Subject: [dpdk-dev] [PATCH] net/virtio: fix uninitialized duplex mode

When virtio front-end initializes, the duplex mode should be set unknown before reading any duplex mode information from configuration space. This patch fixes the issue that duplex mode is by default set to zero, which equals ETH_LINK_HALF_DUPLEX. This will lead to duplex mode being half duplex when fron-end does not have the feature named VIRTIO_NET_F_SPEED_DUPLEX.

Fixes 1357b4b36246 ("net/virtio: support Virtio link speed feature")
---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_ethdev.c +1 -1
index 72d3dda71f..9061db4e41 100644
@@ -1901,6 +1901,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret < 0)
 		return ret;
 	hw->speed = speed;
+	hw->duplex = DUPLEX_UNKNOWN;
 
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("virtio",
--
Quoted 1 line

2.17.1

Applied to next-virtio/main. Thanks!