On 11/2/18 10:57 AM, Maxime Coquelin wrote:
On 11/1/18 3:45 PM, Luca Boccassi wrote:
On Mon, 2017-07-17 at 19:05 -0400, Charles (Chas) Williams wrote:
.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.
Signed-off-by: Chas Williams <ciwil...@brocade.com>
---
drivers/net/virtio/virtio_ethdev.c | 15 ++++++++++++---
drivers/net/virtio/virtio_pci.h | 4 +++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/net/virtio/virtio_ethdev.c
b/drivers/net/virtio/virtio_ethdev.c
index 00a3122..eff0545 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -609,6 +609,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);
@@ -1696,6 +1700,8 @@ virtio_dev_configure(struct rte_eth_dev *dev)
return -EBUSY;
}
+ hw->opened = true;
+
return 0;
}
@@ -1759,7 +1765,7 @@ virtio_dev_start(struct rte_eth_dev *dev)
VIRTQUEUE_DUMP(txvq->vq);
}
- hw->started = 1;
+ hw->started = true;
/* Initialize Link state */
virtio_dev_link_update(dev, 0);
@@ -1824,10 +1830,13 @@ virtio_dev_stop(struct rte_eth_dev *dev)
PMD_INIT_LOG(DEBUG, "stop");
+ if (!hw->started)
+ return;
+ hw->started = false;
+
if (intr_conf->lsc || intr_conf->rxq)
rte_intr_disable(dev->intr_handle);
- hw->started = 0;
memset(&link, 0, sizeof(link));
virtio_dev_atomic_write_link_status(dev, &link);
}
@@ -1844,7 +1853,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev,
__rte_unused int wait_to_complet
link.link_duplex = ETH_LINK_FULL_DUPLEX;
link.link_speed = SPEED_10G;
- 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 18caebd..65bad2d 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -35,6 +35,7 @@
#define _VIRTIO_PCI_H_
#include <stdint.h>
+#include <stdbool.h>
#include <rte_pci.h>
#include <rte_ethdev.h>
@@ -253,7 +254,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;
@@ -268,6 +269,7 @@ struct virtio_hw {
struct virtio_pci_common_cfg *common_cfg;
struct virtio_net_config *dev_cfg;
void *virtio_user_dev;
+ bool opened;
struct virtqueue **vqs;
};
Hi Maxime,
Any chance this could be reviewed and taken care of, please? It's been
forgotten in the queue for a year, but we still use it.
I have sent 2/2 separately so ignore that (I didn't notice this series
was still pending review).
Thanks!
Reviewed-by: Maxime Coquelin <maxime.coque...@redhat.com>
I'll certainly have to rebase it, but it should be trivial.
And as discussed on IRC, it fixes a real issue, so will have to be
backported to stable. I'll take care of it.
Regards,
Maxime
Applied to dpdk-next-virtio/master
If you have some time, please have a look at the branch to ensure the
rebase is correct.
Thanks,
Maxime