DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: yuanhan.liu@linux.intel.com, david.marchand@6wind.com,
	Jianfeng Tan <jianfeng.tan@intel.com>
Subject: [dpdk-dev] [PATCH 1/5] eal/linux: add interrupt type for vdev
Date: Fri,  3 Mar 2017 17:56:39 +0000	[thread overview]
Message-ID: <1488563803-87754-2-git-send-email-jianfeng.tan@intel.com> (raw)
In-Reply-To: <1488563803-87754-1-git-send-email-jianfeng.tan@intel.com>

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_interrupts.c       | 32 ++++++++++++++++++++--
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c         |  2 ++
 .../linuxapp/eal/include/exec-env/rte_interrupts.h |  5 ++--
 3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index b5b3f2b..afe6ee6 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -46,6 +46,7 @@
 #include <sys/ioctl.h>
 #include <sys/eventfd.h>
 #include <assert.h>
+#include <stdbool.h>
 
 #include <rte_common.h>
 #include <rte_interrupts.h>
@@ -581,6 +582,9 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,
 int
 rte_intr_enable(const struct rte_intr_handle *intr_handle)
 {
+	if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV)
+		return 0;
+
 	if (!intr_handle || intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0)
 		return -1;
 
@@ -625,6 +629,9 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)
 int
 rte_intr_disable(const struct rte_intr_handle *intr_handle)
 {
+	if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV)
+		return 0;
+
 	if (!intr_handle || intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0)
 		return -1;
 
@@ -669,6 +676,7 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)
 static int
 eal_intr_process_interrupts(struct epoll_event *events, int nfds)
 {
+	bool call;
 	int n, bytes_read;
 	struct rte_intr_source *src;
 	struct rte_intr_callback *cb;
@@ -701,6 +709,8 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)
 		src->active = 1;
 		rte_spinlock_unlock(&intr_lock);
 
+		call = false;
+
 		/* set the length to be read dor different handle type */
 		switch (src->intr_handle.type) {
 		case RTE_INTR_HANDLE_UIO:
@@ -717,13 +727,18 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)
 			bytes_read = sizeof(buf.vfio_intr_count);
 			break;
 #endif
+		case RTE_INTR_HANDLE_VDEV:
 		case RTE_INTR_HANDLE_EXT:
+			bytes_read = 0;
+			call = true;
+			break;
+
 		default:
 			bytes_read = 1;
 			break;
 		}
 
-		if (src->intr_handle.type != RTE_INTR_HANDLE_EXT) {
+		if (bytes_read > 0) {
 			/**
 			 * read out to clear the ready-to-be-read flag
 			 * for epoll_wait.
@@ -740,12 +755,14 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)
 			} else if (bytes_read == 0)
 				RTE_LOG(ERR, EAL, "Read nothing from file "
 					"descriptor %d\n", events[n].data.fd);
+			else
+				call = true;
 		}
 
 		/* grab a lock, again to call callbacks and update status. */
 		rte_spinlock_lock(&intr_lock);
 
-		if (bytes_read > 0) {
+		if (call) {
 
 			/* Finally, call all callbacks. */
 			TAILQ_FOREACH(cb, &src->callbacks, next) {
@@ -856,7 +873,7 @@ eal_intr_thread_main(__rte_unused void *arg)
 		TAILQ_FOREACH(src, &intr_sources, next) {
 			if (src->callbacks.tqh_first == NULL)
 				continue; /* skip those with no callbacks */
-			ev.events = EPOLLIN | EPOLLPRI;
+			ev.events = EPOLLIN | EPOLLPRI | EPOLLRDHUP | EPOLLHUP;
 			ev.data.fd = src->intr_handle.fd;
 
 			/**
@@ -937,6 +954,12 @@ eal_intr_proc_rxtx_intr(int fd, const struct rte_intr_handle *intr_handle)
 		bytes_read = sizeof(buf.vfio_intr_count);
 		break;
 #endif
+	case RTE_INTR_HANDLE_VDEV:
+		/* for vdev, fd points to:
+		 * a. eventfd which does not need to read out;
+		 * b. datapath fd which needs PMD to read out.
+		 */
+		return;
 	default:
 		bytes_read = 1;
 		RTE_LOG(INFO, EAL, "unexpected intr type\n");
@@ -1242,5 +1265,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)
 	if (intr_handle->type == RTE_INTR_HANDLE_VFIO_MSIX)
 		return 1;
 
+	if (intr_handle->type == RTE_INTR_HANDLE_VDEV)
+		return 1;
+
 	return 0;
 }
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index 5f478c5..5486346 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -268,6 +268,8 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd)
 			return -1;
 		}
 
+		printf("intr_handle.fd = %d\n", fd);
+
 		dev->intr_handle.fd = fd;
 		dev->intr_handle.vfio_dev_fd = vfio_dev_fd;
 
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
index d459bf4..b8ee1de 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
@@ -49,8 +49,9 @@ enum rte_intr_handle_type {
 	RTE_INTR_HANDLE_VFIO_LEGACY,  /**< vfio device handle (legacy) */
 	RTE_INTR_HANDLE_VFIO_MSI,     /**< vfio device handle (MSI) */
 	RTE_INTR_HANDLE_VFIO_MSIX,    /**< vfio device handle (MSIX) */
-	RTE_INTR_HANDLE_ALARM,    /**< alarm handle */
-	RTE_INTR_HANDLE_EXT, /**< external handler */
+	RTE_INTR_HANDLE_ALARM,        /**< alarm handle */
+	RTE_INTR_HANDLE_EXT,          /**< external handler */
+	RTE_INTR_HANDLE_VDEV,         /**< virtual device */
 	RTE_INTR_HANDLE_MAX
 };
 
-- 
2.7.4

  reply	other threads:[~2017-03-03 17:55 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 ` Jianfeng Tan [this message]
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   ` [dpdk-dev] [PATCH v2 2/5] net/virtio: add interrupt configure " Jianfeng Tan
2017-03-29  6:27     ` 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=1488563803-87754-2-git-send-email-jianfeng.tan@intel.com \
    --to=jianfeng.tan@intel.com \
    --cc=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    --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).