From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: yuanhan.liu@linux.intel.com, david.marchand@6wind.com,
maxime.coquelin@redhat.com, Jianfeng Tan <jianfeng.tan@intel.com>
Subject: [dpdk-dev] [PATCH v2 2/5] net/virtio: add interrupt configure for vdev
Date: Tue, 28 Mar 2017 08:21:53 +0000 [thread overview]
Message-ID: <1490689316-131625-3-git-send-email-jianfeng.tan@intel.com> (raw)
In-Reply-To: <1490689316-131625-1-git-send-email-jianfeng.tan@intel.com>
For virtio PCI devices, interrupt should be configured before setting
VIRTIO_CONFIG_STATUS_DRIVER_OK so that QEMU can properly set eventfds
in the host.
For virtio virtual devices, VIRTIO_CONFIG_STATUS_DRIVER_OK should be
set firstly, so that intr_handle is initialized in
virtio_user_start_device().
To accommodate both requirements, we rearrange the sequence like this:
a. set interrupt configure for PCI devices.
b. set VIRTIO_CONFIG_STATUS_DRIVER_OK.
c. set interrupt configure for virtual devices.
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
drivers/net/virtio/virtio_ethdev.c | 57 ++++++++++++++++++++++++++++++++++----
1 file changed, 51 insertions(+), 6 deletions(-)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index d9986ab..f0213ba 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1275,7 +1275,7 @@ virtio_queues_unbind_intr(struct rte_eth_dev *dev)
}
static int
-virtio_configure_intr(struct rte_eth_dev *dev)
+virtio_configure_intr_pci(struct rte_eth_dev *dev)
{
struct virtio_hw *hw = dev->data->dev_private;
@@ -1327,6 +1327,37 @@ virtio_configure_intr(struct rte_eth_dev *dev)
return 0;
}
+static int
+virtio_configure_intr_vdev(struct rte_eth_dev *dev)
+{
+ struct virtio_hw *hw = dev->data->dev_private;
+
+ if (!dev->intr_handle->intr_vec) {
+ dev->intr_handle->intr_vec =
+ rte_zmalloc("intr_vec",
+ hw->max_queue_pairs * sizeof(int), 0);
+ if (!dev->intr_handle->intr_vec) {
+ PMD_INIT_LOG(ERR, "Failed to allocate %u rxq vectors",
+ hw->max_queue_pairs);
+ return -ENOMEM;
+ }
+ }
+
+ /* Re-register callback to update max_intr */
+ rte_intr_callback_unregister(dev->intr_handle,
+ virtio_interrupt_handler,
+ dev);
+ rte_intr_callback_register(dev->intr_handle,
+ virtio_interrupt_handler,
+ dev);
+
+ if (virtio_queues_bind_intr(dev) < 0) {
+ PMD_INIT_LOG(ERR, "Failed to bind queue/interrupt");
+ return -1;
+ }
+
+ return 0;
+}
/* reset device and renegotiate features if needed */
static int
virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
@@ -1450,15 +1481,29 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
if (ret < 0)
return ret;
- if (eth_dev->data->dev_conf.intr_conf.rxq) {
- if (virtio_configure_intr(eth_dev) < 0) {
- PMD_INIT_LOG(ERR, "failed to configure interrupt");
- return -1;
- }
+ /* For virtio PCI devices, setup interrupt configuration before
+ * setting VIRTIO_CONFIG_STATUS_DRIVER_OK, required by QEMU.
+ */
+ if (pci_dev &&
+ eth_dev->data->dev_conf.intr_conf.rxq &&
+ virtio_configure_intr_pci(eth_dev) < 0) {
+ PMD_INIT_LOG(ERR, "failed to configure interrupt");
+ return -1;
}
vtpci_reinit_complete(hw);
+ /* For virtio vdev, setup interrupt configuration after
+ * setting VIRTIO_CONFIG_STATUS_DRIVER_OK, so that intr_handle
+ * is initialized in virtio_user_start_device().
+ */
+ if (!pci_dev &&
+ eth_dev->data->dev_conf.intr_conf.rxq &&
+ virtio_configure_intr_vdev(eth_dev) < 0) {
+ PMD_INIT_LOG(ERR, "failed to configure interrupt");
+ return -1;
+ }
+
if (pci_dev)
PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
eth_dev->data->port_id, pci_dev->id.vendor_id,
--
2.7.4
next prev parent reply other threads:[~2017-03-28 8:21 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 17:56 [dpdk-dev] [PATCH 0/5] add LSC and Rxq interrupt for virtio-user Jianfeng Tan
2017-03-03 17:56 ` [dpdk-dev] [PATCH 1/5] eal/linux: add interrupt type for vdev Jianfeng Tan
2017-03-03 17:56 ` [dpdk-dev] [PATCH 2/5] net/virtio-user: add rxq interrupt mode support Jianfeng Tan
2017-03-17 6:47 ` Yuanhan Liu
2017-03-28 1:33 ` Tan, Jianfeng
2017-03-03 17:56 ` [dpdk-dev] [PATCH 3/5] net/virtio-user: support to report net status Jianfeng Tan
2017-03-17 6:54 ` Yuanhan Liu
2017-03-27 7:46 ` Tan, Jianfeng
2017-03-29 6:33 ` Yuanhan Liu
2017-03-29 7:07 ` Tan, Jianfeng
2017-03-29 7:14 ` Yuanhan Liu
2017-03-29 7:48 ` Tan, Jianfeng
2017-03-29 8:00 ` Yuanhan Liu
2017-03-29 8:33 ` Tan, Jianfeng
2017-03-29 8:36 ` Yuanhan Liu
2017-03-30 3:14 ` Tan, Jianfeng
2017-03-03 17:56 ` [dpdk-dev] [PATCH 4/5] net/virtio-user: add lsc support with vhost-user adapter Jianfeng Tan
2017-03-17 8:29 ` Yuanhan Liu
2017-03-27 1:51 ` Tan, Jianfeng
2017-03-03 17:56 ` [dpdk-dev] [PATCH 5/5] net/virtio-user: add lsc support with vhost-kernel adapter Jianfeng Tan
2017-03-28 8:21 ` [dpdk-dev] [PATCH v2 0/5] add LSC and Rxq interrupt for virtio-user Jianfeng Tan
2017-03-28 8:21 ` [dpdk-dev] [PATCH v2 1/5] eal/linux: add interrupt type for vdev Jianfeng Tan
2017-03-28 8:21 ` Jianfeng Tan [this message]
2017-03-29 6:27 ` [dpdk-dev] [PATCH v2 2/5] net/virtio: add interrupt configure " Yuanhan Liu
2017-03-29 7:03 ` Tan, Jianfeng
2017-03-29 7:09 ` Yuanhan Liu
2017-03-29 7:27 ` Tan, Jianfeng
2017-03-29 7:30 ` Yuanhan Liu
2017-03-28 8:21 ` [dpdk-dev] [PATCH v2 3/5] net/virtio-user: add rxq interrupt mode support Jianfeng Tan
2017-03-28 8:21 ` [dpdk-dev] [PATCH v2 4/5] net/virtio-user: support to report net status Jianfeng Tan
2017-03-28 8:21 ` [dpdk-dev] [PATCH v2 5/5] net/virtio-user: add lsc support Jianfeng Tan
2017-03-31 19:44 ` [dpdk-dev] [PATCH v3 0/5] add LSC and Rxq interrupt for virtio-user Jianfeng Tan
2017-03-31 19:44 ` [dpdk-dev] [PATCH v3 1/5] eal/linux: add interrupt type for vdev Jianfeng Tan
2017-03-31 19:44 ` [dpdk-dev] [PATCH v3 2/5] net/virtio-user: move eventfd open/close into init/uninit Jianfeng Tan
2017-03-31 19:44 ` [dpdk-dev] [PATCH v3 3/5] net/virtio-user: add rxq interrupt mode support Jianfeng Tan
2017-03-31 19:44 ` [dpdk-dev] [PATCH v3 4/5] net/virtio-user: support to report net status Jianfeng Tan
2017-03-31 19:44 ` [dpdk-dev] [PATCH v3 5/5] net/virtio-user: add lsc support Jianfeng Tan
2017-04-01 5:13 ` Yuanhan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1490689316-131625-3-git-send-email-jianfeng.tan@intel.com \
--to=jianfeng.tan@intel.com \
--cc=david.marchand@6wind.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=yuanhan.liu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).