DPDK patches and discussions
 help / color / mirror / Atom feed
From: Alan Carew <alan.carew@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/4] [PATCH 3/4] FreeBSD: Adds the equivalent interrupt mode setting and parsing
Date: Thu,  5 Jun 2014 15:39:18 +0100	[thread overview]
Message-ID: <1401979159-14576-4-git-send-email-alan.carew@intel.com> (raw)
In-Reply-To: <1401979159-14576-1-git-send-email-alan.carew@intel.com>

This patch adds the equivalent functionality to FreeBSD as with patches 1 and 2

Signed-off-by: Alan Carew <alan.carew@intel.com>
---
 lib/librte_eal/bsdapp/eal/eal_pci.c     |   45 +++++++++++++++++++++++++++++++
 lib/librte_eal/bsdapp/nic_uio/nic_uio.c |   14 +++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 94ae461..7c270bb 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -50,6 +50,7 @@
 #include <sys/ioctl.h>
 #include <sys/pciio.h>
 #include <dev/pci/pcireg.h>
+#include <sys/sysctl.h>
 
 #include <rte_interrupts.h>
 #include <rte_log.h>
@@ -108,6 +109,44 @@ TAILQ_HEAD(uio_res_list, uio_resource);
 
 static struct uio_res_list *uio_res_list = NULL;
 
+struct rte_pci_dev_intr_mode {
+	enum igbuio_intr_mode mode;
+	const char *name;
+};
+
+/* Table of interrupt modes */
+const struct rte_pci_dev_intr_mode interrupt_modes[] = {
+#define RTE_PCI_DEV_INTR_MODE(id, mode_name) {INTR_MODE (id, mode_name)},
+#include <rte_pci_dev_features.h>
+};
+
+/*
+ * Determine the kernel configured interrupt mode
+ */
+static int
+pci_parse_intr_mode(struct rte_pci_device *dev)
+{
+	char intr_mode[INTR_NAME_LEN];
+	unsigned int i, num_intr_modes = RTE_DIM(interrupt_modes);
+	size_t sysctl_size = sizeof(intr_mode);
+
+	if (sysctlbyname("hw.nic_uio."RTE_PCI_DEV_FEATURE_INTR_MODE, &intr_mode,
+				&sysctl_size, NULL, 0) < 0) {
+		RTE_LOG(ERR, EAL,
+			"%s(): cannot get sysctlbyname: hw.nic_uio.intr_mode\n",
+			 __func__);
+		return (-1);
+	}
+	for (i = 0; i < num_intr_modes; i++) {
+		if (!strncmp(intr_mode, interrupt_modes[i].name, INTR_NAME_LEN)) {
+			dev->intr_mode = interrupt_modes[i].mode;
+			return 0;
+		}
+	}
+	return -1;
+	
+}
+
 /* unbind kernel driver for this device */
 static int
 pci_unbind_kernel_driver(struct rte_pci_device *dev)
@@ -220,6 +259,12 @@ pci_uio_map_resource(struct rte_pci_device *dev)
 		return -1;
 	}
 
+	if (pci_parse_intr_mode(dev) < 0) {
+		RTE_LOG(ERR, EAL,
+				"%s(): unable to determine interrupt mode\n", __func__);
+		return (-1);
+	}
+
 	/* save fd if in primary process */
 	dev->intr_handle.fd = open(devname, O_RDWR);
 	if (dev->intr_handle.fd < 0) {
diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
index c10e9aa..0e17d63 100644
--- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
+++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
@@ -51,6 +51,10 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
 #include <vm/vm_pager.h>
+#include <sys/sysctl.h>
+
+#include <rte_pci_dev_feature_defs.h>
+#include <rte_pci_dev_features.h>
 
 
 #define MAX_BARS (PCIR_MAX_BAR_0 + 1)
@@ -116,6 +120,16 @@ const struct device devices[] = {
 };
 #define NUM_DEVICES (sizeof(devices)/sizeof(devices[0]))
 
+static char nic_uio_intr_mode[] = {IGBUIO_NONE_INTR_NAME};
+
+TUNABLE_STR("hw.nic_uio."RTE_PCI_DEV_FEATURE_INTR_MODE, nic_uio_intr_mode, sizeof(nic_uio_intr_mode));
+
+static SYSCTL_NODE(_hw, OID_AUTO, nic_uio, CTLFLAG_RD, 0, "nic_uio");
+
+SYSCTL_STRING(_hw_nic_uio, OID_AUTO, interrupt_mode, CTLFLAG_RW,
+			&nic_uio_intr_mode, sizeof(nic_uio_intr_mode),
+			"Configured interrupt mode");
+
 
 static devclass_t nic_uio_devclass;
 
-- 
1.7.0.7

  parent reply	other threads:[~2014-06-05 14:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05 14:39 [dpdk-dev] [PATCH 0/4] librte_pmd_virtio :Fix: virtio_pci.h non-existent virtio feature bit-flag tested Alan Carew
2014-06-05 14:39 ` [dpdk-dev] [PATCH 1/4] [PATCH 1/4] igb_uio: Add interrupt_mode sysfs entry for igb_uio devices Alan Carew
2014-06-05 17:20   ` Stephen Hemminger
2014-06-05 14:39 ` [dpdk-dev] [PATCH 2/4] [PATCH 2/4] eal_pci: Add interrupt mode to rte_pci_device and parsing to eal_pci Alan Carew
2014-06-05 14:39 ` Alan Carew [this message]
2014-06-05 14:39 ` [dpdk-dev] [PATCH 4/4] [PATCH 4/4] virtio: Fixes the VIRTIO_PCI_CONFIG macro to use the correct offset to the Virtio header Alan Carew
2014-06-05 15:22 ` [dpdk-dev] [PATCH 0/4] librte_pmd_virtio :Fix: virtio_pci.h non-existent virtio feature bit-flag tested Stephen Hemminger
2014-06-05 17:06 ` Stephen Hemminger
2014-06-16 10:19 ` Carew, Alan

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=1401979159-14576-4-git-send-email-alan.carew@intel.com \
    --to=alan.carew@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).