[dpdk-dev,v2,7/9] net/virtio: unmapping queue/irq when close device

Message ID 1482996643-113253-8-git-send-email-jianfeng.tan@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Yuanhan Liu
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation fail Compilation issues

Commit Message

Jianfeng Tan Dec. 29, 2016, 7:30 a.m. UTC
  When closing virtio devices, close eventfds, free the struct to
store queue/irq mapping.

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
  

Comments

Yuanhan Liu Dec. 30, 2016, 6:30 a.m. UTC | #1
On Thu, Dec 29, 2016 at 07:30:41AM +0000, Jianfeng Tan wrote:
> When closing virtio devices, close eventfds, free the struct to
> store queue/irq mapping.
> 
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index 0754ba0..d1a0afb 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -591,16 +591,30 @@ virtio_alloc_queues(struct rte_eth_dev *dev)
>  	return 0;
>  }
>  
> +static void virtio_queues_unbind_intr(struct rte_eth_dev *dev);
> +
>  static void
>  virtio_dev_close(struct rte_eth_dev *dev)
>  {
>  	struct virtio_hw *hw = dev->data->dev_private;
> +	struct rte_intr_conf *intr_conf = &dev->data->dev_conf.intr_conf;
> +	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;

I saw quite many occurrence of the two, maybe you could define few
macros for that, say VIRTIO_INTR_ENABLED, VIRTIO_RX_INTR_ENABLED,
VIRTIO_LSC_INTR_ENABLED?

	--yliu
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 0754ba0..d1a0afb 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -591,16 +591,30 @@  virtio_alloc_queues(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static void virtio_queues_unbind_intr(struct rte_eth_dev *dev);
+
 static void
 virtio_dev_close(struct rte_eth_dev *dev)
 {
 	struct virtio_hw *hw = dev->data->dev_private;
+	struct rte_intr_conf *intr_conf = &dev->data->dev_conf.intr_conf;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
 
 	PMD_INIT_LOG(DEBUG, "virtio_dev_close");
 
 	/* reset the NIC */
-	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+	if (intr_conf->lsc)
 		vtpci_irq_config(hw, VIRTIO_MSI_NO_VECTOR);
+	if (intr_conf->lsc)
+		virtio_queues_unbind_intr(dev);
+
+	if (intr_conf->lsc || intr_conf->rxq) {
+		rte_intr_disable(intr_handle);
+		rte_intr_efd_disable(intr_handle);
+		rte_free(intr_handle->intr_vec);
+		intr_handle->intr_vec = NULL;
+	}
+
 	vtpci_reset(hw);
 	virtio_dev_free_mbufs(dev);
 	virtio_free_queues(hw);
@@ -1232,6 +1246,17 @@  virtio_queues_bind_intr(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static void
+virtio_queues_unbind_intr(struct rte_eth_dev *dev)
+{
+	uint32_t i;
+	struct virtio_hw *hw = dev->data->dev_private;
+
+	PMD_INIT_LOG(INFO, "queue/interrupt unbinding\n");
+	for (i = 0; i < dev->data->nb_rx_queues; ++i)
+		vtpci_irq_queue(hw->vqs[i * VTNET_CQ], VIRTIO_MSI_NO_VECTOR);
+}
+
 static int
 virtio_configure_intr(struct rte_eth_dev *dev)
 {