Skip to content

Commit

Permalink
feat(build): add rte header files to support building on aarch64 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzihao3 authored and mynktl committed Nov 18, 2019
1 parent 4debd69 commit a534beb
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 11 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ AC_CONFIG_FILES([
src/Makefile
include/Makefile
include/sys/Makefile
include/generic/Makefile
include/arch/x86/Makefile
include/arch/arm/Makefile
])

AC_OUTPUT
Expand Down
6 changes: 1 addition & 5 deletions include/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
SUBDIRS = sys
SUBDIRS = sys generic arch/arm arch/x86

HEADER_H = \
$(top_srcdir)/include/data_conn.h \
$(top_srcdir)/include/gtest_utils.h \
$(top_srcdir)/include/libuzfs.h \
$(top_srcdir)/include/mgmt_conn.h \
$(top_srcdir)/include/rte_atomic_64.h \
$(top_srcdir)/include/rte_atomic_generic.h \
$(top_srcdir)/include/rte_atomic.h \
$(top_srcdir)/include/rte_common.h \
$(top_srcdir)/include/rte_memory.h \
$(top_srcdir)/include/rte_pause.h \
$(top_srcdir)/include/rte_ring.h \
$(top_srcdir)/include/uzfs_io.h \
$(top_srcdir)/include/uzfs_mgmt.h \
Expand Down
9 changes: 9 additions & 0 deletions include/arch/arm/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HEADER_H = \
$(top_srcdir)/include/arch/arm/rte_atomic.h \
$(top_srcdir)/include/arch/arm/rte_atomic_64.h \
$(top_srcdir)/include/arch/arm/rte_pause.h \
$(top_srcdir)/include/arch/arm/rte_pause_64.h

libcstordir = $(includedir)/libcstor/arch/arm
libcstor_HEADERS = $(HEADER_H)

10 changes: 10 additions & 0 deletions include/arch/arm/rte_atomic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2015 RehiveTech. All rights reserved.
*/

#ifndef _RTE_ATOMIC_ARM_H_
#define _RTE_ATOMIC_ARM_H_

#include <arch/arm/rte_atomic_64.h>

#endif /* _RTE_ATOMIC_ARM_H_ */
51 changes: 51 additions & 0 deletions include/arch/arm/rte_atomic_64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2015 Cavium, Inc
* Copyright(c) 2019 Arm Limited
*/

#ifndef _RTE_ATOMIC_ARM64_H_
#define _RTE_ATOMIC_ARM64_H_

/*
* Platform must be built with CONFIG_RTE_FORCE_INTRINSICS
*/
#ifndef RTE_FORCE_INTRINSICS
#define RTE_FORCE_INTRINSICS
#endif

#ifdef __cplusplus
extern "C" {
#endif

#include "generic/rte_atomic.h"

#define dsb(opt) asm volatile("dsb " #opt : : : "memory")
#define dmb(opt) asm volatile("dmb " #opt : : : "memory")

#define rte_mb() dsb(sy)

#define rte_wmb() dsb(st)

#define rte_rmb() dsb(ld)

#define rte_smp_mb() dmb(ish)

#define rte_smp_wmb() dmb(ishst)

#define rte_smp_rmb() dmb(ishld)

#define rte_io_mb() rte_mb()

#define rte_io_wmb() rte_wmb()

#define rte_io_rmb() rte_rmb()

#define rte_cio_wmb() dmb(oshst)

#define rte_cio_rmb() dmb(oshld)

#ifdef __cplusplus
}
#endif

#endif /* _RTE_ATOMIC_ARM64_H_ */
18 changes: 18 additions & 0 deletions include/arch/arm/rte_pause.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2017 Cavium, Inc
*/

#ifndef _RTE_PAUSE_ARM_H_
#define _RTE_PAUSE_ARM_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <arch/arm/rte_pause_64.h>

#ifdef __cplusplus
}
#endif

#endif /* _RTE_PAUSE_ARM_H_ */
24 changes: 24 additions & 0 deletions include/arch/arm/rte_pause_64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2017 Cavium, Inc
*/

#ifndef _RTE_PAUSE_ARM64_H_
#define _RTE_PAUSE_ARM64_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <rte_common.h>
#include "generic/rte_pause.h"

static inline void rte_pause(void)
{
asm volatile("yield" ::: "memory");
}

#ifdef __cplusplus
}
#endif

#endif /* _RTE_PAUSE_ARM64_H_ */
8 changes: 8 additions & 0 deletions include/arch/x86/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
HEADER_H = \
$(top_srcdir)/include/arch/x86/rte_atomic_64.h \
$(top_srcdir)/include/arch/x86/rte_atomic.h \
$(top_srcdir)/include/arch/x86/rte_pause.h

libcstordir = $(includedir)/libcstor/arch/x86
libcstor_HEADERS = $(HEADER_H)

4 changes: 2 additions & 2 deletions include/rte_atomic.h → include/arch/x86/rte_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)
#endif

#ifdef RTE_ARCH_I686
#include "rte_atomic_32.h"
#include "arch/x86/rte_atomic_32.h"
#else
#include "rte_atomic_64.h"
#include "arch/x86/rte_atomic_64.h"
#endif

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include <stdint.h>
#include <rte_common.h>
#include <rte_atomic.h>
#include <arch/x86/rte_atomic.h>

/*------------------------- 64 bit atomic operations -------------------------*/

Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions include/generic/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HEADER_H = \
$(top_srcdir)/include/generic/rte_atomic.h \
$(top_srcdir)/include/generic/rte_pause.h

libcstordir = $(includedir)/libcstor/generic
libcstor_HEADERS = $(HEADER_H)
3 changes: 3 additions & 0 deletions include/rte_atomic_generic.h → include/generic/rte_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#ifndef _RTE_ATOMIC_H_
#define _RTE_ATOMIC_H_

#ifndef RTE_FORCE_INTRINSICS
#define RTE_FORCE_INTRINSICS
#endif
/**
* @file
* Atomic Operations
Expand Down
23 changes: 23 additions & 0 deletions include/generic/rte_pause.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2017 Cavium, Inc
*/

#ifndef _RTE_PAUSE_H_
#define _RTE_PAUSE_H_

/**
* @file
*
* CPU pause operation.
*
*/

/**
* Pause CPU execution for a short while
*
* This call is intended for tight loops which poll a shared resource or wait
* for an event. A short pause within the loop may reduce the power consumption.
*/
static inline void rte_pause(void);

#endif /* _RTE_PAUSE_H_ */
12 changes: 9 additions & 3 deletions include/rte_ring.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,15 @@ extern "C" {
#include <errno.h>
#include <rte_common.h>
#include <rte_memory.h>
#include <rte_pause.h>
#include <rte_atomic_generic.h>
#include <rte_atomic.h>
#include <generic/rte_atomic.h>

#if defined(__x86_64__)
#include <arch/x86/rte_pause.h>
#include <arch/x86/rte_atomic.h>
#elif defined(__aarch64__)
#include <arch/arm/rte_pause.h>
#include <arch/arm/rte_atomic.h>
#endif

#define RTE_TAILQ_RING_NAME "RTE_RING"

Expand Down

0 comments on commit a534beb

Please sign in to comment.