From: Santosh Shukla <sshukla@mvista.com>
To: dev@dpdk.org
Cc: Rakesh Krishnamurthy <rakeshk@mvista.com>,
Rizwan Ansari <ransari@mvista.com>
Subject: [dpdk-dev] [ [PATCH v2] 09/13] igb_uio: ioport: map iopci region for armv7/v8
Date: Mon, 14 Dec 2015 18:30:28 +0530 [thread overview]
Message-ID: <1450098032-21198-10-git-send-email-sshukla@mvista.com> (raw)
In-Reply-To: <1450098032-21198-1-git-send-email-sshukla@mvista.com>
Module maps iopci region by creating misc device file /dev/igb_ioport.
Applicable for non-x86 arch, tested for arm64/ThuderX platform.
Including three api to register/unregister ioport misc device
- igbuio_ioport_register
- igbuio_ioport_unregister
- igbuio_iomap
Signed-off-by: Santosh Shukla <sshukla@mvista.com>
Signed-off-by: Rizwan Ansari <ransari@mvista.com>
Signed-off-by: Rakesh Krishnamurthy <rakeshk@mvista.com>
---
lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 8 +-
.../linuxapp/igb_uio/igbuio_ioport_misc.h | 133 ++++++++++++++++++++
2 files changed, 140 insertions(+), 1 deletion(-)
create mode 100644 lib/librte_eal/linuxapp/igb_uio/igbuio_ioport_misc.h
diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
index f5617d2..155bf39 100644
--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
@@ -39,6 +39,7 @@
#include <rte_pci_dev_features.h>
#include "compat.h"
+#include "igbuio_ioport_misc.h"
#ifdef RTE_PCI_CONFIG
#define PCI_SYS_FILE_BUF_SIZE 10
@@ -366,7 +367,7 @@ igbuio_pci_setup_ioport(struct pci_dev *dev, struct uio_info *info,
return -EINVAL;
info->port[n].name = name;
- info->port[n].start = addr;
+ info->port[n].start = igbuio_iomap(addr);
info->port[n].size = len;
info->port[n].porttype = UIO_PORT_X86;
@@ -615,6 +616,10 @@ igbuio_pci_init_module(void)
{
int ret;
+ ret = igbuio_ioport_register();
+ if (ret < 0)
+ return ret;
+
ret = igbuio_config_intr_mode(intr_mode);
if (ret < 0)
return ret;
@@ -625,6 +630,7 @@ igbuio_pci_init_module(void)
static void __exit
igbuio_pci_exit_module(void)
{
+ igbuio_ioport_unregister();
pci_unregister_driver(&igbuio_pci_driver);
}
diff --git a/lib/librte_eal/linuxapp/igb_uio/igbuio_ioport_misc.h b/lib/librte_eal/linuxapp/igb_uio/igbuio_ioport_misc.h
new file mode 100644
index 0000000..04e2c28
--- /dev/null
+++ b/lib/librte_eal/linuxapp/igb_uio/igbuio_ioport_misc.h
@@ -0,0 +1,133 @@
+/*-
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2015 Cavium Networks. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.
+ *
+ * Contact Information:
+ * Cavium Networks
+ */
+
+#ifndef _IGBUIO_IOPORT_MISC_H_
+#define _IGBUIO_IOPORT_MISC_H_
+
+unsigned long igbuio_iomap(unsigned long addr);
+int igbuio_ioport_register(void);
+void igbuio_ioport_unregister(void);
+
+#if defined(RTE_ARCH_ARM) || defined(RTE_ARCH_ARM64)
+#ifdef CONFIG_HAS_IOPORT_MAP
+/*
+ * mmap driver to map x86-style PCI_IOBAR (i.e..cat /proc/ioport pci-bar-memory)
+ * from kernel-space virtual address to user-space virtual address. This module
+ * required for non-x86 archs example arm/arm64, as those archs donot do
+ * IO_MAP_IO types access, Infact supports memory-mapped-IO. That is because
+ * arm/arm64 doesn't support direct IO instruction, so the design approach is to
+ * map `cat /proc/ioport` PCI_IOBAR's kernel-space virtual-addr to user-space
+ * virtual-addr. Therefore the need for mmap-driver.
+ */
+#include <linux/fs.h> /* file_operations */
+#include <linux/miscdevice.h>
+#include <linux/mm.h> /* VM_IO */
+#include <linux/uaccess.h>
+#include <asm/page.h>
+#include <asm/io.h>
+#include <linux/sched.h>
+#include <linux/pid.h>
+
+void *__iomem mapped_io; /* ioport addr of `cat /proc/ioport` */
+
+static int igbuio_ioport_mmap(struct file *file, struct vm_area_struct *vma)
+{
+ struct page *npage;
+ int ret = 0;
+
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+ npage = vmalloc_to_page(mapped_io);
+ ret = remap_pfn_range(vma, vma->vm_start,
+ page_to_pfn(npage),
+ vma->vm_end - vma->vm_start,
+ vma->vm_page_prot);
+ if (ret) {
+ pr_info("Error: Failed to remap pfn=%lu error=%d\n",
+ page_to_pfn(npage), ret);
+ }
+ return 0;
+}
+
+static const struct file_operations igbuio_ioport_fops = {
+ .mmap = igbuio_ioport_mmap,
+};
+
+static struct miscdevice igbuio_ioport_dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "igb_ioport",
+ .fops = &igbuio_ioport_fops
+};
+
+unsigned long igbuio_iomap(unsigned long addr)
+{
+ mapped_io = ioport_map(addr, 0);
+ return (unsigned long)(uintptr_t)mapped_io;
+}
+
+int igbuio_ioport_register(void)
+{
+ int ret;
+ ret = misc_register(&igbuio_ioport_dev);
+ if (ret < 0) {
+ pr_info("Error: failed to register ioport map driver (%d)\n",
+ ret);
+ return ret;
+ }
+ return ret;
+}
+
+void igbuio_ioport_unregister(void)
+{
+ misc_deregister(&igbuio_ioport_dev);
+}
+
+#else /* !CONFIG_HAS_IOPORT_MAP */
+
+#error "CONFIG_HAS_IOPORT_MAP not supported for $RTE_ARCH"
+
+#endif /* CONFIG_HAS_IOPORT_MAP */
+
+#else /* !RTE_ARCH_ARM, !RTE_ARCH_ARM64 */
+
+unsigned long igbuio_iomap(unsigned long addr)
+{
+ /* non-arm case : simply return addr */
+ return addr;
+}
+
+int igbuio_ioport_register(void)
+{
+ /* non-arm case : do nothing */
+ return 0;
+}
+
+void igbuio_ioport_unregister(void)
+{
+ /* non-arm case : do nothing */
+ return;
+}
+
+#endif /* RTE_ARCH_ARM , RTE_ARCH_ARM64 */
+
+#endif /* _IGBUIO_IOPORT_MISC_H_ */
--
1.7.9.5
next prev parent reply other threads:[~2015-12-14 13:01 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-14 13:00 [dpdk-dev] [ [PATCH v2] 00/13] Add virtio support in arm/arm64 Santosh Shukla
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 01/13] virtio: Introduce config RTE_VIRTIO_INC_VECTOR Santosh Shukla
2015-12-17 12:02 ` Santosh Shukla
2015-12-17 12:03 ` Thomas Monjalon
2015-12-17 12:18 ` Santosh Shukla
2015-12-17 23:24 ` Stephen Hemminger
2015-12-18 1:31 ` Yuanhan Liu
2015-12-18 9:52 ` Xie, Huawei
2015-12-18 10:41 ` Thomas Monjalon
2015-12-18 17:33 ` Stephen Hemminger
2015-12-18 18:11 ` Thomas Monjalon
2015-12-18 12:46 ` Santosh Shukla
2015-12-22 6:26 ` Yuanhan Liu
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 02/13] config: i686: set RTE_VIRTIO_INC_VECTOR=n Santosh Shukla
2015-12-17 12:03 ` Santosh Shukla
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 03/13] rte_io: armv7/v8: Introduce api to emulate x86-style of PCI/ISA ioport access Santosh Shukla
2015-12-14 14:25 ` Jerin Jacob
2015-12-14 16:29 ` Santosh Shukla
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 04/13] virtio_pci: use rte_io.h for non-x86 arch Santosh Shukla
2015-12-14 14:28 ` Jerin Jacob
2015-12-14 15:29 ` Santosh Shukla
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 05/13] virtio: change io_base datatype from uint32_t to uint64_type Santosh Shukla
2015-12-16 13:48 ` Yuanhan Liu
2015-12-16 14:01 ` Santosh Shukla
2015-12-16 14:23 ` Yuanhan Liu
2015-12-16 14:39 ` Santosh Shukla
2015-12-16 14:58 ` Yuanhan Liu
2015-12-16 15:05 ` Santosh Shukla
2015-12-17 7:19 ` Yuanhan Liu
2015-12-17 8:17 ` Santosh Shukla
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 06/13] config: armv7/v8: Enable RTE_LIBRTE_VIRTIO_PMD Santosh Shukla
2015-12-14 14:31 ` Jerin Jacob
2015-12-14 16:16 ` Santosh Shukla
2015-12-15 5:36 ` Jianbo Liu
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 07/13] linuxapp: eal: arm: Always return 0 for rte_eal_iopl_init() Santosh Shukla
2015-12-14 14:34 ` Jan Viktorin
2015-12-14 15:04 ` Santosh Shukla
2015-12-14 14:37 ` Jerin Jacob
2015-12-14 15:24 ` Santosh Shukla
2015-12-14 15:56 ` Jerin Jacob
2015-12-14 16:13 ` Santosh Shukla
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 08/13] rte_io: x86: Remove sys/io.h ifdef x86 clutter Santosh Shukla
2015-12-14 13:00 ` Santosh Shukla [this message]
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 10/13] include/exec-env: ioport: add rte_virt_ioport header file Santosh Shukla
2015-12-14 14:43 ` Jerin Jacob
2015-12-14 16:17 ` Santosh Shukla
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 11/13] virtio_ioport: armv7/v8: mmap virtio iopci bar region Santosh Shukla
2015-12-16 13:29 ` Yuanhan Liu
2015-12-16 14:20 ` Santosh Shukla
2015-12-16 14:37 ` Yuanhan Liu
2015-12-16 14:40 ` Santosh Shukla
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 12/13] virtio_ethdev: use virtio_ioport api at device init/close Santosh Shukla
2015-12-14 13:00 ` [dpdk-dev] [ [PATCH v2] 13/13] virtio_ethdev : fix format specifier error for 64bit addr case Santosh Shukla
2015-12-14 14:31 ` [dpdk-dev] [ [PATCH v2] 00/13] Add virtio support in arm/arm64 Jan Viktorin
2015-12-14 16:09 ` Santosh Shukla
2015-12-16 7:48 ` Santosh Shukla
2015-12-16 8:47 ` David Marchand
2015-12-16 11:43 ` Santosh Shukla
2015-12-16 12:31 ` [dpdk-dev] [PATCH] eal: map io resources for non x86 architectures David Marchand
2015-12-16 12:48 ` Yuanhan Liu
2015-12-16 13:34 ` David Marchand
2015-12-16 13:42 ` Yuanhan Liu
2015-12-16 13:51 ` Santosh Shukla
2015-12-17 9:38 ` Yuanhan Liu
2015-12-17 10:01 ` Santosh Shukla
2015-12-17 10:02 ` Santosh Shukla
2015-12-17 10:07 ` Santosh Shukla
2015-12-17 10:14 ` Thomas Monjalon
2015-12-17 10:21 ` Santosh Shukla
2015-12-17 10:33 ` Thomas Monjalon
2015-12-17 11:22 ` Santosh Shukla
2015-12-18 5:30 ` Yuanhan Liu
2015-12-18 6:34 ` Jerin Jacob
2015-12-18 7:55 ` Yuanhan Liu
2015-12-18 9:37 ` Thomas Monjalon
2015-12-18 7:54 ` Santosh Shukla
2015-12-18 8:21 ` Yuanhan Liu
2015-12-18 12:55 ` Santosh Shukla
2015-12-29 5:56 ` Santosh Shukla
2015-12-29 9:56 ` Burakov, Anatoly
2015-12-29 10:47 ` Santosh Shukla
2015-12-29 11:06 ` Burakov, Anatoly
2015-12-29 12:23 ` Santosh Shukla
2015-12-29 14:04 ` Alex Williamson
2015-12-29 14:51 ` Santosh Shukla
2015-12-31 14:27 ` Santosh Shukla
2015-12-16 13:15 ` Bruce Richardson
2015-12-16 13:29 ` David Marchand
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=1450098032-21198-10-git-send-email-sshukla@mvista.com \
--to=sshukla@mvista.com \
--cc=dev@dpdk.org \
--cc=rakeshk@mvista.com \
--cc=ransari@mvista.com \
/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).