From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id CF82B6882 for ; Thu, 5 Jun 2014 16:39:33 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 05 Jun 2014 07:39:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,981,1392192000"; d="scan'208";a="542939365" Received: from sie-lab-212-143.ir.intel.com (HELO silpixa00385294.ir.intel.com) ([10.237.212.143]) by fmsmga001.fm.intel.com with ESMTP; 05 Jun 2014 07:39:36 -0700 From: Alan Carew To: dev@dpdk.org Date: Thu, 5 Jun 2014 15:39:18 +0100 Message-Id: <1401979159-14576-4-git-send-email-alan.carew@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1401979159-14576-1-git-send-email-alan.carew@intel.com> References: <1401979159-14576-1-git-send-email-alan.carew@intel.com> Subject: [dpdk-dev] [PATCH 3/4] [PATCH 3/4] FreeBSD: Adds the equivalent interrupt mode setting and parsing 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: Thu, 05 Jun 2014 14:39:34 -0000 This patch adds the equivalent functionality to FreeBSD as with patches 1 and 2 Signed-off-by: Alan Carew --- 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 #include #include +#include #include #include @@ -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 +}; + +/* + * 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 #include #include +#include + +#include +#include #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