net/virtio: unbind interrupt/eventfd when stopping
authorJianfeng Tan <jianfeng.tan@intel.com>
Tue, 17 Jan 2017 07:10:27 +0000 (07:10 +0000)
committerYuanhan Liu <yuanhan.liu@linux.intel.com>
Tue, 17 Jan 2017 08:26:57 +0000 (09:26 +0100)
When virtio devices get stopped, tell the kernel to unbind the
mapping between interrupts and eventfds.

Note: it behaves differently from other NICs which close eventfds,
free struct. In virtio, we do those things when close device in
following patch.

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Tested-by: Lei Yao <lei.a.yao@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
drivers/net/virtio/virtio_ethdev.c

index 8025382..a4cc66f 100644 (file)
@@ -1652,6 +1652,15 @@ virtio_dev_start(struct rte_eth_dev *dev)
                        PMD_DRV_LOG(ERR, "link status not supported by host");
                        return -ENOTSUP;
                }
                        PMD_DRV_LOG(ERR, "link status not supported by host");
                        return -ENOTSUP;
                }
+       }
+
+       /* Enable uio/vfio intr/eventfd mapping: althrough we already did that
+        * in device configure, but it could be unmapped  when device is
+        * stopped.
+        */
+       if (dev->data->dev_conf.intr_conf.lsc ||
+           dev->data->dev_conf.intr_conf.rxq) {
+               rte_intr_disable(dev->intr_handle);
 
                if (rte_intr_enable(dev->intr_handle) < 0) {
                        PMD_DRV_LOG(ERR, "interrupt enable failed");
 
                if (rte_intr_enable(dev->intr_handle) < 0) {
                        PMD_DRV_LOG(ERR, "interrupt enable failed");
@@ -1746,10 +1755,11 @@ static void
 virtio_dev_stop(struct rte_eth_dev *dev)
 {
        struct rte_eth_link link;
 virtio_dev_stop(struct rte_eth_dev *dev)
 {
        struct rte_eth_link link;
+       struct rte_intr_conf *intr_conf = &dev->data->dev_conf.intr_conf;
 
        PMD_INIT_LOG(DEBUG, "stop");
 
 
        PMD_INIT_LOG(DEBUG, "stop");
 
-       if (dev->data->dev_conf.intr_conf.lsc)
+       if (intr_conf->lsc || intr_conf->rxq)
                rte_intr_disable(dev->intr_handle);
 
        memset(&link, 0, sizeof(link));
                rte_intr_disable(dev->intr_handle);
 
        memset(&link, 0, sizeof(link));