From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 87FD9A0096 for ; Tue, 9 Apr 2019 21:06:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4B9B55688; Tue, 9 Apr 2019 21:06:42 +0200 (CEST) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) by dpdk.org (Postfix) with ESMTP id C85EC5398 for ; Tue, 9 Apr 2019 21:06:36 +0200 (CEST) Received: by mail-qt1-f196.google.com with SMTP id w5so21128599qtb.11 for ; Tue, 09 Apr 2019 12:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:reply-to; bh=6RRGwwVTBPCCenQtul9wGFvFLAD4/o+g6qH6+4VrFlM=; b=YZzPGeqe/nhz1TorawDzUx9hzmBXAuZEy22Z8N7FEZmyrDD/sxi3R7j1inb6Ukdhow BjMywiZCUuHZdB2wvF8AoXbKEDqm1W0sTjKbKEQqUN3rAypkJjWh6A3PfPQM9lNGIEcA UljNhHG7UnHrp6i/jCogFyKS/uH4+Xsun3+XJ39yb38t6ddWEPQ5Jofzzz+pePOWeXlw Ywjz0XDNVhQSHm0PnQFjc5smRy+UsmEoHL4l9d1pOUYCV746svz3TEpo+2ArTAOXNXh5 UyJziL7P1ES2xMj+EGUU9BqhcxyfpjEoCQvHfHX+h4UC4CfGMaGLdd1+DPTczZh0nit9 ENQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:reply-to; bh=6RRGwwVTBPCCenQtul9wGFvFLAD4/o+g6qH6+4VrFlM=; b=ZtP7A/iQSIJ+/kB7USHxH9QCNtKIMUnooIBC+TATgZuqwyD8em9JLgJE8T5mBmqN0w BdsK05llSayQYkZQK5N2wQVu0YIlyqfnH2B4fgXz59UG7bun3oAFNj6Ite0Dzi8ycrWp fq0Oq33VV2MFaOyfx4gvHTRHwPe0r5zmdAysI7DuykcRYfhmKdWY/lcAP9Q9aFMvAOZW uKkkrr5IjUUkyJcaXCtAQeILwc2XoShLsXtZmcTpdTURFBvCaarpWd4ABh2BDaVx/oTl U5lQoqmjOS2hBniUO+cNvJDIh45nTFWMOsvBetNPDvDmjipu+BB1aztCH+EBrdZeczTO u1dg== X-Gm-Message-State: APjAAAUDtgqLyouda5YZd9XhD916TVYRntIwMcvcxs+SeH7WNzQsKEB/ R1q7noMZIXEaHixBfZTHZiIv4x/+JjU= X-Google-Smtp-Source: APXvYqwpPFcjEV4iHB3ghFDCWBP/42fx5z3gnaVIMg92bOX3E57Ue5n+ppioz8rK9Rf3PPzYHIzvyw== X-Received: by 2002:ac8:3328:: with SMTP id t37mr31605281qta.246.1554836795196; Tue, 09 Apr 2019 12:06:35 -0700 (PDT) Received: from csz25116.canlab.ibm.com ([199.246.40.57]) by smtp.gmail.com with ESMTPSA id q23sm17934789qkc.16.2019.04.09.12.06.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 12:06:33 -0700 (PDT) From: Vivian Kong X-Google-Original-From: Vivian Kong To: dev@dpdk.org Date: Tue, 9 Apr 2019 15:06:20 -0400 Message-Id: <20190409190630.31975-3-vivkong@ca.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190409190630.31975-1-vivkong@ca.ibm.com> References: <20190409190630.31975-1-vivkong@ca.ibm.com> Subject: [dpdk-dev] [RFC 02/12] eal: add support for s390x architecture X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: vivkong@ca.ibm.com List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190409190620.WvdosunJP7Pih-F6rsIWWMpuPRjqucjdro9me5bQQCI@z> Implement DPDK EAL for s390x architecture. Signed-off-by: Vivian Kong --- .../common/arch/s390x/rte_cpuflags.c | 90 +++++++++++++++++++ lib/librte_eal/common/arch/s390x/rte_cycles.c | 11 +++ .../common/arch/s390x/rte_hypervisor.c | 11 +++ .../common/include/arch/s390x/rte_atomic.h | 47 ++++++++++ .../common/include/arch/s390x/rte_byteorder.h | 43 +++++++++ .../common/include/arch/s390x/rte_cpuflags.h | 42 +++++++++ .../common/include/arch/s390x/rte_cycles.h | 44 +++++++++ .../common/include/arch/s390x/rte_io.h | 18 ++++ .../common/include/arch/s390x/rte_memcpy.h | 55 ++++++++++++ .../common/include/arch/s390x/rte_pause.h | 22 +++++ .../common/include/arch/s390x/rte_prefetch.h | 40 +++++++++ .../common/include/arch/s390x/rte_rwlock.h | 42 +++++++++ .../common/include/arch/s390x/rte_spinlock.h | 85 ++++++++++++++++++ .../include/arch/s390x/rte_ticketlock.h | 18 ++++ .../common/include/arch/s390x/rte_vect.h | 33 +++++++ 15 files changed, 601 insertions(+) create mode 100644 lib/librte_eal/common/arch/s390x/rte_cpuflags.c create mode 100644 lib/librte_eal/common/arch/s390x/rte_cycles.c create mode 100644 lib/librte_eal/common/arch/s390x/rte_hypervisor.c create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_atomic.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_byteorder.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_cpuflags.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_cycles.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_io.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_memcpy.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_pause.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_prefetch.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_rwlock.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_spinlock.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_ticketlock.h create mode 100644 lib/librte_eal/common/include/arch/s390x/rte_vect.h diff --git a/lib/librte_eal/common/arch/s390x/rte_cpuflags.c b/lib/librte_eal/common/arch/s390x/rte_cpuflags.c new file mode 100644 index 000000000..1f8c6ef41 --- /dev/null +++ b/lib/librte_eal/common/arch/s390x/rte_cpuflags.c @@ -0,0 +1,90 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#include "rte_cpuflags.h" + +#include +#include +#include +#include + +/* Symbolic values for the entries in the auxiliary table */ +#define AT_HWCAP 16 +#define AT_HWCAP2 26 + +/* software based registers */ +enum cpu_register_t { + REG_NONE = 0, + REG_HWCAP, + REG_HWCAP2, + REG_MAX +}; + +typedef uint32_t hwcap_registers_t[REG_MAX]; + +struct feature_entry { + uint32_t reg; + uint32_t bit; +#define CPU_FLAG_NAME_MAX_LEN 64 + char name[CPU_FLAG_NAME_MAX_LEN]; +}; + +#define FEAT_DEF(name, reg, bit) \ + [RTE_CPUFLAG_##name] = {reg, bit, #name}, + +const struct feature_entry rte_cpu_feature_table[] = { + FEAT_DEF(ESAN3, REG_HWCAP, 0) + FEAT_DEF(ZARCH, REG_HWCAP, 1) + FEAT_DEF(STFLE, REG_HWCAP, 2) + FEAT_DEF(MSA, REG_HWCAP, 3) + FEAT_DEF(LDISP, REG_HWCAP, 4) + FEAT_DEF(EIMM, REG_HWCAP, 5) + FEAT_DEF(DFP, REG_HWCAP, 6) + FEAT_DEF(HPAGE, REG_HWCAP, 7) + FEAT_DEF(ETF3EH, REG_HWCAP, 8) + FEAT_DEF(HIGH_GPRS, REG_HWCAP, 9) + FEAT_DEF(TE, REG_HWCAP, 10) + FEAT_DEF(VXRS, REG_HWCAP, 11) + FEAT_DEF(VXRS_BCD, REG_HWCAP, 12) + FEAT_DEF(VXRS_EXT, REG_HWCAP, 13) + FEAT_DEF(GS, REG_HWCAP, 14) +}; + +/* + * Read AUXV software register and get cpu features for Power + */ +static void +rte_cpu_get_features(hwcap_registers_t out) +{ + out[REG_HWCAP] = rte_cpu_getauxval(AT_HWCAP); + out[REG_HWCAP2] = rte_cpu_getauxval(AT_HWCAP2); +} + +/* + * Checks if a particular flag is available on current machine. + */ +int +rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) +{ + const struct feature_entry *feat; + hwcap_registers_t regs = {0}; + + if (feature >= RTE_CPUFLAG_NUMFLAGS) + return -ENOENT; + + feat = &rte_cpu_feature_table[feature]; + if (feat->reg == REG_NONE) + return -EFAULT; + + rte_cpu_get_features(regs); + return (regs[feat->reg] >> feat->bit) & 1; +} + +const char * +rte_cpu_get_flag_name(enum rte_cpu_flag_t feature) +{ + if (feature >= RTE_CPUFLAG_NUMFLAGS) + return NULL; + return rte_cpu_feature_table[feature].name; +} diff --git a/lib/librte_eal/common/arch/s390x/rte_cycles.c b/lib/librte_eal/common/arch/s390x/rte_cycles.c new file mode 100644 index 000000000..b29c4454a --- /dev/null +++ b/lib/librte_eal/common/arch/s390x/rte_cycles.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#include "eal_private.h" + +uint64_t +get_tsc_freq_arch(void) +{ + return 0; +} diff --git a/lib/librte_eal/common/arch/s390x/rte_hypervisor.c b/lib/librte_eal/common/arch/s390x/rte_hypervisor.c new file mode 100644 index 000000000..22b0c5cc4 --- /dev/null +++ b/lib/librte_eal/common/arch/s390x/rte_hypervisor.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#include "rte_hypervisor.h" + +enum rte_hypervisor +rte_hypervisor_get(void) +{ + return RTE_HYPERVISOR_UNKNOWN; +} diff --git a/lib/librte_eal/common/include/arch/s390x/rte_atomic.h b/lib/librte_eal/common/include/arch/s390x/rte_atomic.h new file mode 100644 index 000000000..5fce6d5f0 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_atomic.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#ifndef _RTE_ATOMIC_S390X_H_ +#define _RTE_ATOMIC_S390X_H_ + +#ifndef RTE_FORCE_INTRINSICS +# error Platform must be built with CONFIG_RTE_FORCE_INTRINSICS +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_atomic.h" + +//#define dsb(opt) asm volatile("" : : : "memory") +//#define dmb(opt) asm volatile("" : : : "memory") + +#define rte_mb() rte_compiler_barrier() //asm volatile("" : : : "memory") + +#define rte_wmb() rte_mb() + +#define rte_rmb() rte_mb() + +#define rte_smp_mb() rte_mb() + +#define rte_smp_wmb() rte_wmb() + +#define rte_smp_rmb() rte_rmb() + +#define rte_io_mb() rte_mb() + +#define rte_io_wmb() rte_wmb() + +#define rte_io_rmb() rte_rmb() + +#define rte_cio_wmb() rte_wmb() + +#define rte_cio_rmb() rte_rmb() + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_ATOMIC_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_byteorder.h b/lib/librte_eal/common/include/arch/s390x/rte_byteorder.h new file mode 100644 index 000000000..de6e410b4 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_byteorder.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +/* Inspired from FreeBSD src/sys/powerpc/include/endian.h + * Copyright (c) 1987, 1991, 1993 + * The Regents of the University of California. All rights reserved. + */ + +#ifndef _RTE_BYTEORDER_S390X_H_ +#define _RTE_BYTEORDER_S390X_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "generic/rte_byteorder.h" + +/* s390x is big endian + */ + +#define rte_cpu_to_le_16(x) rte_bswap16(x) +#define rte_cpu_to_le_32(x) rte_bswap32(x) +#define rte_cpu_to_le_64(x) rte_bswap64(x) + +#define rte_cpu_to_be_16(x) (x) +#define rte_cpu_to_be_32(x) (x) +#define rte_cpu_to_be_64(x) (x) + +#define rte_le_to_cpu_16(x) rte_bswap16(x) +#define rte_le_to_cpu_32(x) rte_bswap32(x) +#define rte_le_to_cpu_64(x) rte_bswap64(x) + +#define rte_be_to_cpu_16(x) (x) +#define rte_be_to_cpu_32(x) (x) +#define rte_be_to_cpu_64(x) (x) + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_BYTEORDER_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_cpuflags.h b/lib/librte_eal/common/include/arch/s390x/rte_cpuflags.h new file mode 100644 index 000000000..bfeff3f98 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_cpuflags.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#ifndef _RTE_CPUFLAGS_S390X_H_ +#define _RTE_CPUFLAGS_S390X_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Enumeration of all CPU features supported + */ +enum rte_cpu_flag_t { + RTE_CPUFLAG_ESAN3 = 0, + RTE_CPUFLAG_ZARCH, + RTE_CPUFLAG_STFLE, + RTE_CPUFLAG_MSA, + RTE_CPUFLAG_LDISP, + RTE_CPUFLAG_EIMM, + RTE_CPUFLAG_DFP, + RTE_CPUFLAG_HPAGE, //from elf.h + //RTE_CPUFLAG_EDAT, //from hwcap.h + RTE_CPUFLAG_ETF3EH, + RTE_CPUFLAG_HIGH_GPRS, + RTE_CPUFLAG_TE, + RTE_CPUFLAG_VXRS, + RTE_CPUFLAG_VXRS_BCD, + RTE_CPUFLAG_VXRS_EXT, + RTE_CPUFLAG_GS, + /* The last item */ + RTE_CPUFLAG_NUMFLAGS,/**< This should always be the last! */ +}; + +#include "generic/rte_cpuflags.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_CPUFLAGS_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_cycles.h b/lib/librte_eal/common/include/arch/s390x/rte_cycles.h new file mode 100644 index 000000000..211bbe448 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_cycles.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#ifndef _RTE_CYCLES_S390X_H_ +#define _RTE_CYCLES_S390X_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_cycles.h" + +#include + +/** + * Read the time base register. + * + * @return + * The time base for this lcore. + */ +static inline uint64_t +rte_rdtsc(void) +{ + uint64_t tsc; + asm volatile("stck %0" : "=Q"(tsc) : : "cc"); + return tsc; +} + +static inline uint64_t +rte_rdtsc_precise(void) +{ + rte_mb(); + return rte_rdtsc(); +} + +static inline uint64_t +rte_get_tsc_cycles(void) { return rte_rdtsc(); } + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_CYCLES_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_io.h b/lib/librte_eal/common/include/arch/s390x/rte_io.h new file mode 100644 index 000000000..e6b718ef3 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_io.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#ifndef _RTE_IO_S390X_H_ +#define _RTE_IO_S390X_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_io.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_IO_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_memcpy.h b/lib/librte_eal/common/include/arch/s390x/rte_memcpy.h new file mode 100644 index 000000000..1135b1af6 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_memcpy.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#ifndef _RTE_MEMCPY_S390X_H_ +#define _RTE_MEMCPY_S390X_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_memcpy.h" + + +static inline void +rte_mov16(uint8_t *dst, const uint8_t *src) +{ + memcpy(dst, src, 16); +} +static inline void +rte_mov32(uint8_t *dst, const uint8_t *src) +{ + memcpy(dst, src, 32); +} +static inline void +rte_mov48(uint8_t *dst, const uint8_t *src) +{ + memcpy(dst, src, 48); +} +static inline void +rte_mov64(uint8_t *dst, const uint8_t *src) +{ + memcpy(dst, src, 64); +} +static inline void +rte_mov128(uint8_t *dst, const uint8_t *src) +{ + memcpy(dst, src, 128); +} +static inline void +rte_mov256(uint8_t *dst, const uint8_t *src) +{ + memcpy(dst, src, 256); +} +#define rte_memcpy(d, s, n) memcpy((d), (s), (n)) + + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MEMCPY_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_pause.h b/lib/librte_eal/common/include/arch/s390x/rte_pause.h new file mode 100644 index 000000000..be90ce6a1 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_pause.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#ifndef _RTE_PAUSE_S390X_H_ +#define _RTE_PAUSE_S390X_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_pause.h" + +static inline void rte_pause(void) +{ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_PAUSE_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_prefetch.h b/lib/librte_eal/common/include/arch/s390x/rte_prefetch.h new file mode 100644 index 000000000..c76c6d898 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_prefetch.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#ifndef _RTE_PREFETCH_S390X_H_ +#define _RTE_PREFETCH_S390X_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "generic/rte_prefetch.h" + +static inline void rte_prefetch0(const volatile void *p) +{ + asm volatile ("pfd 1, 0(%[p])" : : [p] "r" (p)); +} + +static inline void rte_prefetch1(const volatile void *p) +{ + asm volatile ("pfd 1, 0(%[p])" : : [p] "r" (p)); +} + +static inline void rte_prefetch2(const volatile void *p) +{ + asm volatile ("pfd 1, 0(%[p])" : : [p] "r" (p)); +} + +static inline void rte_prefetch_non_temporal(const volatile void *p) +{ + /* non-temporal version not available, fallback to rte_prefetch0 */ + rte_prefetch0(p); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_PREFETCH_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_rwlock.h b/lib/librte_eal/common/include/arch/s390x/rte_rwlock.h new file mode 100644 index 000000000..f649484f3 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_rwlock.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#ifndef _RTE_RWLOCK_S390X_H_ +#define _RTE_RWLOCK_S390X_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_rwlock.h" + +static inline void +rte_rwlock_read_lock_tm(rte_rwlock_t *rwl) +{ + rte_rwlock_read_lock(rwl); +} + +static inline void +rte_rwlock_read_unlock_tm(rte_rwlock_t *rwl) +{ + rte_rwlock_read_unlock(rwl); +} + +static inline void +rte_rwlock_write_lock_tm(rte_rwlock_t *rwl) +{ + rte_rwlock_write_lock(rwl); +} + +static inline void +rte_rwlock_write_unlock_tm(rte_rwlock_t *rwl) +{ + rte_rwlock_write_unlock(rwl); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_RWLOCK_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_spinlock.h b/lib/librte_eal/common/include/arch/s390x/rte_spinlock.h new file mode 100644 index 000000000..0434864fb --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_spinlock.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#ifndef _RTE_SPINLOCK_S390X_H_ +#define _RTE_SPINLOCK_S390X_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "generic/rte_spinlock.h" + +#ifndef RTE_FORCE_INTRINSICS + +static inline void +rte_spinlock_lock(rte_spinlock_t *sl) +{ + while (__sync_lock_test_and_set(&sl->locked, 1)) + while (sl->locked) + rte_pause(); +} + +static inline void +rte_spinlock_unlock(rte_spinlock_t *sl) +{ + __sync_lock_release(&sl->locked); +} + +static inline int +rte_spinlock_trylock(rte_spinlock_t *sl) +{ + return __sync_lock_test_and_set(&sl->locked, 1) == 0; +} + +#endif + + +static inline int rte_tm_supported(void) +{ + return 0; +} + +static inline void +rte_spinlock_lock_tm(rte_spinlock_t *sl) +{ + rte_spinlock_lock(sl); /* fall-back */ +} + +static inline int +rte_spinlock_trylock_tm(rte_spinlock_t *sl) +{ + return rte_spinlock_trylock(sl); +} + +static inline void +rte_spinlock_unlock_tm(rte_spinlock_t *sl) +{ + rte_spinlock_unlock(sl); +} + +static inline void +rte_spinlock_recursive_lock_tm(rte_spinlock_recursive_t *slr) +{ + rte_spinlock_recursive_lock(slr); /* fall-back */ +} + +static inline void +rte_spinlock_recursive_unlock_tm(rte_spinlock_recursive_t *slr) +{ + rte_spinlock_recursive_unlock(slr); +} + +static inline int +rte_spinlock_recursive_trylock_tm(rte_spinlock_recursive_t *slr) +{ + return rte_spinlock_recursive_trylock(slr); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_SPINLOCK_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_ticketlock.h b/lib/librte_eal/common/include/arch/s390x/rte_ticketlock.h new file mode 100644 index 000000000..0785363c9 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_ticketlock.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2019 + */ + +#ifndef _RTE_TICKETLOCK_S390X_H_ +#define _RTE_TICKETLOCK_S390X_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_ticketlock.h" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_TICKETLOCK_S390X_H_ */ diff --git a/lib/librte_eal/common/include/arch/s390x/rte_vect.h b/lib/librte_eal/common/include/arch/s390x/rte_vect.h new file mode 100644 index 000000000..459744aa4 --- /dev/null +++ b/lib/librte_eal/common/include/arch/s390x/rte_vect.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * (c) Copyright IBM Corp. 2018, 2019 + */ + +#ifndef _RTE_VECT_S390X_H_ +#define _RTE_VECT_S390X_H_ + +#include +#include "generic/rte_vect.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int xmm_t __attribute__((vector_size(4*sizeof(int)))); + +#define XMM_SIZE (sizeof(xmm_t)) +#define XMM_MASK (XMM_SIZE - 1) + +typedef union rte_xmm { + xmm_t x; + uint8_t u8[XMM_SIZE / sizeof(uint8_t)]; + uint16_t u16[XMM_SIZE / sizeof(uint16_t)]; + uint32_t u32[XMM_SIZE / sizeof(uint32_t)]; + uint64_t u64[XMM_SIZE / sizeof(uint64_t)]; + double pd[XMM_SIZE / sizeof(double)]; +} __attribute__((aligned(16))) rte_xmm_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_VECT_S390X_H_ */ -- 2.17.1