From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by dpdk.org (Postfix) with ESMTP id E3380C672 for ; Tue, 28 Apr 2015 18:36:40 +0200 (CEST) Received: by pabtp1 with SMTP id tp1so303601pab.2 for ; Tue, 28 Apr 2015 09:36:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pYy3n2NXyuhCEKIoi9wFm3Gdf/QxGb0ieHW7sV2co30=; b=b5auDvJrVX5scqy8/YqWgwQ+KM7b+aWiT3D3nPCYqjHRTia7UDpcmKKLbCOZoNWcy3 KUuY6gD5Zsdu10Xc8YorF6rWhrxw/HrZFNsJdSbQ4KHWBukRxbLBa7GtIXMxSp1+Dycq DlbcmFWglkTDByQ/lGipszfWNYdr0RRYAlO86o3yy/2AW8mAFIPtHw+Xtv9kL7VPX853 f02Tk4mdiPULEIBVqvO23Oo7RLBBoDPqCACN8PNYIepVhmniJViAiHOz8kLePFh4Urdl D1WvygaftprMkbS/1lHSpKPKWUNPBfBmqPWH1DKY2uV8J3GfwNZgsoNyrUFtg/R/t1Q+ u/iw== X-Gm-Message-State: ALoCoQlBJQMhM3Jj3TYM8j9b801rgxuzdHrDt+JXRWJYaczTlKzqM+KEEGPaoqRyfk/a7IHV/RVf X-Received: by 10.68.248.129 with SMTP id ym1mr33087790pbc.101.1430239000246; Tue, 28 Apr 2015 09:36:40 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by mx.google.com with ESMTPSA id yc2sm22833392pbb.87.2015.04.28.09.36.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Apr 2015 09:36:39 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Date: Tue, 28 Apr 2015 09:36:40 -0700 Message-Id: <1430239000-30881-4-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1430239000-30881-1-git-send-email-stephen@networkplumber.org> References: <1430239000-30881-1-git-send-email-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH 3/3] eal: use pci_uio_read/write config to enable/disable INTX X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2015 16:36:42 -0000 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 --- 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 #include #include +#include #include #include #include @@ -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