net/virtio: fix default duplex mode
authorChenbo Xia <chenbo.xia@intel.com>
Tue, 27 Jul 2021 05:14:41 +0000 (13:14 +0800)
committerChenbo Xia <chenbo.xia@intel.com>
Wed, 28 Jul 2021 06:33:16 +0000 (08:33 +0200)
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 front-end does not have the feature
named VIRTIO_NET_F_SPEED_DUPLEX.

Fixes: 1357b4b36246 ("net/virtio: support Virtio link speed feature")
Cc: stable@dpdk.org
Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_ethdev.c

index a4adeec..e58085a 100644 (file)
@@ -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",