diff options
author | Dave Barach <dave@barachs.net> | 2016-01-22 08:23:09 -0500 |
---|---|---|
committer | Dave Barach <dave@barachs.net> | 2016-01-22 08:23:27 -0500 |
commit | 61efa140b1f44e0c568697fbc31cf3f430131ab2 (patch) | |
tree | 780880f2fce0882840b204eb26bd7465ed7c7e09 | |
parent | bfdedbd5a3ba7e6fdc036d212253aa55c9062211 (diff) |
aarch64 CPU arch / ThunderX platform initial support
Change-Id: Ia2edd3cee2c25c26c7c47a9023744b97226434c7
Signed-off-by: Dave Barach <dave@barachs.net>
37 files changed, 592 insertions, 115 deletions
diff --git a/build-data/packages/cavium-dpdk.mk b/build-data/packages/cavium-dpdk.mk new file mode 100644 index 00000000000..ce8ee228429 --- /dev/null +++ b/build-data/packages/cavium-dpdk.mk @@ -0,0 +1,55 @@ +# Temporary until Cavium upstreams their work + +cavium-dpdk_configure = \ + src_dir=$(call find_source_fn,$(PACKAGE_SOURCE)) ; \ + dst_dir=$(PACKAGE_BUILD_DIR) ; \ + tar -C $${src_dir} -cf - . | tar -C $${dst_dir} -xf - ; \ + cd $${dst_dir} ; \ + : colossal hemorrhoid to configure headroom ; \ + if [ x$($(PACKAGE)_configure_args_$(PLATFORM)) = "x" ] ; then \ + HR=256 ; \ + else \ + dpdk_configure_args=$($(PACKAGE)_configure_args_$(PLATFORM)) ; \ + if [ $$dpdk_configure_args = "--with-headroom=256" ] ; then \ + HR=256 ; \ + elif [ $$dpdk_configure_args = "--with-headroom=384" ] ; then \ + HR=384 ; \ + else \ + HR=256 ; \ + fi ; \ + fi ; \ + env HR=$$HR \ + spp -o \ + $(PACKAGE_BUILD_DIR)/config/common_linuxapp \ + $(PACKAGE_BUILD_DIR)/config/common_linuxapp.spp \ + ; \ + env $(CONFIGURE_ENV) \ + make config T=arm64-thunderx-linuxapp-gcc RTE_ARCH=arm64 \ + CC=aarch64-thunderx-linux-gnu-gcc V=0 \ + RTE_SDK=$(PACKAGE_BUILD_DIR) \ + RTE_TARGET=arm-default-linuxapp-gcc + +# Note: add e.g. "-O0" to EXTRA_CFLAGS if desired: EXTRA_CFLAGS='-g -O0' + +cavium-dpdk_make_args = install T=arm64-thunderx-linuxapp-gcc RTE_ARCH=arm64 \ + CC=aarch64-thunderx-linux-gnu-gcc V=0 \ + RTE_SDK=$(PACKAGE_BUILD_DIR) \ + RTE_TARGET=arm-default-linuxapp-gcc + +cavium-dpdk_install = \ + src_dir=$(PACKAGE_BUILD_DIR) ; \ + dst_dir=$(PACKAGE_INSTALL_DIR) ; \ + tar -h -C $${src_dir}/arm64-thunderx-linuxapp-gcc -cf - . \ + | tar -C $${dst_dir} -xf - + +# dpdk libraries end up in .../lib not .../lib64. Fix it. +cavium-dpdk_post_install = \ + if [ "$(arch_lib_dir)" != "lib" ] ; then \ + mkdir -p $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir) ; \ + cd $(PACKAGE_INSTALL_DIR)/lib ; \ + tar cf - . | ( cd $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir); tar xf - ) ; \ + fi + +# nothing to install, all static libraries +cavium-dpdk_image_include = echo + diff --git a/build-data/packages/sample-plugin.mk b/build-data/packages/sample-plugin.mk index 4532817c766..e9f2789aa49 100644 --- a/build-data/packages/sample-plugin.mk +++ b/build-data/packages/sample-plugin.mk @@ -9,7 +9,7 @@ sample-plugin_configure_depend = \ vpp-api-test-install # -sample-plugin_configure_args = --with-q-platform=$(PLATFORM) --with-dpdk +sample-plugin_configure_args = --with-dpdk sample-plugin_CPPFLAGS = $(call installed_includes_fn, \ vppinfra \ diff --git a/build-data/packages/vlib-api-cavium-dpdk.mk b/build-data/packages/vlib-api-cavium-dpdk.mk new file mode 100644 index 00000000000..7a4fe2cd718 --- /dev/null +++ b/build-data/packages/vlib-api-cavium-dpdk.mk @@ -0,0 +1,6 @@ +vlib-api-cavium-dpdk_source = vlib-api + +vlib-api-cavium-dpdk_configure_depend = vppinfra-install svm-install vlib-cavium-dpdk-install + +vlib-api-cavium-dpdk_CPPFLAGS = $(call installed_includes_fn, vppinfra svm vlib-cavium-dpdk) +vlib-api-cavium-dpdk_LDFLAGS = $(call installed_libs_fn, vppinfra svm vlib-cavium-dpdk) diff --git a/build-data/packages/vlib-api.mk b/build-data/packages/vlib-api.mk index f4bd67d9c15..29b0d17dba2 100644 --- a/build-data/packages/vlib-api.mk +++ b/build-data/packages/vlib-api.mk @@ -2,5 +2,3 @@ vlib-api_configure_depend = vppinfra-install svm-install vlib-install vlib-api_CPPFLAGS = $(call installed_includes_fn, vppinfra svm vlib) vlib-api_LDFLAGS = $(call installed_libs_fn, vppinfra svm vlib) - -vlib-api_top_srcdir = $(call find_source_fn,vlib-api) diff --git a/build-data/packages/vlib-cavium-dpdk.mk b/build-data/packages/vlib-cavium-dpdk.mk new file mode 100644 index 00000000000..0f2f132d05c --- /dev/null +++ b/build-data/packages/vlib-cavium-dpdk.mk @@ -0,0 +1,7 @@ +vlib-cavium-dpdk_source = vlib +vlib-cavium-dpdk_configure_depend = vppinfra-install cavium-dpdk-install + +vlib-cavium-dpdk_configure_args += --with-dpdk + +vlib-cavium-dpdk_CPPFLAGS = $(call installed_includes_fn, vppinfra cavium-dpdk) +vlib-cavium-dpdk_LDFLAGS = $(call installed_libs_fn, vppinfra cavium-dpdk) diff --git a/build-data/packages/vnet-cavium-dpdk.mk b/build-data/packages/vnet-cavium-dpdk.mk new file mode 100644 index 00000000000..4c35b04dce8 --- /dev/null +++ b/build-data/packages/vnet-cavium-dpdk.mk @@ -0,0 +1,29 @@ +vnet-cavium-dpdk_source = vnet + +vnet-cavium-dpdk_configure_depend = \ + vppinfra-install \ + cavium-dpdk-install \ + svm-install \ + vlib-api-cavium-dpdk-install \ + vlib-cavium-dpdk-install + + +vnet-cavium-dpdk_CPPFLAGS = $(call installed_includes_fn, \ + vppinfra \ + cavium-dpdk \ + openssl \ + svm \ + vlib-cavium-dpdk \ + vlib-api-cavium-dpdk) + +vnet-cavium-dpdk_LDFLAGS = $(call installed_libs_fn, \ + vppinfra \ + cavium-dpdk \ + openssl \ + svm \ + vlib-cavium-dpdk \ + vlib-api-cavium-dpdk) + +# Platform dependent configure flags +vnet-cavium-dpdk_configure_args += $(vnet-cavium-dpdk_configure_args_$(PLATFORM)) + diff --git a/build-data/packages/vpp-api-test-cavium-dpdk.mk b/build-data/packages/vpp-api-test-cavium-dpdk.mk new file mode 100644 index 00000000000..e352317ff8d --- /dev/null +++ b/build-data/packages/vpp-api-test-cavium-dpdk.mk @@ -0,0 +1,32 @@ +vpp-api-test-cavium-dpdk_source = vpp-api-test + +vpp-api-test-cavium-dpdk_configure_depend = \ + vppinfra-install \ + cavium-dpdk-install \ + svm-install \ + vlib-api-cavium-dpdk-install \ + vlib-cavium-dpdk-install \ + vnet-cavium-dpdk-install \ + vpp-cavium-dpdk-install + +# +vpp-api-test-cavium-dpdk_configure_args = --with-dpdk + +vpp-api-test-cavium-dpdk_CPPFLAGS = $(call installed_includes_fn, \ + vppinfra \ + cavium-dpdk \ + svm \ + vlib-cavium-dpdk \ + vlib-api-cavium-dpdk \ + vnet-cavium-dpdk \ + vpp-cavium-dpdk) + +vpp-api-test-cavium-dpdk_LDFLAGS = $(call installed_libs_fn, \ + vppinfra \ + cavium-dpdk \ + svm \ + vlib-cavium-dpdk \ + vlib-api-cavium-dpdk \ + vnet-cavium-dpdk \ + vpp-cavium-dpdk) + diff --git a/build-data/packages/vpp-api-test-no-dpdk.mk b/build-data/packages/vpp-api-test-no-dpdk.mk index b511f2caf9b..7aab11c3a46 100644 --- a/build-data/packages/vpp-api-test-no-dpdk.mk +++ b/build-data/packages/vpp-api-test-no-dpdk.mk @@ -9,8 +9,7 @@ vpp-api-test-no-dpdk_configure_depend = \ vpp-no-dpdk-install # -vpp-api-test-no-dpdk_configure_args = --with-q-platform=$(PLATFORM) \ - --with-q-plugin-prefix=$(MU_BUILD_ROOT_DIR)/packages-$(PLATFORM) +vpp-api-test-no-dpdk_configure_args = vpp-api-test-no-dpdk_CPPFLAGS = $(call installed_includes_fn, \ vppinfra \ diff --git a/build-data/packages/vpp-api-test.mk b/build-data/packages/vpp-api-test.mk index eb7f466a24a..6ad70bc527d 100644 --- a/build-data/packages/vpp-api-test.mk +++ b/build-data/packages/vpp-api-test.mk @@ -8,24 +8,23 @@ vpp-api-test_configure_depend = \ vpp-install # -vpp-api-test_configure_args = --with-q-platform=$(PLATFORM) --with-dpdk \ - --with-q-plugin-prefix=$(MU_BUILD_ROOT_DIR)/packages-$(PLATFORM) +vpp-api-test_configure_args = --with-dpdk vpp-api-test_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - dpdk \ - svm \ - vlib \ - vlib-api \ - vnet \ + vppinfra \ + dpdk \ + svm \ + vlib \ + vlib-api \ + vnet \ vpp) vpp-api-test_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - dpdk \ - svm \ - vlib \ - vlib-api \ - vnet \ + vppinfra \ + dpdk \ + svm \ + vlib \ + vlib-api \ + vnet \ vpp) diff --git a/build-data/packages/vpp-cavium-dpdk.mk b/build-data/packages/vpp-cavium-dpdk.mk new file mode 100644 index 00000000000..704e3a95535 --- /dev/null +++ b/build-data/packages/vpp-cavium-dpdk.mk @@ -0,0 +1,30 @@ +vpp-cavium-dpdk_source = vpp + +vpp-cavium-dpdk_configure_depend = \ + vppinfra-install \ + cavium-dpdk-install \ + svm-install \ + vlib-api-cavium-dpdk-install \ + vlib-cavium-dpdk-install \ + vnet-cavium-dpdk-install + +# Platform dependent configure flags +vpp-cavium-dpdk_configure_args += $(vpp-cavium-dpdk_configure_args_$(PLATFORM)) + +vpp-cavium-dpdk_CPPFLAGS = $(call installed_includes_fn, \ + vppinfra \ + cavium-dpdk \ + openssl \ + svm \ + vlib-cavium-dpdk \ + vlib-api-cavium-dpdk \ + vnet-cavium-dpdk) + +vpp-cavium-dpdk_LDFLAGS = $(call installed_libs_fn, \ + vppinfra \ + cavium-dpdk \ + openssl \ + svm \ + vlib-cavium-dpdk \ + vlib-api-cavium-dpdk \ + vnet-cavium-dpdk) diff --git a/build-data/packages/vpp-no-dpdk.mk b/build-data/packages/vpp-no-dpdk.mk index f509bdf399f..81f3f75a100 100644 --- a/build-data/packages/vpp-no-dpdk.mk +++ b/build-data/packages/vpp-no-dpdk.mk @@ -1,33 +1,32 @@ vpp-no-dpdk_source = vpp -vpp-no-dpdk_configure_depend = \ +vpp-no-dpdk_configure_depend = \ vppinfra-install \ - openssl-install \ + openssl-install \ svm-install \ - vlib-api-no-dpdk-install \ - vlib-no-dpdk-install \ - vnet-no-dpdk-install \ + vlib-api-no-dpdk-install \ + vlib-no-dpdk-install \ + vnet-no-dpdk-install # -vpp-no-dpdk_configure_args = --with-q-platform=$(PLATFORM) \ - --with-q-plugin-prefix=$(MU_BUILD_ROOT_DIR)/packages-$(PLATFORM) +vpp-no-dpdk_configure_args = # Platform dependent configure flags vpp-no-dpdk_configure_args += $(vpp-no-dpdk_configure_args_$(PLATFORM)) vpp-no-dpdk_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - openssl \ - svm \ + vppinfra \ + openssl \ + svm \ vlib-no-dpdk \ vlib-api-no-dpdk \ vnet-no-dpdk) -vpp-no-dpdk_LDFLAGS = $(call installed_libs_fn, \ +vpp-no-dpdk_LDFLAGS = $(call installed_libs_fn, \ vppinfra \ openssl \ svm \ - vlib-no-dpdk \ - vlib-api-no-dpdk \ + vlib-no-dpdk \ + vlib-api-no-dpdk \ vnet-no-dpdk) diff --git a/build-data/packages/vpp.mk b/build-data/packages/vpp.mk index ff2c551965a..02aca4e6426 100644 --- a/build-data/packages/vpp.mk +++ b/build-data/packages/vpp.mk @@ -7,8 +7,7 @@ vpp_configure_depend = \ vnet-install \ # -vpp_configure_args = --with-q-platform=$(PLATFORM) \ - --with-q-plugin-prefix=$(MU_BUILD_ROOT_DIR)/packages-$(PLATFORM) +vpp_configure_args = # Platform dependent configure flags vpp_configure_args += $(vpp_configure_args_$(PLATFORM)) diff --git a/build-data/platforms/thunder.mk b/build-data/platforms/thunder.mk new file mode 100644 index 00000000000..8fb00456b05 --- /dev/null +++ b/build-data/platforms/thunder.mk @@ -0,0 +1,36 @@ +# Override OS so we can use the sdk toolchain instead of building one +thunder_os = thunderx-linux-gnu + +# Override CROSS_LDFLAGS so we can use +# /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 instead of building glibc +thunder_cross_ldflags = \ + -Wl,--dynamic-linker=/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 \ + -Wl,-rpath -Wl,$(lots_of_slashes_to_pad_names)$(TOOL_INSTALL_LIB_DIR) + +thunder_arch = aarch64 +# suppress -march=foo, the cross compiler doesn't understand it +thunder_march = " " + +thunder_root_packages = vppinfra vlib-cavium-dpdk vnet-cavium-dpdk cavium-dpdk \ + vpp-cavium-dpdk vpp-api-test-cavium-dpdk + +vnet-cavium-dpdk_configure_args_thunder = \ + --with-dpdk --without-ipsec --without-vcgn --without-ipv6sr + +vpp-cavium-dpdk_configure_args_thunder = \ + --with-dpdk --without-ipsec --without-vcgn --without-ipv6sr + +cavium-dpdk_configure_args_thunder = --with-headroom=256 + +vlib-cavium-dpdk_configure_args_thunder = --with-pre-data=128 + +# native tool chain additions for this platform +thunder_native_tools = vppapigen + +thunder_debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG +thunder_debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG + +thunder_TAG_CFLAGS = -g -O2 +thunder_TAG_LDFLAGS = -g -O2 + + diff --git a/build-root/Makefile b/build-root/Makefile index ed25a0cc06d..aa50255b007 100644 --- a/build-root/Makefile +++ b/build-root/Makefile @@ -172,7 +172,12 @@ native_libdir = $($(NATIVE_ARCH)_libdir) arch_lib_dir = lib$($(BASIC_ARCH)_libdir) # OS to configure for. configure --host will be set to $(ARCH)-$(OS) -OS = mu-linux +# Allow per-platform overrides + +OS = $(strip $($(PLATFORM)_os)) +ifeq ($(OS),) + OS = mu-linux +endif spu_target = spu native_target = @@ -506,9 +511,13 @@ DYNAMIC_LINKER=${shell cd $(TOOL_INSTALL_LIB_DIR); echo ld*.so.*} lots_of_slashes_to_pad_names = "/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" # When PLATFORM != native we *always* use our own versions of GLIBC and dynamic linker -CROSS_LDFLAGS = \ - -Wl,--dynamic-linker=$(lots_of_slashes_to_pad_names)$(TOOL_INSTALL_LIB_DIR)/$(DYNAMIC_LINKER) \ - -Wl,-rpath -Wl,$(lots_of_slashes_to_pad_names)$(TOOL_INSTALL_LIB_DIR) +# Allow per-platform overrides +CROSS_LDFLAGS = $(strip $($(PLATFORM)_cross_ldflags)) +ifeq ($(CROSS_LDFLAGS),) + CROSS_LDFLAGS = \ + -Wl,--dynamic-linker=$(lots_of_slashes_to_pad_names)$(TOOL_INSTALL_LIB_DIR)/$(DYNAMIC_LINKER) \ + -Wl,-rpath -Wl,$(lots_of_slashes_to_pad_names)$(TOOL_INSTALL_LIB_DIR) +endif cross_ldflags = $(if $(is_native)$(is_build_tool),,$(CROSS_LDFLAGS) ) diff --git a/vnet/Makefile.am b/vnet/Makefile.am index a0c20e9eb37..81cc012f046 100644 --- a/vnet/Makefile.am +++ b/vnet/Makefile.am @@ -13,7 +13,7 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -AM_CFLAGS = -Wall @DPDK@ @VIRL@ +AM_CFLAGS = -Wall @DPDK@ @VIRL@ @IPSEC@ @VCGN@ @IPV6SR@ libvnet_la_SOURCES = libvnetplugin_la_SOURCES = @@ -278,7 +278,7 @@ nobase_include_HEADERS += \ ######################################## # Layer 3 protocol: IPSec ######################################## -if WITH_DPDK +if WITH_IPSEC libvnet_la_SOURCES += \ vnet/ipsec/ipsec.c \ vnet/ipsec/ipsec_cli.c \ @@ -295,13 +295,13 @@ libvnet_la_SOURCES += \ vnet/ipsec/ikev2_cli.c \ vnet/ipsec/ikev2_payload.c \ vnet/ipsec/ikev2_format.c +endif nobase_include_HEADERS += \ vnet/ipsec/ipsec.h \ vnet/ipsec/esp.h \ vnet/ipsec/ikev2.h \ vnet/ipsec/ikev2_priv.h -endif ######################################## # Layer 3 protocol: osi @@ -441,8 +441,11 @@ nobase_include_HEADERS += \ ######################################## # ipv6 segment routing ######################################## + +if WITH_IPV6SR libvnet_la_SOURCES += \ vnet/sr/sr.c +endif nobase_include_HEADERS += \ vnet/sr/sr_packet.h \ @@ -452,6 +455,8 @@ nobase_include_HEADERS += \ ######################################## # CGN ######################################### + +if WITH_VCGN libvnet_la_SOURCES += \ vnet/vcgn/cnat_bulk_port.c \ vnet/vcgn/cnat_config.c \ @@ -480,6 +485,7 @@ libvnet_la_SOURCES += \ vnet/vcgn/index_list.c \ vnet/vcgn/spp_platform_trace_log.c \ vnet/vcgn/vcgn_classify.c +endif ######################################## # DHCPv6 proxy diff --git a/vnet/configure.ac b/vnet/configure.ac index a570389e3fb..cc55dc3b4c1 100644 --- a/vnet/configure.ac +++ b/vnet/configure.ac @@ -17,10 +17,34 @@ AC_ARG_WITH(virl, [with_virl=1], [with_virl=0]) +AC_ARG_WITH(ipsec, + AC_HELP_STRING([--without-ipsec],[Disable ipsec]), + [with_ipsec=0], + [with_ipsec=1]) + +AC_ARG_WITH(vcgn, + AC_HELP_STRING([--without-vcgn],[Disable vcgn]), + [with_vcgn=0], + [with_vcgn=1]) + +AC_ARG_WITH(ipv6sr, + AC_HELP_STRING([--without-ipv6sr],[Disable ipv6sr]), + [with_ipv6sr=0], + [with_ipv6sr=1]) + AM_CONDITIONAL(WITH_DPDK, test "$with_dpdk" = "1") AC_SUBST(DPDK,[-DDPDK=${with_dpdk}]) AM_CONDITIONAL(WITH_VIRL, test "$with_virl" = "1") AC_SUBST(VIRL,[-DVIRL=${with_virl}]) +AM_CONDITIONAL(WITH_IPSEC, test "$with_ipsec" = "1") +AC_SUBST(IPSEC,[-DIPSEC=${with_ipsec}]) + +AM_CONDITIONAL(WITH_VCGN, test "$with_vcgn" = "1") +AC_SUBST(VCGN,[-DVCGN=${with_vcgn}]) + +AM_CONDITIONAL(WITH_IPV6SR, test "$with_ipv6sr" = "1") +AC_SUBST(IPV6SR,[-DIPV6SR=${with_ipv6sr}]) + AC_OUTPUT([Makefile]) diff --git a/vnet/vnet/classify/vnet_classify.h b/vnet/vnet/classify/vnet_classify.h index 03271ad2e06..3e93ba34229 100644 --- a/vnet/vnet/classify/vnet_classify.h +++ b/vnet/vnet/classify/vnet_classify.h @@ -294,7 +294,9 @@ vnet_classify_find_entry_inline (vnet_classify_table_t * t, u32x4 result __attribute__((aligned(sizeof(u32x4)))); vnet_classify_bucket_t * b; u32 value_index; +#ifndef __aarch64__ u32 result_mask; +#endif u32 bucket_index; int i; @@ -357,6 +359,7 @@ vnet_classify_find_entry_inline (vnet_classify_table_t * t, abort(); } +#ifndef __aarch64__ result_mask = u32x4_zero_byte_mask (result); if (result_mask == 0xffff) { @@ -367,6 +370,24 @@ vnet_classify_find_entry_inline (vnet_classify_table_t * t, } return (v); } +#else + { + typedef union {u32x4 as_u32x4; u64 as_u64[2];} u64u_t; + u64u_t u; + u.as_u32x4 = result; + + if (u.as_u64[0] == 0 && u.as_u64[1] == 0) + { + if (PREDICT_TRUE(now)) + { + v->hits++; + v->last_heard = now; + } + return (v); + } + } +#endif + v = vnet_classify_entry_at_index (t, v, 1); } return 0; diff --git a/vnet/vnet/devices/dpdk/dpdk.h b/vnet/vnet/devices/dpdk/dpdk.h index fd984e4d4df..bb3ef4ffba8 100644 --- a/vnet/vnet/devices/dpdk/dpdk.h +++ b/vnet/vnet/devices/dpdk/dpdk.h @@ -75,6 +75,7 @@ typedef enum { } dpdk_device_type_t; #define foreach_dpdk_pmd \ + _ ("rte_nicvf_pmd", THUNDERX) \ _ ("rte_em_pmd", E1000EM) \ _ ("rte_igb_pmd", IGB) \ _ ("rte_igbvf_pmd", IGBVF) \ diff --git a/vnet/vnet/devices/dpdk/init.c b/vnet/vnet/devices/dpdk/init.c index a4b0f01475f..a8e84949a52 100644 --- a/vnet/vnet/devices/dpdk/init.c +++ b/vnet/vnet/devices/dpdk/init.c @@ -341,6 +341,7 @@ dpdk_lib_init (dpdk_main_t * dm) /* 10G adapters */ case VNET_DPDK_PMD_IXGBE: case VNET_DPDK_PMD_IXGBEVF: + case VNET_DPDK_PMD_THUNDERX: xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G; xd->nb_rx_desc = DPDK_NB_RX_DESC_10GE; xd->nb_tx_desc = DPDK_NB_TX_DESC_10GE; @@ -1686,6 +1687,22 @@ do { \ #undef _ +/* + * At the moment, the ThunderX NIC driver doesn't have + * an entry point named "devinitfn_rte_xxx_driver" + */ +#define _(d) \ +do { \ + void d(void); \ + __attribute__((unused)) void (* volatile pf)(void); \ + pf = d; \ +} while(0); + +#ifdef RTE_LIBRTE_THUNDERVNIC_PMD +_(rte_nicvf_pmd_init) +#endif +#undef _ + dm->vlib_main = vm; dm->vnet_main = vnet_get_main(); diff --git a/vnet/vnet/devices/dpdk/node.c b/vnet/vnet/devices/dpdk/node.c index f05c37fed52..770af2a04ac 100644 --- a/vnet/vnet/devices/dpdk/node.c +++ b/vnet/vnet/devices/dpdk/node.c @@ -541,6 +541,7 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, u32 n_trace, trace_cnt __attribute__((unused)); vlib_buffer_free_list_t * fl; u8 efd_discard_burst = 0; + u16 ip_align_offset = 0; if (xd->admin_up == 0) return 0; @@ -559,6 +560,9 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, return 0; } + if (xd->pmd == VNET_DPDK_PMD_THUNDERX) + ip_align_offset = 6; + vec_reset_length (xd->d_trace_buffers); trace_cnt = n_trace = vlib_get_trace_count (vm, node); @@ -706,6 +710,14 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, b0->current_data = l3_offset0; b0->current_length = mb->data_len - l3_offset0; + + if (PREDICT_FALSE (ip_align_offset != 0)) + { + if (next0 == DPDK_RX_NEXT_IP4_INPUT || + next0 == DPDK_RX_NEXT_IP6_INPUT) + b0->current_data += ip_align_offset; + } + b0->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID; if (VMWARE_LENGTH_BUG_WORKAROUND) diff --git a/vnet/vnet/map/map.c b/vnet/vnet/map/map.c index 3cf5e692489..b55c4c2e519 100644 --- a/vnet/vnet/map/map.c +++ b/vnet/vnet/map/map.c @@ -17,7 +17,7 @@ #include "map.h" -#ifdef __powerpc64__ +#if defined(__powerpc64__) || defined(__aarch64__) #include <vppinfra/xxhash.h> static inline u32 diff --git a/vnet/vnet/plugin/p1.c b/vnet/vnet/plugin/p1.c index 6ede7938ee9..9029f130dc5 100644 --- a/vnet/vnet/plugin/p1.c +++ b/vnet/vnet/plugin/p1.c @@ -51,8 +51,6 @@ _(format_ip6_address_and_length) \ _(udp_register_dst_port) \ _(ethernet_register_input_type) \ _(ethernet_set_flags) \ -_(vnet_register_sr_app_callback) \ -_(format_ip6_sr_header) \ _(format_ip6_address) \ _(unformat_ip6_address) \ _(ip6_main) \ @@ -101,9 +99,18 @@ _(efd_config) #define foreach_dpdk_plugin_reference #endif +#if IPV6SR > 0 +#define foreach_ip6_sr_plugin_reference \ +_(vnet_register_sr_app_callback) \ +_(format_ip6_sr_header) +#else +#define foreach_ip6_sr_plugin_reference +#endif + #define _(a) void a (void); foreach_plugin_reference foreach_dpdk_plugin_reference +foreach_ip6_sr_plugin_reference #undef _ void *vnet_library_plugin_references[] = @@ -111,6 +118,7 @@ void *vnet_library_plugin_references[] = #define _(a) &a, foreach_plugin_reference foreach_dpdk_plugin_reference + foreach_ip6_sr_plugin_reference #undef _ }; diff --git a/vpp-japi/m4/libtool.m4 b/vpp-japi/m4/libtool.m4 index 44e0ecff11e..d7c043f4f99 100644 --- a/vpp-japi/m4/libtool.m4 +++ b/vpp-japi/m4/libtool.m4 @@ -1312,7 +1312,7 @@ ia64-*-hpux*) rm -rf conftest* ;; -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext @@ -1324,9 +1324,19 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - LD="${LD-ld} -m elf_i386" + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*) + LD="${LD-ld} -m elf32lppclinux" ;; - ppc64-*linux*|powerpc64-*linux*) + powerpc64-*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) @@ -1345,7 +1355,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - ppc*-*linux*|powerpc*-*linux*) + powerpcle-*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) @@ -1688,7 +1701,8 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else @@ -2512,17 +2526,6 @@ freebsd* | dragonfly*) esac ;; -gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no @@ -2639,7 +2642,7 @@ linux*oldld* | linux*aout* | linux*coff*) ;; # This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no @@ -2684,6 +2687,18 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu) dynamic_linker='GNU/Linux ld.so' ;; +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + netbsd*) version_type=sunos need_lib_prefix=no @@ -3243,10 +3258,6 @@ freebsd* | dragonfly*) fi ;; -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - haiku*) lt_cv_deplibs_check_method=pass_all ;; @@ -3285,11 +3296,11 @@ irix5* | irix6* | nonstopux*) ;; # This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; -netbsd*) +netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else @@ -4037,7 +4048,7 @@ m4_if([$1], [CXX], [ ;; esac ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # KAI C++ Compiler @@ -4101,7 +4112,7 @@ m4_if([$1], [CXX], [ ;; esac ;; - netbsd*) + netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise @@ -4336,7 +4347,7 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) @@ -4578,6 +4589,9 @@ m4_if([$1], [CXX], [ ;; esac ;; + linux* | k*bsd*-gnu | gnu*) + _LT_TAGVAR(link_all_deplibs, $1)=no + ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; @@ -4640,6 +4654,9 @@ dnl Note also adjust exclude_expsyms for C++ above. openbsd*) with_gnu_ld=no ;; + linux* | k*bsd*-gnu | gnu*) + _LT_TAGVAR(link_all_deplibs, $1)=no + ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes @@ -4861,7 +4878,7 @@ _LT_EOF fi ;; - netbsd*) + netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= @@ -5038,6 +5055,7 @@ _LT_EOF if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi + _LT_TAGVAR(link_all_deplibs, $1)=no else # not using gcc if test "$host_cpu" = ia64; then @@ -5342,7 +5360,7 @@ _LT_EOF _LT_TAGVAR(link_all_deplibs, $1)=yes ;; - netbsd*) + netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else @@ -6222,9 +6240,6 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(ld_shlibs, $1)=yes ;; - gnu*) - ;; - haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes @@ -6386,7 +6401,7 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(inherit_rpath, $1)=yes ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler diff --git a/vpp/Makefile.am b/vpp/Makefile.am index 5103646c5c9..73e01b79c1c 100644 --- a/vpp/Makefile.am +++ b/vpp/Makefile.am @@ -13,7 +13,7 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -AM_CFLAGS = -Wall @Q_PLATFORM_DEFINE@ @Q_PLATFORM_PLUGPATH@ @DPDK@ +AM_CFLAGS = -Wall @DPDK@ @IPSEC@ @VCGN@ @IPV6SR@ noinst_PROGRAMS = BUILT_SOURCES = @@ -75,9 +75,11 @@ if WITH_DPDK vpp_LDADD += -l:libdpdk.a endif -# These go last +vpp_LDADD += -lvppinfra -lm -lpthread -ldl -vpp_LDADD += -lvppinfra -lm -lpthread -lcrypto -ldl +if WITH_IPV6SR + vpp_LDADD += -lcrypto +endif SUFFIXES = .api.h .api diff --git a/vpp/api/api.c b/vpp/api/api.c index fe9267914ac..9f3da214356 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -52,7 +52,9 @@ #include <vnet/mpls-gre/mpls.h> #include <vnet/dhcp/proxy.h> #include <vnet/dhcp/client.h> +#if IPV6SR > 0 #include <vnet/sr/sr.h> +#endif #include <vnet/dhcpv6/proxy.h> #include <vlib/vlib.h> #include <vlib/unix/unix.h> @@ -73,7 +75,9 @@ #include <vnet/l2/l2_fib.h> #if DPDK > 0 +#if IPSEC > 0 #include <vnet/ipsec/ipsec.h> +#endif /* IPSEC */ #include <vnet/devices/virtio/vhost-user.h> #endif @@ -3276,6 +3280,9 @@ static void vl_api_set_arp_neighbor_limit_t_handler (vl_api_set_arp_neighbor_lim static void vl_api_sr_tunnel_add_del_t_handler (vl_api_sr_tunnel_add_del_t *mp) { +#if IPV6SR == 0 + clib_warning ("unimplemented"); +#else ip6_sr_add_del_tunnel_args_t _a, *a=&_a; int rv = 0; vl_api_sr_tunnel_add_del_reply_t * rmp; @@ -3319,6 +3326,7 @@ static void vl_api_sr_tunnel_add_del_t_handler out: REPLY_MACRO(VL_API_SR_TUNNEL_ADD_DEL_REPLY); +#endif } #define foreach_classify_add_del_table_field \ @@ -4509,6 +4517,10 @@ static void vl_api_input_acl_set_interface_t_handler static void vl_api_ipsec_spd_add_del_t_handler (vl_api_ipsec_spd_add_del_t * mp) { +#if IPSEC == 0 + clib_warning ("unimplemented"); +#else + vlib_main_t *vm __attribute__((unused)) = vlib_get_main(); vl_api_ipsec_spd_add_del_reply_t * rmp; int rv; @@ -4520,6 +4532,7 @@ static void vl_api_ipsec_spd_add_del_t_handler #endif REPLY_MACRO(VL_API_IPSEC_SPD_ADD_DEL_REPLY); +#endif } static void vl_api_ipsec_interface_add_del_spd_t_handler @@ -4536,7 +4549,7 @@ static void vl_api_ipsec_interface_add_del_spd_t_handler VALIDATE_SW_IF_INDEX(mp); -#if DPDK > 0 +#if IPSEC > 0 rv = ipsec_set_interface_spd(vm, sw_if_index, spd_id, mp->is_add); #else rv = VNET_API_ERROR_UNIMPLEMENTED; @@ -4554,7 +4567,7 @@ static void vl_api_ipsec_spd_add_del_entry_t_handler vl_api_ipsec_spd_add_del_entry_reply_t * rmp; int rv; -#if DPDK > 0 +#if IPSEC > 0 ipsec_policy_t p; p.id = ntohl(mp->spd_id); @@ -4604,7 +4617,7 @@ static void vl_api_ipsec_sad_add_del_entry_t_handler vlib_main_t *vm __attribute__((unused)) = vlib_get_main(); vl_api_ipsec_sad_add_del_entry_reply_t * rmp; int rv; -#if DPDK > 0 +#if IPSEC > 0 ipsec_sa_t sa; sa.id = ntohl(mp->sad_id); @@ -4830,7 +4843,7 @@ static void vl_api_ipsec_sa_set_key_t_handler vlib_main_t *vm __attribute__((unused)) = vlib_get_main(); vl_api_ipsec_sa_set_key_reply_t *rmp; int rv; -#if DPDK > 0 +#if IPSEC > 0 ipsec_sa_t sa; sa.id = ntohl(mp->sa_id); sa.crypto_key_len = mp->crypto_key_length; diff --git a/vpp/api/test_client.c b/vpp/api/test_client.c index b635f04f7f3..cfb133c7e60 100644 --- a/vpp/api/test_client.c +++ b/vpp/api/test_client.c @@ -42,7 +42,6 @@ #include <vppinfra/error.h> #include <vnet/vnet.h> -#include <vnet/sr/sr.h> #include <vlib/vlib.h> #include <vlib/unix/unix.h> #include <vlibapi/api.h> diff --git a/vpp/configure.ac b/vpp/configure.ac index 8c7beb4d94d..f2756a305ef 100644 --- a/vpp/configure.ac +++ b/vpp/configure.ac @@ -7,27 +7,36 @@ AM_PROG_AS AC_PROG_CC AM_PROG_CC_C_O -AC_ARG_WITH(q-plugin-prefix, - AC_HELP_STRING([--with-q-plugin-prefix],[vlib plugin prefix]), - [case $with_q_plugin_prefix in - *) ;; - esac]) - -AC_ARG_WITH(q-platform, - AC_HELP_STRING([--with-q-platform],[Build version for given platform (qnative)]), - [case $with_q_platform in - qnative) ;; - *) with_q_platform=qnative;; - esac]) - AC_ARG_WITH(dpdk, AC_HELP_STRING([--with-dpdk],[Use the Intel dpdk]), [with_dpdk=1], [with_dpdk=0]) +AC_ARG_WITH(ipsec, + AC_HELP_STRING([--without-ipsec],[Disable ipsec]), + [with_ipsec=0], + [with_ipsec=1]) + +AC_ARG_WITH(vcgn, + AC_HELP_STRING([--without-vcgn],[Disable vcgn]), + [with_vcgn=0], + [with_vcgn=1]) + +AC_ARG_WITH(ipv6sr, + AC_HELP_STRING([--without-ipv6sr],[Disable ipv6sr]), + [with_ipv6sr=0], + [with_ipv6sr=1]) + AM_CONDITIONAL(WITH_DPDK, test "$with_dpdk" = "1") -AC_SUBST(Q_PLATFORM_DEFINE,[-DQ_PLATFORM_${with_q_platform}]) -AC_SUBST(Q_PLATFORM_PLUGPATH,[-DQ_PLUGIN_PREFIX=${with_q_plugin_prefix}]) AC_SUBST(DPDK,[-DDPDK=${with_dpdk}]) +AM_CONDITIONAL(WITH_IPSEC, test "$with_ipsec" = "1") +AC_SUBST(IPSEC,[-DIPSEC=${with_ipsec}]) + +AM_CONDITIONAL(WITH_VCGN, test "$with_vcgn" = "1") +AC_SUBST(VCGN,[-DVCGN=${with_vcgn}]) + +AM_CONDITIONAL(WITH_IPV6SR, test "$with_ipv6sr" = "1") +AC_SUBST(IPV6SR,[-DIPV6SR=${with_ipv6sr}]) + AC_OUTPUT([Makefile]) diff --git a/vpp/vnet/main.c b/vpp/vnet/main.c index d60b489e936..1dffa7c2552 100644 --- a/vpp/vnet/main.c +++ b/vpp/vnet/main.c @@ -52,8 +52,6 @@ vpe_main_init (vlib_main_t * vm) return error; if ((error = vlib_call_init_function (vm, ethernet_arp_init))) return error; - if ((error = vlib_call_init_function (vm, sr_init))) - return error; if ((error = vlib_call_init_function (vm, map_init))) return error; if ((error = vlib_call_init_function (vm, sixrd_init))) @@ -72,8 +70,10 @@ vpe_main_init (vlib_main_t * vm) return error; if ((error = vlib_call_init_function (vm, vhost_user_init))) return error; +#if IPSEC > 0 if ((error = vlib_call_init_function (vm, ipsec_init))) return error; +#endif /* IPSEC */ #endif if ((error = vlib_call_init_function (vm, vlibmemory_init))) return error; @@ -102,16 +102,20 @@ vpe_main_init (vlib_main_t * vm) return error; if ((error = vlib_call_init_function (vm, tuntap_init))) return error; +#if IPV6SR > 0 if ((error = vlib_call_init_function (vm, sr_init))) return error; +#endif if ((error = vlib_call_init_function (vm, l2_classify_init))) return error; if ((error = vlib_call_init_function (vm, policer_init))) return error; if ((error = vlib_call_init_function (vm, vxlan_init))) return error; +#if VCGN > 0 if ((error = vlib_call_init_function (vm, vcgn_init))) return error; +#endif if ((error = vlib_call_init_function (vm, li_init))) return error; @@ -339,6 +343,39 @@ u32 vlib_app_num_thread_stacks_needed (void) return 1; } +/* + * Depending on the configuration selected above, + * it may be necessary to generate stub graph nodes. + * It is never OK to ignore "node 'x' refers to unknown node 'y' + * messages! + */ + +#if IPV6SR == 0 +#define foreach_ipv6_sr_stub_node \ +_(ipsec-output, ipsec_output) +#else +#define foreach_ipv6_sr_stub_node +#endif + +#define _(n,m) \ +static uword \ +m##_node_fn (vlib_main_t *vm, \ + vlib_node_runtime_t *node, \ + vlib_frame_t *frame) \ +{ \ + clib_warning("unimplemented, leaking buffers..."); \ + return 0; \ +} \ + \ +VLIB_REGISTER_NODE(m##_node) = { \ + .function = m##_node_fn, \ + .name = #n, \ + .vector_size = sizeof(u32), \ + .type = VLIB_NODE_TYPE_INTERNAL, \ +}; +foreach_ipv6_sr_stub_node; +#undef _ + #if CLIB_DEBUG > 0 static clib_error_t * diff --git a/vppinfra/vppinfra/bihash_24_8.h b/vppinfra/vppinfra/bihash_24_8.h index c789c980fb6..c0dff8ccfcd 100644 --- a/vppinfra/vppinfra/bihash_24_8.h +++ b/vppinfra/vppinfra/bihash_24_8.h @@ -50,14 +50,6 @@ crc_u32(u32 data, u32 value) static inline u64 clib_bihash_hash_24_8 (clib_bihash_kv_24_8_t *v) { -#if 0 - u64 * dp = (u64 *) &v->key[0]; - u64 value = 0; - - value __builtin_ia32_crc32di (dp[0], value); - value __builtin_ia32_crc32di (dp[1], value); - value __builtin_ia32_crc32di (dp[2], value); -#endif u32 * dp = (u32 *) &v->key[0]; u32 value = 0; @@ -70,8 +62,7 @@ static inline u64 clib_bihash_hash_24_8 (clib_bihash_kv_24_8_t *v) return value; } - -#else +#else static inline u64 clib_bihash_hash_24_8 (clib_bihash_kv_24_8_t *v) { u64 tmp = v->key[0] ^ v->key[1] ^ v->key[2]; diff --git a/vppinfra/vppinfra/byte_order.h b/vppinfra/vppinfra/byte_order.h index 9c556327f9f..4f385f152df 100644 --- a/vppinfra/vppinfra/byte_order.h +++ b/vppinfra/vppinfra/byte_order.h @@ -40,7 +40,7 @@ #include <vppinfra/clib.h> -#if defined(__x86_64__) || defined(i386) +#if defined(__x86_64__) || defined(i386) || defined(__aarch64__) #define CLIB_ARCH_IS_BIG_ENDIAN (0) #define CLIB_ARCH_IS_LITTLE_ENDIAN (1) #else diff --git a/vppinfra/vppinfra/longjmp.S b/vppinfra/vppinfra/longjmp.S index ac138a96257..9ba237d4489 100644 --- a/vppinfra/vppinfra/longjmp.S +++ b/vppinfra/vppinfra/longjmp.S @@ -580,6 +580,109 @@ clib_longjmp: clib_calljmp: 1: B .S1 1b +#elif defined (__aarch64__) +/* + Copyright (c) 2011, 2012 ARM Ltd + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The name of the company may not be used to endorse or promote + products derived from this software without specific prior written + permission. + THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define GPR_LAYOUT \ + REG_PAIR (x19, x20, 0); \ + REG_PAIR (x21, x22, 16); \ + REG_PAIR (x23, x24, 32); \ + REG_PAIR (x25, x26, 48); \ + REG_PAIR (x27, x28, 64); \ + REG_PAIR (x29, x30, 80); \ + REG_ONE (x16, 96) +#define FPR_LAYOUT \ + REG_PAIR ( d8, d9, 112); \ + REG_PAIR (d10, d11, 128); \ + REG_PAIR (d12, d13, 144); \ + REG_PAIR (d14, d15, 160); +// int clib_setjmp (jmp_buf) + .global clib_setjmp + .type clib_setjmp, %function +clib_setjmp: + mov x16, sp +#define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS] +#define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS] + GPR_LAYOUT + FPR_LAYOUT +#undef REG_PAIR +#undef REG_ONE + mov x0, x1 + ret + .size clib_setjmp, .-clib_setjmp +// void clib_longjmp (jmp_buf, int) __attribute__ ((noreturn)) + .global clib_longjmp + .type clib_longjmp, %function +clib_longjmp: +#define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS] +#define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS] + GPR_LAYOUT + FPR_LAYOUT +#undef REG_PAIR +#undef REG_ONE + mov sp, x16 + mov x0, x1 + // cmp w1, #0 + // cinc w0, w1, eq + // use br not ret, as ret is guaranteed to mispredict + br x30 + .size clib_longjmp, .-clib_longjmp + + +// void clib_calljmp (x0=function, x1=arg, x2=new_stack) + .global clib_calljmp + .type clib_calljmp, %function +clib_calljmp: + // save fn ptr + mov x3, x0 + // set up fn arg + mov x0, x1 + // switch stacks + mov x4, sp + + // space for saved sp, lr on new stack + sub x2, x2, #16 + mov sp, x2 + + // save old sp and link register on new stack + str x4, [sp] + str x30,[sp,#8] + mov x4, sp + + // go there + blr x3 + + // restore old sp and link register + mov x4, sp + + ldr x3, [x4] + ldr x30,[x4, #8] + mov sp, x3 + ret + .size clib_calljmp, .-clib_calljmp #else #error "unknown machine" #endif diff --git a/vppinfra/vppinfra/longjmp.h b/vppinfra/vppinfra/longjmp.h index a28b20cdae6..7252aa3cd62 100644 --- a/vppinfra/vppinfra/longjmp.h +++ b/vppinfra/vppinfra/longjmp.h @@ -91,6 +91,8 @@ /* setjmp/longjmp not supported for the moment. */ #define CLIB_ARCH_LONGJMP_REGS 0 +#elif defined(__aarch64__) +#define CLIB_ARCH_LONGJMP_REGS (22) #else #error "unknown machine" #endif diff --git a/vppinfra/vppinfra/test_longjmp.c b/vppinfra/vppinfra/test_longjmp.c index 40b144080b6..299de258c2a 100644 --- a/vppinfra/vppinfra/test_longjmp.c +++ b/vppinfra/vppinfra/test_longjmp.c @@ -92,7 +92,7 @@ static uword f3 (uword arg) static void test_calljmp (unformat_input_t * input) { - static u8 stack[32*1024]; + static u8 stack[32*1024] __attribute__((aligned(16))); uword v; v = clib_calljmp (f3, 0, stack + sizeof (stack)); diff --git a/vppinfra/vppinfra/time.c b/vppinfra/vppinfra/time.c index 0da469eb054..9af599ac10c 100644 --- a/vppinfra/vppinfra/time.c +++ b/vppinfra/vppinfra/time.c @@ -78,6 +78,11 @@ static f64 clock_frequency_from_proc_filesystem (void) int fd; unformat_input_t input; +/* $$$$ aarch64 kernel doesn't report "cpu MHz" */ +#if defined(__aarch64__) + return 0.0; +#endif + cpu_freq = 0; fd = open ("/proc/cpuinfo", 0); if (fd < 0) diff --git a/vppinfra/vppinfra/time.h b/vppinfra/vppinfra/time.h index 524eff6c7a1..3c481082ced 100644 --- a/vppinfra/vppinfra/time.h +++ b/vppinfra/vppinfra/time.h @@ -143,8 +143,18 @@ always_inline u64 clib_cpu_time_now (void) return ((u64)h << 32) | l; } -#else +#elif defined (__aarch64__) +always_inline u64 clib_cpu_time_now (void) +{ + u64 tsc; + + /* Works on Cavium ThunderX. Other platforms: YMMV */ + asm volatile("mrs %0, cntvct_el0" : "=r" (tsc)); + return tsc; +} + +#else #error "don't know how to read CPU time stamp" #endif diff --git a/vppinfra/vppinfra/types.h b/vppinfra/vppinfra/types.h index d43e9613b03..d5ad6ba18cd 100644 --- a/vppinfra/vppinfra/types.h +++ b/vppinfra/vppinfra/types.h @@ -77,7 +77,7 @@ typedef unsigned long long u64; #define log2_uword_bits 6 #define clib_address_bits _MIPS_SZPTR -#elif defined(alpha) || defined(__x86_64__) || defined (__powerpc64__) +#elif defined(alpha) || defined(__x86_64__) || defined (__powerpc64__) || defined (__aarch64__) typedef int i32; typedef long i64; diff --git a/vppinfra/vppinfra/vector.h b/vppinfra/vppinfra/vector.h index b3019333731..84c52a2836d 100644 --- a/vppinfra/vppinfra/vector.h +++ b/vppinfra/vppinfra/vector.h @@ -61,6 +61,10 @@ #define _vector_size(n) __attribute__ ((vector_size (n))) +#if defined (__aarch64__) +typedef unsigned int u32x4 _vector_size (16); +#endif + #ifdef CLIB_HAVE_VEC64 /* Signed 64 bit. */ typedef char i8x8 _vector_size (8); |