From 7885b5b9ee6b5039b476a0fafc07b9be6adab5dc Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 10 Dec 2019 16:38:34 +0100 Subject: [PATCH] add CMake flag to enable 5G-NR components --- CMakeLists.txt | 5 ++++ lib/src/common/CMakeLists.txt | 31 +++++++++++++++++++--- lib/src/upper/CMakeLists.txt | 10 ++++--- lib/src/upper/rlc.cc | 5 ++++ lib/test/common/CMakeLists.txt | 8 +++--- lib/test/upper/CMakeLists.txt | 44 ++++++++++++++++++------------- lib/test/upper/rlc_stress_test.cc | 2 +- 7 files changed, 75 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a1a6f8dc..549036d42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,7 @@ configure_file( option(ENABLE_SRSUE "Build srsUE application" ON) option(ENABLE_SRSENB "Build srsENB application" ON) option(ENABLE_SRSEPC "Build srsEPC application" ON) +option(ENABLE_5GNR "Build with 5G-NR components" OFF) option(DISABLE_SIMD "disable simd instructions" OFF) option(ENABLE_GUI "Enable GUI (using srsGUI)" ON) @@ -92,6 +93,10 @@ else(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") set(GCC_ARCH native CACHE STRING "GCC compile for specific architecture.") endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") +if (ENABLE_5GNR) + add_definitions(-DHAVE_5GNR) +endif (ENABLE_5GNR) + ######################################################################## # Find dependencies ######################################################################## diff --git a/lib/src/common/CMakeLists.txt b/lib/src/common/CMakeLists.txt index bf612999d..adf0485e9 100644 --- a/lib/src/common/CMakeLists.txt +++ b/lib/src/common/CMakeLists.txt @@ -18,13 +18,38 @@ # and at http://www.gnu.org/licenses/. # -file(GLOB CXX_SOURCES "*.cc") -file(GLOB C_SOURCES "*.c") + +set(SOURCES arch_select.cc + backtrace.c + buffer_pool.cc + crash_handler.c + gen_mch_tables.c + liblte_security.cc + log_filter.cc + logger_file.cc + mac_pcap.cc + nas_pcap.cc + network_utils.cc + pdu.cc + pdu_queue.cc + rlc_pcap.cc + s1ap_pcap.cc + security.cc + snow_3g.cc + thread_pool.cc + threads.c + tti_sync_cv.cc + version.c + zuc.cc) + +if (ENABLE_5GNR) + set(SOURCES ${SOURCES} mac_nr_pcap.cc mac_nr_pdu.cc) +endif(ENABLE_5GNR) # Avoid warnings caused by libmbedtls about deprecated functions set_source_files_properties(security.cc PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations) -add_library(srslte_common STATIC ${C_SOURCES} ${CXX_SOURCES}) +add_library(srslte_common STATIC ${SOURCES}) add_custom_target(gen_build_info COMMAND cmake -P ${CMAKE_BINARY_DIR}/SRSLTEbuildinfo.cmake) add_dependencies(srslte_common gen_build_info) diff --git a/lib/src/upper/CMakeLists.txt b/lib/src/upper/CMakeLists.txt index 56f4471f6..d88536948 100644 --- a/lib/src/upper/CMakeLists.txt +++ b/lib/src/upper/CMakeLists.txt @@ -22,15 +22,17 @@ set(SOURCES gtpu.cc pdcp.cc pdcp_entity_base.cc pdcp_entity_lte.cc - pdcp_entity_nr.cc rlc.cc rlc_tm.cc rlc_um_base.cc rlc_um_lte.cc - rlc_um_nr.cc rlc_am_base.cc - rlc_am_lte.cc - rlc_am_nr.cc) + rlc_am_lte.cc) + +if (ENABLE_5GNR) + set(SOURCES ${SOURCES} pdcp_entity_nr.cc rlc_um_nr.cc rlc_am_nr.cc) +endif(ENABLE_5GNR) + add_library(srslte_upper STATIC ${SOURCES}) target_link_libraries(srslte_upper srslte_common srslte_asn1) install(TARGETS srslte_upper DESTINATION ${LIBRARY_DIR}) \ No newline at end of file diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index db7536226..7c02247e4 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -410,6 +410,7 @@ void rlc::add_bearer(uint32_t lcid, rlc_config_t cnfg) rlc_log->error("Cannot add RLC entity - invalid mode\n"); goto unlock_and_exit; } +#ifdef HAVE_5GNR } else if (cnfg.rat == srslte_rat_t::nr) { switch (cnfg.rlc_mode) { case rlc_mode_t::tm: @@ -422,6 +423,10 @@ void rlc::add_bearer(uint32_t lcid, rlc_config_t cnfg) rlc_log->error("Cannot add RLC entity - invalid mode\n"); goto unlock_and_exit; } +#endif + } else { + rlc_log->error("RAT not supported\n"); + goto unlock_and_exit; } if (not rlc_array.insert(rlc_map_pair_t(lcid, rlc_entity)).second) { diff --git a/lib/test/common/CMakeLists.txt b/lib/test/common/CMakeLists.txt index 5f4b5873a..deb2668a5 100644 --- a/lib/test/common/CMakeLists.txt +++ b/lib/test/common/CMakeLists.txt @@ -67,9 +67,11 @@ add_executable(pdu_test pdu_test.cc) target_link_libraries(pdu_test srslte_phy srslte_common ${CMAKE_THREAD_LIBS_INIT}) add_test(pdu_test pdu_test) -add_executable(mac_nr_pdu_test mac_nr_pdu_test.cc) -target_link_libraries(mac_nr_pdu_test srslte_phy srslte_common ${CMAKE_THREAD_LIBS_INIT}) -add_test(mac_nr_pdu_test mac_nr_pdu_test) +if (ENABLE_5GNR) + add_executable(mac_nr_pdu_test mac_nr_pdu_test.cc) + target_link_libraries(mac_nr_pdu_test srslte_phy srslte_common ${CMAKE_THREAD_LIBS_INIT}) + add_test(mac_nr_pdu_test mac_nr_pdu_test) +endif(ENABLE_5GNR) add_executable(stack_procedure_test stack_procedure_test.cc) add_test(stack_procedure_test stack_procedure_test) diff --git a/lib/test/upper/CMakeLists.txt b/lib/test/upper/CMakeLists.txt index 58f000903..d1547dc06 100644 --- a/lib/test/upper/CMakeLists.txt +++ b/lib/test/upper/CMakeLists.txt @@ -30,16 +30,20 @@ add_executable(rlc_am_test rlc_am_test.cc) target_link_libraries(rlc_am_test srslte_upper srslte_phy srslte_common) add_test(rlc_am_test rlc_am_test) -add_executable(rlc_am_nr_pdu_test rlc_am_nr_pdu_test.cc) -target_link_libraries(rlc_am_nr_pdu_test srslte_upper srslte_phy) -add_test(rlc_am_nr_pdu_test rlc_am_nr_pdu_test) +if (ENABLE_5GNR) + add_executable(rlc_am_nr_pdu_test rlc_am_nr_pdu_test.cc) + target_link_libraries(rlc_am_nr_pdu_test srslte_upper srslte_phy) + add_test(rlc_am_nr_pdu_test rlc_am_nr_pdu_test) +endif(ENABLE_5GNR) add_executable(rlc_stress_test rlc_stress_test.cc) target_link_libraries(rlc_stress_test srslte_upper srslte_phy srslte_common ${Boost_LIBRARIES}) add_test(rlc_am_stress_test rlc_stress_test --mode=AM --loglevel 1 --sdu_gen_delay 250) add_test(rlc_um_stress_test rlc_stress_test --mode=UM --loglevel 1) add_test(rlc_tm_stress_test rlc_stress_test --mode=TM --loglevel 1 --random_opp=false) -add_test(rlc_um_nr_stress_test rlc_stress_test --rat NR --mode=UM --loglevel 1) +if (ENABLE_5GNR) + add_test(rlc_um_nr_stress_test rlc_stress_test --rat NR --mode=UM --loglevel 1) +endif(ENABLE_5GNR) set_tests_properties(rlc_am_stress_test PROPERTIES TIMEOUT 3000) set_tests_properties(rlc_um_stress_test PROPERTIES TIMEOUT 3000) set_tests_properties(rlc_tm_stress_test PROPERTIES TIMEOUT 3000) @@ -56,25 +60,27 @@ add_executable(rlc_common_test rlc_common_test.cc) target_link_libraries(rlc_common_test srslte_upper srslte_phy) add_test(rlc_common_test rlc_common_test) -add_executable(rlc_um_nr_pdu_test rlc_um_nr_pdu_test.cc) -target_link_libraries(rlc_um_nr_pdu_test srslte_upper srslte_phy) -add_test(rlc_um_nr_pdu_test rlc_um_nr_pdu_test) +if (ENABLE_5GNR) + add_executable(rlc_um_nr_pdu_test rlc_um_nr_pdu_test.cc) + target_link_libraries(rlc_um_nr_pdu_test srslte_upper srslte_phy) + add_test(rlc_um_nr_pdu_test rlc_um_nr_pdu_test) -add_executable(rlc_um_nr_test rlc_um_nr_test.cc) -target_link_libraries(rlc_um_nr_test srslte_upper srslte_phy) -add_test(rlc_um_nr_test rlc_um_nr_test) + add_executable(rlc_um_nr_test rlc_um_nr_test.cc) + target_link_libraries(rlc_um_nr_test srslte_upper srslte_phy) + add_test(rlc_um_nr_test rlc_um_nr_test) -add_executable(pdcp_nr_test_tx pdcp_nr_test_tx.cc) -target_link_libraries(pdcp_nr_test_tx srslte_upper srslte_common) -add_test(pdcp_nr_test_tx pdcp_nr_test_tx) + add_executable(pdcp_nr_test_tx pdcp_nr_test_tx.cc) + target_link_libraries(pdcp_nr_test_tx srslte_upper srslte_common) + add_test(pdcp_nr_test_tx pdcp_nr_test_tx) -add_executable(pdcp_nr_test_rx pdcp_nr_test_rx.cc) -target_link_libraries(pdcp_nr_test_rx srslte_upper srslte_common) -add_test(pdcp_nr_test_rx pdcp_nr_test_rx) + add_executable(pdcp_nr_test_rx pdcp_nr_test_rx.cc) + target_link_libraries(pdcp_nr_test_rx srslte_upper srslte_common) + add_test(pdcp_nr_test_rx pdcp_nr_test_rx) -add_executable(pdcp_nr_test_discard_sdu pdcp_nr_test_discard_sdu.cc) -target_link_libraries(pdcp_nr_test_discard_sdu srslte_upper srslte_common) -add_test(pdcp_nr_test_discard_sdu pdcp_nr_test_discard_sdu) + add_executable(pdcp_nr_test_discard_sdu pdcp_nr_test_discard_sdu.cc) + target_link_libraries(pdcp_nr_test_discard_sdu srslte_upper srslte_common) + add_test(pdcp_nr_test_discard_sdu pdcp_nr_test_discard_sdu) +endif(ENABLE_5GNR) ######################################################################## # Option to run command after build (useful for remote builds) diff --git a/lib/test/upper/rlc_stress_test.cc b/lib/test/upper/rlc_stress_test.cc index 70ace7f79..b29f1bb5f 100644 --- a/lib/test/upper/rlc_stress_test.cc +++ b/lib/test/upper/rlc_stress_test.cc @@ -35,7 +35,7 @@ #define LOG_HEX_LIMIT (-1) -#define PCAP 1 +#define PCAP 0 #define PCAP_CRNTI (0x1001) #define PCAP_TTI (666)