[dpdk-dev,1/3] eal: new interrupt handler type

Message ID 1444067795-29748-2-git-send-email-adrien.mazarguil@6wind.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Adrien Mazarguil Oct. 5, 2015, 5:56 p.m. UTC
  From: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Add RTE_INTR_HANDLE_EXT handler type for PMDs that do not support VFIO or
UIO.  Those are expected to manage the file descriptor themselves.

Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 lib/librte_eal/linuxapp/eal/eal_interrupts.c       | 34 ++++++++++++----------
 .../linuxapp/eal/include/exec-env/rte_interrupts.h |  1 +
 2 files changed, 20 insertions(+), 15 deletions(-)
  

Comments

David Marchand Oct. 20, 2015, 8:25 p.m. UTC | #1
On Mon, Oct 5, 2015 at 7:56 PM, Adrien Mazarguil <adrien.mazarguil@6wind.com
> wrote:

> From: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
>
> Add RTE_INTR_HANDLE_EXT handler type for PMDs that do not support VFIO or
> UIO.  Those are expected to manage the file descriptor themselves.
>
> Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
>

Maybe a title like "eal: allow external interrupt handler" would be better.
Acked-by: David Marchand <david.marchand@6wind.com>
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 078318c..79eedaf 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -691,26 +691,30 @@  eal_intr_process_interrupts(struct epoll_event *events, int nfds)
 			bytes_read = sizeof(buf.vfio_intr_count);
 			break;
 #endif
+		case RTE_INTR_HANDLE_EXT:
 		default:
 			bytes_read = 1;
 			break;
 		}
 
-		/**
-		 * read out to clear the ready-to-be-read flag
-		 * for epoll_wait.
-		 */
-		bytes_read = read(events[n].data.fd, &buf, bytes_read);
-		if (bytes_read < 0) {
-			if (errno == EINTR || errno == EWOULDBLOCK)
-				continue;
-
-			RTE_LOG(ERR, EAL, "Error reading from file "
-				"descriptor %d: %s\n", events[n].data.fd,
-							strerror(errno));
-		} else if (bytes_read == 0)
-			RTE_LOG(ERR, EAL, "Read nothing from file "
-				"descriptor %d\n", events[n].data.fd);
+		if (src->intr_handle.type != RTE_INTR_HANDLE_EXT) {
+			/**
+			 * read out to clear the ready-to-be-read flag
+			 * for epoll_wait.
+			 */
+			bytes_read = read(events[n].data.fd, &buf, bytes_read);
+			if (bytes_read < 0) {
+				if (errno == EINTR || errno == EWOULDBLOCK)
+					continue;
+
+				RTE_LOG(ERR, EAL, "Error reading from file "
+					"descriptor %d: %s\n",
+					events[n].data.fd,
+					strerror(errno));
+			} else if (bytes_read == 0)
+				RTE_LOG(ERR, EAL, "Read nothing from file "
+					"descriptor %d\n", events[n].data.fd);
+		}
 
 		/* grab a lock, again to call callbacks and update status. */
 		rte_spinlock_lock(&intr_lock);
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 45071b7..b095b86 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
@@ -48,6 +48,7 @@  enum rte_intr_handle_type {
 	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_MAX
 };