From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id 85356A49 for ; Wed, 19 Sep 2018 14:58:13 +0200 (CEST) Received: by mail-wr1-f68.google.com with SMTP id y8-v6so2049435wrh.7 for ; Wed, 19 Sep 2018 05:58:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Bp86lqXLR1c8Vsh7ycbEg1XVFB7NiysjDh0rE9VoSP8=; b=YnvdHdFsBP/ThFMfUXwfvZkzfIxjQlRaRZdfGyQYoKQS6PDlNs0K0BXBezw4amwdv2 +1Z9lDvY0J1o8ahUfmePhcFcP9rugTF3brZykcOPyDC2zL+BRHJumjKBjtrMSBvs/BtW tpk7ef6TQyv6ctA0kQUOpBPFXtWDM6rDhugOgFs9dOdntnROaiou/7nIcWpgOj7B5ePa 4o8oOTTnP/gZhuVsBQBrefcVWa7qZqHBpqvnrvJw8opjT3kvAwa/xIbeKIfl1Z/rENj4 ylWhVwTq9ipjtW06PMJDeevzH/+hZNvxh48aNt6CL+P751+RVJtQmn0lMMrDZ6ekeXaw iMcA== X-Gm-Message-State: APzg51AJeOXfktO1efGcDqNCiAKdiRImeWJqPmNRn0BSb3H2GdxuUVb2 OLJlNTNT1S8qhEX+ZD/hGHuZ+yAHl5o= X-Google-Smtp-Source: ANB0VdYhTQVsRbpKs65i/Z6hewwCErH0eEUkrIhOCJ8ynvoUbg+In24PuF+O2sIiYoyPrJR9M79CEQ== X-Received: by 2002:adf:facf:: with SMTP id a15-v6mr28907858wrs.74.1537361892489; Wed, 19 Sep 2018 05:58:12 -0700 (PDT) Received: from localhost ([2001:1be0:110d:fcfe:489f:80a9:5d59:c6bd]) by smtp.gmail.com with ESMTPSA id 144-v6sm6093311wma.45.2018.09.19.05.58.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Sep 2018 05:58:10 -0700 (PDT) From: Luca Boccassi To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, tiwei.bie@intel.com, yongwang@vmware.com, 3chas3@gmail.com, bruce.richardson@intel.com, jianfeng.tan@intel.com, anatoly.burakov@intel.com, llouis@vmware.com, brussell@vyatta.att-mail.com Date: Wed, 19 Sep 2018 13:57:55 +0100 Message-Id: <20180919125757.17938-1-bluca@debian.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180816135032.28283-1-bluca@debian.org> References: <20180816135032.28283-1-bluca@debian.org> Subject: [dpdk-dev] [PATCH v2 1/3] net/virtio: register/unregister intr handler on start/stop X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2018 12:58:13 -0000 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 Signed-off-by: Luca Boccassi --- drivers/net/virtio/virtio_ethdev.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index b81df0a99f..adc6a30a32 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: @@ -1709,11 +1704,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) rte_free(eth_dev->data->mac_addrs); eth_dev->data->mac_addrs = 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)); @@ -1972,6 +1962,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; @@ -2081,9 +2077,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); -- 2.18.0