[dpdk-dev,3/3] eal: use pci_uio_read/write config to enable/disable INTX
Commit Message
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(-)
@@ -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);