From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 2/3] eal: add interrupt enable/disable routines for uio_pci_generic
Date: Fri, 20 Feb 2015 16:59:16 +0000 [thread overview]
Message-ID: <1424451557-27419-3-git-send-email-bruce.richardson@intel.com> (raw)
In-Reply-To: <1424451557-27419-1-git-send-email-bruce.richardson@intel.com>
From: Zhou Danny <danny.zhou@intel.com>
enable/disable interrupt by manipulating a control bit of command
register on NIC's PCIe configuration space.
Signed-off-by: Danny Zhou <danny.zhou@intel.com>
Tested-by: Qun Wan <qun.wan@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/librte_eal/linuxapp/eal/eal_interrupts.c | 68 +++++++++++++++++++++-------
1 file changed, 52 insertions(+), 16 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index dc2668a..8c5b834 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -361,6 +361,54 @@ vfio_disable_msix(struct rte_intr_handle *intr_handle) {
}
#endif
+static int
+uio_intr_disable(struct rte_intr_handle *intr_handle)
+{
+ unsigned char command_high;
+
+ /* use UIO config file descriptor for uio_pci_generic */
+ if (pread(intr_handle->uio_cfg_fd, &command_high, 1, 5) != 1) {
+ 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) {
+ RTE_LOG(ERR, EAL,
+ "Error disabling interrupts for fd %d\n",
+ intr_handle->uio_cfg_fd);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+uio_intr_enable(struct rte_intr_handle *intr_handle)
+{
+ unsigned char command_high;
+
+ /* use UIO config file descriptor for uio_pci_generic */
+ if (pread(intr_handle->uio_cfg_fd, &command_high, 1, 5) != 1) {
+ 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) {
+ RTE_LOG(ERR, EAL,
+ "Error enabling interrupts for fd %d\n",
+ intr_handle->uio_cfg_fd);
+ return -1;
+ }
+
+ return 0;
+}
+
int
rte_intr_callback_register(struct rte_intr_handle *intr_handle,
rte_intr_callback_fn cb, void *cb_arg)
@@ -500,20 +548,14 @@ rte_intr_callback_unregister(struct rte_intr_handle *intr_handle,
int
rte_intr_enable(struct rte_intr_handle *intr_handle)
{
- const int value = 1;
-
- if (!intr_handle || intr_handle->fd < 0)
+ if (!intr_handle || intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0)
return -1;
switch (intr_handle->type){
/* write to the uio fd to enable the interrupt */
case RTE_INTR_HANDLE_UIO:
- if (write(intr_handle->fd, &value, sizeof(value)) < 0) {
- RTE_LOG(ERR, EAL,
- "Error enabling interrupts for fd %d\n",
- intr_handle->fd);
+ if (uio_intr_enable(intr_handle))
return -1;
- }
break;
/* not used at this moment */
case RTE_INTR_HANDLE_ALARM:
@@ -546,20 +588,14 @@ rte_intr_enable(struct rte_intr_handle *intr_handle)
int
rte_intr_disable(struct rte_intr_handle *intr_handle)
{
- const int value = 0;
-
- if (!intr_handle || intr_handle->fd < 0)
+ if (!intr_handle || intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0)
return -1;
switch (intr_handle->type){
/* write to the uio fd to disable the interrupt */
case RTE_INTR_HANDLE_UIO:
- if (write(intr_handle->fd, &value, sizeof(value)) < 0){
- RTE_LOG(ERR, EAL,
- "Error disabling interrupts for fd %d\n",
- intr_handle->fd);
+ if (uio_intr_disable(intr_handle))
return -1;
- }
break;
/* not used at this moment */
case RTE_INTR_HANDLE_ALARM:
--
2.1.0
next prev parent reply other threads:[~2015-02-20 16:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-19 17:08 [dpdk-dev] [PATCH v2 0/3] Enable uio_pci_generic support Zhou Danny
2015-02-19 17:08 ` [dpdk-dev] [PATCH v2 1/3] eal: enable " Zhou Danny
2015-02-20 9:01 ` Thomas Monjalon
2015-02-20 10:15 ` Bruce Richardson
2015-02-19 17:08 ` [dpdk-dev] [PATCH v2 2/3] eal: add interrupt enable/disable routines for uio_pci_generic Zhou Danny
2015-02-19 17:08 ` [dpdk-dev] [PATCH v2 3/3] tools: enable binding NIC device to uio_pci_generic Zhou Danny
2015-02-20 16:59 ` [dpdk-dev] [PATCH v3 0/3] enable uio_pci_generic support Bruce Richardson
2015-02-20 16:59 ` [dpdk-dev] [PATCH v3 1/3] eal: " Bruce Richardson
2015-02-23 15:24 ` David Marchand
2015-02-20 16:59 ` Bruce Richardson [this message]
2015-02-20 16:59 ` [dpdk-dev] [PATCH v3 3/3] tools: enable binding NIC device to uio_pci_generic Bruce Richardson
2015-02-20 17:44 ` [dpdk-dev] [PATCH v3 0/3] enable uio_pci_generic support Declan Doherty
2015-02-20 22:35 ` 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=1424451557-27419-3-git-send-email-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--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).