summaryrefslogtreecommitdiff
path: root/drivers/net/virtio/virtio_ethdev.c
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2018-10-31 18:39:43 +0000
committerThomas Monjalon <thomas@monjalon.net>2018-11-02 10:49:22 +0100
commitf9b0d1902caf893493b5e07763ecf817c34fc75c (patch)
treea1b451854ea92d14f2cd26b4685ade1dd9d1ad59 /drivers/net/virtio/virtio_ethdev.c
parent95781f4c64419a126b864f76dd1f00f9c01e0f43 (diff)
downloaddpdk-next-eventdev-f9b0d1902caf893493b5e07763ecf817c34fc75c.zip
dpdk-next-eventdev-f9b0d1902caf893493b5e07763ecf817c34fc75c.tar.gz
dpdk-next-eventdev-f9b0d1902caf893493b5e07763ecf817c34fc75c.tar.xz
net/virtio: register/unregister intr handler on start/stop
Register and unregister the virtio interrupt handler when the device is started and stopped. This allows a virtio device to be hotplugged or unplugged. Fixes: c1f86306a026 ("virtio: add new driver") Cc: stable@dpdk.org Signed-off-by: Brian Russell <brussell@brocade.com> Signed-off-by: Luca Boccassi <bluca@debian.org> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Diffstat (limited to 'drivers/net/virtio/virtio_ethdev.c')
-rw-r--r--drivers/net/virtio/virtio_ethdev.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 10a7e3f..da87177 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1679,11 +1679,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
if (ret < 0)
goto out;
- /* Setup interrupt callback */
- if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
- rte_intr_callback_register(eth_dev->intr_handle,
- virtio_interrupt_handler, eth_dev);
-
return 0;
out:
@@ -1706,11 +1701,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
eth_dev->tx_pkt_burst = NULL;
eth_dev->rx_pkt_burst = NULL;
- /* reset interrupt callback */
- if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
- rte_intr_callback_unregister(eth_dev->intr_handle,
- virtio_interrupt_handler,
- eth_dev);
if (eth_dev->device)
rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev));
@@ -1969,6 +1959,12 @@ virtio_dev_start(struct rte_eth_dev *dev)
dev->data->dev_conf.intr_conf.rxq) {
virtio_intr_disable(dev);
+ /* Setup interrupt callback */
+ if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+ rte_intr_callback_register(dev->intr_handle,
+ virtio_interrupt_handler,
+ dev);
+
if (virtio_intr_enable(dev) < 0) {
PMD_DRV_LOG(ERR, "interrupt enable failed");
return -EIO;
@@ -2078,9 +2074,17 @@ virtio_dev_stop(struct rte_eth_dev *dev)
PMD_INIT_LOG(DEBUG, "stop");
rte_spinlock_lock(&hw->state_lock);
- if (intr_conf->lsc || intr_conf->rxq)
+ if (intr_conf->lsc || intr_conf->rxq) {
virtio_intr_disable(dev);
+ /* Reset interrupt callback */
+ if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
+ rte_intr_callback_unregister(dev->intr_handle,
+ virtio_interrupt_handler,
+ dev);
+ }
+ }
+
hw->started = 0;
memset(&link, 0, sizeof(link));
rte_eth_linkstatus_set(dev, &link);