From 5b1ff351aa2d38446487eed6ccd7ace1b654bbe6 Mon Sep 17 00:00:00 2001 From: Ricardo Salveti Date: Mon, 25 Jul 2016 13:22:22 -0300 Subject: Imported Upstream version 16.07-rc4 Change-Id: Ic57f6a3726f2dbd1682223648d91310f45705327 Signed-off-by: Ricardo Salveti --- lib/librte_eal/common/eal_common_memzone.c | 12 ++++++------ lib/librte_eal/common/eal_common_options.c | 4 ++-- lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h | 12 ++++++++++-- lib/librte_eal/common/include/rte_tailq.h | 8 ++++++++ lib/librte_eal/common/include/rte_version.h | 2 +- lib/librte_eal/linuxapp/eal/eal_memory.c | 17 +++++++++++++---- 6 files changed, 40 insertions(+), 15 deletions(-) (limited to 'lib/librte_eal') diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c index 5d28341f..1bd0a33d 100644 --- a/lib/librte_eal/common/eal_common_memzone.c +++ b/lib/librte_eal/common/eal_common_memzone.c @@ -144,16 +144,16 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, return NULL; } - /* zone already exist */ - if ((memzone_lookup_thread_unsafe(name)) != NULL) { - RTE_LOG(DEBUG, EAL, "%s(): memzone <%s> already exists\n", + if (strlen(name) > sizeof(mz->name) - 1) { + RTE_LOG(DEBUG, EAL, "%s(): memzone <%s>: name too long\n", __func__, name); - rte_errno = EEXIST; + rte_errno = ENAMETOOLONG; return NULL; } - if (strlen(name) >= sizeof(mz->name) - 1) { - RTE_LOG(DEBUG, EAL, "%s(): memzone <%s>: name too long\n", + /* zone already exist */ + if ((memzone_lookup_thread_unsafe(name)) != NULL) { + RTE_LOG(DEBUG, EAL, "%s(): memzone <%s> already exists\n", __func__, name); rte_errno = EEXIST; return NULL; diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 0a594d7f..481c732b 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -116,9 +116,9 @@ TAILQ_HEAD_INITIALIZER(solib_list); static const char *default_solib_dir = RTE_EAL_PMD_PATH; /* - * Stringified version of solib path used by pmdinfo.py + * Stringified version of solib path used by dpdk-pmdinfo.py * Note: PLEASE DO NOT ALTER THIS without making a corresponding - * change to tools/pmdinfo.py + * change to tools/dpdk-pmdinfo.py */ static const char dpdk_solib_path[] __attribute__((used)) = "DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH; diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h b/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h index feae4868..924e8940 100644 --- a/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h +++ b/lib/librte_eal/common/include/arch/ppc_64/rte_atomic.h @@ -62,7 +62,11 @@ extern "C" { * Guarantees that the STORE operations generated before the barrier * occur before the STORE operations generated after. */ +#ifdef RTE_ARCH_64 +#define rte_wmb() {asm volatile("lwsync" : : : "memory"); } +#else #define rte_wmb() {asm volatile("sync" : : : "memory"); } +#endif /** * Read memory barrier. @@ -70,13 +74,17 @@ extern "C" { * Guarantees that the LOAD operations generated before the barrier * occur before the LOAD operations generated after. */ +#ifdef RTE_ARCH_64 +#define rte_rmb() {asm volatile("lwsync" : : : "memory"); } +#else #define rte_rmb() {asm volatile("sync" : : : "memory"); } +#endif #define rte_smp_mb() rte_mb() -#define rte_smp_wmb() rte_compiler_barrier() +#define rte_smp_wmb() rte_wmb() -#define rte_smp_rmb() rte_compiler_barrier() +#define rte_smp_rmb() rte_rmb() /*------------------------- 16 bit atomic operations -------------------------*/ /* To be compatible with Power7, use GCC built-in functions for 16 bit diff --git a/lib/librte_eal/common/include/rte_tailq.h b/lib/librte_eal/common/include/rte_tailq.h index 4a686e68..cc3c0f1d 100644 --- a/lib/librte_eal/common/include/rte_tailq.h +++ b/lib/librte_eal/common/include/rte_tailq.h @@ -155,6 +155,14 @@ void __attribute__((constructor, used)) tailqinitfn_ ##t(void) \ rte_panic("Cannot initialize tailq: %s\n", t.name); \ } +/* This macro permits both remove and free var within the loop safely.*/ +#ifndef TAILQ_FOREACH_SAFE +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = TAILQ_FIRST((head)); \ + (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/common/include/rte_version.h b/lib/librte_eal/common/include/rte_version.h index eacc86c1..bbffecff 100644 --- a/lib/librte_eal/common/include/rte_version.h +++ b/lib/librte_eal/common/include/rte_version.h @@ -77,7 +77,7 @@ extern "C" { * 0-15 = release candidates * 16 = release */ -#define RTE_VER_RELEASE 3 +#define RTE_VER_RELEASE 4 /** * Macro to compute a version number usable for comparisons diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 42a29faf..41e0a928 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -99,6 +99,8 @@ #include "eal_filesystem.h" #include "eal_hugepages.h" +#define PFN_MASK_SIZE 8 + #ifdef RTE_LIBRTE_XEN_DOM0 int rte_xen_dom0_supported(void) { @@ -158,7 +160,7 @@ rte_mem_lock_page(const void *virt) phys_addr_t rte_mem_virt2phy(const void *virtaddr) { - int fd; + int fd, retval; uint64_t page, physaddr; unsigned long virt_pfn; int page_size; @@ -209,10 +211,17 @@ rte_mem_virt2phy(const void *virtaddr) close(fd); return RTE_BAD_PHYS_ADDR; } - if (read(fd, &page, sizeof(uint64_t)) < 0) { + + retval = read(fd, &page, PFN_MASK_SIZE); + close(fd); + if (retval < 0) { RTE_LOG(ERR, EAL, "%s(): cannot read /proc/self/pagemap: %s\n", __func__, strerror(errno)); - close(fd); + return RTE_BAD_PHYS_ADDR; + } else if (retval != PFN_MASK_SIZE) { + RTE_LOG(ERR, EAL, "%s(): read %d bytes from /proc/self/pagemap " + "but expected %d:\n", + __func__, retval, PFN_MASK_SIZE); return RTE_BAD_PHYS_ADDR; } @@ -222,7 +231,7 @@ rte_mem_virt2phy(const void *virtaddr) */ physaddr = ((page & 0x7fffffffffffffULL) * page_size) + ((unsigned long)virtaddr % page_size); - close(fd); + return physaddr; } -- cgit 1.2.3-korg