From 598594c51a6d6754c6120b81e30c93c560f44f81 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 28 Apr 2021 23:25:38 +0200 Subject: [PATCH 01/10] all: bunch of pass by const& changes suggested by LGTM --- lib/include/srsran/interfaces/ue_pdcp_interfaces.h | 4 ++-- lib/include/srsran/interfaces/ue_phy_interfaces.h | 2 +- lib/include/srsran/test/ue_test_interfaces.h | 2 +- lib/include/srsran/upper/pdcp.h | 4 ++-- lib/src/asn1/gtpc.cc | 2 +- lib/src/upper/pdcp.cc | 4 ++-- srsenb/hdr/stack/upper/s1ap.h | 2 +- srsenb/src/stack/upper/s1ap.cc | 2 +- srsepc/hdr/mme/s1ap.h | 2 +- srsepc/hdr/mme/s1ap_mngmt_proc.h | 2 +- srsepc/src/mme/s1ap.cc | 2 +- srsepc/src/mme/s1ap_mngmt_proc.cc | 2 +- srsue/hdr/phy/phy.h | 2 +- srsue/hdr/phy/phy_common.h | 12 ++++++------ srsue/src/phy/phy.cc | 2 +- srsue/src/phy/phy_common.cc | 12 ++++++------ srsue/test/ttcn3/hdr/lte_ttcn3_phy.h | 2 +- srsue/test/ttcn3/src/lte_ttcn3_phy.cc | 2 +- srsue/test/upper/rrc_meas_test.cc | 2 +- 19 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/include/srsran/interfaces/ue_pdcp_interfaces.h b/lib/include/srsran/interfaces/ue_pdcp_interfaces.h index 530fcebf2..9c3968da0 100644 --- a/lib/include/srsran/interfaces/ue_pdcp_interfaces.h +++ b/lib/include/srsran/interfaces/ue_pdcp_interfaces.h @@ -28,8 +28,8 @@ public: virtual void add_bearer(uint32_t lcid, srsran::pdcp_config_t cnfg) = 0; virtual void del_bearer(uint32_t lcid) = 0; virtual void change_lcid(uint32_t old_lcid, uint32_t new_lcid) = 0; - virtual void config_security(uint32_t lcid, srsran::as_security_config_t sec_cfg) = 0; - virtual void config_security_all(srsran::as_security_config_t sec_cfg) = 0; + virtual void config_security(uint32_t lcid, const srsran::as_security_config_t& sec_cfg) = 0; + virtual void config_security_all(const srsran::as_security_config_t& sec_cfg) = 0; virtual void enable_integrity(uint32_t lcid, srsran::srsran_direction_t direction) = 0; virtual void enable_encryption(uint32_t lcid, srsran::srsran_direction_t direction = srsran::srsran_direction_t::DIRECTION_TXRX) = 0; diff --git a/lib/include/srsran/interfaces/ue_phy_interfaces.h b/lib/include/srsran/interfaces/ue_phy_interfaces.h index ddebb3564..c86a850da 100644 --- a/lib/include/srsran/interfaces/ue_phy_interfaces.h +++ b/lib/include/srsran/interfaces/ue_phy_interfaces.h @@ -141,7 +141,7 @@ public: class phy_interface_rrc_lte { public: - virtual bool set_config(srsran::phy_cfg_t config, uint32_t cc_idx = 0) = 0; + virtual bool set_config(const srsran::phy_cfg_t& config, uint32_t cc_idx = 0) = 0; virtual bool set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) = 0; virtual void set_config_tdd(srsran_tdd_config_t& tdd_config) = 0; virtual void set_config_mbsfn_sib2(srsran::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) = 0; diff --git a/lib/include/srsran/test/ue_test_interfaces.h b/lib/include/srsran/test/ue_test_interfaces.h index 720963b45..e871c8f28 100644 --- a/lib/include/srsran/test/ue_test_interfaces.h +++ b/lib/include/srsran/test/ue_test_interfaces.h @@ -60,7 +60,7 @@ public: class phy_dummy_interface : public phy_interface_rrc_lte { - bool set_config(srsran::phy_cfg_t config, uint32_t cc_idx) override { return true; } + bool set_config(const srsran::phy_cfg_t& config, uint32_t cc_idx) override { return true; } bool set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) override { return true; } void set_config_tdd(srsran_tdd_config_t& tdd_config) override {} void set_config_mbsfn_sib2(srsran::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override {} diff --git a/lib/include/srsran/upper/pdcp.h b/lib/include/srsran/upper/pdcp.h index a3b37c71d..ffa27897c 100644 --- a/lib/include/srsran/upper/pdcp.h +++ b/lib/include/srsran/upper/pdcp.h @@ -46,8 +46,8 @@ public: void add_bearer_mrb(uint32_t lcid, pdcp_config_t cnfg); void del_bearer(uint32_t lcid) override; void change_lcid(uint32_t old_lcid, uint32_t new_lcid) override; - void config_security(uint32_t lcid, as_security_config_t sec_cfg) override; - void config_security_all(as_security_config_t sec_cfg) override; + void config_security(uint32_t lcid, const as_security_config_t& sec_cfg) override; + void config_security_all(const as_security_config_t& sec_cfg) override; void enable_integrity(uint32_t lcid, srsran_direction_t direction) override; void enable_encryption(uint32_t lcid, srsran_direction_t direction) override; void enable_security_timed(uint32_t lcid, srsran_direction_t direction, uint32_t sn); diff --git a/lib/src/asn1/gtpc.cc b/lib/src/asn1/gtpc.cc index a3d114575..7a97f2e64 100644 --- a/lib/src/asn1/gtpc.cc +++ b/lib/src/asn1/gtpc.cc @@ -178,7 +178,7 @@ const char* gtpc_msg_type_to_str(uint8_t type) return "GTPC_MSG_TYPE_INVALID"; } -int gtpc_pack_create_session_request(struct gtpc_create_session_request* cs_req, srsran::byte_buffer_t) +int gtpc_pack_create_session_request(struct gtpc_create_session_request* cs_req, srsran::byte_buffer_t&) { // TODO return 0; diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index 88bc1fa0c..a1a68ae8b 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -194,14 +194,14 @@ void pdcp::change_lcid(uint32_t old_lcid, uint32_t new_lcid) } } -void pdcp::config_security(uint32_t lcid, as_security_config_t sec_cfg) +void pdcp::config_security(uint32_t lcid, const as_security_config_t& sec_cfg) { if (valid_lcid(lcid)) { pdcp_array.at(lcid)->config_security(sec_cfg); } } -void pdcp::config_security_all(as_security_config_t sec_cfg) +void pdcp::config_security_all(const as_security_config_t& sec_cfg) { for (auto& it : pdcp_array) { it.second->config_security(sec_cfg); diff --git a/srsenb/hdr/stack/upper/s1ap.h b/srsenb/hdr/stack/upper/s1ap.h index 97d8fddeb..5615a105a 100644 --- a/srsenb/hdr/stack/upper/s1ap.h +++ b/srsenb/hdr/stack/upper/s1ap.h @@ -61,7 +61,7 @@ public: s1ap(srsran::task_sched_handle task_sched_, srslog::basic_logger& logger, srsran::socket_manager_itf* rx_socket_handler); - int init(s1ap_args_t args_, rrc_interface_s1ap* rrc_); + int init(const s1ap_args_t& args_, rrc_interface_s1ap* rrc_); void stop(); void get_metrics(s1ap_metrics_t& m); diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index a9aef2116..a828911d7 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -289,7 +289,7 @@ s1ap::s1ap(srsran::task_sched_handle task_sched_, mme_task_queue = task_sched.make_task_queue(); } -int s1ap::init(s1ap_args_t args_, rrc_interface_s1ap* rrc_) +int s1ap::init(const s1ap_args_t& args_, rrc_interface_s1ap* rrc_) { rrc = rrc_; args = args_; diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index 2cbd125b3..d07a7eda9 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -50,7 +50,7 @@ public: static void cleanup(); int enb_listen(); - int init(s1ap_args_t s1ap_args); + int init(const s1ap_args_t& s1ap_args); void stop(); int get_s1_mme(); diff --git a/srsepc/hdr/mme/s1ap_mngmt_proc.h b/srsepc/hdr/mme/s1ap_mngmt_proc.h index 05d2b3b5a..d4156c093 100644 --- a/srsepc/hdr/mme/s1ap_mngmt_proc.h +++ b/srsepc/hdr/mme/s1ap_mngmt_proc.h @@ -35,7 +35,7 @@ public: // Packing/unpacking helper functions bool unpack_s1_setup_request(const asn1::s1ap::s1_setup_request_s& msg, enb_ctx_t* enb_ctx); bool send_s1_setup_failure(asn1::s1ap::cause_misc_opts::options cause, struct sctp_sndrcvinfo* enb_sri); - bool send_s1_setup_response(s1ap_args_t s1ap_args, struct sctp_sndrcvinfo* enb_sri); + bool send_s1_setup_response(const s1ap_args_t& s1ap_args, struct sctp_sndrcvinfo* enb_sri); private: s1ap_mngmt_proc(); diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index c6678977e..ef4725e4a 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -49,7 +49,7 @@ void s1ap::cleanup(void) pthread_mutex_unlock(&s1ap_instance_mutex); } -int s1ap::init(s1ap_args_t s1ap_args) +int s1ap::init(const s1ap_args_t& s1ap_args) { m_s1ap_args = s1ap_args; srsran::s1ap_mccmnc_to_plmn(s1ap_args.mcc, s1ap_args.mnc, &m_plmn); diff --git a/srsepc/src/mme/s1ap_mngmt_proc.cc b/srsepc/src/mme/s1ap_mngmt_proc.cc index b0097235c..57f7187b1 100644 --- a/srsepc/src/mme/s1ap_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_mngmt_proc.cc @@ -182,7 +182,7 @@ bool s1ap_mngmt_proc::send_s1_setup_failure(asn1::s1ap::cause_misc_opts::options return true; } -bool s1ap_mngmt_proc::send_s1_setup_response(s1ap_args_t s1ap_args, struct sctp_sndrcvinfo* enb_sri) +bool s1ap_mngmt_proc::send_s1_setup_response(const s1ap_args_t& s1ap_args, struct sctp_sndrcvinfo* enb_sri) { m_logger.debug("Sending S1 Setup Response"); diff --git a/srsue/hdr/phy/phy.h b/srsue/hdr/phy/phy.h index 127253345..b3a30576b 100644 --- a/srsue/hdr/phy/phy.h +++ b/srsue/hdr/phy/phy.h @@ -107,7 +107,7 @@ public: // Sets the new PHY configuration for the given CC. The configuration is applied in the background. The notify() // function will be called when the reconfiguration is completed. Unless the PRACH configuration has changed, the // reconfiguration will not take more than 3 ms - bool set_config(srsran::phy_cfg_t config, uint32_t cc_idx) final; + bool set_config(const srsran::phy_cfg_t& config, uint32_t cc_idx) final; // Adds or modifies the cell configuration for a given CC. If the EARFCN has changed w.r.t. the previous value, or if // the cell is new, this function might take a few hundred ms to complete, depending on the radio diff --git a/srsue/hdr/phy/phy_common.h b/srsue/hdr/phy/phy_common.h index ef210afa3..2a635912e 100644 --- a/srsue/hdr/phy/phy_common.h +++ b/srsue/hdr/phy/phy_common.h @@ -165,12 +165,12 @@ public: */ uint32_t get_ul_earfcn(uint32_t dl_earfcn); - void update_measurements(uint32_t cc_idx, - srsran_chest_dl_res_t chest_res, - srsran_dl_sf_cfg_t sf_cfg_dl, - float tx_crs_power, - std::vector& serving_cells, - cf_t* rssi_power_buffer = nullptr); + void update_measurements(uint32_t cc_idx, + const srsran_chest_dl_res_t& chest_res, + srsran_dl_sf_cfg_t sf_cfg_dl, + float tx_crs_power, + std::vector& serving_cells, + cf_t* rssi_power_buffer = nullptr); void update_cfo_measurement(uint32_t cc_idx, float cfo_hz); diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index 2f8302669..694fa6444 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -429,7 +429,7 @@ void phy::enable_pregen_signals(bool enable) } } -bool phy::set_config(srsran::phy_cfg_t config_, uint32_t cc_idx) +bool phy::set_config(const srsran::phy_cfg_t& config_, uint32_t cc_idx) { if (!is_initiated()) { fprintf(stderr, "Error calling set_config(): PHY not initialized\n"); diff --git a/srsue/src/phy/phy_common.cc b/srsue/src/phy/phy_common.cc index 80e2d5985..6e0c350fe 100644 --- a/srsue/src/phy/phy_common.cc +++ b/srsue/src/phy/phy_common.cc @@ -615,12 +615,12 @@ void phy_common::update_cfo_measurement(uint32_t cc_idx, float cfo_hz) avg_cfo_hz[cc_idx] = SRSRAN_VEC_EMA(cfo_hz, avg_cfo_hz[cc_idx], args->snr_ema_coeff); } -void phy_common::update_measurements(uint32_t cc_idx, - srsran_chest_dl_res_t chest_res, - srsran_dl_sf_cfg_t sf_cfg_dl, - float tx_crs_power, - std::vector& serving_cells, - cf_t* rssi_power_buffer) +void phy_common::update_measurements(uint32_t cc_idx, + const srsran_chest_dl_res_t& chest_res, + srsran_dl_sf_cfg_t sf_cfg_dl, + float tx_crs_power, + std::vector& serving_cells, + cf_t* rssi_power_buffer) { bool insync = true; { diff --git a/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h b/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h index c25bb2da0..a1cc99ec7 100644 --- a/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h +++ b/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h @@ -58,7 +58,7 @@ public: void enable_pregen_signals(bool enable) override; void deactivate_scells() override; void set_activation_deactivation_scell(uint32_t cmd, uint32_t tti) override; - bool set_config(srsran::phy_cfg_t config, uint32_t cc_idx = 0) override; + bool set_config(const srsran::phy_cfg_t& config, uint32_t cc_idx = 0) override; bool set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) override; void set_config_tdd(srsran_tdd_config_t& tdd_config) override; void set_config_mbsfn_sib2(srsran::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override{}; diff --git a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc index 8c45a6bcd..d34a75e01 100644 --- a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc +++ b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc @@ -76,7 +76,7 @@ void lte_ttcn3_phy::set_activation_deactivation_scell(uint32_t cmd, uint32_t tti logger.debug("%s not implemented.", __FUNCTION__); } -bool lte_ttcn3_phy::set_config(srsran::phy_cfg_t config, uint32_t cc_idx_) +bool lte_ttcn3_phy::set_config(const srsran::phy_cfg_t& config, uint32_t cc_idx_) { logger.debug("%s not implemented.", __FUNCTION__); task_sched.defer_task([this]() { stack->set_config_complete(true); }); diff --git a/srsue/test/upper/rrc_meas_test.cc b/srsue/test/upper/rrc_meas_test.cc index 3bc02e360..5e2cfce1f 100644 --- a/srsue/test/upper/rrc_meas_test.cc +++ b/srsue/test/upper/rrc_meas_test.cc @@ -34,7 +34,7 @@ public: } // Not implemented methods - bool set_config(srsran::phy_cfg_t config, uint32_t cc_idx) override { return true; } + bool set_config(const srsran::phy_cfg_t& config, uint32_t cc_idx) override { return true; } bool set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) override { return true; } void set_config_tdd(srsran_tdd_config_t& tdd_config) override {} void set_config_mbsfn_sib2(srsran::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override {} From 8622b1c284b101b784e48b8ff5e697e866667de8 Mon Sep 17 00:00:00 2001 From: Nikita Pushchin Date: Sat, 13 Feb 2021 20:32:23 +0300 Subject: [PATCH 02/10] cmake/modules fix --- cmake/modules/FindFFTW3F.cmake | 5 ++--- cmake/modules/FindMbedTLS.cmake | 4 ++-- cmake/modules/FindPCSCLite.cmake | 4 ++-- cmake/modules/FindPolarssl.cmake | 4 ++-- cmake/modules/FindSCTP.cmake | 2 +- cmake/modules/FindUHD.cmake | 3 ++- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmake/modules/FindFFTW3F.cmake b/cmake/modules/FindFFTW3F.cmake index f498ab57d..11048879a 100644 --- a/cmake/modules/FindFFTW3F.cmake +++ b/cmake/modules/FindFFTW3F.cmake @@ -13,7 +13,7 @@ # FFTW3F_LIBRARIES - The libraries needed to use fftw3f # FFTW3F_DEFINITIONS - Compiler switches required for using fftw3f -find_package(PkgConfig) +find_package(PkgConfig REQUIRED) pkg_check_modules(PC_FFTW3F "fftw3f >= 3.0") set(FFTW3F_DEFINITIONS ${PC_FFTW3F_CFLAGS_OTHER}) @@ -46,7 +46,6 @@ 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) +find_package_handle_standard_args(FFTW3F DEFAULT_MSG FFTW3F_LIBRARY FFTW3F_INCLUDE_DIR) mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_STATIC_LIBRARY FFTW3F_LIBRARY ) diff --git a/cmake/modules/FindMbedTLS.cmake b/cmake/modules/FindMbedTLS.cmake index d8fb3b400..7ac1f3d8b 100644 --- a/cmake/modules/FindMbedTLS.cmake +++ b/cmake/modules/FindMbedTLS.cmake @@ -13,7 +13,7 @@ # MBEDTLS_INCLUDE_DIRS - The mbedtls include directories # MBEDTLS_LIBRARIES - The mbedtls library -INCLUDE(FindPkgConfig) +FIND_PACKAGE(PkgConfig REQUIRED) PKG_CHECK_MODULES(PC_MBEDTLS mbedtls) #find Mbedtls @@ -58,5 +58,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_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/FindPCSCLite.cmake b/cmake/modules/FindPCSCLite.cmake index f9257637c..110d8fad4 100644 --- a/cmake/modules/FindPCSCLite.cmake +++ b/cmake/modules/FindPCSCLite.cmake @@ -13,7 +13,7 @@ # PCSCLITE_LIBRARIES - List of libraries when using PCSC-Lite. # PCSCLITE_FOUND - True if PCSC-Lite found. -FIND_PACKAGE(PkgConfig) +FIND_PACKAGE(PkgConfig REQUIRED) PKG_CHECK_MODULES(PC_PCSCLITE libpcsclite) IF(NOT PCSCLITE_FOUND) @@ -41,7 +41,7 @@ FIND_LIBRARY(PCSCLITE_LIBRARY NAMES pcsclite libpcsclite PCSC # handle the QUIETLY and REQUIRED arguments and set PCSCLITE_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCSCLITE DEFAULT_MSG PCSCLITE_LIBRARY PCSCLITE_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCSCLite DEFAULT_MSG PCSCLITE_LIBRARY PCSCLITE_INCLUDE_DIR) IF(PCSCLITE_FOUND) SET(PCSCLITE_LIBRARIES ${PCSCLITE_LIBRARY}) diff --git a/cmake/modules/FindPolarssl.cmake b/cmake/modules/FindPolarssl.cmake index 91d0e528e..54fa89aa1 100644 --- a/cmake/modules/FindPolarssl.cmake +++ b/cmake/modules/FindPolarssl.cmake @@ -13,7 +13,7 @@ # POLARSSL_INCLUDE_DIRS - The polarssl include directories # POLARSSL_LIBRARIES - The polarssl library -INCLUDE(FindPkgConfig) +FIND_PACKAGE(PkgConfig REQUIRED) PKG_CHECK_MODULES(PC_POLARSSL polarssl) FIND_PATH( @@ -57,5 +57,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_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) diff --git a/cmake/modules/FindSCTP.cmake b/cmake/modules/FindSCTP.cmake index e32d4d6ed..635584530 100644 --- a/cmake/modules/FindSCTP.cmake +++ b/cmake/modules/FindSCTP.cmake @@ -13,7 +13,7 @@ # SCTP_INCLUDE_DIRS - The mbedtls include directories # SCTP_LIBRARIES - The mbedtls library -INCLUDE(FindPkgConfig) +FIND_PACKAGE(PkgConfig REQUIRED) PKG_CHECK_MODULES(PC_SCTP sctp) #find Mbedtls diff --git a/cmake/modules/FindUHD.cmake b/cmake/modules/FindUHD.cmake index 9a36b52b5..94616b0b3 100644 --- a/cmake/modules/FindUHD.cmake +++ b/cmake/modules/FindUHD.cmake @@ -6,7 +6,8 @@ # the distribution. # -INCLUDE(FindPkgConfig) +FIND_PACKAGE(PkgConfig REQUIRED) + #PKG_CHECK_MODULES(UHD uhd) IF(NOT UHD_FOUND) From 3b553359c0bc0c8ca1d944593f38d832d54caa8a Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 24 Feb 2021 22:14:34 +0100 Subject: [PATCH 03/10] cmake: fix some warnings --- cmake/modules/FindBackward.cmake | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/cmake/modules/FindBackward.cmake b/cmake/modules/FindBackward.cmake index 3e5cf7dca..65efdd719 100644 --- a/cmake/modules/FindBackward.cmake +++ b/cmake/modules/FindBackward.cmake @@ -76,8 +76,7 @@ if (STACK_WALKING_LIBUNWIND) set(LIBUNWIND_INCLUDE_DIRS ${LIBUNWIND_INCLUDE_DIR}) set(LIBDWARF_LIBRARIES ${LIBUNWIND_LIBRARY}) - find_package_handle_standard_args(libunwind DEFAULT_MSG - LIBUNWIND_LIBRARY LIBUNWIND_INCLUDE_DIR) + find_package_handle_standard_args(libunwind DEFAULT_MSG LIBUNWIND_LIBRARY LIBUNWIND_INCLUDE_DIR) mark_as_advanced(LIBUNWIND_INCLUDE_DIR LIBUNWIND_LIBRARY) list(APPEND _BACKWARD_LIBRARIES ${LIBUNWIND_LIBRARY}) endif() @@ -93,8 +92,7 @@ if (${STACK_DETAILS_AUTO_DETECT}) find_library(LIBDW_LIBRARY dw) set(LIBDW_INCLUDE_DIRS ${LIBDW_INCLUDE_DIR} ) set(LIBDW_LIBRARIES ${LIBDW_LIBRARY} ) - find_package_handle_standard_args(libdw DEFAULT_MSG - LIBDW_LIBRARY LIBDW_INCLUDE_DIR) + find_package_handle_standard_args(libdw DEFAULT_MSG LIBDW_LIBRARY LIBDW_INCLUDE_DIR) mark_as_advanced(LIBDW_INCLUDE_DIR LIBDW_LIBRARY) # find libbfd @@ -104,11 +102,8 @@ if (${STACK_DETAILS_AUTO_DETECT}) find_library(LIBDL_LIBRARY dl) set(LIBBFD_INCLUDE_DIRS ${LIBBFD_INCLUDE_DIR} ${LIBDL_INCLUDE_DIR}) set(LIBBFD_LIBRARIES ${LIBBFD_LIBRARY} ${LIBDL_LIBRARY}) - find_package_handle_standard_args(libbfd DEFAULT_MSG - LIBBFD_LIBRARY LIBBFD_INCLUDE_DIR - LIBDL_LIBRARY LIBDL_INCLUDE_DIR) - mark_as_advanced(LIBBFD_INCLUDE_DIR LIBBFD_LIBRARY - LIBDL_INCLUDE_DIR LIBDL_LIBRARY) + find_package_handle_standard_args(libbfd DEFAULT_MSG LIBBFD_LIBRARY LIBBFD_INCLUDE_DIR LIBDL_LIBRARY LIBDL_INCLUDE_DIR) + mark_as_advanced(LIBBFD_INCLUDE_DIR LIBBFD_LIBRARY LIBDL_INCLUDE_DIR LIBDL_LIBRARY) # find libdwarf find_path(LIBDWARF_INCLUDE_DIR NAMES "libdwarf.h" PATH_SUFFIXES libdwarf) @@ -119,13 +114,8 @@ if (${STACK_DETAILS_AUTO_DETECT}) find_library(LIBDL_LIBRARY dl) set(LIBDWARF_INCLUDE_DIRS ${LIBDWARF_INCLUDE_DIR} ${LIBELF_INCLUDE_DIR} ${LIBDL_INCLUDE_DIR}) set(LIBDWARF_LIBRARIES ${LIBDWARF_LIBRARY} ${LIBELF_LIBRARY} ${LIBDL_LIBRARY}) - find_package_handle_standard_args(libdwarf DEFAULT_MSG - LIBDWARF_LIBRARY LIBDWARF_INCLUDE_DIR - LIBELF_LIBRARY LIBELF_INCLUDE_DIR - LIBDL_LIBRARY LIBDL_INCLUDE_DIR) - mark_as_advanced(LIBDWARF_INCLUDE_DIR LIBDWARF_LIBRARY - LIBELF_INCLUDE_DIR LIBELF_LIBRARY - LIBDL_INCLUDE_DIR LIBDL_LIBRARY) + find_package_handle_standard_args(libdwarf DEFAULT_MSG LIBDWARF_LIBRARY LIBDWARF_INCLUDE_DIR LIBELF_LIBRARY LIBELF_INCLUDE_DIR LIBDL_LIBRARY LIBDL_INCLUDE_DIR) + mark_as_advanced(LIBDWARF_INCLUDE_DIR LIBDWARF_LIBRARY LIBELF_INCLUDE_DIR LIBELF_LIBRARY LIBDL_INCLUDE_DIR LIBDL_LIBRARY) if (LIBDW_FOUND) LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBDW_INCLUDE_DIRS}) @@ -201,8 +191,7 @@ if(DEFINED _BACKWARD_LIBRARIES) endif() include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Backward - REQUIRED_VARS ${FIND_PACKAGE_REQUIRED_VARS} +find_package_handle_standard_args(Backward REQUIRED_VARS ${FIND_PACKAGE_REQUIRED_VARS} ) list(APPEND _BACKWARD_INCLUDE_DIRS ${BACKWARD_INCLUDE_DIR}) From c8b03a20fbaafca28dbadf521a46c7b27de3d12b Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Wed, 28 Apr 2021 08:06:30 -0400 Subject: [PATCH 04/10] Updated findBackward cmake file to suppress dev warnings --- cmake/modules/FindBackward.cmake | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/cmake/modules/FindBackward.cmake b/cmake/modules/FindBackward.cmake index 65efdd719..025383fc1 100644 --- a/cmake/modules/FindBackward.cmake +++ b/cmake/modules/FindBackward.cmake @@ -86,13 +86,17 @@ if (STACK_WALKING_LIBUNWIND) set(STACK_WALKING_BACKTRACE FALSE) endif() -if (${STACK_DETAILS_AUTO_DETECT}) +if (STACK_DETAILS_AUTO_DETECT) + if(NOT CMAKE_VERSION VERSION_LESS 3.17) + set(_name_mismatched_arg NAME_MISMATCHED) + endif() # find libdw find_path(LIBDW_INCLUDE_DIR NAMES "elfutils/libdw.h" "elfutils/libdwfl.h") find_library(LIBDW_LIBRARY dw) set(LIBDW_INCLUDE_DIRS ${LIBDW_INCLUDE_DIR} ) set(LIBDW_LIBRARIES ${LIBDW_LIBRARY} ) - find_package_handle_standard_args(libdw DEFAULT_MSG LIBDW_LIBRARY LIBDW_INCLUDE_DIR) + find_package_handle_standard_args(libdw REQUIRED_VARS + LIBDW_LIBRARY LIBDW_INCLUDE_DIR ${_name_mismatched_arg}) mark_as_advanced(LIBDW_INCLUDE_DIR LIBDW_LIBRARY) # find libbfd @@ -102,9 +106,11 @@ if (${STACK_DETAILS_AUTO_DETECT}) find_library(LIBDL_LIBRARY dl) set(LIBBFD_INCLUDE_DIRS ${LIBBFD_INCLUDE_DIR} ${LIBDL_INCLUDE_DIR}) set(LIBBFD_LIBRARIES ${LIBBFD_LIBRARY} ${LIBDL_LIBRARY}) - find_package_handle_standard_args(libbfd DEFAULT_MSG LIBBFD_LIBRARY LIBBFD_INCLUDE_DIR LIBDL_LIBRARY LIBDL_INCLUDE_DIR) - mark_as_advanced(LIBBFD_INCLUDE_DIR LIBBFD_LIBRARY LIBDL_INCLUDE_DIR LIBDL_LIBRARY) - + find_package_handle_standard_args(libbfd REQUIRED_VARS + LIBBFD_LIBRARY LIBBFD_INCLUDE_DIR + LIBDL_LIBRARY LIBDL_INCLUDE_DIR ${_name_mismatched_arg}) + mark_as_advanced(LIBBFD_INCLUDE_DIR LIBBFD_LIBRARY + LIBDL_INCLUDE_DIR LIBDL_LIBRARY) # find libdwarf find_path(LIBDWARF_INCLUDE_DIR NAMES "libdwarf.h" PATH_SUFFIXES libdwarf) find_path(LIBELF_INCLUDE_DIR NAMES "libelf.h") @@ -114,9 +120,14 @@ if (${STACK_DETAILS_AUTO_DETECT}) find_library(LIBDL_LIBRARY dl) set(LIBDWARF_INCLUDE_DIRS ${LIBDWARF_INCLUDE_DIR} ${LIBELF_INCLUDE_DIR} ${LIBDL_INCLUDE_DIR}) set(LIBDWARF_LIBRARIES ${LIBDWARF_LIBRARY} ${LIBELF_LIBRARY} ${LIBDL_LIBRARY}) - find_package_handle_standard_args(libdwarf DEFAULT_MSG LIBDWARF_LIBRARY LIBDWARF_INCLUDE_DIR LIBELF_LIBRARY LIBELF_INCLUDE_DIR LIBDL_LIBRARY LIBDL_INCLUDE_DIR) - mark_as_advanced(LIBDWARF_INCLUDE_DIR LIBDWARF_LIBRARY LIBELF_INCLUDE_DIR LIBELF_LIBRARY LIBDL_INCLUDE_DIR LIBDL_LIBRARY) - + find_package_handle_standard_args(libdwarf REQUIRED_VARS + LIBDWARF_LIBRARY LIBDWARF_INCLUDE_DIR + LIBELF_LIBRARY LIBELF_INCLUDE_DIR + LIBDL_LIBRARY LIBDL_INCLUDE_DIR ${_name_mismatched_arg}) + mark_as_advanced(LIBDWARF_INCLUDE_DIR LIBDWARF_LIBRARY + LIBELF_INCLUDE_DIR LIBELF_LIBRARY + LIBDL_INCLUDE_DIR LIBDL_LIBRARY) + if (LIBDW_FOUND) LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBDW_INCLUDE_DIRS}) LIST(APPEND _BACKWARD_LIBRARIES ${LIBDW_LIBRARIES}) @@ -168,7 +179,7 @@ endif() macro(map_definitions var_prefix define_prefix) foreach(def ${ARGN}) - if (${${var_prefix}${def}}) + if (${var_prefix}${def}) LIST(APPEND _BACKWARD_DEFINITIONS "${define_prefix}${def}=1") else() LIST(APPEND _BACKWARD_DEFINITIONS "${define_prefix}${def}=0") From 95dafcb413f2423f97b129129bd6dea27a9451e4 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Thu, 29 Apr 2021 11:16:05 +0200 Subject: [PATCH 05/10] SRSUE: fix NR carrier PCI in metrics --- srsue/src/phy/nr/worker_pool.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/srsue/src/phy/nr/worker_pool.cc b/srsue/src/phy/nr/worker_pool.cc index 115aff662..f4d66bc9f 100644 --- a/srsue/src/phy/nr/worker_pool.cc +++ b/srsue/src/phy/nr/worker_pool.cc @@ -130,6 +130,12 @@ bool worker_pool::set_config(const srsran::phy_cfg_nr_t& cfg) logger.info( "Setting new PHY configuration ARFCN=%d, PCI=%d", cfg.carrier.absolute_frequency_point_a, cfg.carrier.pci); + // Set carrier information + info_metrics_t info = {}; + info.pci = cfg.carrier.pci; + info.dl_earfcn = cfg.carrier.absolute_frequency_ssb; + phy_state.set_info_metrics(info); + // Best effort to convert NR carrier into LTE cell srsran_cell_t cell = {}; int ret = srsran_carrier_to_cell(&phy_state.cfg.carrier, &cell); From 526a076906836c99df4b9e9bad5266e843e4ae06 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 29 Apr 2021 15:16:19 +0200 Subject: [PATCH 06/10] readme: update CI banners --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 585bbd06c..7124140cd 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ srsRAN ====== -[![Build Status](https://travis-ci.org/srsRAN/srsRAN.svg?branch=master)](https://travis-ci.org/srsRAN/srsRAN) -[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/srsRAN/srsRAN.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/srsRAN/srsRAN/context:cpp) -[![Coverity](https://scan.coverity.com/projects/10045/badge.svg)](https://scan.coverity.com/projects/srsran) +[![Build Status](https://travis-ci.com/srsran/srsRAN.svg?branch=master)](https://travis-ci.com/srsran/srsRAN) +[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/srsran/srsRAN.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/srsran/srsRAN/context:cpp) +[![Coverity](https://scan.coverity.com/projects/23045/badge.svg)](https://scan.coverity.com/projects/srsran) srsRAN is a 4G/5G software radio suite developed by [SRS](http://www.srs.io). From ad1a0eb2accd037c4a7982c52bc6cdf74266e9fd Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 29 Apr 2021 11:59:55 +0100 Subject: [PATCH 07/10] rlc,fix - Add PDCP PDUs to undelivered_sdu_info_queue when the PDUs are popped from the tx_sdu_queue, rather than they are pushed to. - This simplifies the sdu discard - This also fixes an existing race condition --- lib/src/upper/rlc_am_lte.cc | 43 +++++++++++++++---------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index f2b10ed8d..b91fb0ef7 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -361,6 +361,9 @@ void rlc_am_lte::rlc_am_lte_tx::empty_queue() } // deallocate SDU that is currently processed + if (tx_sdu != nullptr) { + undelivered_sdu_info_queue.clear_pdcp_sdu(tx_sdu->md.pdcp_sn); + } tx_sdu.reset(); } @@ -504,15 +507,6 @@ int rlc_am_lte::rlc_am_lte_tx::write_sdu(unique_byte_buffer_t sdu) return SRSRAN_ERROR; } - if (undelivered_sdu_info_queue.has_pdcp_sn(sdu_pdcp_sn)) { - logger.warning("PDCP_SN=%d already marked as undelivered", sdu_pdcp_sn); - return SRSRAN_ERROR; - } - - // Store SDU info - logger.debug("Marking PDCP_SN=%d as undelivered (queue_len=%ld)", sdu_pdcp_sn, undelivered_sdu_info_queue.nof_sdus()); - - undelivered_sdu_info_queue.add_pdcp_sdu(sdu_pdcp_sn); return SRSRAN_SUCCESS; } @@ -532,13 +526,6 @@ void rlc_am_lte::rlc_am_lte_tx::discard_sdu(uint32_t discard_sn) // Discard fails when the PDCP PDU is already in Tx window. logger.info("%s PDU with PDCP_SN=%d", discarded ? "Discarding" : "Couldn't discard", discard_sn); - - // always try remove from undelivered SDUs queue - if (not undelivered_sdu_info_queue.has_pdcp_sn(discard_sn)) { - logger.info("PDCP SDU info does not exists for discarded SDU. PDCP_SN=%d", discard_sn); - } else { - undelivered_sdu_info_queue.clear_pdcp_sdu(discard_sn); - } } bool rlc_am_lte::rlc_am_lte_tx::sdu_queue_is_full() @@ -1075,7 +1062,6 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt do { tx_sdu = tx_sdu_queue.read(); } while (tx_sdu == nullptr && tx_sdu_queue.size() != 0); - if (tx_sdu == nullptr) { if (header.N_li > 0) { header.N_li--; @@ -1083,6 +1069,17 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt break; } + // store sdu info + if (undelivered_sdu_info_queue.has_pdcp_sn(tx_sdu->md.pdcp_sn)) { + logger.warning("PDCP_SN=%d already marked as undelivered", tx_sdu->md.pdcp_sn); + } else { + logger.debug("marking pdcp_sn=%d as undelivered (queue_len=%ld)", + tx_sdu->md.pdcp_sn, + undelivered_sdu_info_queue.nof_sdus()); + undelivered_sdu_info_queue.add_pdcp_sdu(tx_sdu->md.pdcp_sn); + } + pdcp_pdu_info& pdcp_pdu = undelivered_sdu_info_queue[tx_sdu->md.pdcp_sn]; + to_move = ((pdu_space - head_len) >= tx_sdu->N_bytes) ? tx_sdu->N_bytes : pdu_space - head_len; memcpy(pdu_ptr, tx_sdu->msg, to_move); last_li = to_move; @@ -1090,15 +1087,9 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt pdu->N_bytes += to_move; tx_sdu->N_bytes -= to_move; tx_sdu->msg += to_move; - if (undelivered_sdu_info_queue.has_pdcp_sn(tx_sdu->md.pdcp_sn)) { - pdcp_pdu_info& pdcp_pdu = undelivered_sdu_info_queue[tx_sdu->md.pdcp_sn]; - segment_pool.make_segment(tx_pdu, pdcp_pdu); - if (tx_sdu->N_bytes == 0) { - pdcp_pdu.fully_txed = true; - } - } else { - // PDCP SNs for the RLC SDU has been removed from the queue - logger.warning("Couldn't find PDCP_SN=%d in SDU info queue.", tx_sdu->md.pdcp_sn); + segment_pool.make_segment(tx_pdu, pdcp_pdu); + if (tx_sdu->N_bytes == 0) { + pdcp_pdu.fully_txed = true; } if (tx_sdu->N_bytes == 0) { From 5cecb40410ef90734770f2b5ab64a5be0376cf87 Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 29 Apr 2021 12:01:45 +0100 Subject: [PATCH 08/10] rlc,bugfix - increase pdcp sn notification ack list maximum size --- lib/include/srsran/interfaces/pdcp_interface_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/include/srsran/interfaces/pdcp_interface_types.h b/lib/include/srsran/interfaces/pdcp_interface_types.h index f51e232a4..15ba28a54 100644 --- a/lib/include/srsran/interfaces/pdcp_interface_types.h +++ b/lib/include/srsran/interfaces/pdcp_interface_types.h @@ -175,7 +175,7 @@ struct pdcp_lte_state_t { // Custom type for interface between PDCP and RLC to convey SDU delivery status // Arbitrarily chosen limit, optimal value depends on the RLC (pollPDU) and PDCP config, channel BLER, // traffic characterisitcs, etc. The chosen value has been tested with 100 PRB bi-dir TCP -#define MAX_SDUS_TO_NOTIFY (1024) +#define MAX_SDUS_TO_NOTIFY (4096) typedef srsran::bounded_vector pdcp_sn_vector_t; } // namespace srsran From b9be7c7594138f701c0b6a4ea7afee36d982180a Mon Sep 17 00:00:00 2001 From: faluco Date: Thu, 29 Apr 2021 12:54:35 +0200 Subject: [PATCH 09/10] Small cleanup in the stdout UE metrics. - Switch to use fmt for formatting the output. - Change the CC column to be rat now. - Reworked and re-styled the column alignment. --- srsue/hdr/metrics_stdout.h | 3 +- srsue/src/metrics_stdout.cc | 82 ++++++++++++++++++++----------------- 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/srsue/hdr/metrics_stdout.h b/srsue/hdr/metrics_stdout.h index ecf58cdc2..70383a75f 100644 --- a/srsue/hdr/metrics_stdout.h +++ b/srsue/hdr/metrics_stdout.h @@ -43,7 +43,8 @@ private: const mac_metrics_t mac[SRSRAN_MAX_CARRIERS], const rrc_metrics_t& rrc, bool display_neighbours, - const uint32_t r); + const uint32_t r, + bool is_nr); std::string float_to_string(float f, int digits); std::string float_to_eng_string(float f, int digits); void print_table(const bool display_neighbours); diff --git a/srsue/src/metrics_stdout.cc b/srsue/src/metrics_stdout.cc index 3c555e2b8..0098f9ba1 100644 --- a/srsue/src/metrics_stdout.cc +++ b/srsue/src/metrics_stdout.cc @@ -64,13 +64,11 @@ void metrics_stdout::toggle_print(bool b) void metrics_stdout::print_table(const bool display_neighbours) { if (display_neighbours) { - cout << "--------Signal-------------Neighbour--DL-------------------------------------UL----------------------" - << endl; - cout << "cc pci rsrp pl cfo pci rsrp mcs snr turbo brate bler ta_us mcs buff brate bler" - << endl; + fmt::print("---------Signal----------|-Neighbour-|-----------------DL-----------------|-----------UL-----------\n"); + fmt::print("rat pci rsrp pl cfo | pci rsrp | mcs snr iter brate bler ta_us | mcs buff brate bler\n"); } else { - cout << "--------Signal--------------DL-------------------------------------UL----------------------" << endl; - cout << "cc pci rsrp pl cfo mcs snr turbo brate bler ta_us mcs buff brate bler" << endl; + fmt::print("---------Signal----------|-----------------DL-----------------|-----------UL-----------\n"); + fmt::print("rat pci rsrp pl cfo | mcs snr iter brate bler ta_us | mcs buff brate bler\n"); } table_has_neighbours = display_neighbours; n_reports = 0; @@ -80,56 +78,66 @@ void metrics_stdout::set_metrics_helper(const phy_metrics_t& phy, const mac_metrics_t mac[SRSRAN_MAX_CARRIERS], const rrc_metrics_t& rrc, bool display_neighbours, - const uint32_t r) + const uint32_t r, + bool is_nr) { + fmt::print("{:>3.3}", is_nr ? "nr" : "lte"); + if (phy.info[r].pci != UINT32_MAX) { - cout << std::setw(4) << phy.info[r].pci << std::setw(0); + fmt::print(" {:>3}", phy.info[r].pci); } else { - cout << " n/a"; + fmt::print(" {:>3.3}", "n/a"); } - cout << float_to_string(phy.ch[r].rsrp, 2); - cout << float_to_string(phy.ch[r].pathloss, 2); - cout << float_to_eng_string(phy.sync[r].cfo, 2); + + fmt::print(" {:>4}", int(phy.ch[r].rsrp)); + fmt::print(" {:>2}", int(phy.ch[r].pathloss)); + fmt::print(" {:>5.5}", float_to_eng_string(phy.sync[r].cfo, 2)); // Find strongest neighbour for this EARFCN (cells are ordered) if (display_neighbours) { bool has_neighbour = false; + fmt::print(" |"); for (auto& c : rrc.neighbour_cells) { if (c.earfcn == phy.info[r].dl_earfcn && c.pci != phy.info[r].pci) { - cout << std::setw(4) << c.pci << std::setw(0); - cout << float_to_string(c.rsrp, 2); + fmt::print(" {:>3}", c.pci); + fmt::print(" {:>4}", int(c.rsrp)); has_neighbour = true; break; } } if (!has_neighbour) { - cout << " n/a"; - cout << " n/a"; + fmt::print(" {:>3.3}", "n/a"); + fmt::print(" {:>4.4}", "n/a"); } } - cout << float_to_string(phy.dl[r].mcs, 2); - cout << float_to_string(phy.ch[r].sinr, 2); - cout << float_to_string(phy.dl[r].fec_iters, 2); + fmt::print(" |"); + + fmt::print(" {:>2}", int(phy.dl[r].mcs)); + fmt::print(" {:>3}", int(phy.ch[r].sinr)); + fmt::print(" {:>4.1f}", phy.dl[r].fec_iters); - cout << float_to_eng_string((float)mac[r].rx_brate / (mac[r].nof_tti * 1e-3), 2); + fmt::print(" {:>6.6}", float_to_eng_string((float)mac[r].rx_brate / (mac[r].nof_tti * 1e-3), 2)); if (mac[r].rx_pkts > 0) { - cout << float_to_string((float)100 * mac[r].rx_errors / mac[r].rx_pkts, 1) << "%"; + fmt::print(" {:>3}%", int((float)100 * mac[r].rx_errors / mac[r].rx_pkts)); } else { - cout << float_to_string(0, 1) << "%"; + fmt::print(" {:>3}%", 0); } - cout << float_to_string(phy.sync[r].ta_us, 2); + fmt::print(" {:>4.1f}", phy.sync[r].ta_us); + + fmt::print(" |"); + + fmt::print(" {:>2}", int(phy.ul[r].mcs)); + fmt::print(" {:>6.6}", float_to_eng_string((float)mac[r].ul_buffer, 2)); + fmt::print(" {:>6.6}", float_to_eng_string((float)mac[r].tx_brate / (mac[r].nof_tti * 1e-3), 2)); - cout << float_to_string(phy.ul[r].mcs, 2); - cout << float_to_eng_string((float)mac[r].ul_buffer, 2); - cout << float_to_eng_string((float)mac[r].tx_brate / (mac[r].nof_tti * 1e-3), 2); if (mac[r].tx_pkts > 0) { - cout << float_to_string((float)100 * mac[r].tx_errors / mac[r].tx_pkts, 1) << "%"; + fmt::print(" {:>3}%", int((float)100 * mac[r].tx_errors / mac[r].tx_pkts)); } else { - cout << float_to_string(0, 1) << "%"; + fmt::print(" {:>3}%", 0); } - cout << endl; + fmt::print("\n"); } void metrics_stdout::set_metrics(const ue_metrics_t& metrics, const uint32_t period_usec) @@ -140,7 +148,7 @@ void metrics_stdout::set_metrics(const ue_metrics_t& metrics, const uint32_t per // always print RF error if (metrics.rf.rf_error) { - printf("RF status: O=%d, U=%d, L=%d\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l); + fmt::print("RF status: O={}, U={}, L={}\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l); } if (!do_print) { @@ -148,7 +156,7 @@ void metrics_stdout::set_metrics(const ue_metrics_t& metrics, const uint32_t per } if (metrics.stack.rrc.state != RRC_STATE_CONNECTED) { - cout << "--- disconnected ---" << endl; + fmt::print("--- disconnected ---\n"); return; } @@ -170,18 +178,16 @@ void metrics_stdout::set_metrics(const ue_metrics_t& metrics, const uint32_t per } for (uint32_t r = 0; r < metrics.phy.nof_active_cc; r++) { - cout << std::setw(2) << r; - set_metrics_helper(metrics.phy, metrics.stack.mac, metrics.stack.rrc, display_neighbours, r); + set_metrics_helper(metrics.phy, metrics.stack.mac, metrics.stack.rrc, display_neighbours, r, false); } for (uint32_t r = 0; r < metrics.phy_nr.nof_active_cc; r++) { // Assumption LTE is followed by the NR carriers. - cout << std::setw(2) << metrics.phy_nr.nof_active_cc + r; - set_metrics_helper(metrics.phy_nr, metrics.stack.mac_nr, metrics.stack.rrc, display_neighbours, r); + set_metrics_helper(metrics.phy_nr, metrics.stack.mac_nr, metrics.stack.rrc, display_neighbours, r, true); } if (metrics.rf.rf_error) { - printf("RF status: O=%d, U=%d, L=%d\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l); + fmt::print("RF status: O={}, U={}, L={}\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l); } } @@ -190,7 +196,7 @@ std::string metrics_stdout::float_to_string(float f, int digits) std::ostringstream os; const int precision = SRSRAN_MIN((int)((f == 0.0f || f == 100.0f) ? digits - 1 : digits - log10f(fabsf(f)) - 2 * FLT_EPSILON), 3); - os << std::setw(6) << std::fixed << std::setprecision(precision) << f; + os << std::fixed << std::setprecision(precision) << f; return os.str(); } @@ -213,7 +219,7 @@ std::string metrics_stdout::float_to_eng_string(float f, int digits) if (degree != 0) { return float_to_string(scaled, digits) + factor; } else { - return " " + float_to_string(scaled, digits) + factor; + return float_to_string(scaled, digits) + factor; } } From 90e23d9de65ee40c1b74925d0db6afb216907f73 Mon Sep 17 00:00:00 2001 From: faluco Date: Thu, 29 Apr 2021 17:03:01 +0200 Subject: [PATCH 10/10] Print in the ue stdout metrics the CC number for LTE and the RAT for NR. --- srsue/hdr/metrics_stdout.h | 5 +++-- srsue/src/metrics_stdout.cc | 45 +++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/srsue/hdr/metrics_stdout.h b/srsue/hdr/metrics_stdout.h index 70383a75f..727461587 100644 --- a/srsue/hdr/metrics_stdout.h +++ b/srsue/hdr/metrics_stdout.h @@ -44,10 +44,11 @@ private: const rrc_metrics_t& rrc, bool display_neighbours, const uint32_t r, - bool is_nr); + bool is_carrier_nr, + bool print_carrier_num); std::string float_to_string(float f, int digits); std::string float_to_eng_string(float f, int digits); - void print_table(const bool display_neighbours); + void print_table(const bool display_neighbours, const bool is_nr); bool do_print = false; bool table_has_neighbours = false; ///< state of last table head diff --git a/srsue/src/metrics_stdout.cc b/srsue/src/metrics_stdout.cc index 0098f9ba1..43ec1f55b 100644 --- a/srsue/src/metrics_stdout.cc +++ b/srsue/src/metrics_stdout.cc @@ -61,14 +61,28 @@ void metrics_stdout::toggle_print(bool b) do_print = b; } -void metrics_stdout::print_table(const bool display_neighbours) +void metrics_stdout::print_table(const bool display_neighbours, const bool is_nr) { - if (display_neighbours) { - fmt::print("---------Signal----------|-Neighbour-|-----------------DL-----------------|-----------UL-----------\n"); - fmt::print("rat pci rsrp pl cfo | pci rsrp | mcs snr iter brate bler ta_us | mcs buff brate bler\n"); + if (is_nr) { + if (display_neighbours) { + fmt::print( + "---------Signal----------|-Neighbour-|-----------------DL-----------------|-----------UL-----------\n"); + fmt::print( + "rat pci rsrp pl cfo | pci rsrp | mcs snr iter brate bler ta_us | mcs buff brate bler\n"); + } else { + fmt::print("---------Signal----------|-----------------DL-----------------|-----------UL-----------\n"); + fmt::print("rat pci rsrp pl cfo | mcs snr iter brate bler ta_us | mcs buff brate bler\n"); + } } else { - fmt::print("---------Signal----------|-----------------DL-----------------|-----------UL-----------\n"); - fmt::print("rat pci rsrp pl cfo | mcs snr iter brate bler ta_us | mcs buff brate bler\n"); + if (display_neighbours) { + fmt::print( + "---------Signal----------|-Neighbour-|-----------------DL-----------------|-----------UL-----------\n"); + fmt::print( + " cc pci rsrp pl cfo | pci rsrp | mcs snr iter brate bler ta_us | mcs buff brate bler\n"); + } else { + fmt::print("---------Signal----------|-----------------DL-----------------|-----------UL-----------\n"); + fmt::print(" cc pci rsrp pl cfo | mcs snr iter brate bler ta_us | mcs buff brate bler\n"); + } } table_has_neighbours = display_neighbours; n_reports = 0; @@ -79,9 +93,14 @@ void metrics_stdout::set_metrics_helper(const phy_metrics_t& phy, const rrc_metrics_t& rrc, bool display_neighbours, const uint32_t r, - bool is_nr) + bool is_carrier_nr, + bool print_carrier_num) { - fmt::print("{:>3.3}", is_nr ? "nr" : "lte"); + if (print_carrier_num) { + fmt::print("{:>3}", r); + } else { + fmt::print("{:>3.3}", (is_carrier_nr) ? "nr" : "lte"); + } if (phy.info[r].pci != UINT32_MAX) { fmt::print(" {:>3}", phy.info[r].pci); @@ -167,23 +186,25 @@ void metrics_stdout::set_metrics(const ue_metrics_t& metrics, const uint32_t per display_neighbours |= metrics.stack.rrc.neighbour_cells.size() > 0; } + bool is_nr = metrics.phy_nr.nof_active_cc > 0; + // print table header every 10 reports if (++n_reports > 10) { - print_table(display_neighbours); + print_table(display_neighbours, is_nr); } // also print table header if neighbours are added/removed in between if (display_neighbours != table_has_neighbours) { - print_table(display_neighbours); + print_table(display_neighbours, is_nr); } for (uint32_t r = 0; r < metrics.phy.nof_active_cc; r++) { - set_metrics_helper(metrics.phy, metrics.stack.mac, metrics.stack.rrc, display_neighbours, r, false); + set_metrics_helper(metrics.phy, metrics.stack.mac, metrics.stack.rrc, display_neighbours, r, false, !is_nr); } for (uint32_t r = 0; r < metrics.phy_nr.nof_active_cc; r++) { // Assumption LTE is followed by the NR carriers. - set_metrics_helper(metrics.phy_nr, metrics.stack.mac_nr, metrics.stack.rrc, display_neighbours, r, true); + set_metrics_helper(metrics.phy_nr, metrics.stack.mac_nr, metrics.stack.rrc, display_neighbours, r, true, !is_nr); } if (metrics.rf.rf_error) {