From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f180.google.com (mail-pf0-f180.google.com [209.85.192.180]) by dpdk.org (Postfix) with ESMTP id 76BCE58C3 for ; Mon, 22 Feb 2016 09:18:27 +0100 (CET) Received: by mail-pf0-f180.google.com with SMTP id e127so89079729pfe.3 for ; Mon, 22 Feb 2016 00:18:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=+mgT3P6cPGvpwgP9khl7Dd4jkOmp1mqUjVmK0RQOmEs=; b=GSho4o7MGoH+GyEPuPw/8VbuxwTUeYSSmClcy9HwJ97pvtkw9F3WQOH2u60xAaM37k MoABbppXQo4jOhnoAElKyG/MEXG8W/LvXqDxLWxJoLk+JtgSl+F2N003kfQ7JinQ63Su V+0qWZCGRNmxdUHXzAGB/X5KDt8GOhr87ZpU5E8VGfZt/l5j82cuFkmnujzOhuUuRp9p e63KIWOKZ+EiwmygGOwWXhkK9mMGCOffO4LlXUu4YibNo5gz15BIbCwYKAcaL+2Qhv20 xvLfL6xKLaj3GqqhK+rSehdTzgqLqYEiX0k5neqgP9+cx6zwmr0Pq0KyLT2OiilKh+cQ XIPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=+mgT3P6cPGvpwgP9khl7Dd4jkOmp1mqUjVmK0RQOmEs=; b=AuXfU7vCs3LTD7t92pfeqaT9JdbGzvsqFv7u2l2gFYYEtZ/MdGR/gbaoRz8dOfXDSt agCKJvqNHa/NKaLt9OTVpCa6h2fwqzujUsWdGOLHhHqOQG6QIsh7Vf1TeAFTF8TA71Ok 6rOxOlXuw5SNlFS2aEUiCz2xID+h2Y8P/yjjo465uoD4/iFPk+u6jzCR36FcHQcL0SJK 4YN3/VmEHf31A98bv3Gl7yvjF9Wgl0uXFECVovJ3Y+2/AJptRQVNVfm226CVPsKS0mCK nSSzc0P1ORaG/QqD6uii6T1SLN6TiN5c9jVTSwon/wX6nGMmo9vbgOC5xyUA69LC7w3s 90BQ== X-Gm-Message-State: AG10YOQ+Ox52a3w7E7LIkFhOTZkY/WKnoyt223wA2JEnjGeKEFboArjWAB7/UAgmpwtjMw== X-Received: by 10.98.1.85 with SMTP id 82mr36974555pfb.10.1456129106930; Mon, 22 Feb 2016 00:18:26 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id xg9sm34945136pac.9.2016.02.22.00.18.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Feb 2016 00:18:24 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Mon, 22 Feb 2016 17:17:53 +0900 Message-Id: <1456129075-14909-5-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456129075-14909-1-git-send-email-mukawa@igel.co.jp> References: <1456129075-14909-1-git-send-email-mukawa@igel.co.jp> In-Reply-To: <1455075613-3605-3-git-send-email-mukawa@igel.co.jp> References: <1455075613-3605-3-git-send-email-mukawa@igel.co.jp> Subject: [dpdk-dev] [PATCH v3 4/6] EAL: Add a new "--align-memsize" option 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: Mon, 22 Feb 2016 08:18:27 -0000 The option will work with "--range-virtaddr", and if the option is specified, mapped address will be align by EAL memory size. Such an alignment is required for using virtio-net PMD extension on container that uses QEMU QTest framework. Signed-off-by: Tetsuya Mukawa --- lib/librte_eal/common/eal_common_options.c | 8 ++++++++ lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/common/eal_options.h | 2 ++ lib/librte_eal/linuxapp/eal/eal.c | 4 ++++ lib/librte_eal/linuxapp/eal/eal_memory.c | 9 +++++++++ 5 files changed, 24 insertions(+) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 3b4f789..853420a 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -75,6 +75,7 @@ const struct option eal_long_options[] = { {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM }, {OPT_RANGE_VIRTADDR, 1, NULL, OPT_RANGE_VIRTADDR_NUM }, + {OPT_ALIGN_MEMSIZE, 0, NULL, OPT_ALIGN_MEMSIZE_NUM }, {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM }, {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM }, {OPT_HELP, 0, NULL, OPT_HELP_NUM }, @@ -140,6 +141,7 @@ eal_reset_internal_config(struct internal_config *internal_cfg) internal_cfg->base_virtaddr = 0; internal_cfg->range_virtaddr_start = 0; internal_cfg->range_virtaddr_end = 0; + internal_cfg->align_memsize = 0; internal_cfg->syslog_facility = LOG_DAEMON; /* default value from build option */ @@ -994,6 +996,12 @@ eal_check_common_options(struct internal_config *internal_cfg) return -1; } + if (internal_cfg->range_virtaddr_end == 0 && internal_cfg->align_memsize) { + RTE_LOG(ERR, EAL, "Option --"OPT_RANGE_VIRTADDR" should be " + "specified together with --"OPT_ALIGN_MEMSIZE"\n"); + return -1; + } + return 0; } diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h index 0734630..df33a9f 100644 --- a/lib/librte_eal/common/eal_internal_cfg.h +++ b/lib/librte_eal/common/eal_internal_cfg.h @@ -80,6 +80,7 @@ struct internal_config { uintptr_t base_virtaddr; /**< base address to try and reserve memory from */ uintptr_t range_virtaddr_start; /**< start address of mappable region */ uintptr_t range_virtaddr_end; /**< end address of mappable region */ + volatile unsigned align_memsize; /**< true to align virtaddr by memory size */ volatile int syslog_facility; /**< facility passed to openlog() */ volatile uint32_t log_level; /**< default log level */ /** default interrupt mode for VFIO */ diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h index 8e4cf1d..9e36f68 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -49,6 +49,8 @@ enum { OPT_BASE_VIRTADDR_NUM, #define OPT_RANGE_VIRTADDR "range-virtaddr" OPT_RANGE_VIRTADDR_NUM, +#define OPT_ALIGN_MEMSIZE "align-memsize" + OPT_ALIGN_MEMSIZE_NUM, #define OPT_CREATE_UIO_DEV "create-uio-dev" OPT_CREATE_UIO_DEV_NUM, #define OPT_FILE_PREFIX "file-prefix" diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 80f1995..095e866 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -643,6 +643,10 @@ eal_parse_args(int argc, char **argv) } break; + case OPT_ALIGN_MEMSIZE_NUM: + internal_config.align_memsize = 1; + break; + case OPT_VFIO_INTR_NUM: if (eal_parse_vfio_intr(optarg) < 0) { RTE_LOG(ERR, EAL, "invalid parameters for --" diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index d608273..221c358 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -272,6 +272,15 @@ rte_eal_get_free_region(uint64_t pagesz) return NULL; } + if (internal_config.align_memsize) { + /* + * Typically, BAR register of PCI device requiers such + * an alignment. + */ + 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"); -- 2.1.4