diff options
| author | 童宗振 <[email protected]> | 2024-08-06 02:13:16 +0000 |
|---|---|---|
| committer | 童宗振 <[email protected]> | 2024-08-06 02:13:16 +0000 |
| commit | e279579397030323cb451cba23660ac823b3fab0 (patch) | |
| tree | 3687f0df72b291dbed01bb7e26d5cb3c6d8d5a10 | |
| parent | cb4c34cf1904910b622b36454f378630e11731b3 (diff) | |
Build in aarch64
| -rw-r--r-- | CMakeLists.txt | 36 | ||||
| -rw-r--r-- | cmake/FindProgram.cmake | 14 | ||||
| -rw-r--r-- | service/include/sc_node_common.h | 10 | ||||
| -rw-r--r-- | service/src/core.c | 2 | ||||
| -rw-r--r-- | service/src/node_etherfabric.c | 10 | ||||
| -rw-r--r-- | support/CMakeLists.txt | 21 | ||||
| -rw-r--r-- | support/dpdk/dpdk-23.11.1-fix-dup-msl-name-sec-process.patch | 3 | ||||
| -rw-r--r-- | tools/monit_device/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | tools/monit_obp/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | tools/monit_stream/CMakeLists.txt | 2 | ||||
| -rwxr-xr-x | tools/mrmarch/mrmarch.in | 26 |
11 files changed, 104 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b72286..e4c2fd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,13 +22,15 @@ message(STATUS "C Compiler Version: ${CMAKE_C_COMPILER_VERSION}") message(STATUS "CXX Compiler Version: ${CMAKE_CXX_COMPILER_VERSION}") message(STATUS "C Standard: ${CMAKE_C_STANDARD}") message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}") +message(STATUS "System Processor: ${CMAKE_SYSTEM_PROCESSOR}") # machine set(COREI7 "corei7") set(ICELAKE_SERVER "icelake-server") set(ZNVER1 "znver1") set(ZNVER4 "znver4") -set(SUPPORTED_MACHINES ${COREI7} ${ICELAKE_SERVER} ${ZNVER1} ${ZNVER4}) +set(AARCH64 "aarch64") +set(SUPPORTED_MACHINES ${COREI7} ${ICELAKE_SERVER} ${ZNVER1} ${ZNVER4} ${AARCH64}) if(NOT MACHINE) set(MACHINE "corei7") endif() @@ -39,6 +41,19 @@ else() message(FATAL_ERROR "${MACHINE} is not in the support machines list.") endif() +# verify +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64|amd64") + if(MACHINE STREQUAL ${AARCH64}) + message(FATAL_ERROR "${MACHINE} macro definition is not support in ${CMAKE_SYSTEM_PROCESSOR} processor.") + endif() +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64|arm64") + if(NOT MACHINE STREQUAL ${AARCH64}) + message(FATAL_ERROR "${MACHINE} macro definition is not support in ${CMAKE_SYSTEM_PROCESSOR} processor.") + endif() +else() + message(FATAL_ERROR "${CMAKE_SYSTEM_PROCESSOR} processor is not currently supported") +endif() + if(${MACHINE} STREQUAL ${ZNVER4}) message(WARNING "The ${ZNVER4} architecture is only used for testing.It is currently not allowed in production environments.") if(${CMAKE_C_COMPILER_VERSION} VERSION_LESS 13) @@ -46,14 +61,21 @@ if(${MACHINE} STREQUAL ${ZNVER4}) endif() endif() +if(MACHINE STREQUAL ${AARCH64}) + set(MR_CPU_FLAGS "-mtune=generic") +else() + set(MR_CPU_FLAGS "-march=${MACHINE}") +endif() +message(STATUS "current MR_CPU_FLAGS is ${MR_CPU_FLAGS}.") + # If the command line specifies the type, use the command line specified type. # If the command line does not specify the type, use the default value. set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type") message(STATUS "cmake build type: ${CMAKE_BUILD_TYPE}") # FLAGS and define -set(CMAKE_C_FLAGS "-std=gnu99 -m64 -march=${MACHINE} -fPIC -Wall -Wno-format-truncation") -set(CMAKE_CXX_FLAGS "-std=gnu++11 -m64 -march=${MACHINE} -fPIC -Wall -Wno-format-truncation") +set(CMAKE_C_FLAGS "-std=gnu99 ${MR_CPU_FLAGS} -fPIC -Wall -Wno-format-truncation") +set(CMAKE_CXX_FLAGS "-std=gnu++11 ${MR_CPU_FLAGS} -fPIC -Wall -Wno-format-truncation") # Force -O3 for release and relwithdebinfo #string(REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") @@ -81,11 +103,14 @@ if(ENABLE_FUZZING_TEST) # ref: https://github.com/google/fuzzer-test-suite/blob/master/common.sh set(FSANITIZE_FUZZER_FLAGS "-fsanitize=address,fuzzer-no-link") set(COVERAGE_FLAGS "-fprofile-instr-generate -fcoverage-mapping") - set(OTHER_FLAGS "-fPIC -m64 -march=${MACHINE}") + set(OTHER_FLAGS "-fPIC ${MR_CPU_FLAGS}") set(CMAKE_C_FLAGS "${FSANITIZE_FUZZER_FLAGS} ${COVERAGE_FLAGS} ${OTHER_FLAGS}") set(CMAKE_CXX_FLAGS "${FSANITIZE_FUZZER_FLAGS} ${COVERAGE_FLAGS} ${OTHER_FLAGS}") endif() +message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") +message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") + if(ENABLE_PTF_TEST OR ENABLE_FUZZING_TEST) enable_testing() endif() @@ -122,6 +147,8 @@ elseif(MACHINE STREQUAL ${ICELAKE_SERVER}) set(ALTERANTIVES_PRIORITY 200) elseif(MACHINE STREQUAL ${ZNVER1}) set(ALTERANTIVES_PRIORITY 100) +elseif(MACHINE STREQUAL ${AARCH64}) + set(ALTERANTIVES_PRIORITY 90) endif() exec_program(pkg-config ARGS systemd --variable=systemdsystemunitdir OUTPUT_VARIABLE MR_INSTALL_SYSUNITDIR) @@ -129,6 +156,7 @@ exec_program(pkg-config ARGS systemd --variable=systemdsystemunitdir OUTPUT_VARI # compile set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) include(Version) +include(FindProgram) include_directories(include/external) include_directories(include/internal) diff --git a/cmake/FindProgram.cmake b/cmake/FindProgram.cmake new file mode 100644 index 0000000..a525b57 --- /dev/null +++ b/cmake/FindProgram.cmake @@ -0,0 +1,14 @@ +find_program(NUITKA_EXECUTABLE nuitka) +find_program(NUITKA3_EXECUTABLE nuitka3) + +# 设置使用的 Nuitka 命令 +if (NUITKA_EXECUTABLE) + set(NUITKA_COMMAND ${NUITKA_EXECUTABLE}) +elseif (NUITKA3_EXECUTABLE) + set(NUITKA_COMMAND ${NUITKA3_EXECUTABLE}) +else() + message(FATAL_ERROR "Neither 'nuitka' nor 'nuitka3' was found.") +endif() + +# 打印找到的 Nuitka 命令路径 +message(STATUS "Using Nuitka command: ${NUITKA_COMMAND}")
\ No newline at end of file diff --git a/service/include/sc_node_common.h b/service/include/sc_node_common.h index 7e672d1..13c234b 100644 --- a/service/include/sc_node_common.h +++ b/service/include/sc_node_common.h @@ -64,6 +64,7 @@ struct mr_generic_ip_hdr void forwarder_table_insert(uint16_t sid, uint16_t type); +#if defined(__x86_64__) static inline void swap_mac_addr(struct rte_ether_hdr * eth_hdr) { /* swap eth_hdr */ @@ -72,6 +73,15 @@ static inline void swap_mac_addr(struct rte_ether_hdr * eth_hdr) mac_addr = _mm_shuffle_epi8(mac_addr, mac_shfl_msk); _mm_storeu_si128((__m128i *)eth_hdr, mac_addr); } +#elif defined(__aarch64__) +static inline void swap_mac_addr(struct rte_ether_hdr * eth_hdr) +{ + struct rte_ether_addr tmp_addr; + rte_ether_addr_copy(ð_hdr->dst_addr, &tmp_addr); + rte_ether_addr_copy(ð_hdr->src_addr, ð_hdr->dst_addr); + rte_ether_addr_copy(&tmp_addr, ð_hdr->src_addr); +} +#endif static inline int mr_is_local_addr_for_trunk(struct mr_dev_desc * dev_desc, uint16_t vlan_id, struct mr_generic_ip_hdr * ip_hdr) diff --git a/service/src/core.c b/service/src/core.c index 01feaca..e3fe00a 100644 --- a/service/src/core.c +++ b/service/src/core.c @@ -507,6 +507,7 @@ static void sc_eal_init(struct sc_main * sc, const char * cmd) devmgr_eal_args_generate(sc->devmgr_main, eal_argv, &eal_argc, MR_SERVICE_MAX_EAL_ARGC); +#if defined(__x86_64__) /* Force AVX512 */ unsigned int max_simd_bit_width = 0; MESA_load_profile_uint_def(sc->local_cfgfile, "eal", "max_simd_bit_width", &max_simd_bit_width, 0); @@ -515,6 +516,7 @@ static void sc_eal_init(struct sc_main * sc, const char * cmd) { rte_vect_set_max_simd_bitwidth(max_simd_bit_width); } +#endif // DPDK和SYSTEMD的日志级别差1 unsigned int loglevel = g_logger_level + 1; diff --git a/service/src/node_etherfabric.c b/service/src/node_etherfabric.c index c81080a..b959101 100644 --- a/service/src/node_etherfabric.c +++ b/service/src/node_etherfabric.c @@ -56,7 +56,6 @@ union ef_peer_key { uint32_t ip_src; struct rte_ether_addr mac_src; }; - xmm_t xmm; }; /* ef_peer struct */ @@ -543,11 +542,8 @@ int tl_to_ef_peer_map_get(uint16_t traffic_link_id) static inline void vxlan_encap_forwarded_pkt(struct rte_mbuf * mbuf) { /* swap eth_hdr */ - __m128i mac_shfl_msk = _mm_set_epi8(15, 14, 13, 12, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6); struct rte_ether_hdr * eth_hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr *); - __m128i mac_addr = _mm_loadu_si128((__m128i *)eth_hdr); - mac_addr = _mm_shuffle_epi8(mac_addr, mac_shfl_msk); - _mm_storeu_si128((__m128i *)eth_hdr, mac_addr); + swap_mac_addr(eth_hdr); struct rte_ipv4_hdr * ip_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *, sizeof(struct rte_ether_hdr)); uint32_t _swap_ip_addr = ip_hdr->src_addr; @@ -611,8 +607,8 @@ static __rte_always_inline uint16_t ef_ingress_node_process(struct rte_graph * g /* Prepare headers */ struct rte_ether_hdr * outer_ether_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ether_hdr *, 0); - struct rte_ipv4_hdr * outer_ipv4_hdr = - rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *, sizeof(struct rte_ether_hdr)); + struct rte_ipv4_hdr * outer_ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *, + sizeof(struct rte_ether_hdr)); struct g_vxlan_hdr * outer_g_vxlan_hdr = rte_pktmbuf_mtod_offset( mbuf, struct g_vxlan_hdr *, sizeof(struct rte_udp_hdr) + sizeof(struct rte_ipv4_hdr) + sizeof(struct rte_ether_hdr)); diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt index 2c43f8c..4da503c 100644 --- a/support/CMakeLists.txt +++ b/support/CMakeLists.txt @@ -134,8 +134,27 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release") else() set(DPDK_BUILD_TYPE debugoptimized) endif() + +if(MACHINE STREQUAL ${AARCH64}) + set(DPDK_MESON_MACHINE generic) +else() + set(DPDK_MESON_MACHINE ${MACHINE}) +endif() + +set(DPDK_C_ARGS "['-DRTE_ETHDEV_PROFILE_WITH_VTUNE']") +if((MACHINE STREQUAL ${AARCH64}) AND (CMAKE_BUILD_TYPE STREQUAL "Debug")) + # arm unrecognized argument in option ‘-mcmodel=medium’ + # set(DPDK_C_ARGS "['-DRTE_ETHDEV_PROFILE_WITH_VTUNE','-mcmodel=large']") + set(DPDK_BUILD_TYPE debugoptimized) +endif() + +message(STATUS "dpdk build machine: ${DPDK_MESON_MACHINE}") +message(STATUS "dpdk c args: ${DPDK_C_ARGS}") message(STATUS "dpdk build type: ${DPDK_BUILD_TYPE}") + +set(DPDK_MESON_ENABLE_APPS "pdump,proc-info,test-pmd") + set(DPDK_MESON_DISABLED_DRIVERS "common/cpt,common/dpaax,common/octeontx,common/octeontx2,common/sfc_efx,\ common/qat,bus/dpaa,bus/fslmc,bus/ifpga,bus/vmbus,mempool/bucket,mempool/dpaa,\ mempool/dpaa2,mempool/octeontx,mempool/octeontx2,mempool/stack,raw/ifpga,raw/ioat,\ @@ -152,7 +171,7 @@ ExternalProject_Add(dpdk PREFIX dpdk COMMAND patch -Ns -p1 -i ${MERGED_PATCH_FILE} COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR> bash ${DPDK_SOURCE_DIR}/dpdk-config-set.sh CONFIGURE_COMMAND - COMMAND meson -Dmax_lcores=256 -Dc_args=-DRTE_ETHDEV_PROFILE_WITH_VTUNE -Ddisable_drivers=${DPDK_MESON_DISABLED_DRIVERS} -Dprefix=<INSTALL_DIR> -Dcpu_instruction_set=${MACHINE} -Dibverbs_link=dlopen -Dbuildtype=${DPDK_BUILD_TYPE} build + COMMAND meson -Dmax_lcores=256 -Dc_args=${DPDK_C_ARGS} -Ddisable_drivers=${DPDK_MESON_DISABLED_DRIVERS} -Dprefix=<INSTALL_DIR> -Dplatform=generic -Dcpu_instruction_set=${DPDK_MESON_MACHINE} -Dibverbs_link=dlopen -Dbuildtype=${DPDK_BUILD_TYPE} -Denable_apps=${DPDK_MESON_ENABLE_APPS} build BUILD_COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR>/build ninja INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR>/build ninja install diff --git a/support/dpdk/dpdk-23.11.1-fix-dup-msl-name-sec-process.patch b/support/dpdk/dpdk-23.11.1-fix-dup-msl-name-sec-process.patch index 4191e59..daac876 100644 --- a/support/dpdk/dpdk-23.11.1-fix-dup-msl-name-sec-process.patch +++ b/support/dpdk/dpdk-23.11.1-fix-dup-msl-name-sec-process.patch @@ -1,10 +1,11 @@ --- dpdk-stable-23.11.1/lib/eal/linux/eal_memalloc.c 2024-05-17 14:46:11.000000000 +0800 +++ dpdk-stable-23.11.1-mr/lib/eal/linux/eal_memalloc.c 2024-07-12 17:27:43.833952738 +0800 -@@ -7,6 +7,7 @@ +@@ -7,6 +7,8 @@ #include <stdlib.h> #include <stdio.h> #include <stdint.h> +#include <inttypes.h> ++#include <rte_cycles.h> #include <string.h> #include <sys/mman.h> #include <sys/stat.h> diff --git a/tools/monit_device/CMakeLists.txt b/tools/monit_device/CMakeLists.txt index daa742c..562e793 100644 --- a/tools/monit_device/CMakeLists.txt +++ b/tools/monit_device/CMakeLists.txt @@ -1,7 +1,7 @@ set(PI_DIST_PATH ${CMAKE_CURRENT_BINARY_DIR}/pi_dist) add_custom_command(OUTPUT ${PI_DIST_PATH}/monit_device - COMMAND nuitka3 --standalone --onefile + COMMAND ${NUITKA_COMMAND} --standalone --onefile --product-name=${MACHINE} --output-dir=${PI_DIST_PATH} -o monit_device diff --git a/tools/monit_obp/CMakeLists.txt b/tools/monit_obp/CMakeLists.txt index 4476e38..32e3c2f 100644 --- a/tools/monit_obp/CMakeLists.txt +++ b/tools/monit_obp/CMakeLists.txt @@ -1,7 +1,7 @@ set(PI_DIST_PATH ${CMAKE_CURRENT_BINARY_DIR}/pi_dist) add_custom_command(OUTPUT ${PI_DIST_PATH}/monit_obp - COMMAND nuitka3 --standalone --onefile + COMMAND ${NUITKA_COMMAND} --standalone --onefile --product-name=${MACHINE} --output-dir=${PI_DIST_PATH} -o monit_obp diff --git a/tools/monit_stream/CMakeLists.txt b/tools/monit_stream/CMakeLists.txt index 77c435e..eef43b4 100644 --- a/tools/monit_stream/CMakeLists.txt +++ b/tools/monit_stream/CMakeLists.txt @@ -1,7 +1,7 @@ set(PI_DIST_PATH ${CMAKE_CURRENT_BINARY_DIR}/pi_dist) add_custom_command(OUTPUT ${PI_DIST_PATH}/monit_stream - COMMAND nuitka3 --standalone --onefile + COMMAND ${NUITKA_COMMAND} --standalone --onefile --product-name=${MACHINE} --output-dir=${PI_DIST_PATH} -o monit_stream diff --git a/tools/mrmarch/mrmarch.in b/tools/mrmarch/mrmarch.in index 99f3a9a..4b9b2c3 100755 --- a/tools/mrmarch/mrmarch.in +++ b/tools/mrmarch/mrmarch.in @@ -6,6 +6,7 @@ set_flag=false display_flag=false config_flag=false help_flag=false +arch=$(uname -m) march="" # Handle command-line arguments @@ -70,16 +71,25 @@ if [ "$config_flag" = true ]; then fi if [ "$auto_flag" = true ]; then - march=$(gcc -march=native -Q --help=target | grep -- '-march=' | cut -f3) + # march=$(gcc -march=native -Q --help=target | grep -- '-march=' | cut -f3) + march=$(gcc -march=native -Q --help=target | grep -- '-march=' | head -n 1 | awk -F '-march=' '{print $2}' | awk '{$1=$1};1') fi -if [ "$march" == "icelake-server" ]; then - update-alternatives --set mrzcpd /opt/tsg/mrzcpd/icelake-server/bin/mrzcpd --altdir @CMAKE_INSTALL_PREFIX@/altdir - exit -elif [ "$march" == "znver1" ]; then - update-alternatives --set mrzcpd /opt/tsg/mrzcpd/znver1/bin/mrzcpd --altdir @CMAKE_INSTALL_PREFIX@/altdir +echo "current CPU architecture is $arch." +echo "current CPU micro architecture is $march." + +if [ "$arch" == "aarch64" ]; then + update-alternatives --set mrzcpd /opt/tsg/mrzcpd/aarch64/bin/mrzcpd --altdir @CMAKE_INSTALL_PREFIX@/altdir exit else - update-alternatives --set mrzcpd /opt/tsg/mrzcpd/corei7/bin/mrzcpd --altdir @CMAKE_INSTALL_PREFIX@/altdir - exit + if [ "$march" == "icelake-server" ]; then + update-alternatives --set mrzcpd /opt/tsg/mrzcpd/icelake-server/bin/mrzcpd --altdir @CMAKE_INSTALL_PREFIX@/altdir + exit + elif [ "$march" == "znver1" ]; then + update-alternatives --set mrzcpd /opt/tsg/mrzcpd/znver1/bin/mrzcpd --altdir @CMAKE_INSTALL_PREFIX@/altdir + exit + else + update-alternatives --set mrzcpd /opt/tsg/mrzcpd/corei7/bin/mrzcpd --altdir @CMAKE_INSTALL_PREFIX@/altdir + exit + fi fi |
