summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorChas Williams <ciwillia@brocade.com>2017-07-17 19:05:22 -0400
committerFerruh Yigit <ferruh.yigit@intel.com>2018-11-05 15:01:25 +0100
commit2a821d81f355a40508c81c006f1e3002a1ba2494 (patch)
tree62cab13a170cd4cb35a6f857c761c60507719190 /drivers
parent0408f47ba4d67f0cb96f5e907bc9336b6cbff0dd (diff)
downloaddpdk-2a821d81f355a40508c81c006f1e3002a1ba2494.zip
dpdk-2a821d81f355a40508c81c006f1e3002a1ba2494.tar.gz
dpdk-2a821d81f355a40508c81c006f1e3002a1ba2494.tar.xz
net/virtio: do not re-enter clean up routines
.dev_uninit calls .dev_stop and .dev_close. The work that is done in those routines doesn't need repeated. Use started and opened to track the adapter's status. Fixes: c1f86306a026 ("virtio: add new driver") Cc: stable@dpdk.org Signed-off-by: Chas Williams <ciwillia@brocade.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/virtio/virtio_ethdev.c16
-rw-r--r--drivers/net/virtio/virtio_pci.h3
2 files changed, 15 insertions, 4 deletions
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index cb6248e..e1fe36a 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -588,6 +588,10 @@ virtio_dev_close(struct rte_eth_dev *dev)
PMD_INIT_LOG(DEBUG, "virtio_dev_close");
+ if (!hw->opened)
+ return;
+ hw->opened = false;
+
/* reset the NIC */
if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
VTPCI_OPS(hw)->set_config_irq(hw, VIRTIO_MSI_NO_VECTOR);
@@ -1924,6 +1928,8 @@ virtio_dev_configure(struct rte_eth_dev *dev)
DEV_RX_OFFLOAD_VLAN_STRIP))
hw->use_simple_rx = 0;
+ hw->opened = true;
+
return 0;
}
@@ -2014,7 +2020,7 @@ virtio_dev_start(struct rte_eth_dev *dev)
}
set_rxtx_funcs(dev);
- hw->started = 1;
+ hw->started = true;
/* Initialize Link state */
virtio_dev_link_update(dev, 0);
@@ -2080,6 +2086,10 @@ virtio_dev_stop(struct rte_eth_dev *dev)
PMD_INIT_LOG(DEBUG, "stop");
rte_spinlock_lock(&hw->state_lock);
+ if (!hw->started)
+ goto out_unlock;
+ hw->started = false;
+
if (intr_conf->lsc || intr_conf->rxq) {
virtio_intr_disable(dev);
@@ -2091,9 +2101,9 @@ virtio_dev_stop(struct rte_eth_dev *dev)
}
}
- hw->started = 0;
memset(&link, 0, sizeof(link));
rte_eth_linkstatus_set(dev, &link);
+out_unlock:
rte_spinlock_unlock(&hw->state_lock);
}
@@ -2109,7 +2119,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
link.link_speed = ETH_SPEED_NUM_10G;
link.link_autoneg = ETH_LINK_FIXED;
- if (hw->started == 0) {
+ if (!hw->started) {
link.link_status = ETH_LINK_DOWN;
} else if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
PMD_INIT_LOG(DEBUG, "Get link status from hw");
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index 64ba6ec..e961a58 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -231,7 +231,7 @@ struct virtio_hw {
uint64_t req_guest_features;
uint64_t guest_features;
uint32_t max_queue_pairs;
- uint16_t started;
+ bool started;
uint16_t max_mtu;
uint16_t vtnet_hdr_size;
uint8_t vlan_strip;
@@ -257,6 +257,7 @@ struct virtio_hw {
*/
rte_spinlock_t state_lock;
struct rte_mbuf **inject_pkts;
+ bool opened;
struct virtqueue **vqs;
};