DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/3] eal: use pci_uio_read/write config to enable/disable INTX
Date: Tue, 28 Apr 2015 09:36:40 -0700	[thread overview]
Message-ID: <1430239000-30881-4-git-send-email-stephen@networkplumber.org> (raw)
In-Reply-To: <1430239000-30881-1-git-send-email-stephen@networkplumber.org>

Change the code use to enable/disable interrupts with UIO_PCI_GENERIC
driver. Instead of having magic constants for the PCI register values
use the standard defines available on Linux. Also use the new
routines available to peek/poke PCI config space.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/linuxapp/eal/eal_interrupts.c | 30 +++++++++++++++++-----------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 3a84b3c..3a90944 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -41,6 +41,7 @@
 #include <string.h>
 #include <errno.h>
 #include <inttypes.h>
+#include <linux/pci_regs.h>
 #include <sys/epoll.h>
 #include <sys/signalfd.h>
 #include <sys/ioctl.h>
@@ -66,6 +67,7 @@
 
 #include "eal_private.h"
 #include "eal_vfio.h"
+#include "eal_pci_init.h"
 
 #define EAL_INTR_EPOLL_WAIT_FOREVER (-1)
 
@@ -363,18 +365,20 @@ vfio_disable_msix(struct rte_intr_handle *intr_handle) {
 static int
 uio_intx_intr_disable(struct rte_intr_handle *intr_handle)
 {
-	unsigned char command_high;
+	uint16_t cmd;
 
-	/* use UIO config file descriptor for uio_pci_generic */
-	if (pread(intr_handle->uio_cfg_fd, &command_high, 1, 5) != 1) {
+	if (pci_uio_read_config(intr_handle, &cmd, sizeof(cmd),
+				PCI_COMMAND) < 0) {
 		RTE_LOG(ERR, EAL,
 			"Error reading interrupts status for fd %d\n",
 			intr_handle->uio_cfg_fd);
 		return -1;
 	}
-	/* disable interrupts */
-	command_high |= 0x4;
-	if (pwrite(intr_handle->uio_cfg_fd, &command_high, 1, 5) != 1) {
+
+	cmd |= PCI_COMMAND_INTX_DISABLE;
+
+	if (pci_uio_write_config(intr_handle, &cmd, sizeof(cmd),
+				 PCI_COMMAND) < 0) {
 		RTE_LOG(ERR, EAL,
 			"Error disabling interrupts for fd %d\n",
 			intr_handle->uio_cfg_fd);
@@ -387,18 +391,20 @@ uio_intx_intr_disable(struct rte_intr_handle *intr_handle)
 static int
 uio_intx_intr_enable(struct rte_intr_handle *intr_handle)
 {
-	unsigned char command_high;
+	uint16_t cmd;
 
-	/* use UIO config file descriptor for uio_pci_generic */
-	if (pread(intr_handle->uio_cfg_fd, &command_high, 1, 5) != 1) {
+	if (pci_uio_read_config(intr_handle, &cmd, sizeof(cmd),
+				PCI_COMMAND) < 0) {
 		RTE_LOG(ERR, EAL,
 			"Error reading interrupts status for fd %d\n",
 			intr_handle->uio_cfg_fd);
 		return -1;
 	}
-	/* enable interrupts */
-	command_high &= ~0x4;
-	if (pwrite(intr_handle->uio_cfg_fd, &command_high, 1, 5) != 1) {
+
+	cmd &= ~PCI_COMMAND_INTX_DISABLE;
+
+	if (pci_uio_write_config(intr_handle, &cmd, sizeof(cmd),
+				 PCI_COMMAND) < 0) {
 		RTE_LOG(ERR, EAL,
 			"Error enabling interrupts for fd %d\n",
 			intr_handle->uio_cfg_fd);
-- 
2.1.4

  parent reply	other threads:[~2015-04-28 16:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 16:36 [dpdk-dev] [PATCH 0/3] eal: uio irq fixes and enhancements Stephen Hemminger
2015-04-28 16:36 ` [dpdk-dev] [PATCH 1/3] uio: fix irq handling with igb_uio Stephen Hemminger
2015-04-30 16:27   ` Bruce Richardson
2015-05-13  9:31     ` Thomas Monjalon
2015-04-28 16:36 ` [dpdk-dev] [PATCH 2/3] pci: add ability to read/write config space Stephen Hemminger
2015-04-28 16:36 ` Stephen Hemminger [this message]
2015-05-12 20:02 ` [dpdk-dev] [PATCH 0/3] eal: uio irq fixes and enhancements Thomas Monjalon
2015-05-13  8:57   ` Bruce Richardson
2015-05-13  9:32     ` Thomas Monjalon

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=1430239000-30881-4-git-send-email-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /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).