From: Tetsuya Mukawa <mukawa@igel.co.jp>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 2/5] EAL: Add new EAL "--qtest-virtio" option
Date: Wed, 10 Feb 2016 12:40:10 +0900 [thread overview]
Message-ID: <1455075613-3605-3-git-send-email-mukawa@igel.co.jp> (raw)
In-Reply-To: <1455075613-3605-1-git-send-email-mukawa@igel.co.jp>
In-Reply-To: <1453374478-30996-6-git-send-email-mukawa@igel.co.jp>
To work with qtest virtio-net PMD, virtual address that maps hugepages
should be between (1 << 31) to (1 << 44). This patch adds one more option
to map like this. Also all hugepages should consists of one file.
Because of this, the option will work only when '--single-file' option is
specified.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
lib/librte_eal/common/eal_common_options.c | 10 ++++
lib/librte_eal/common/eal_internal_cfg.h | 1 +
lib/librte_eal/common/eal_options.h | 2 +
lib/librte_eal/linuxapp/eal/eal_memory.c | 81 +++++++++++++++++++++++++++++-
4 files changed, 93 insertions(+), 1 deletion(-)
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 65bccbd..34c8bd1 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -96,6 +96,7 @@ eal_long_options[] = {
{OPT_VMWARE_TSC_MAP, 0, NULL, OPT_VMWARE_TSC_MAP_NUM },
{OPT_XEN_DOM0, 0, NULL, OPT_XEN_DOM0_NUM },
{OPT_SINGLE_FILE, 0, NULL, OPT_SINGLE_FILE_NUM },
+ {OPT_QTEST_VIRTIO, 0, NULL, OPT_QTEST_VIRTIO_NUM },
{0, 0, NULL, 0 }
};
@@ -902,6 +903,10 @@ eal_parse_common_option(int opt, const char *optarg,
conf->single_file = 1;
break;
+ case OPT_QTEST_VIRTIO_NUM:
+ conf->qtest_virtio = 1;
+ break;
+
/* don't know what to do, leave this to caller */
default:
return 1;
@@ -971,6 +976,11 @@ eal_check_common_options(struct internal_config *internal_cfg)
"be specified together with --"OPT_SINGLE_FILE"\n");
return -1;
}
+ if (internal_cfg->qtest_virtio && !internal_cfg->single_file) {
+ RTE_LOG(ERR, EAL, "Option --"OPT_QTEST_VIRTIO" cannot "
+ "be specified without --"OPT_SINGLE_FILE"\n");
+ return -1;
+ }
if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink) {
RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot "
diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h
index 9117ed9..7f3df39 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -71,6 +71,7 @@ struct internal_config {
volatile unsigned no_hpet; /**< true to disable HPET */
volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping
* instead of native TSC */
+ volatile unsigned qtest_virtio; /**< mmap hugepages to fit qtest virtio PMD */
volatile unsigned no_shconf; /**< true if there is no shared config */
volatile unsigned create_uio_dev; /**< true to create /dev/uioX devices */
volatile enum rte_proc_type_t process_type; /**< multi-process proc type */
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index e5da14a..b33a3c3 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -85,6 +85,8 @@ enum {
OPT_XEN_DOM0_NUM,
#define OPT_SINGLE_FILE "single-file"
OPT_SINGLE_FILE_NUM,
+#define OPT_QTEST_VIRTIO "qtest-virtio"
+ OPT_QTEST_VIRTIO_NUM,
OPT_LONG_MAX_NUM
};
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index a6b3616..677d6a7 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1092,6 +1092,73 @@ calc_num_pages_per_socket(uint64_t * memory,
}
/*
+ * Find memory space that fits qtest virtio-net PMD.
+ */
+static void *
+rte_eal_get_free_region(uint64_t alloc_size, uint64_t pagesz)
+{
+ uint64_t start, end, next_start;
+ uint64_t high_limit, low_limit;
+ char buf[1024], *p;
+ FILE *fp;
+ void *addr = NULL;
+
+ /* all hugepages should be mapped between below values */
+ low_limit = 1UL << 31;
+ high_limit = 1UL << 44;
+
+ /* allocation size should be aligned by page size */
+ if (alloc_size != RTE_ALIGN_CEIL(alloc_size, pagesz)) {
+ rte_panic("Invalid allocation size 0x%lx\n", alloc_size);
+ return NULL;
+ }
+
+ /*
+ * address should be aligned by allocation size because
+ * BAR register requiers such an address
+ */
+ low_limit = RTE_ALIGN_CEIL(low_limit, alloc_size);
+ high_limit = RTE_ALIGN_FLOOR(high_limit, alloc_size);
+
+ fp = fopen("/proc/self/maps", "r");
+ if (fp == NULL) {
+ rte_panic("Cannot open /proc/self/maps\n");
+ return NULL;
+ }
+
+ next_start = 0;
+ do {
+ start = next_start;
+
+ if ((p = fgets(buf, sizeof(buf), fp)) != NULL) {
+ if (sscanf(p, "%lx-%lx ", &end, &next_start) < 2)
+ break;
+
+ next_start = RTE_ALIGN_CEIL(next_start, alloc_size);
+ end = RTE_ALIGN_CEIL(end, alloc_size) - 1;
+ } else
+ end = UINT64_MAX;
+
+ if (start >= high_limit)
+ break;
+ if (end < low_limit)
+ continue;
+
+ start = RTE_MAX(start, low_limit);
+ end = RTE_MIN(end, high_limit - 1);
+
+ if (end - start >= alloc_size - 1) {
+ addr = (void *)start;
+ break;
+ }
+ } while (end != UINT64_MAX);
+
+ fclose(fp);
+
+ return addr;
+}
+
+/*
* Prepare physical memory mapping: fill configuration structure with
* these infos, return 0 on success.
* 1. map N huge pages in separate files in hugetlbfs
@@ -1132,6 +1199,7 @@ rte_eal_hugepage_init(void)
uint64_t pagesize;
unsigned socket_id = rte_socket_id();
char filepath[MAX_HUGEPAGE_PATH];
+ void *fixed;
if (internal_config.no_hugetlbfs) {
eal_get_hugefile_path(filepath, sizeof(filepath),
@@ -1158,7 +1226,18 @@ rte_eal_hugepage_init(void)
return -1;
}
- addr = mmap(NULL, internal_config.memory,
+ if (internal_config.qtest_virtio) {
+ fixed = rte_eal_get_free_region(
+ internal_config.memory, pagesize);
+ if (fixed == NULL) {
+ RTE_LOG(ERR, EAL, "no free space to mmap %s\n",
+ filepath);
+ return -1;
+ }
+ } else
+ fixed = NULL;
+
+ addr = mmap(fixed, internal_config.memory,
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, fd, 0);
if (addr == MAP_FAILED) {
--
2.1.4
next prev parent reply other threads:[~2016-02-10 3:40 UTC|newest]
Thread overview: 120+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-18 9:13 [dpdk-dev] [PATCH 0/3] virtio: Add a new layer to abstract pci access method Tetsuya Mukawa
2016-01-18 9:13 ` [dpdk-dev] [PATCH 1/3] virtio: Change the parameter order of io_write8/16/32() Tetsuya Mukawa
2016-01-21 11:07 ` [dpdk-dev] [RFC PATCH 0/5] virtio: Add a new layer to abstract pci access method Tetsuya Mukawa
2016-01-21 11:10 ` Tetsuya Mukawa
2016-01-21 11:07 ` [dpdk-dev] [RFC PATCH 1/5] virtio: Change the parameter order of io_write8/16/32() Tetsuya Mukawa
2016-01-21 11:07 ` [dpdk-dev] [RFC PATCH 2/5] virtio: move rte_eal_pci_unmap_device() to virtio_pci.c Tetsuya Mukawa
2016-01-21 11:07 ` [dpdk-dev] [RFC PATCH 3/5] virtio: Add a new layer to abstract pci access method Tetsuya Mukawa
2016-01-22 7:26 ` Xie, Huawei
2016-01-22 7:35 ` Tetsuya Mukawa
2016-01-21 11:07 ` [dpdk-dev] [RFC PATCH 4/5] EAL: Add new EAL "--shm" option Tetsuya Mukawa
2016-01-22 1:43 ` Tan, Jianfeng
2016-01-22 2:07 ` Tan, Jianfeng
2016-01-22 3:23 ` Tetsuya Mukawa
2016-01-21 11:07 ` [dpdk-dev] [RFC PATCH 5/5] virtio: Extend virtio-net PMD to support container environment Tetsuya Mukawa
2016-01-22 8:14 ` Xie, Huawei
2016-01-22 10:37 ` Tetsuya Mukawa
2016-01-25 10:15 ` Xie, Huawei
2016-01-26 2:58 ` Tetsuya Mukawa
2016-01-27 9:39 ` Xie, Huawei
2016-01-28 2:33 ` Tetsuya Mukawa
2016-01-25 10:17 ` Xie, Huawei
2016-01-26 2:58 ` Tetsuya Mukawa
2016-01-25 10:29 ` Xie, Huawei
2016-01-26 2:58 ` Tetsuya Mukawa
2016-01-27 10:03 ` Xie, Huawei
2016-01-28 2:44 ` Tetsuya Mukawa
2016-01-29 8:56 ` Xie, Huawei
2016-01-27 15:58 ` Xie, Huawei
2016-01-28 2:47 ` Tetsuya Mukawa
2016-01-28 9:48 ` Xie, Huawei
2016-01-28 9:53 ` Tetsuya Mukawa
2016-01-27 16:45 ` Xie, Huawei
2016-01-28 2:47 ` Tetsuya Mukawa
2016-01-28 6:15 ` Xie, Huawei
2016-01-28 6:29 ` Tetsuya Mukawa
2016-01-29 8:57 ` Yuanhan Liu
2016-01-29 9:13 ` Yuanhan Liu
2016-02-01 1:49 ` Tetsuya Mukawa
2016-02-10 3:40 ` [dpdk-dev] [PATCH v2 0/5] Virtio-net PMD: QEMU QTest extension for container Tetsuya Mukawa
2016-02-10 3:40 ` [dpdk-dev] [PATCH v2 1/5] virtio: Retrieve driver name from eth_dev Tetsuya Mukawa
2016-02-10 3:40 ` Tetsuya Mukawa [this message]
2016-02-15 7:52 ` [dpdk-dev] [PATCH v2 2/5] EAL: Add new EAL "--qtest-virtio" option Tan, Jianfeng
2016-02-16 1:32 ` Tetsuya Mukawa
2016-02-16 5:53 ` David Marchand
2016-02-16 11:36 ` Tan, Jianfeng
2016-02-17 3:36 ` Tetsuya Mukawa
2016-02-22 8:17 ` [dpdk-dev] [PATCH v3 0/6] Virtio-net PMD: QEMU QTest extension for container Tetsuya Mukawa
2016-02-22 8:17 ` [dpdk-dev] [PATCH v3 1/6] virtio: Retrieve driver name from eth_dev Tetsuya Mukawa
2016-02-22 8:17 ` [dpdk-dev] [PATCH v3 2/6] vhost: Add a function to check virtio device type Tetsuya Mukawa
2016-02-22 8:17 ` [dpdk-dev] [PATCH v3 3/6] EAL: Add new EAL "--range-virtaddr" option Tetsuya Mukawa
2016-03-04 2:20 ` Tan, Jianfeng
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 00/12] Virtio-net PMD: QEMU QTest extension for container Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 01/12] virtio: Retrieve driver name from eth_dev Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 02/12] vhost: Add a function to check virtio device type Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 03/12] EAL: Add a new "--range-virtaddr" option Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 04/12] EAL: Add a new "--align-memsize" option Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 05/12] virtio, qtest: Add QTest utility basic functions Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 06/12] virtio, qtest: Add pci device initialization function to qtest utils Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 07/12] virtio, qtest: Add functionality to share memory between QTest guest Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 08/12] virtio, qtest: Add functionality to handle interrupt Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 09/12] virtio, qtest: Add misc functions to handle pci information Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 10/12] virtio: Add QTest support to vtpci abstraction Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 11/12] virtio: Add QTest support for virtio-net PMD Tetsuya Mukawa
2016-06-02 3:29 ` [dpdk-dev] [PATCH v5 0/6] Virtio-net PMD: QEMU QTest extension for container Tetsuya Mukawa
2016-06-02 7:31 ` Yuanhan Liu
2016-06-02 9:30 ` Tetsuya Mukawa
2016-06-03 4:17 ` Yuanhan Liu
2016-06-03 13:51 ` Thomas Monjalon
2016-06-06 5:10 ` Tetsuya Mukawa
2016-06-06 7:21 ` Yuanhan Liu
2016-06-06 8:33 ` Tetsuya Mukawa
2016-06-06 8:49 ` Yuanhan Liu
2016-06-06 9:30 ` Tetsuya Mukawa
2016-06-06 9:58 ` Yuanhan Liu
2016-06-06 10:50 ` Tan, Jianfeng
2016-06-07 7:12 ` Tetsuya Mukawa
2016-06-07 7:33 ` Yuanhan Liu
2016-06-06 8:03 ` Tan, Jianfeng
2016-06-06 9:28 ` Tetsuya Mukawa
2016-06-06 10:35 ` Tan, Jianfeng
2016-06-02 3:29 ` [dpdk-dev] [PATCH v5 1/6] virtio, qtest: Add QTest utility basic functions Tetsuya Mukawa
2016-06-02 3:29 ` [dpdk-dev] [PATCH v5 2/6] virtio, qtest: Add pci device initialization function to qtest utils Tetsuya Mukawa
2016-06-02 3:29 ` [dpdk-dev] [PATCH v5 3/6] virtio, qtest: Add functionality to share memory between QTest guest Tetsuya Mukawa
2016-06-02 3:29 ` [dpdk-dev] [PATCH v5 4/6] virtio, qtest: Add misc functions to handle pci information Tetsuya Mukawa
2016-06-02 3:29 ` [dpdk-dev] [PATCH v5 5/6] virtio: Add QTest support to vtpci abstraction Tetsuya Mukawa
2016-06-02 3:29 ` [dpdk-dev] [PATCH v5 6/6] virtio: Add QTest support for virtio-net PMD Tetsuya Mukawa
2016-06-02 3:30 ` [dpdk-dev] [PATCH v1 0/2] Supplement patches for virtio-qtest to support LSC interrupt Tetsuya Mukawa
2016-06-02 3:30 ` [dpdk-dev] [PATCH v1 1/2] virtio: Handle interrupt things under vtpci abstraction Tetsuya Mukawa
2016-06-02 3:30 ` [dpdk-dev] [PATCH v1 2/2] virtio, qtest: Add functionality to handle interrupt Tetsuya Mukawa
2016-03-09 8:33 ` [dpdk-dev] [PATCH v4 12/12] docs: add release note for qtest virtio container support Tetsuya Mukawa
2016-02-22 8:17 ` [dpdk-dev] [PATCH v3 4/6] EAL: Add a new "--align-memsize" option Tetsuya Mukawa
2016-02-22 8:17 ` [dpdk-dev] [PATCH v3 5/6] virtio: Add support for qtest virtio-net PMD Tetsuya Mukawa
2016-03-04 2:18 ` Tan, Jianfeng
2016-03-04 5:05 ` Tetsuya Mukawa
2016-03-04 6:10 ` Tan, Jianfeng
2016-03-04 9:53 ` Tetsuya Mukawa
2016-02-22 8:17 ` [dpdk-dev] [PATCH v3 6/6] docs: add release note for qtest virtio container support Tetsuya Mukawa
2016-02-22 15:40 ` Mcnamara, John
2016-02-23 10:28 ` Mcnamara, John
2016-02-24 1:20 ` Tetsuya Mukawa
2016-02-10 3:40 ` [dpdk-dev] [PATCH v2 3/5] vhost: Add a function to check virtio device type Tetsuya Mukawa
2016-02-10 3:40 ` [dpdk-dev] [PATCH v2 4/5] virtio: Add support for qtest virtio-net PMD Tetsuya Mukawa
2016-02-10 3:40 ` [dpdk-dev] [PATCH v2 5/5] docs: add release note for qtest virtio container support Tetsuya Mukawa
2016-01-28 9:33 ` [dpdk-dev] [PATCH v2 0/3] virtio: Add a new layer to abstract pci access method Tetsuya Mukawa
2016-01-28 9:33 ` [dpdk-dev] [PATCH v2 1/3] virtio: Change the parameter order of io_write8/16/32() Tetsuya Mukawa
2016-01-28 9:33 ` [dpdk-dev] [PATCH v2 2/3] virtio: move rte_eal_pci_unmap_device() to virtio_pci.c Tetsuya Mukawa
2016-01-28 9:33 ` [dpdk-dev] [PATCH v2 3/3] virtio: Add a new layer to abstract pci access method Tetsuya Mukawa
2016-01-29 9:17 ` Yuanhan Liu
2016-02-01 1:50 ` Tetsuya Mukawa
2016-02-01 13:15 ` Yuanhan Liu
2016-02-02 2:19 ` Tetsuya Mukawa
2016-02-02 2:45 ` Yuanhan Liu
2016-02-02 3:55 ` Tetsuya Mukawa
2016-01-18 9:13 ` [dpdk-dev] [PATCH 2/3] virtio: move rte_eal_pci_unmap_device() to virtio_pci.c Tetsuya Mukawa
2016-01-18 9:13 ` [dpdk-dev] [PATCH 3/3] virtio: Add a new layer to abstract pci access method Tetsuya Mukawa
2016-01-18 13:46 ` Yuanhan Liu
2016-01-19 1:22 ` Tetsuya Mukawa
2016-01-19 2:41 ` Xie, Huawei
2016-01-18 13:13 ` [dpdk-dev] [PATCH 0/3] " Tan, Jianfeng
2016-01-19 1:22 ` Tetsuya Mukawa
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=1455075613-3605-3-git-send-email-mukawa@igel.co.jp \
--to=mukawa@igel.co.jp \
--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).