From 242fe9adc93ec93b6366499bcf7a359a0d53607f Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 22 Jun 2017 15:54:36 +0200 Subject: [PATCH 01/15] add apt-get line for Ubuntu to install required packages --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index f03ae6c2e..f7c699ed3 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,12 @@ Build Instructions * lksctp: http://lksctp.sourceforge.net/ * config: http://www.hyperrealm.com/libconfig/ +For example, on Ubuntu 17.04, one can install the required libraries with: +``` +sudo apt-get install libfftw3-dev libmbedtls-dev libboost-all-dev libconfig++-dev libsctp-dev +``` +Note that depending on your flavor and version of Linux, the actual package names may be different. + * Optional requirements: * srsgui: https://github.com/srslte/srsgui - for real-time plotting. * VOLK: https://github.com/gnuradio/volk - if the VOLK library and headers are detected, they will be used to accelerate some signal processing functions. From 12cbf026060b8d713e9a7a533d4aef16db9dc8f4 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 22 Jun 2017 18:52:12 +0200 Subject: [PATCH 02/15] changed name of vector_simd function --- lib/include/srslte/phy/utils/vector_simd.h | 18 ++---------------- lib/src/phy/utils/vector.c | 2 +- lib/src/phy/utils/vector_simd.c | 2 +- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/include/srslte/phy/utils/vector_simd.h b/lib/include/srslte/phy/utils/vector_simd.h index 7e4197e4b..1894a0803 100644 --- a/lib/include/srslte/phy/utils/vector_simd.h +++ b/lib/include/srslte/phy/utils/vector_simd.h @@ -39,22 +39,14 @@ SRSLTE_API int srslte_vec_dot_prod_sss_sse(short *x, short *y, uint32_t len); SRSLTE_API int srslte_vec_dot_prod_sss_avx2(short *x, short *y, uint32_t len); - - SRSLTE_API void srslte_vec_sum_sss_sse(short *x, short *y, short *z, uint32_t len); SRSLTE_API void srslte_vec_sum_sss_avx2(short *x, short *y, short *z, uint32_t len); - - SRSLTE_API void srslte_vec_sub_sss_sse(short *x, short *y, short *z, uint32_t len); SRSLTE_API void srslte_vec_sub_sss_avx2(short *x, short *y, short *z, uint32_t len); - - - - SRSLTE_API void srslte_vec_prod_sss_sse(short *x, short *y, short *z, uint32_t len); SRSLTE_API void srslte_vec_prod_sss_avx2(short *x, short *y, short *z, uint32_t len); @@ -64,17 +56,11 @@ SRSLTE_API void srslte_vec_sc_div2_sss_sse(short *x, int n_rightshift, short *z, SRSLTE_API void srslte_vec_sc_div2_sss_avx2(short *x, int k, short *z, uint32_t len); - - - - SRSLTE_API void srslte_vec_lut_sss_sse(short *x, unsigned short *lut, short *y, uint32_t len); -SRSLTE_API void srslte_vec_convert_fi_sse(float *x, int16_t *z, float scale, uint32_t len); - - +SRSLTE_API void srslte_vec_convert_fi_sse(float *x, int16_t *z, float scale, uint32_t len); -SRSLTE_API void srslte_vec_mult_scalar_cf_f_avx( cf_t *z,const cf_t *x,const float h,const uint32_t len); +SRSLTE_API void srslte_vec_sc_prod_cfc_avx(const cf_t *x,const float h,cf_t *y,const uint32_t len); #ifdef __cplusplus } #endif diff --git a/lib/src/phy/utils/vector.c b/lib/src/phy/utils/vector.c index 7ce954c78..30527510d 100644 --- a/lib/src/phy/utils/vector.c +++ b/lib/src/phy/utils/vector.c @@ -240,7 +240,7 @@ void srslte_vec_norm_cfc(cf_t *x, float amplitude, cf_t *y, uint32_t len) { void srslte_vec_sc_prod_cfc(cf_t *x, float h, cf_t *z, uint32_t len) { #ifdef LV_HAVE_AVX - srslte_vec_mult_scalar_cf_f_avx(z,x, h, len); + srslte_vec_sc_prod_cfc_avx(x,h,z,len); #else int i; for (i=0;i Date: Fri, 23 Jun 2017 14:49:21 +0100 Subject: [PATCH 03/15] Adding support for static builds --- CMakeLists.txt | 18 +++++++++++++++--- cmake/modules/FindMbedTLS.cmake | 18 ++++++++++++++++-- cmake/modules/FindPolarssl.cmake | 18 ++++++++++++++++-- lib/include/srslte/upper/pdcp.h | 7 +++---- lib/src/phy/CMakeLists.txt | 6 +++--- srsenb/CMakeLists.txt | 4 ++-- srsenb/src/CMakeLists.txt | 4 ++-- srsue/src/CMakeLists.txt | 5 +++++ 8 files changed, 62 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd2aaf433..17609e65f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ option(ENABLE_BLADERF "Enable BladeRF" ON) option(BUILD_STATIC "Attempt to statically link external deps" OFF) option(RPATH "Enable RPATH" OFF) -option(USE_LTE_RATES "Use standard LTE sampling rates" OFF) +option(USE_LTE_RATES "Use standard LTE sampling rates" OFF) set(GCC_ARCH native CACHE STRING "GCC compile for specific architecture.") @@ -79,13 +79,21 @@ find_package(Threads REQUIRED) find_package(Polarssl) if (POLARSSL_FOUND) set(SEC_INCLUDE_DIRS "${POLARSSL_INCLUDE_DIRS}") - set(SEC_LIBRARIES "${POLARSSL_LIBRARIES}") + if(BUILD_STATIC) + set(SEC_LIBRARIES "${POLARSSL_STATIC_LIBRARIES}") + else(BUILD_STATIC) + set(SEC_LIBRARIES "${POLARSSL_LIBRARIES}") + endif(BUILD_STATIC) add_definitions(-DHAVE_POLARSSL) else(POLARSSL_FOUND) find_package(MbedTLS REQUIRED) if (MBEDTLS_FOUND) set(SEC_INCLUDE_DIRS "${MBEDTLS_INCLUDE_DIRS}") - set(SEC_LIBRARIES "${MBEDTLS_LIBRARIES}") + if(BUILD_STATIC) + set(SEC_LIBRARIES "${MBEDTLS_STATIC_LIBRARIES}") + else(BUILD_STATIC) + set(SEC_LIBRARIES "${MBEDTLS_LIBRARIES}") + endif(BUILD_STATIC) add_definitions(-DHAVE_MBEDTLS) endif (MBEDTLS_FOUND) endif(POLARSSL_FOUND) @@ -119,6 +127,10 @@ endif(BLADERF_FOUND OR UHD_FOUND OR SOAPYSDR_FOUND) if(ENABLE_SRSUE OR ENABLE_SRSENB) # Find Boost + if(BUILD_STATIC) + set(Boost_USE_STATIC_LIBS ON) + endif(BUILD_STATIC) + set(BOOST_REQUIRED_COMPONENTS program_options system diff --git a/cmake/modules/FindMbedTLS.cmake b/cmake/modules/FindMbedTLS.cmake index 94d814874..11499bad4 100644 --- a/cmake/modules/FindMbedTLS.cmake +++ b/cmake/modules/FindMbedTLS.cmake @@ -32,9 +32,23 @@ FIND_LIBRARY( /usr/lib64 ) +FIND_LIBRARY( + MBEDTLS_STATIC_LIBRARIES + NAMES libmbedcrypto.a + HINTS $ENV{MBEDTLS_DIR}/lib + ${PC_MBEDTLS_LIBDIR} + ${CMAKE_INSTALL_PREFIX}/lib + ${CMAKE_INSTALL_PREFIX}/lib64 + PATHS /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 +) + message(STATUS "MBEDTLS LIBRARIES: " ${MBEDTLS_LIBRARIES}) +message(STATUS "MBEDTLS STATIC LIBRARIES: " ${MBEDTLS_STATIC_LIBRARIES}) message(STATUS "MBEDTLS INCLUDE DIRS: " ${MBEDTLS_INCLUDE_DIRS}) INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(MBEDTLS DEFAULT_MSG MBEDTLS_LIBRARIES MBEDTLS_INCLUDE_DIRS) -MARK_AS_ADVANCED(MBEDTLS_LIBRARIES MBEDTLS_INCLUDE_DIRS) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(MBEDTLS DEFAULT_MSG MBEDTLS_LIBRARIES MBEDTLS_STATIC_LIBRARIES MBEDTLS_INCLUDE_DIRS) +MARK_AS_ADVANCED(MBEDTLS_LIBRARIES MBEDTLS_STATIC_LIBRARIES MBEDTLS_INCLUDE_DIRS) diff --git a/cmake/modules/FindPolarssl.cmake b/cmake/modules/FindPolarssl.cmake index ccf0d6b91..6e6c5c2cb 100644 --- a/cmake/modules/FindPolarssl.cmake +++ b/cmake/modules/FindPolarssl.cmake @@ -31,9 +31,23 @@ FIND_LIBRARY( /usr/lib64 ) +FIND_LIBRARY( + POLARSSL_STATIC_LIBRARIES + NAMES libpolarssl.a + HINTS $ENV{POLARSSL_DIR}/lib + ${PC_POLARSSL_LIBDIR} + ${CMAKE_INSTALL_PREFIX}/lib + ${CMAKE_INSTALL_PREFIX}/lib64 + PATHS /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 +) + message(STATUS "POLARSSL LIBRARIES: " ${POLARSSL_LIBRARIES}) +message(STATUS "POLARSSL STATIC LIBRARIES: " ${POLARSSL_STATIC_LIBRARIES}) message(STATUS "POLARSSL INCLUDE DIRS: " ${POLARSSL_INCLUDE_DIRS}) INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(POLARSSL DEFAULT_MSG POLARSSL_LIBRARIES POLARSSL_INCLUDE_DIRS) -MARK_AS_ADVANCED(POLARSSL_LIBRARIES POLARSSL_INCLUDE_DIRS) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(POLARSSL DEFAULT_MSG POLARSSL_LIBRARIES POLARSSL_STATIC_LIBRARIES POLARSSL_INCLUDE_DIRS) +MARK_AS_ADVANCED(POLARSSL_STATIC_LIBRARIES POLARSSL_LIBRARIES POLARSSL_INCLUDE_DIRS) diff --git a/lib/include/srslte/upper/pdcp.h b/lib/include/srslte/upper/pdcp.h index 090f8f045..857806810 100644 --- a/lib/include/srslte/upper/pdcp.h +++ b/lib/include/srslte/upper/pdcp.h @@ -66,14 +66,13 @@ public: void write_pdu_pcch(byte_buffer_t *sdu); private: - log *pdcp_log; - pdcp_entity pdcp_array[SRSLTE_N_RADIO_BEARERS]; - srsue::rlc_interface_pdcp *rlc; srsue::rrc_interface_pdcp *rrc; srsue::gw_interface_pdcp *gw; - uint8_t direction; + log *pdcp_log; + pdcp_entity pdcp_array[SRSLTE_N_RADIO_BEARERS]; + uint8_t direction; bool valid_lcid(uint32_t lcid); }; diff --git a/lib/src/phy/CMakeLists.txt b/lib/src/phy/CMakeLists.txt index 074ddec55..26271f2a7 100644 --- a/lib/src/phy/CMakeLists.txt +++ b/lib/src/phy/CMakeLists.txt @@ -72,11 +72,11 @@ endif(MKL_FOUND) if(MKL_FOUND) - if(STATIC_MKL) + if(BUILD_STATIC) target_link_libraries(srslte_phy ${MKL_STATIC_LIBRARIES}) - else(STATIC_MKL) + else(BUILD_STATIC) target_link_libraries(srslte_phy ${MKL_LIBRARIES}) - endif(STATIC_MKL) + endif(BUILD_STATIC) else(MKL_FOUND) target_link_libraries(srslte_phy ${FFTW3F_LIBRARIES}) endif(MKL_FOUND) diff --git a/srsenb/CMakeLists.txt b/srsenb/CMakeLists.txt index 7fa60301a..c836f36d5 100644 --- a/srsenb/CMakeLists.txt +++ b/srsenb/CMakeLists.txt @@ -21,9 +21,9 @@ find_package(LibConfig REQUIRED) find_package(SCTP REQUIRED) -if(STATIC_LIBCONFIGPP) +if(BUILD_STATIC) set(LIBCONFIGPP_LIBRARIES "${LIBCONFIGPP_STATIC_LIBRARY_PATH}") -endif(STATIC_LIBCONFIGPP) +endif(BUILD_STATIC) if(NOT Boost_FOUND) message(FATAL_ERROR "Boost required to compile srsENB") diff --git a/srsenb/src/CMakeLists.txt b/srsenb/src/CMakeLists.txt index 199650fac..23272ea85 100644 --- a/srsenb/src/CMakeLists.txt +++ b/srsenb/src/CMakeLists.txt @@ -5,9 +5,9 @@ add_subdirectory(upper) # Link libstdc++ and libgcc -if(STATIC_LIB) +if(BUILD_STATIC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc") -endif(STATIC_LIB) +endif(BUILD_STATIC) if (RPATH) diff --git a/srsue/src/CMakeLists.txt b/srsue/src/CMakeLists.txt index 5a56bb057..1c6b87bc1 100644 --- a/srsue/src/CMakeLists.txt +++ b/srsue/src/CMakeLists.txt @@ -22,6 +22,11 @@ add_subdirectory(phy) add_subdirectory(mac) add_subdirectory(upper) +# Link libstdc++ and libgcc +if(BUILD_STATIC) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc") +endif(BUILD_STATIC) + if (RPATH) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) endif (RPATH) From 6037a2f2bdc5f28242744a00c392f9387f4498a0 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Fri, 23 Jun 2017 16:29:46 +0200 Subject: [PATCH 04/15] changed logger classes --- lib/examples/CMakeLists.txt | 2 +- lib/include/srslte/common/log_filter.h | 8 +- lib/include/srslte/common/log_stdout.h | 82 ------ lib/include/srslte/common/logger.h | 34 +-- lib/include/srslte/common/logger_file.h | 76 +++++ lib/include/srslte/common/logger_stdout.h | 51 ++++ lib/src/common/log_filter.cc | 5 + lib/src/common/log_stdout.cc | 290 ------------------- lib/src/common/{logger.cc => logger_file.cc} | 21 +- lib/test/common/log_filter_test.cc | 5 +- lib/test/common/logger_test.cc | 8 +- lib/test/upper/rlc_am_test.cc | 43 +-- lib/test/upper/rlc_um_test.cc | 10 +- srsenb/hdr/enb.h | 20 +- srsenb/test/mac/scheduler_test.cc | 4 +- srsenb/test/upper/ip_test.cc | 12 +- srsue/hdr/ue.h | 22 +- srsue/test/mac/mac_test.cc | 4 +- srsue/test/phy/ue_itf_test_prach.cc | 4 +- srsue/test/phy/ue_itf_test_sib1.cc | 4 +- srsue/test/upper/ip_test.cc | 14 +- srsue/test/upper/rrc_reconfig_test.cc | 6 +- srsue/test/upper/usim_test.cc | 4 +- 23 files changed, 235 insertions(+), 494 deletions(-) delete mode 100644 lib/include/srslte/common/log_stdout.h create mode 100644 lib/include/srslte/common/logger_file.h create mode 100644 lib/include/srslte/common/logger_stdout.h delete mode 100644 lib/src/common/log_stdout.cc rename lib/src/common/{logger.cc => logger_file.cc} (85%) diff --git a/lib/examples/CMakeLists.txt b/lib/examples/CMakeLists.txt index 652a2c195..9c6ee193e 100644 --- a/lib/examples/CMakeLists.txt +++ b/lib/examples/CMakeLists.txt @@ -65,7 +65,7 @@ if(RF_FOUND) add_executable(cell_search cell_search.c) target_link_libraries(cell_search srslte_phy srslte_rf) - add_executable(cell_measurement cell_measurement.c) + add_executable(cell_measurement cell_measurement.c ../include/srslte/common/logger_stdout.h) target_link_libraries(cell_measurement srslte_phy srslte_rf) add_executable(usrp_capture usrp_capture.c) diff --git a/lib/include/srslte/common/log_filter.h b/lib/include/srslte/common/log_filter.h index c1ed1998a..ae232f135 100644 --- a/lib/include/srslte/common/log_filter.h +++ b/lib/include/srslte/common/log_filter.h @@ -38,15 +38,19 @@ #include #include #include "srslte/common/log.h" -#include "logger.h" +#include "srslte/common/logger.h" +#include "srslte/common/logger_stdout.h" namespace srslte { +typedef std::string* str_ptr; + class log_filter : public srslte::log { public: log_filter(); + log_filter(std::string layer); log_filter(std::string layer, logger *logger_, bool tti=false); void init(std::string layer, logger *logger_, bool tti=false); @@ -71,6 +75,8 @@ private: logger *logger_h; bool do_tti; + logger_stdout def_logger_stdout; + void all_log(srslte::LOG_LEVEL_ENUM level, uint32_t tti, char *msg); void all_log(srslte::LOG_LEVEL_ENUM level, uint32_t tti, char *msg, uint8_t *hex, int size); void all_log_line(srslte::LOG_LEVEL_ENUM level, uint32_t tti, std::string file, int line, char *msg); diff --git a/lib/include/srslte/common/log_stdout.h b/lib/include/srslte/common/log_stdout.h deleted file mode 100644 index df1b5b5fb..000000000 --- a/lib/include/srslte/common/log_stdout.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2015 Software Radio Systems Limited - * - * \section LICENSE - * - * This file is part of the srsUE library. - * - * srsUE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsUE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * A copy of the GNU Affero General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - -/****************************************************************************** - * File: log_stout.h - * - * Description: Logging service through standard output. Inherits log interface - * - * Reference: - *****************************************************************************/ - -#ifndef LOGSTDOUT_H -#define LOGSTDOUT_H - -#include -#include -#include "srslte/common/log.h" - -namespace srslte { - -class log_stdout : public log -{ -public: - - log_stdout(std::string service_name_) : log(service_name_) { } - - void console(std::string message, ...); - void error(std::string message, ...); - void warning(std::string message, ...); - void info(std::string message, ...); - void debug(std::string message, ...); - - // Same with hex dump - void error_hex(uint8_t *hex, int size, std::string message, ...); - void warning_hex(uint8_t *hex, int size, std::string message, ...); - void info_hex(uint8_t *hex, int size, std::string message, ...); - void debug_hex(uint8_t *hex, int size, std::string message, ...); - - // Same with line and file info - void error_line(std::string file, int line, std::string message, ...); - void warning_line(std::string file, int line, std::string message, ...); - void info_line(std::string file, int line, std::string message, ...); - void debug_line(std::string file, int line, std::string message, ...); - -private: - void printlog(srslte::LOG_LEVEL_ENUM level, uint32_t tti, std::string file, int line, std::string message, va_list args); - void printlog(srslte::LOG_LEVEL_ENUM level, uint32_t tti, std::string message, va_list args); - - void all_log(srslte::LOG_LEVEL_ENUM level, uint32_t tti, char *msg); - void all_log(srslte::LOG_LEVEL_ENUM level, uint32_t tti, char *msg, uint8_t *hex, int size); - void all_log_line(srslte::LOG_LEVEL_ENUM level, uint32_t tti, std::string file, int line, char *msg); - std::string now_time(); - std::string hex_string(uint8_t *hex, int size); -}; - -} - -#endif - diff --git a/lib/include/srslte/common/logger.h b/lib/include/srslte/common/logger.h index 67a897824..95e52922c 100644 --- a/lib/include/srslte/common/logger.h +++ b/lib/include/srslte/common/logger.h @@ -26,49 +26,23 @@ /****************************************************************************** * File: logger.h - * Description: Common log object. Maintains a queue of log messages - * and runs a thread to read messages and write to file. - * Multiple producers, single consumer. If full, producers - * increase queue size. If empty, consumer blocks. + * Description: Interface for logging output *****************************************************************************/ #ifndef LOGGER_H #define LOGGER_H #include -#include #include -#include "srslte/common/threads.h" namespace srslte { -typedef std::string* str_ptr; - -class logger : public thread +class logger { public: - logger(); - logger(std::string file); - ~logger(); - void init(std::string file); - void log(const char *msg); - void log(str_ptr msg); - -private: - void run_thread(); - void flush(); - - FILE* logfile; - bool inited; - bool not_done; - std::string filename; - pthread_cond_t not_empty; - pthread_cond_t not_full; - pthread_mutex_t mutex; - pthread_t thread; - std::deque buffer; + virtual void log(std::string *msg) = 0; }; -} // namespace srsue +} // namespace srslte #endif // LOGGER_H diff --git a/lib/include/srslte/common/logger_file.h b/lib/include/srslte/common/logger_file.h new file mode 100644 index 000000000..1bc41f883 --- /dev/null +++ b/lib/include/srslte/common/logger_file.h @@ -0,0 +1,76 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2015 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of the srsUE library. + * + * srsUE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsUE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +/****************************************************************************** + * File: logger_file.h + * Description: Common log object. Maintains a queue of log messages + * and runs a thread to read messages and write to file. + * Multiple producers, single consumer. If full, producers + * increase queue size. If empty, consumer blocks. + *****************************************************************************/ + +#ifndef LOGGER_FILE_H +#define LOGGER_FILE_H + +#include +#include +#include +#include "srslte/common/logger.h" +#include "srslte/common/threads.h" + +namespace srslte { + +typedef std::string* str_ptr; + +class logger_file : public thread, public logger +{ +public: + logger_file(); + logger_file(std::string file); + ~logger_file(); + void init(std::string file); + // Implementation of log_out + void log(str_ptr msg); + void log(const char *msg); + +private: + void run_thread(); + void flush(); + + FILE* logfile; + bool inited; + bool not_done; + std::string filename; + pthread_cond_t not_empty; + pthread_cond_t not_full; + pthread_mutex_t mutex; + pthread_t thread; + std::deque buffer; +}; + +} // namespace srsue + +#endif // LOGGER_H diff --git a/lib/include/srslte/common/logger_stdout.h b/lib/include/srslte/common/logger_stdout.h new file mode 100644 index 000000000..00e4ffa7a --- /dev/null +++ b/lib/include/srslte/common/logger_stdout.h @@ -0,0 +1,51 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2015 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of the srsUE library. + * + * srsUE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsUE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +/****************************************************************************** + * File: logger_stdout.h + * Description: Interface for logging output + *****************************************************************************/ + +#ifndef LOGGER_STDOUT_H +#define LOGGER_STDOUT_H + +#include +#include +#include "srslte/common/logger.h" + +namespace srslte { + + class logger_stdout : public logger + { + public: + void log(std::string *msg) { + fprintf(stdout, "%s", msg->c_str()); + } + }; + +} // namespace srslte + +#endif // LOGGER_H diff --git a/lib/src/common/log_filter.cc b/lib/src/common/log_filter.cc index 12f004d5e..899a224d6 100644 --- a/lib/src/common/log_filter.cc +++ b/lib/src/common/log_filter.cc @@ -40,6 +40,11 @@ log_filter::log_filter() do_tti = false; } +log_filter::log_filter(std::string layer) +{ + init(layer, &def_logger_stdout, tti); +} + log_filter::log_filter(std::string layer, logger *logger_, bool tti) { init(layer, logger_, tti); diff --git a/lib/src/common/log_stdout.cc b/lib/src/common/log_stdout.cc deleted file mode 100644 index 2e50b755e..000000000 --- a/lib/src/common/log_stdout.cc +++ /dev/null @@ -1,290 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2015 Software Radio Systems Limited - * - * \section LICENSE - * - * This file is part of the srsUE library. - * - * srsUE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsUE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * A copy of the GNU Affero General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "srslte/common/log_stdout.h" - - -using namespace std; - -namespace srslte { - -void log_stdout::all_log(srslte::LOG_LEVEL_ENUM level, - uint32_t tti, - char *msg) -{ - std::stringstream ss; - - ss << now_time() << " "; - ss << "[" < 0) - printf("%s",args_msg); // Print directly to stdout - va_end(args); - free(args_msg); -} - -void log_stdout::error(std::string message, ...) { - if (level >= LOG_LEVEL_ERROR) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log(LOG_LEVEL_ERROR, tti, args_msg); - va_end(args); - free(args_msg); - } -} -void log_stdout::warning(std::string message, ...) { - if (level >= LOG_LEVEL_WARNING) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log(LOG_LEVEL_WARNING, tti, args_msg); - va_end(args); - free(args_msg); - } -} -void log_stdout::info(std::string message, ...) { - if (level >= LOG_LEVEL_INFO) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log(LOG_LEVEL_INFO, tti, args_msg); - va_end(args); - free(args_msg); - } -} -void log_stdout::debug(std::string message, ...) { - if (level >= LOG_LEVEL_DEBUG) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log(LOG_LEVEL_DEBUG, tti, args_msg); - va_end(args); - free(args_msg); - } -} - -void log_stdout::error_hex(uint8_t *hex, int size, std::string message, ...) { - if (level >= LOG_LEVEL_ERROR) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log(LOG_LEVEL_ERROR, tti, args_msg, hex, size); - va_end(args); - free(args_msg); - } -} -void log_stdout::warning_hex(uint8_t *hex, int size, std::string message, ...) { - if (level >= LOG_LEVEL_WARNING) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log(LOG_LEVEL_WARNING, tti, args_msg, hex, size); - va_end(args); - free(args_msg); - } -} -void log_stdout::info_hex(uint8_t *hex, int size, std::string message, ...) { - if (level >= LOG_LEVEL_INFO) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log(LOG_LEVEL_INFO, tti, args_msg, hex, size); - va_end(args); - free(args_msg); - } -} -void log_stdout::debug_hex(uint8_t *hex, int size, std::string message, ...) { - if (level >= LOG_LEVEL_DEBUG) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log(LOG_LEVEL_DEBUG, tti, args_msg, hex, size); - va_end(args); - free(args_msg); - } -} - -void log_stdout::error_line(std::string file, int line, std::string message, ...) -{ - if (level >= LOG_LEVEL_ERROR) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log_line(LOG_LEVEL_ERROR, tti, file, line, args_msg); - va_end(args); - free(args_msg); - } -} - -void log_stdout::warning_line(std::string file, int line, std::string message, ...) -{ - if (level >= LOG_LEVEL_WARNING) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log_line(LOG_LEVEL_WARNING, tti, file, line, args_msg); - va_end(args); - free(args_msg); - } -} - -void log_stdout::info_line(std::string file, int line, std::string message, ...) -{ - if (level >= LOG_LEVEL_INFO) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log_line(LOG_LEVEL_INFO, tti, file, line, args_msg); - va_end(args); - free(args_msg); - } -} - -void log_stdout::debug_line(std::string file, int line, std::string message, ...) -{ - if (level >= LOG_LEVEL_DEBUG) { - char *args_msg; - va_list args; - va_start(args, message); - if(vasprintf(&args_msg, message.c_str(), args) > 0) - all_log_line(LOG_LEVEL_DEBUG, tti, file, line, args_msg); - va_end(args); - free(args_msg); - } -} - - - -std::string log_stdout::now_time() -{ - struct timeval rawtime; - struct tm * timeinfo; - char buffer[64]; - char us[16]; - - gettimeofday(&rawtime, NULL); - timeinfo = localtime(&rawtime.tv_sec); - - strftime(buffer,64,"%H:%M:%S",timeinfo); - strcat(buffer,"."); - snprintf(us,16,"%ld",rawtime.tv_usec); - strcat(buffer,us); - - return std::string(buffer); -} - -std::string log_stdout::hex_string(uint8_t *hex, int size) -{ - std::stringstream ss; - int c = 0; - - ss << std::hex << std::setfill('0'); - if(hex_limit >= 0) { - size = (size > hex_limit) ? hex_limit : size; - } - while(c < size) { - ss << " " << std::setw(4) << static_cast(c) << ": "; - int tmp = (size-c < 16) ? size-c : 16; - for(int i=0;i(hex[c++]) << " "; - } - ss << "\n"; - } - return ss.str(); -} - -} - - diff --git a/lib/src/common/logger.cc b/lib/src/common/logger_file.cc similarity index 85% rename from lib/src/common/logger.cc rename to lib/src/common/logger_file.cc index b48f6e1c7..94e5e8405 100644 --- a/lib/src/common/logger.cc +++ b/lib/src/common/logger_file.cc @@ -27,20 +27,20 @@ #define LOG_BUFFER_SIZE 1024*32 -#include "srslte/common/logger.h" +#include "srslte/common/logger_file.h" using namespace std; namespace srslte{ -logger::logger() +logger_file::logger_file() :inited(false) ,not_done(true) {} -logger::~logger() { +logger_file::~logger_file() { not_done = false; - log("Closing log"); + log(new std::string("Closing log")); if(inited) { wait_thread_finish(); flush(); @@ -48,7 +48,7 @@ logger::~logger() { } } -void logger::init(std::string file) { +void logger_file::init(std::string file) { pthread_mutex_init(&mutex, NULL); pthread_cond_init(¬_empty, NULL); pthread_cond_init(¬_full, NULL); @@ -61,19 +61,18 @@ void logger::init(std::string file) { inited = true; } -void logger::log(const char *msg) { - str_ptr s_ptr(new std::string(msg)); - log(s_ptr); +void logger_file::log(const char *msg) { + log(new std::string(msg)); } -void logger::log(str_ptr msg) { +void logger_file::log(str_ptr msg) { pthread_mutex_lock(&mutex); buffer.push_back(msg); pthread_cond_signal(¬_empty); pthread_mutex_unlock(&mutex); } -void logger::run_thread() { +void logger_file::run_thread() { while(not_done) { pthread_mutex_lock(&mutex); while(buffer.empty()) { @@ -89,7 +88,7 @@ void logger::run_thread() { } } -void logger::flush() { +void logger_file::flush() { std::deque::iterator it; for(it=buffer.begin();it!=buffer.end();it++) { diff --git a/lib/test/common/log_filter_test.cc b/lib/test/common/log_filter_test.cc index d48821dac..350e42837 100644 --- a/lib/test/common/log_filter_test.cc +++ b/lib/test/common/log_filter_test.cc @@ -29,11 +29,12 @@ #include #include "srslte/common/log_filter.h" +#include "srslte/common/logger_file.h" using namespace srslte; typedef struct { - logger *l; + logger_file *l; int thread_id; }args_t; @@ -78,7 +79,7 @@ void* thread_loop_hex(void *a) { } void write(std::string filename) { - logger l; + logger_file l; l.init(filename); pthread_t threads[NTHREADS]; args_t args[NTHREADS]; diff --git a/lib/test/common/logger_test.cc b/lib/test/common/logger_test.cc index 1baf5260f..845d4c104 100644 --- a/lib/test/common/logger_test.cc +++ b/lib/test/common/logger_test.cc @@ -29,12 +29,12 @@ #include #include -#include "srslte/common/logger.h" +#include "srslte/common/logger_file.h" using namespace srslte; typedef struct { - logger *l; + logger_file *l; int thread_id; }args_t; @@ -44,13 +44,13 @@ void* thread_loop(void *a) { for(int i=0;ithread_id, i); - args->l->log(buf); + args->l->log(new std::string(buf)); } return NULL; } void write(std::string filename) { - logger l; + logger_file l; l.init(filename); pthread_t threads[NTHREADS]; args_t args[NTHREADS]; diff --git a/lib/test/upper/rlc_am_test.cc b/lib/test/upper/rlc_am_test.cc index bacc819ec..dfe62905e 100644 --- a/lib/test/upper/rlc_am_test.cc +++ b/lib/test/upper/rlc_am_test.cc @@ -25,7 +25,8 @@ */ #include -#include "srslte/common/log_stdout.h" +#include "srslte/common/log_filter.h" +#include "srslte/common/logger_stdout.h" #include "srslte/upper/rlc_am.h" #include #define NBUFS 5 @@ -73,8 +74,8 @@ public: void basic_test() { - srslte::log_stdout log1("RLC_AM_1"); - srslte::log_stdout log2("RLC_AM_2"); + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -152,8 +153,8 @@ void basic_test() void concat_test() { - srslte::log_stdout log1("RLC_AM_1"); - srslte::log_stdout log2("RLC_AM_2"); + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -216,8 +217,8 @@ void concat_test() void segment_test() { - srslte::log_stdout log1("RLC_AM_1"); - srslte::log_stdout log2("RLC_AM_2"); + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -298,8 +299,8 @@ void segment_test() void retx_test() { - srslte::log_stdout log1("RLC_AM_1"); - srslte::log_stdout log2("RLC_AM_2"); + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -394,8 +395,8 @@ void resegment_test_1() // PDUs: | 10 | 10 | 10 | 10 | 10 | // Retx PDU segments: | 5 | 5| - srslte::log_stdout log1("RLC_AM_1"); - srslte::log_stdout log2("RLC_AM_2"); + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -503,8 +504,8 @@ void resegment_test_2() // PDUs: | 5 | 10 | 20 | 10 | 5 | // Retx PDU segments: | 10 | 10 | - srslte::log_stdout log1("RLC_AM_1"); - srslte::log_stdout log2("RLC_AM_2"); + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -609,8 +610,8 @@ void resegment_test_3() // PDUs: | 5 | 5| 20 | 10 | 10 | // Retx PDU segments: | 10 | 10 | - srslte::log_stdout log1("RLC_AM_1"); - srslte::log_stdout log2("RLC_AM_2"); + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -711,8 +712,8 @@ void resegment_test_4() // PDUs: | 5 | 5| 30 | 5 | 5| // Retx PDU segments: | 15 | 15 | - srslte::log_stdout log1("RLC_AM_1"); - srslte::log_stdout log2("RLC_AM_2"); + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -813,8 +814,8 @@ void resegment_test_5() // PDUs: |2|3| 40 |3|2| // Retx PDU segments: | 20 | 20 | - srslte::log_stdout log1("RLC_AM_1"); - srslte::log_stdout log2("RLC_AM_2"); + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -914,8 +915,8 @@ void resegment_test_6() // PDUs: |10|10|10| 270 | 54 | // Retx PDU segments: | 120 | 150 | - srslte::log_stdout log1("RLC_AM_1"); - srslte::log_stdout log2("RLC_AM_2"); + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); diff --git a/lib/test/upper/rlc_um_test.cc b/lib/test/upper/rlc_um_test.cc index dfc2883d8..491d816cc 100644 --- a/lib/test/upper/rlc_um_test.cc +++ b/lib/test/upper/rlc_um_test.cc @@ -25,7 +25,7 @@ */ #include -#include "srslte/common/log_stdout.h" +#include "srslte/common/log_filter.h" #include "srslte/upper/rlc_um.h" #include @@ -78,8 +78,8 @@ public: void basic_test() { - srslte::log_stdout log1("RLC_UM_1"); - srslte::log_stdout log2("RLC_UM_2"); + srslte::log_filter log1("RLC_UM_1"); + srslte::log_filter log2("RLC_UM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -146,8 +146,8 @@ void basic_test() void loss_test() { - srslte::log_stdout log1("RLC_UM_1"); - srslte::log_stdout log2("RLC_UM_2"); + srslte::log_filter log1("RLC_UM_1"); + srslte::log_filter log2("RLC_UM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index 8db5c85b6..b28d12ab4 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -50,7 +50,7 @@ #include "srslte/common/bcd_helpers.h" #include "srslte/common/buffer_pool.h" #include "srslte/interfaces/ue_interfaces.h" -#include "srslte/common/logger.h" +#include "srslte/common/logger_file.h" #include "srslte/common/log_filter.h" #include "srslte/common/mac_pcap.h" #include "srslte/interfaces/sched_interface.h" @@ -173,15 +173,15 @@ private: srsenb::gtpu gtpu; srsenb::s1ap s1ap; - srslte::logger logger; - srslte::log_filter rf_log; - std::vector phy_log; - srslte::log_filter mac_log; - srslte::log_filter rlc_log; - srslte::log_filter pdcp_log; - srslte::log_filter rrc_log; - srslte::log_filter gtpu_log; - srslte::log_filter s1ap_log; + srslte::logger_file logger; + srslte::log_filter rf_log; + std::vector phy_log; + srslte::log_filter mac_log; + srslte::log_filter rlc_log; + srslte::log_filter pdcp_log; + srslte::log_filter rrc_log; + srslte::log_filter gtpu_log; + srslte::log_filter s1ap_log; srslte::byte_buffer_pool *pool; diff --git a/srsenb/test/mac/scheduler_test.cc b/srsenb/test/mac/scheduler_test.cc index 53bb28e18..e9afd61cb 100644 --- a/srsenb/test/mac/scheduler_test.cc +++ b/srsenb/test/mac/scheduler_test.cc @@ -6,7 +6,7 @@ #include "srslte/interfaces/enb_interfaces.h" #include "srslte/interfaces/sched_interface.h" -#include "srslte/common/log_stdout.h" +#include "srslte/common/log_filter.h" #include "srslte/radio/radio.h" #include "srslte/phy/utils/debug.h" @@ -62,7 +62,7 @@ private: // Create classes -srslte::log_stdout log_out("ALL"); +srslte::log_filter log_out("ALL"); srsenb::sched my_sched; srsenb::dl_metric_rr dl_metric; srsenb::ul_metric_rr ul_metric; diff --git a/srsenb/test/upper/ip_test.cc b/srsenb/test/upper/ip_test.cc index f2ec84f64..41c430f29 100644 --- a/srsenb/test/upper/ip_test.cc +++ b/srsenb/test/upper/ip_test.cc @@ -16,7 +16,7 @@ #include "srslte/interfaces/enb_interfaces.h" #include "srslte/common/common.h" #include "srslte/common/buffer_pool.h" -#include "srslte/common/logger.h" +#include "srslte/common/logger_file.h" #include "srslte/common/log_filter.h" #include "srslte/upper/rlc.h" #include "srslte/radio/radio.h" @@ -320,11 +320,11 @@ private: // Create classes -srslte::logger logger; -srslte::log_filter log_phy; -srslte::log_filter log_mac; -srslte::log_filter log_rlc; -srslte::log_filter log_tester; +srslte::logger_file logger; +srslte::log_filter log_phy; +srslte::log_filter log_mac; +srslte::log_filter log_rlc; +srslte::log_filter log_tester; srsenb::phy my_phy; srsenb::mac my_mac; srslte::rlc my_rlc; diff --git a/srsue/hdr/ue.h b/srsue/hdr/ue.h index f401697e9..6fb593d55 100644 --- a/srsue/hdr/ue.h +++ b/srsue/hdr/ue.h @@ -49,7 +49,7 @@ #include "srslte/common/buffer_pool.h" #include "srslte/interfaces/ue_interfaces.h" -#include "srslte/common/logger.h" +#include "srslte/common/logger_file.h" #include "srslte/common/log_filter.h" #include "ue_metrics_interface.h" @@ -173,16 +173,16 @@ private: srslte::gw gw; srsue::usim usim; - srslte::logger logger; - srslte::log_filter rf_log; - srslte::log_filter phy_log; - srslte::log_filter mac_log; - srslte::log_filter rlc_log; - srslte::log_filter pdcp_log; - srslte::log_filter rrc_log; - srslte::log_filter nas_log; - srslte::log_filter gw_log; - srslte::log_filter usim_log; + srslte::logger_file logger; + srslte::log_filter rf_log; + srslte::log_filter phy_log; + srslte::log_filter mac_log; + srslte::log_filter rlc_log; + srslte::log_filter pdcp_log; + srslte::log_filter rrc_log; + srslte::log_filter nas_log; + srslte::log_filter gw_log; + srslte::log_filter usim_log; srslte::byte_buffer_pool *pool; diff --git a/srsue/test/mac/mac_test.cc b/srsue/test/mac/mac_test.cc index 7c7e19cf0..cb2ad2945 100644 --- a/srsue/test/mac/mac_test.cc +++ b/srsue/test/mac/mac_test.cc @@ -32,7 +32,7 @@ #include "srslte/radio/radio_multi.h" #include "phy/phy.h" #include "srslte/interfaces/ue_interfaces.h" -#include "srslte/common/log_stdout.h" +#include "srslte/common/log_filter.h" #include "mac/mac.h" #include "srslte/common/mac_pcap.h" @@ -427,7 +427,7 @@ private: int main(int argc, char *argv[]) { - srslte::log_stdout mac_log("MAC"), phy_log("PHY"); + srslte::log_filter mac_log("MAC"), phy_log("PHY"); rlctest my_rlc; parse_args(&prog_args, argc, argv); diff --git a/srsue/test/phy/ue_itf_test_prach.cc b/srsue/test/phy/ue_itf_test_prach.cc index 91df6a2fc..76adcacdf 100644 --- a/srsue/test/phy/ue_itf_test_prach.cc +++ b/srsue/test/phy/ue_itf_test_prach.cc @@ -29,7 +29,7 @@ #include "srslte/phy/utils/debug.h" #include "phy/phy.h" #include "srslte/interfaces/ue_interfaces.h" -#include "srslte/common/log_stdout.h" +#include "srslte/common/log_filter.h" #include "srslte/radio/radio_multi.h" /********************************************************************** @@ -330,7 +330,7 @@ srslte::radio_multi radio; int main(int argc, char *argv[]) { - srslte::log_stdout log("PHY"); + srslte::log_filter log("PHY"); parse_args(&prog_args, argc, argv); diff --git a/srsue/test/phy/ue_itf_test_sib1.cc b/srsue/test/phy/ue_itf_test_sib1.cc index 08116b22c..10e78b23a 100644 --- a/srsue/test/phy/ue_itf_test_sib1.cc +++ b/srsue/test/phy/ue_itf_test_sib1.cc @@ -28,7 +28,7 @@ #include "srslte/phy/utils/debug.h" #include "phy/phy.h" -#include "srslte/common/log_stdout.h" +#include "srslte/common/log_filter.h" #include "srslte/interfaces/ue_interfaces.h" #include "srslte/radio/radio_multi.h" @@ -153,7 +153,7 @@ srslte::radio_multi radio; int main(int argc, char *argv[]) { - srslte::log_stdout log("PHY"); + srslte::log_filter log("PHY"); parse_args(&prog_args, argc, argv); diff --git a/srsue/test/upper/ip_test.cc b/srsue/test/upper/ip_test.cc index a26f273a8..93021cd2b 100644 --- a/srsue/test/upper/ip_test.cc +++ b/srsue/test/upper/ip_test.cc @@ -21,7 +21,7 @@ #include "srslte/common/threads.h" #include "srslte/common/common.h" #include "srslte/common/buffer_pool.h" -#include "srslte/common/logger.h" +#include "srslte/common/logger_file.h" #include "srslte/common/log_filter.h" #include "srslte/upper/rlc.h" #include "upper/rrc.h" @@ -464,12 +464,12 @@ private: // Create classes -srslte::logger logger; -srslte::log_filter log_phy; -srslte::log_filter log_mac; -srslte::log_filter log_rlc; -srslte::log_filter log_tester; -srslte::mac_pcap mac_pcap; +srslte::logger_file logger; +srslte::log_filter log_phy; +srslte::log_filter log_mac; +srslte::log_filter log_rlc; +srslte::log_filter log_tester; +srslte::mac_pcap mac_pcap; srsue::phy my_phy; srsue::mac my_mac; srslte::rlc rlc; diff --git a/srsue/test/upper/rrc_reconfig_test.cc b/srsue/test/upper/rrc_reconfig_test.cc index 25629bcd7..c9df04e32 100644 --- a/srsue/test/upper/rrc_reconfig_test.cc +++ b/srsue/test/upper/rrc_reconfig_test.cc @@ -26,12 +26,12 @@ #include #include -#include "srslte/common/log_stdout.h" +#include "srslte/common/log_filter.h" #include "srslte/asn1/liblte_rrc.h" #include "srslte/asn1/liblte_mme.h" void nas_test() { - srslte::log_stdout log1("NAS"); + srslte::log_filter log1("NAS"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); @@ -91,7 +91,7 @@ void nas_test() { } void basic_test() { - srslte::log_stdout log1("RRC"); + srslte::log_filter log1("RRC"); log1.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); diff --git a/srsue/test/upper/usim_test.cc b/srsue/test/upper/usim_test.cc index 8e7d53bfe..c8a248184 100644 --- a/srsue/test/upper/usim_test.cc +++ b/srsue/test/upper/usim_test.cc @@ -26,7 +26,7 @@ #include #include "upper/usim.h" -#include "srslte/common/log_stdout.h" +#include "srslte/common/log_filter.h" #include using namespace srsue; @@ -67,7 +67,7 @@ uint16 mnc = 93; int main(int argc, char **argv) { - srslte::log_stdout usim_log("USIM"); + srslte::log_filter usim_log("USIM"); bool net_valid; uint8_t res[16]; From 776c1bbc9da8240adbeb4e98d6857ccad021e984 Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Fri, 23 Jun 2017 15:51:36 +0100 Subject: [PATCH 05/15] Moving fftw checks to top CMakeLists --- CMakeLists.txt | 12 ++++++++++++ lib/src/phy/CMakeLists.txt | 13 ------------- srsenb/src/CMakeLists.txt | 4 +++- srsue/src/CMakeLists.txt | 2 ++ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 17609e65f..62a56371b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,18 @@ set(GCC_ARCH native CACHE STRING "GCC compile for specific architecture.") ######################################################################## find_package(Threads REQUIRED) +find_package(MKL) +if(MKL_FOUND) + include_directories(${MKL_INCLUDE_DIRS}) + link_directories(${MKL_LIBRARY_DIRS}) +else(MKL_FOUND) + find_package(FFTW3F REQUIRED) + if(FFTW3F_FOUND) + include_directories(${FFTW3F_INCLUDE_DIRS}) + link_directories(${FFTW3F_LIBRARY_DIRS}) + endif(FFTW3F_FOUND) +endif(MKL_FOUND) + find_package(Polarssl) if (POLARSSL_FOUND) set(SEC_INCLUDE_DIRS "${POLARSSL_INCLUDE_DIRS}") diff --git a/lib/src/phy/CMakeLists.txt b/lib/src/phy/CMakeLists.txt index 26271f2a7..7f26f9836 100644 --- a/lib/src/phy/CMakeLists.txt +++ b/lib/src/phy/CMakeLists.txt @@ -58,19 +58,6 @@ add_library(srslte_phy STATIC ${srslte_srcs}) set_target_properties(srslte_phy PROPERTIES VERSION ${SRSLTE_VERSION_MAJOR}.${SRSLTE_VERSION_MINOR}) -find_package(MKL) -if(MKL_FOUND) - include_directories(${MKL_INCLUDE_DIRS}) - link_directories(${MKL_LIBRARY_DIRS}) -else(MKL_FOUND) - find_package(FFTW3F REQUIRED) - if(FFTW3F_FOUND) - include_directories(${FFTW3F_INCLUDE_DIRS}) - link_directories(${FFTW3F_LIBRARY_DIRS}) - endif(FFTW3F_FOUND) -endif(MKL_FOUND) - - if(MKL_FOUND) if(BUILD_STATIC) target_link_libraries(srslte_phy ${MKL_STATIC_LIBRARIES}) diff --git a/srsenb/src/CMakeLists.txt b/srsenb/src/CMakeLists.txt index 23272ea85..a83e974a8 100644 --- a/srsenb/src/CMakeLists.txt +++ b/srsenb/src/CMakeLists.txt @@ -31,7 +31,9 @@ target_link_libraries(srsenb srsenb_upper if (RPATH) set_target_properties(srsenb PROPERTIES INSTALL_RPATH ".") -endif (RPATH) +endif (RPATH) + +install(TARGETS srsenb DESTINATION ${RUNTIME_DIR}) ######################################################################## # Option to run command after build (useful for remote builds) diff --git a/srsue/src/CMakeLists.txt b/srsue/src/CMakeLists.txt index 1c6b87bc1..4b2a7e282 100644 --- a/srsue/src/CMakeLists.txt +++ b/srsue/src/CMakeLists.txt @@ -46,6 +46,8 @@ if (RPATH) set_target_properties(srsue PROPERTIES INSTALL_RPATH ".") endif (RPATH) +install(TARGETS srsue DESTINATION ${RUNTIME_DIR}) + ######################################################################## # Option to run command after build (useful for remote builds) ######################################################################## From fd08dd56bab4b61b6545ad7e86dfdf40a75bb794 Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Fri, 23 Jun 2017 16:47:54 +0100 Subject: [PATCH 06/15] Fix for security library find scripts --- CMakeLists.txt | 2 ++ cmake/modules/FindMbedTLS.cmake | 2 +- cmake/modules/FindPolarssl.cmake | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62a56371b..e40737900 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,8 @@ else(POLARSSL_FOUND) set(SEC_LIBRARIES "${MBEDTLS_LIBRARIES}") endif(BUILD_STATIC) add_definitions(-DHAVE_MBEDTLS) + else(MBEDTLS_FOUND) + message(FATAL_ERROR "Either polarssl or mbedtls is required to compile srsLTE") endif (MBEDTLS_FOUND) endif(POLARSSL_FOUND) diff --git a/cmake/modules/FindMbedTLS.cmake b/cmake/modules/FindMbedTLS.cmake index 11499bad4..2c9464e79 100644 --- a/cmake/modules/FindMbedTLS.cmake +++ b/cmake/modules/FindMbedTLS.cmake @@ -50,5 +50,5 @@ message(STATUS "MBEDTLS STATIC LIBRARIES: " ${MBEDTLS_STATIC_LIBRARIES}) message(STATUS "MBEDTLS INCLUDE DIRS: " ${MBEDTLS_INCLUDE_DIRS}) INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(MBEDTLS DEFAULT_MSG MBEDTLS_LIBRARIES MBEDTLS_STATIC_LIBRARIES MBEDTLS_INCLUDE_DIRS) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(MBEDTLS DEFAULT_MSG MBEDTLS_LIBRARIES MBEDTLS_INCLUDE_DIRS) MARK_AS_ADVANCED(MBEDTLS_LIBRARIES MBEDTLS_STATIC_LIBRARIES MBEDTLS_INCLUDE_DIRS) diff --git a/cmake/modules/FindPolarssl.cmake b/cmake/modules/FindPolarssl.cmake index 6e6c5c2cb..58f21d13e 100644 --- a/cmake/modules/FindPolarssl.cmake +++ b/cmake/modules/FindPolarssl.cmake @@ -49,5 +49,5 @@ message(STATUS "POLARSSL STATIC LIBRARIES: " ${POLARSSL_STATIC_LIBRARIES}) message(STATUS "POLARSSL INCLUDE DIRS: " ${POLARSSL_INCLUDE_DIRS}) INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(POLARSSL DEFAULT_MSG POLARSSL_LIBRARIES POLARSSL_STATIC_LIBRARIES POLARSSL_INCLUDE_DIRS) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(POLARSSL DEFAULT_MSG POLARSSL_LIBRARIES POLARSSL_INCLUDE_DIRS) MARK_AS_ADVANCED(POLARSSL_STATIC_LIBRARIES POLARSSL_LIBRARIES POLARSSL_INCLUDE_DIRS) From f48b1f3d66c39365ffb3752609b6b47a8192046f Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Fri, 23 Jun 2017 17:20:35 +0100 Subject: [PATCH 07/15] Adding ability to statically link FFTW --- cmake/modules/FindFFTW3F.cmake | 15 +++++++++++++-- lib/src/phy/CMakeLists.txt | 7 ++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cmake/modules/FindFFTW3F.cmake b/cmake/modules/FindFFTW3F.cmake index ebaa7c6df..ef7bc1397 100644 --- a/cmake/modules/FindFFTW3F.cmake +++ b/cmake/modules/FindFFTW3F.cmake @@ -15,6 +15,12 @@ find_path(FFTW3F_INCLUDE_DIR PATHS /usr/local/include /usr/include ) +find_library(FFTW3F_STATIC_LIBRARY + NAMES fftw3f.a libfftw3f.a libfftw3f-3.a + HINTS ${PC_FFTW3F_LIBDIR} ${PC_FFTW3F_LIBRARY_DIRS} $ENV{FFTW3_DIR}/lib + PATHS /usr/local/lib + /usr/lib) + find_library(FFTW3F_LIBRARY NAMES fftw3f libfftw3f libfftw3f-3 HINTS ${PC_FFTW3F_LIBDIR} ${PC_FFTW3F_LIBRARY_DIRS} $ENV{FFTW3_DIR}/lib @@ -22,12 +28,17 @@ find_library(FFTW3F_LIBRARY /usr/lib) set(FFTW3F_LIBRARIES ${FFTW3F_LIBRARY} ) +set(FFTW3F_STATIC_LIBRARIES ${FFTW3F_STATIC_LIBRARY} ) set(FFTW3F_INCLUDE_DIRS ${FFTW3F_INCLUDE_DIR} ) +message(STATUS "FFTW3F LIBRARIES: " ${FFTW3F_LIBRARIES}) +message(STATUS "FFTW3F STATIC LIBRARIES: " ${FFTW3F_STATIC_LIBRARIES}) +message(STATUS "FFTW3F INCLUDE DIRS: " ${FFTW3F_INCLUDE_DIRS}) + include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set FFTW3F_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args(fftw3f DEFAULT_MSG - FFTW3F_LIBRARY FFTW3F_INCLUDE_DIR) + FFTW3F_LIBRARY FFTW3F_STATIC_LIBRARY FFTW3F_INCLUDE_DIR) -mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY ) +mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_STATIC_LIBRARY FFTW3F_LIBRARY ) diff --git a/lib/src/phy/CMakeLists.txt b/lib/src/phy/CMakeLists.txt index 7f26f9836..bd5ae332d 100644 --- a/lib/src/phy/CMakeLists.txt +++ b/lib/src/phy/CMakeLists.txt @@ -65,7 +65,12 @@ if(MKL_FOUND) target_link_libraries(srslte_phy ${MKL_LIBRARIES}) endif(BUILD_STATIC) else(MKL_FOUND) - target_link_libraries(srslte_phy ${FFTW3F_LIBRARIES}) + if(BUILD_STATIC) + target_link_libraries(srslte_phy ${FFTW3F_STATIC_LIBRARIES}) + else(BUILD_STATIC) + target_link_libraries(srslte_phy ${FFTW3F_LIBRARIES}) + endif(BUILD_STATIC) + endif(MKL_FOUND) From ce88544d073529b30a542baf3d8928da696814dc Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Fri, 23 Jun 2017 19:36:30 +0100 Subject: [PATCH 08/15] Minor fft library tidy-up --- CMakeLists.txt | 19 ++++++++++++++++--- lib/src/phy/CMakeLists.txt | 19 +------------------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e40737900..269b5a6a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,20 +74,30 @@ set(GCC_ARCH native CACHE STRING "GCC compile for specific architecture.") ######################################################################## # Find dependencies ######################################################################## + +# Threads find_package(Threads REQUIRED) +# FFT find_package(MKL) if(MKL_FOUND) include_directories(${MKL_INCLUDE_DIRS}) link_directories(${MKL_LIBRARY_DIRS}) + set(FFT_LIBRARIES "${MKL_STATIC_LIBRARIES}") # Static by default else(MKL_FOUND) find_package(FFTW3F REQUIRED) if(FFTW3F_FOUND) include_directories(${FFTW3F_INCLUDE_DIRS}) link_directories(${FFTW3F_LIBRARY_DIRS}) + if(BUILD_STATIC) + set(FFT_LIBRARIES "${FFTW3F_STATIC_LIBRARIES}") + else(BUILD_STATIC) + set(FFT_LIBRARIES "${FFTW3F_LIBRARIES}") + endif(BUILD_STATIC) endif(FFTW3F_FOUND) endif(MKL_FOUND) +# Crypto find_package(Polarssl) if (POLARSSL_FOUND) set(SEC_INCLUDE_DIRS "${POLARSSL_INCLUDE_DIRS}") @@ -112,12 +122,14 @@ else(POLARSSL_FOUND) endif (MBEDTLS_FOUND) endif(POLARSSL_FOUND) +# UHD find_package(UHD) if(UHD_FOUND) include_directories(${UHD_INCLUDE_DIRS}) link_directories(${UHD_LIBRARY_DIRS}) endif(UHD_FOUND) +# BladeRF if(ENABLE_BLADERF) find_package(bladeRF) if(BLADERF_FOUND) @@ -126,6 +138,7 @@ if(ENABLE_BLADERF) endif(BLADERF_FOUND) endif(ENABLE_BLADERF) +# Soapy find_package(SoapySDR) if(SOAPYSDR_FOUND) include_directories(${SOAPYSDR_INCLUDE_DIRS}) @@ -139,8 +152,8 @@ else(BLADERF_FOUND OR UHD_FOUND OR SOAPYSDR_FOUND) add_definitions(-DDISABLE_RF) endif(BLADERF_FOUND OR UHD_FOUND OR SOAPYSDR_FOUND) +# Boost if(ENABLE_SRSUE OR ENABLE_SRSENB) - # Find Boost if(BUILD_STATIC) set(Boost_USE_STATIC_LIBS ON) endif(BUILD_STATIC) @@ -164,7 +177,7 @@ if(ENABLE_SRSUE OR ENABLE_SRSENB) find_package(Boost "1.35" COMPONENTS ${BOOST_REQUIRED_COMPONENTS}) endif(ENABLE_SRSUE OR ENABLE_SRSENB) - +# srsGUI if(ENABLE_GUI) find_package(SRSGUI) if(SRSGUI_FOUND) @@ -174,6 +187,7 @@ if(ENABLE_GUI) endif(SRSGUI_FOUND) endif(ENABLE_GUI) +# VOLK include(CheckFunctionExistsMath) if(ENABLE_VOLK) find_package(Volk) @@ -188,7 +202,6 @@ else(ENABLE_VOLK) message(STATUS "VOLK library disabled") endif(ENABLE_VOLK) - ######################################################################## # Install Dirs ######################################################################## diff --git a/lib/src/phy/CMakeLists.txt b/lib/src/phy/CMakeLists.txt index bd5ae332d..572ff19c3 100644 --- a/lib/src/phy/CMakeLists.txt +++ b/lib/src/phy/CMakeLists.txt @@ -55,24 +55,7 @@ set(srslte_srcs $ ) add_library(srslte_phy STATIC ${srslte_srcs}) -set_target_properties(srslte_phy PROPERTIES - VERSION ${SRSLTE_VERSION_MAJOR}.${SRSLTE_VERSION_MINOR}) - -if(MKL_FOUND) - if(BUILD_STATIC) - target_link_libraries(srslte_phy ${MKL_STATIC_LIBRARIES}) - else(BUILD_STATIC) - target_link_libraries(srslte_phy ${MKL_LIBRARIES}) - endif(BUILD_STATIC) -else(MKL_FOUND) - if(BUILD_STATIC) - target_link_libraries(srslte_phy ${FFTW3F_STATIC_LIBRARIES}) - else(BUILD_STATIC) - target_link_libraries(srslte_phy ${FFTW3F_LIBRARIES}) - endif(BUILD_STATIC) - -endif(MKL_FOUND) - +target_link_libraries(srslte_phy ${FFT_LIBRARIES}) if(VOLK_FOUND) target_link_libraries(srslte_phy ${VOLK_LIBRARIES}) From e92418d2da43556f136a8149dbf6d9e4af85ab3d Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Sat, 24 Jun 2017 16:10:38 +0200 Subject: [PATCH 09/15] minor edit in cmake --- lib/examples/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/examples/CMakeLists.txt b/lib/examples/CMakeLists.txt index 9c6ee193e..652a2c195 100644 --- a/lib/examples/CMakeLists.txt +++ b/lib/examples/CMakeLists.txt @@ -65,7 +65,7 @@ if(RF_FOUND) add_executable(cell_search cell_search.c) target_link_libraries(cell_search srslte_phy srslte_rf) - add_executable(cell_measurement cell_measurement.c ../include/srslte/common/logger_stdout.h) + add_executable(cell_measurement cell_measurement.c) target_link_libraries(cell_measurement srslte_phy srslte_rf) add_executable(usrp_capture usrp_capture.c) From cec7b95d4517164293e854afbb701449fb259aaa Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Sat, 24 Jun 2017 19:39:33 +0100 Subject: [PATCH 10/15] Fix for race condition, fix for window size checks --- lib/src/upper/rlc_am.cc | 47 +++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index b9545375a..bef8bb024 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -208,12 +208,14 @@ uint32_t rlc_am::get_total_buffer_state() } // Bytes needed for tx SDUs - n_sdus = tx_sdu_queue.size(); - n_bytes += tx_sdu_queue.size_bytes(); - if(tx_sdu) - { - n_sdus++; - n_bytes += tx_sdu->N_bytes; + if(tx_window.size() < 1024) { + n_sdus = tx_sdu_queue.size(); + n_bytes += tx_sdu_queue.size_bytes(); + if(tx_sdu) + { + n_sdus++; + n_bytes += tx_sdu->N_bytes; + } } // Room needed for header extensions? (integer rounding) @@ -256,7 +258,7 @@ uint32_t rlc_am::get_buffer_state() } // Bytes needed for tx SDUs - if(tx_window.size() < RLC_AM_WINDOW_SIZE) { + if(tx_window.size() < 1024) { n_sdus = tx_sdu_queue.size(); n_bytes = tx_sdu_queue.size_bytes(); if(tx_sdu) @@ -286,6 +288,7 @@ int rlc_am::read_pdu(uint8_t *payload, uint32_t nof_bytes) pthread_mutex_lock(&mutex); log->debug("MAC opportunity - %d bytes\n", nof_bytes); + log->debug("tx_window size - %d PDUs\n", tx_window.size()); // Tx STATUS if requested if(do_status && !status_prohibited()) { @@ -298,10 +301,11 @@ int rlc_am::read_pdu(uint8_t *payload, uint32_t nof_bytes) return build_retx_pdu(payload, nof_bytes); } - pthread_mutex_unlock(&mutex); - // Build a PDU from SDUs - return build_data_pdu(payload, nof_bytes); + int ret = build_data_pdu(payload, nof_bytes); + + pthread_mutex_unlock(&mutex); + return ret; } void rlc_am::write_pdu(uint8_t *payload, uint32_t nof_bytes) @@ -582,6 +586,16 @@ int rlc_am::build_data_pdu(uint8_t *payload, uint32_t nof_bytes) byte_buffer_t *pdu = pool_allocate; if (!pdu) { log->console("Fatal Error: Could not allocate PDU in build_data_pdu()\n"); + log->console("tx_window size: %d PDUs\n", tx_window.size()); + log->console("vt_a = %d, vt_ms = %d, vt_s = %d, poll_sn = %d " + "vr_r = %d, vr_mr = %d, vr_x = %d, vr_ms = %d, vr_h = %d\n", + vt_a, vt_ms, vt_s, poll_sn, + vr_r, vr_mr, vr_x, vr_ms, vr_h); + log->console("retx_queue size: %d PDUs\n", retx_queue.size()); + std::map::iterator txit; + for(txit = tx_window.begin(); txit != tx_window.end(); txit++) { + log->console("tx_window - SN: %d\n", txit->first); + } exit(-1); } rlc_amd_pdu_header_t header; @@ -943,14 +957,15 @@ void rlc_am::handle_control_pdu(uint8_t *payload, uint32_t nof_bytes) if(!nack) { //ACKed SNs get marked and removed from tx_window if possible - it = tx_window.find(i); - if(tx_window.end() != it) - { - tx_window[i].is_acked = true; + if(tx_window.count(i) > 0) { + it = tx_window.find(i); + it->second.is_acked = true; if(update_vt_a) { - pool->deallocate(tx_window[i].buf); - tx_window.erase(i); + if(it->second.buf) { + pool->deallocate(it->second.buf); + } + tx_window.erase(it); vt_a = (vt_a + 1)%MOD; vt_ms = (vt_ms + 1)%MOD; } From 89cc50c7c4a03a89372e359a8f40122673dc94b6 Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Sun, 25 Jun 2017 14:35:41 +0100 Subject: [PATCH 11/15] Deallocating buffers for ACKed RLC tx PDUs --- lib/include/srslte/common/buffer_pool.h | 3 +++ lib/src/upper/rlc_am.cc | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/include/srslte/common/buffer_pool.h b/lib/include/srslte/common/buffer_pool.h index eec35b79a..94439387a 100644 --- a/lib/include/srslte/common/buffer_pool.h +++ b/lib/include/srslte/common/buffer_pool.h @@ -156,6 +156,9 @@ public: return pool->allocate(debug_name); } void deallocate(byte_buffer_t *b) { + if(!b) { + return; + } b->reset(); pool->deallocate(b); } diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index bef8bb024..416a141c8 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -911,13 +911,13 @@ void rlc_am::handle_control_pdu(uint8_t *payload, uint32_t nof_bytes) poll_retx_timeout.reset(); // Handle ACKs and NACKs + std::map::iterator it; bool update_vt_a = true; - uint32_t i = vt_a; + uint32_t i = vt_a; + while(TX_MOD_BASE(i) < TX_MOD_BASE(status.ack_sn) && TX_MOD_BASE(i) < TX_MOD_BASE(vt_s)) { - std::map::iterator it; - bool nack = false; for(uint32_t j=0;j 0) { it = tx_window.find(i); it->second.is_acked = true; + if(it->second.buf) { + pool->deallocate(it->second.buf); + it->second.buf = 0; + } if(update_vt_a) { - if(it->second.buf) { - pool->deallocate(it->second.buf); - } tx_window.erase(it); vt_a = (vt_a + 1)%MOD; vt_ms = (vt_ms + 1)%MOD; From 2c85d3f8905090c6a1f19156fa99886d5e71c5ef Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 27 Jun 2017 11:42:20 +0200 Subject: [PATCH 12/15] added ctest options for valgrind --- CMakeLists.txt | 2 ++ CTestCustom.cmake.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 269b5a6a3..c4904e5f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,8 @@ include(SRSLTEPackage) #setup cpack include(CTest) set(CTEST_MEMORYCHECK_COMMAND valgrind) +set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" ) + configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake" diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index a66fe53e2..180c08de4 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -7,7 +7,7 @@ SET(CTEST_CUSTOM_MEMCHECK_IGNORE realplot_test complexplot_test -# Ignore these to, they take too lonk +# Ignore these to, they take too long fft_normal fft_extened chest_test_all_cellids From 6c0587e5a497c97e43b1225a46610e3d3f337214 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 28 Jun 2017 14:59:54 +0200 Subject: [PATCH 13/15] fixed missing initialization of PUSCH scrambling sequence --- lib/src/phy/phch/pusch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/phy/phch/pusch.c b/lib/src/phy/phch/pusch.c index 65ab08411..5e1cbd922 100644 --- a/lib/src/phy/phch/pusch.c +++ b/lib/src/phy/phch/pusch.c @@ -393,7 +393,7 @@ int srslte_pusch_set_rnti(srslte_pusch_t *q, uint16_t rnti) { uint32_t i; if (!q->users[rnti]) { - q->users[rnti] = malloc(sizeof(srslte_pusch_user_t)); + q->users[rnti] = calloc(1, sizeof(srslte_pusch_user_t)); if (q->users[rnti]) { for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { if (srslte_sequence_pusch(&q->users[rnti]->seq[i], rnti, 2 * i, q->cell.id, From bfa10148f5830341125e8a6ee73916a0e82e5e60 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 30 Jun 2017 16:14:05 +0200 Subject: [PATCH 14/15] fix bug in c-rnti MAC subheader --- lib/src/common/pdu.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/common/pdu.cc b/lib/src/common/pdu.cc index 960f7d85e..c54636fcd 100644 --- a/lib/src/common/pdu.cc +++ b/lib/src/common/pdu.cc @@ -515,8 +515,8 @@ bool sch_subh::set_bsr(uint32_t buff_size[4], sch_subh::cetype format) bool sch_subh::set_c_rnti(uint16_t crnti) { if (((sch_pdu*)parent)->has_space_ce(2)) { - w_payload_ce[0] = (uint8_t) (crnti&0xff00)>>8; - w_payload_ce[1] = (uint8_t) (crnti&0x00ff); + w_payload_ce[0] = (uint8_t) ((crnti&0xff00)>>8); + w_payload_ce[1] = (uint8_t) ((crnti&0x00ff)); lcid = CRNTI; ((sch_pdu*)parent)->update_space_ce(2); nof_bytes = 2; From 3d658cfdd81f7790e5e7f93f92e24c8266669f4e Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 6 Jul 2017 10:37:51 +0200 Subject: [PATCH 15/15] fixed number of ports in pdsch tx --- lib/src/phy/phch/pdsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/phy/phch/pdsch.c b/lib/src/phy/phch/pdsch.c index 4da881531..8791ac8e7 100644 --- a/lib/src/phy/phch/pdsch.c +++ b/lib/src/phy/phch/pdsch.c @@ -260,7 +260,7 @@ int srslte_pdsch_init_multi(srslte_pdsch_t *q, srslte_cell_t cell, uint32_t nof_ } } } - for (int j=0;jnof_rx_antennas;j++) { + for (int j=0;jnof_rx_antennas, q->cell.nof_ports);j++) { q->symbols[j] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->symbols[j]) { goto clean;