diff --git a/.gitlab/ci-shared/e2e.yml b/.gitlab/ci-shared/e2e.yml index 57e53d712e..f8e511161b 100644 --- a/.gitlab/ci-shared/e2e.yml +++ b/.gitlab/ci-shared/e2e.yml @@ -70,11 +70,11 @@ variables: ARTIFACT_COMPRESSION_LEVEL: slowest RUNNER_AFTER_SCRIPT_TIMEOUT: 1m KUBERNETES_CPU_REQUEST: 1 - KUBERNETES_CPU_LIMIT: 1 + KUBERNETES_CPU_LIMIT: 2 KUBERNETES_MEMORY_REQUEST: 2Gi KUBERNETES_MEMORY_LIMIT: 2Gi - KUBERNETES_EPHEMERAL_STORAGE_REQUEST: "10G" - KUBERNETES_EPHEMERAL_STORAGE_LIMIT: "10G" + KUBERNETES_EPHEMERAL_STORAGE_REQUEST: "20G" + KUBERNETES_EPHEMERAL_STORAGE_LIMIT: "20G" <<: *setup_kube_variables GROUP: zmq tags: diff --git a/.gitlab/ci/e2e.yml b/.gitlab/ci/e2e.yml index ceb171cd0a..561a6544f8 100644 --- a/.gitlab/ci/e2e.yml +++ b/.gitlab/ci/e2e.yml @@ -268,7 +268,7 @@ amari 32UE 2x2 mimo: cudu amari 8UE: extends: .zmq - timeout: 1h + timeout: 2h variables: TESTBED: zmq_cudu MARKERS: "zmq and not smoke" @@ -279,7 +279,7 @@ cudu amari 8UE: cudu amari 32UE: extends: .zmq - timeout: 1h + timeout: 2h variables: TESTBED: zmq_cudu MARKERS: "zmq and not smoke" @@ -290,7 +290,7 @@ cudu amari 32UE: cudu amari 64UE: extends: .zmq - timeout: 2h + timeout: 3h variables: TESTBED: zmq_cudu MARKERS: "zmq and not smoke" @@ -473,7 +473,7 @@ android x300: artifacts: true - *retina-needs -android x300 drx: +android drx: stage: rf extends: .e2e-run allow_failure: true diff --git a/.gitlab/ci/e2e/.env b/.gitlab/ci/e2e/.env index d08a36cb8f..bb6906acae 100644 --- a/.gitlab/ci/e2e/.env +++ b/.gitlab/ci/e2e/.env @@ -1,6 +1,6 @@ SRSGNB_REGISTRY_URI=registry.gitlab.com/softwareradiosystems/srsgnb RETINA_REGISTRY_PREFIX=registry.gitlab.com/softwareradiosystems/ci/retina -RETINA_VERSION=0.59.0 +RETINA_VERSION=0.59.2 UBUNTU_VERSION=24.04 AMARISOFT_VERSION=2023-09-08 SRSUE_VERSION=23.11 diff --git a/.gitlab/ci/e2e/retina_request_rf_b200.yml b/.gitlab/ci/e2e/retina_request_rf_b200.yml index bd353901c4..8d3adbce40 100644 --- a/.gitlab/ci/e2e/retina_request_rf_b200.yml +++ b/.gitlab/ci/e2e/retina_request_rf_b200.yml @@ -9,7 +9,7 @@ - name: amarisoft-ue type: ue image: ${RETINA_REGISTRY_PREFIX}/amarisoftue:${AMARISOFT_VERSION}_${RETINA_VERSION} - labels: ["kubernetes.io/hostname=hp-oran"] + labels: ["kubernetes.io/hostname=ci-buildmaster"] nof_ports: 4 requirements: arch: amd64 @@ -17,8 +17,8 @@ requests: 12 limits: 12 memory: - requests: "48G" - limits: "48G" + requests: "20G" + limits: "20G" ephemeral-storage: requests: "6G" limits: "6G" diff --git a/.gitlab/run_viavi_pipeline.py b/.gitlab/run_viavi_pipeline.py index 4d257b59ef..22f0cb702e 100755 --- a/.gitlab/run_viavi_pipeline.py +++ b/.gitlab/run_viavi_pipeline.py @@ -134,6 +134,8 @@ def run_test(args_definition: _ArgsDefinition, test_definition: _TestDefinition) {"key": "TEST_MODE", "value": TESTMODE}, {"key": "BUILD_ARGS", "value": BUILD_ARGS}, {"key": "MAKE_ARGS", "value": MAKE_ARGS}, + {"key": "SRS_TARGET", "value": "gnb_split_7_2"}, + {"key": "PLUGIN_BRANCH", "value": "main"}, {"key": "UHD_VERSION", "value": ""}, {"key": "DPDK_VERSION", "value": DPDK_VERSION}, {"key": "TESTBED", "value": TESTBED}, diff --git a/apps/gnb/gnb.cpp b/apps/gnb/gnb.cpp index 7f8180b184..84d8e45499 100644 --- a/apps/gnb/gnb.cpp +++ b/apps/gnb/gnb.cpp @@ -53,7 +53,6 @@ #include "srsran/support/backtrace.h" #include "srsran/support/config_parsers.h" #include "srsran/support/cpu_features.h" -#include "srsran/support/dynlink_manager.h" #include "srsran/support/io/io_broker_factory.h" #include "srsran/support/signal_handling.h" #include "srsran/support/tracing/event_tracing.h" diff --git a/apps/units/flexible_o_du/o_du_high/CMakeLists.txt b/apps/units/flexible_o_du/o_du_high/CMakeLists.txt index ee266d87b1..d7e72d92c4 100644 --- a/apps/units/flexible_o_du/o_du_high/CMakeLists.txt +++ b/apps/units/flexible_o_du/o_du_high/CMakeLists.txt @@ -24,4 +24,8 @@ add_subdirectory(fapi) add_library(srsran_o_du_high_unit_helpers STATIC o_du_high_unit_factory.cpp) target_include_directories(srsran_o_du_high_unit_helpers PRIVATE ${CMAKE_SOURCE_DIR}) -target_link_libraries(srsran_o_du_high_unit_helpers PRIVATE srsran_du_high_unit_helpers srsran_fapi_app_unit srsran_o_du_high_app_unit_e2) +target_link_libraries(srsran_o_du_high_unit_helpers PRIVATE + srsran_du_high_unit_helpers + srsran_fapi_app_unit + srsran_o_du_high_app_unit_e2 + srsran_o_du_high) diff --git a/apps/units/flexible_o_du/o_du_low/CMakeLists.txt b/apps/units/flexible_o_du/o_du_low/CMakeLists.txt index 5471b88742..c70a2b19ba 100644 --- a/apps/units/flexible_o_du/o_du_low/CMakeLists.txt +++ b/apps/units/flexible_o_du/o_du_low/CMakeLists.txt @@ -28,7 +28,7 @@ set(SOURCES add_library(srsran_o_du_low_unit_helpers STATIC ${SOURCES}) target_include_directories(srsran_o_du_low_unit_helpers PRIVATE ${CMAKE_SOURCE_DIR}) -set(DU_LOW_UNIT_HELPERS_LIBRARIES srsran_upper_phy srsran_cpu_affinities_helper) +set(DU_LOW_UNIT_HELPERS_LIBRARIES srsran_upper_phy srsran_cpu_affinities_helper srsran_o_du_low) # Hardware acceleration for both PUSCH and PDSCH is enabled by default when using DPDK. if (DPDK_FOUND) diff --git a/apps/units/flexible_o_du/split_6/split6_o_du_impl.cpp b/apps/units/flexible_o_du/split_6/split6_o_du_impl.cpp index d40a459da2..71ab8bb280 100644 --- a/apps/units/flexible_o_du/split_6/split6_o_du_impl.cpp +++ b/apps/units/flexible_o_du/split_6/split6_o_du_impl.cpp @@ -21,6 +21,8 @@ */ #include "split6_o_du_impl.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_adaptor.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_sector_adaptor.h" #include "srsran/support/srsran_assert.h" using namespace srsran; @@ -32,15 +34,15 @@ split6_o_du_impl::split6_o_du_impl(std::vectorget_mac_fapi_adaptor().get_sector_adaptor(i); + adaptors[i]->get_message_interface_collection().set_slot_data_message_notifier( - odu_hi->get_slot_data_message_notifier(i)); + fapi_sector.get_slot_data_message_notifier()); adaptors[i]->get_message_interface_collection().set_slot_error_message_notifier( - odu_hi->get_slot_error_message_notifier(i)); + fapi_sector.get_slot_error_message_notifier()); adaptors[i]->get_message_interface_collection().set_slot_time_message_notifier( - odu_hi->get_slot_time_message_notifier(i)); + fapi_sector.get_slot_time_message_notifier()); } } diff --git a/apps/units/flexible_o_du/split_helpers/flexible_o_du_factory.cpp b/apps/units/flexible_o_du/split_helpers/flexible_o_du_factory.cpp index e7897a0c3b..3e2f3a6a4b 100644 --- a/apps/units/flexible_o_du/split_helpers/flexible_o_du_factory.cpp +++ b/apps/units/flexible_o_du/split_helpers/flexible_o_du_factory.cpp @@ -30,6 +30,10 @@ #include "flexible_o_du_impl.h" #include "srsran/du/o_du_factory.h" #include "srsran/e2/e2_du_metrics_connector.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_adaptor.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_sector_adaptor.h" +#include "srsran/fapi_adaptor/phy/phy_fapi_adaptor.h" +#include "srsran/fapi_adaptor/phy/phy_fapi_sector_adaptor.h" using namespace srsran; @@ -74,16 +78,29 @@ o_du_unit flexible_o_du_factory::create_flexible_o_du(const o_du_unit_dependenci // Adjust the dependencies. for (unsigned i = 0, e = du_cells.size(); i != e; ++i) { - auto& sector_dependencies = odu_hi_unit_dependencies.o_du_hi_dependencies.sectors.emplace_back(); - sector_dependencies.gateway = &odu_lo_unit.o_du_lo->get_slot_message_gateway(i); - sector_dependencies.last_msg_notifier = &odu_lo_unit.o_du_lo->get_slot_last_message_notifier(i); - sector_dependencies.fapi_executor = config.odu_high_cfg.fapi_cfg.l2_nof_slots_ahead != 0 - ? std::optional(dependencies.workers->fapi_exec[i]) - : std::make_optional(); + auto& sector_dependencies = odu_hi_unit_dependencies.o_du_hi_dependencies.sectors.emplace_back(); + sector_dependencies.gateway = + &odu_lo_unit.o_du_lo->get_phy_fapi_adaptor().get_sector_adaptor(i).get_slot_message_gateway(); + sector_dependencies.last_msg_notifier = + &odu_lo_unit.o_du_lo->get_phy_fapi_adaptor().get_sector_adaptor(i).get_slot_last_message_notifier(); + sector_dependencies.fapi_executor = config.odu_high_cfg.fapi_cfg.l2_nof_slots_ahead != 0 + ? std::optional(dependencies.workers->fapi_exec[i]) + : std::make_optional(); } o_du_high_unit odu_hi_unit = make_o_du_high_unit(config.odu_high_cfg, std::move(odu_hi_unit_dependencies)); + // Connect the adaptors. + for (unsigned i = 0, e = du_cells.size(); i != e; ++i) { + fapi_adaptor::phy_fapi_sector_adaptor& odu_lo = odu_lo_unit.o_du_lo->get_phy_fapi_adaptor().get_sector_adaptor(i); + fapi_adaptor::mac_fapi_sector_adaptor& odu_hi = odu_hi_unit.o_du_hi->get_mac_fapi_adaptor().get_sector_adaptor(i); + + // Connect O-DU low with O-DU high. + odu_lo.set_slot_time_message_notifier(odu_hi.get_slot_time_message_notifier()); + odu_lo.set_slot_error_message_notifier(odu_hi.get_slot_error_message_notifier()); + odu_lo.set_slot_data_message_notifier(odu_hi.get_slot_data_message_notifier()); + } + o_du.metrics = std::move(odu_hi_unit.metrics); o_du.commands = std::move(odu_hi_unit.commands); diff --git a/apps/units/flexible_o_du/split_helpers/flexible_o_du_impl.cpp b/apps/units/flexible_o_du/split_helpers/flexible_o_du_impl.cpp index 66107ee86a..bbf16486c4 100644 --- a/apps/units/flexible_o_du/split_helpers/flexible_o_du_impl.cpp +++ b/apps/units/flexible_o_du/split_helpers/flexible_o_du_impl.cpp @@ -30,8 +30,8 @@ using namespace srsran; -flexible_o_du_impl::flexible_o_du_impl(unsigned nof_cells) : - ru_ul_adapt(nof_cells), ru_timing_adapt(nof_cells), ru_error_adapt(nof_cells) +flexible_o_du_impl::flexible_o_du_impl(unsigned nof_cells_) : + nof_cells(nof_cells_), ru_ul_adapt(nof_cells_), ru_timing_adapt(nof_cells_), ru_error_adapt(nof_cells_) { } @@ -63,11 +63,11 @@ void flexible_o_du_impl::add_du(std::unique_ptr active_du) srsran_assert(du, "Cannot set an invalid DU"); // Connect all the sectors of the DU low to the RU adaptors. - span upper_ptrs = du->get_o_du_low().get_du_low().get_all_upper_phys(); - for (auto* upper : upper_ptrs) { + for (unsigned i = 0; i != nof_cells; ++i) { + auto& upper = du->get_o_du_low().get_du_low().get_upper_phy(i); // Make connections between DU and RU. - ru_ul_adapt.map_handler(upper->get_sector_id(), upper->get_rx_symbol_handler()); - ru_timing_adapt.map_handler(upper->get_sector_id(), upper->get_timing_handler()); - ru_error_adapt.map_handler(upper->get_sector_id(), upper->get_error_handler()); + ru_ul_adapt.map_handler(i, upper.get_rx_symbol_handler()); + ru_timing_adapt.map_handler(i, upper.get_timing_handler()); + ru_error_adapt.map_handler(i, upper.get_error_handler()); } } diff --git a/apps/units/flexible_o_du/split_helpers/flexible_o_du_impl.h b/apps/units/flexible_o_du/split_helpers/flexible_o_du_impl.h index 8d23a67e0d..ca9df37eb5 100644 --- a/apps/units/flexible_o_du/split_helpers/flexible_o_du_impl.h +++ b/apps/units/flexible_o_du/split_helpers/flexible_o_du_impl.h @@ -38,7 +38,7 @@ class radio_unit; class flexible_o_du_impl : public srs_du::du, public du_power_controller { public: - explicit flexible_o_du_impl(unsigned nof_cells); + explicit flexible_o_du_impl(unsigned nof_cells_); // See interface for documentation. du_power_controller& get_power_controller() override { return *this; } @@ -63,6 +63,7 @@ class flexible_o_du_impl : public srs_du::du, public du_power_controller upper_phy_ru_ul_request_adapter& get_upper_ru_ul_request_adapter() { return ru_ul_request_adapt; } private: + const unsigned nof_cells; upper_phy_ru_ul_adapter ru_ul_adapt; upper_phy_ru_timing_adapter ru_timing_adapt; upper_phy_ru_error_adapter ru_error_adapt; diff --git a/external/fmt/include/fmt/format.h b/external/fmt/include/fmt/format.h index 67f0ab739b..dd4945973b 100644 --- a/external/fmt/include/fmt/format.h +++ b/external/fmt/include/fmt/format.h @@ -673,6 +673,8 @@ FMT_CONSTEXPR void for_each_codepoint(string_view s, F f) { } } if (auto num_chars_left = s.data() + s.size() - p) { + // Suppress bogus -Wstringop-overflow. + if (FMT_GCC_VERSION) num_chars_left &= 3; char buf[2 * block_size - 1] = {}; copy(p, p + num_chars_left, buf); const char* buf_ptr = buf; diff --git a/include/srsran/cu_cp/cu_cp_types.h b/include/srsran/cu_cp/cu_cp_types.h index de060b9cc2..19b17e8d8f 100644 --- a/include/srsran/cu_cp/cu_cp_types.h +++ b/include/srsran/cu_cp/cu_cp_types.h @@ -29,6 +29,7 @@ #include "srsran/ran/cause/ngap_cause.h" #include "srsran/ran/crit_diagnostics.h" #include "srsran/ran/cu_types.h" +#include "srsran/ran/gnb_constants.h" #include "srsran/ran/gnb_id.h" #include "srsran/ran/nr_cgi.h" #include "srsran/ran/pci.h" @@ -38,7 +39,6 @@ #include "srsran/ran/tac.h" #include "srsran/ran/up_transport_layer_info.h" #include -#include #include #include #include @@ -49,7 +49,7 @@ namespace srs_cu_cp { /// Maximum number of DUs supported by CU-CP (implementation-defined). const uint16_t MAX_NOF_DUS = 65535; /// Maximum number of cells per DU supported by CU-CP (implementation-defined). -const uint16_t MAX_NOF_DU_CELLS = 16; +const uint16_t MAX_NOF_DU_CELLS = MAX_CELLS_PER_DU; /// Maximum number of CU-UPs supported by CU-CP (implementation-defined). const uint16_t MAX_NOF_CU_UPS = 65535; /// Maximum number of UEs supported by CU-CP (implementation-defined). diff --git a/include/srsran/cu_cp/up_context.h b/include/srsran/cu_cp/up_context.h index c2152ead27..66c4b120b1 100644 --- a/include/srsran/cu_cp/up_context.h +++ b/include/srsran/cu_cp/up_context.h @@ -25,6 +25,7 @@ #include "srsran/cu_cp/cu_cp_types.h" #include "srsran/ran/rb_id.h" #include "srsran/rlc/rlc_config.h" +#include namespace srsran { diff --git a/include/srsran/du/du_high/o_du_high.h b/include/srsran/du/du_high/o_du_high.h index a07d67c44c..9991644303 100644 --- a/include/srsran/du/du_high/o_du_high.h +++ b/include/srsran/du/du_high/o_du_high.h @@ -26,11 +26,9 @@ namespace srsran { class du_power_controller; -namespace fapi { -class slot_data_message_notifier; -class slot_error_message_notifier; -class slot_time_message_notifier; -} // namespace fapi +namespace fapi_adaptor { +class mac_fapi_adaptor; +} // namespace fapi_adaptor namespace srs_du { @@ -48,14 +46,8 @@ class o_du_high /// Returns the DU high from this O-RAN DU high. virtual du_high& get_du_high() = 0; - /// Returns the FAPI slot data message notifier for the given cell of this O-RAN DU high. - virtual fapi::slot_data_message_notifier& get_slot_data_message_notifier(unsigned cell_id) = 0; - - /// Returns the FAPI slot error message notifier for the given cell of this O-RAN DU high. - virtual fapi::slot_error_message_notifier& get_slot_error_message_notifier(unsigned cell_id) = 0; - - /// Returns the FAPI slot time message notifier for the given cell of this O-RAN DU high. - virtual fapi::slot_time_message_notifier& get_slot_time_message_notifier(unsigned cell_id) = 0; + /// Returns the MAC-FAPI adaptor of this O-RAN DU high. + virtual fapi_adaptor::mac_fapi_adaptor& get_mac_fapi_adaptor() = 0; }; } // namespace srs_du diff --git a/include/srsran/du/du_low/du_low.h b/include/srsran/du/du_low/du_low.h index b28441f08f..bff0c2ac2e 100644 --- a/include/srsran/du/du_low/du_low.h +++ b/include/srsran/du/du_low/du_low.h @@ -43,9 +43,6 @@ class du_low /// Returns the upper PHY for the given cell of this DU low. virtual upper_phy& get_upper_phy(unsigned cell_id) = 0; - - /// Returns a span of the upper PHYs managed by this DU low. - virtual span get_all_upper_phys() = 0; }; } // namespace srs_du diff --git a/include/srsran/du/du_low/o_du_low.h b/include/srsran/du/du_low/o_du_low.h index bffa89e130..4cceb9101b 100644 --- a/include/srsran/du/du_low/o_du_low.h +++ b/include/srsran/du/du_low/o_du_low.h @@ -24,13 +24,9 @@ namespace srsran { -namespace fapi { -class slot_data_message_notifier; -class slot_error_message_notifier; -class slot_last_message_notifier; -class slot_message_gateway; -class slot_time_message_notifier; -} // namespace fapi +namespace fapi_adaptor { +class phy_fapi_adaptor; +} namespace srs_du { @@ -43,26 +39,11 @@ class o_du_low /// Default destructor. virtual ~o_du_low() = default; - /// Returns the upper PHY of this DU low. + /// Returns the upper PHY of this O-DU low. virtual du_low& get_du_low() = 0; - /// Returns a reference to the FAPI slot-based message gateway for the given cell of this O-RAN DU low. - virtual fapi::slot_message_gateway& get_slot_message_gateway(unsigned cell_id) = 0; - - /// Returns a reference to the FAPI slot-based last message notifier for the given cell of this O-RAN DU low. - virtual fapi::slot_last_message_notifier& get_slot_last_message_notifier(unsigned cell_id) = 0; - - /// Configures the FAPI slot-based, time-specific message notifier for the given cell to the given one. - virtual void set_slot_time_message_notifier(unsigned cell_id, - fapi::slot_time_message_notifier& fapi_time_notifier) = 0; - - /// Configures the FAPI slot-based, error-specific message notifier for the given cell to the given one. - virtual void set_slot_error_message_notifier(unsigned cell_id, - fapi::slot_error_message_notifier& fapi_error_notifier) = 0; - - /// Configures the FAPI slot-based, data-specific message notifier for the given cell to the given one. - virtual void set_slot_data_message_notifier(unsigned cell_id, - fapi::slot_data_message_notifier& fapi_data_notifier) = 0; + /// Returns the PHY–FAPI adaptor of this O-DU low. + virtual fapi_adaptor::phy_fapi_adaptor& get_phy_fapi_adaptor() = 0; }; } // namespace srs_du diff --git a/include/srsran/du/o_du_factory.h b/include/srsran/du/o_du_factory.h index b7ac8e3329..1e140054f3 100644 --- a/include/srsran/du/o_du_factory.h +++ b/include/srsran/du/o_du_factory.h @@ -29,9 +29,6 @@ namespace srsran { namespace srs_du { -/// Instantiates an O-RAN Distributed Unit (O-DU) object with the given configuration and dependencies. -std::unique_ptr make_o_du(const o_du_config& du_cfg, o_du_dependencies&& dependencies); - /// Instantiates an O-RAN Distributed Unit (O-DU) object with the given configuration and dependencies. std::unique_ptr make_o_du(std::unique_ptr odu_hi, std::unique_ptr odu_lo); diff --git a/include/srsran/fapi_adaptor/mac/mac_fapi_adaptor.h b/include/srsran/fapi_adaptor/mac/mac_fapi_adaptor.h index d491f27b0d..807faa9af9 100644 --- a/include/srsran/fapi_adaptor/mac/mac_fapi_adaptor.h +++ b/include/srsran/fapi_adaptor/mac/mac_fapi_adaptor.h @@ -23,55 +23,18 @@ #pragma once namespace srsran { - -namespace fapi { -class slot_data_message_notifier; -class slot_error_message_notifier; -class slot_time_message_notifier; -} // namespace fapi - -class mac_cell_control_information_handler; -class mac_cell_rach_handler; -class mac_cell_result_notifier; -class mac_cell_slot_handler; -class mac_pdu_handler; - namespace fapi_adaptor { -/// \brief MAC–FAPI bidirectional adaptor interface. -/// -/// This adaptor is a collection of interfaces to translate FAPI messages into their MAC layer counterpart and vice -/// versa. -/// -/// \note All implementations of this public interface must hold the ownership of all its internal components. +class mac_fapi_sector_adaptor; + +/// MAC–FAPI bidirectional adaptor interface. class mac_fapi_adaptor { public: virtual ~mac_fapi_adaptor() = default; - /// \brief Returns a reference to the slot time notifier used by the adaptor. - virtual fapi::slot_time_message_notifier& get_slot_time_message_notifier() = 0; - - /// \brief Returns a reference to the slot error notifier used by the adaptor. - virtual fapi::slot_error_message_notifier& get_slot_error_message_notifier() = 0; - - /// \brief Returns a reference to the slot data notifier used by the adaptor. - virtual fapi::slot_data_message_notifier& get_slot_data_message_notifier() = 0; - - /// \brief Returns a reference to the MAC cell results notifier used by the adaptor. - virtual mac_cell_result_notifier& get_cell_result_notifier() = 0; - - /// \brief Configures the MAC cell slot handler to the given one. - virtual void set_cell_slot_handler(mac_cell_slot_handler& mac_slot_handler) = 0; - - /// \brief Configures the MAC cell RACH handler to the given one. - virtual void set_cell_rach_handler(mac_cell_rach_handler& mac_rach_handler) = 0; - - /// \brief Configures the MAC cell PDU handler to the given one. - virtual void set_cell_pdu_handler(mac_pdu_handler& handler) = 0; - - /// \brief Configures the MAC cell CRC handler to the given one. - virtual void set_cell_crc_handler(mac_cell_control_information_handler& handler) = 0; + /// Returns the MAC–FAPI sector adaptor for the given cell id. + virtual mac_fapi_sector_adaptor& get_sector_adaptor(unsigned cell_id) = 0; }; } // namespace fapi_adaptor diff --git a/include/srsran/fapi_adaptor/mac/mac_fapi_adaptor_config.h b/include/srsran/fapi_adaptor/mac/mac_fapi_adaptor_config.h index e835c42f99..0c948c47c8 100644 --- a/include/srsran/fapi_adaptor/mac/mac_fapi_adaptor_config.h +++ b/include/srsran/fapi_adaptor/mac/mac_fapi_adaptor_config.h @@ -22,28 +22,38 @@ #pragma once -#include "srsran/fapi/slot_last_message_notifier.h" -#include "srsran/fapi/slot_message_gateway.h" #include "srsran/fapi_adaptor/precoding_matrix_mapper.h" #include "srsran/fapi_adaptor/uci_part2_correspondence_mapper.h" #include "srsran/ran/subcarrier_spacing.h" #include namespace srsran { + +class task_executor; + +namespace fapi { +class slot_message_gateway; +class slot_last_message_notifier; +} // namespace fapi + namespace fapi_adaptor { -/// MAC–FAPI adaptor configuration. -struct mac_fapi_adaptor_config { +/// MAC–FAPI sector adaptor configuration. +struct mac_fapi_sector_adaptor_config { /// Base station sector identifier. unsigned sector_id; /// Cell number of resource blocks. unsigned cell_nof_prbs; /// Subcarrier spacing as per TS38.331 Section 6.2.2. subcarrier_spacing scs; + /// Log level. + srslog::basic_levels log_level; + /// Number of slots the L2 is ahead the L1. + unsigned l2_nof_slots_ahead; }; -/// MAC–FAPI adaptor dependencies. -struct mac_fapi_adaptor_dependencies { +/// MAC–FAPI sector adaptor dependencies. +struct mac_fapi_sector_adaptor_dependencies { /// Slot-specific FAPI message gateway. fapi::slot_message_gateway* gateway; /// Slot-specific last message notifier. @@ -52,6 +62,18 @@ struct mac_fapi_adaptor_dependencies { std::unique_ptr pm_mapper; /// UCI Part2 mapper. std::unique_ptr part2_mapper; + /// FAPI message bufferer task executor. + std::optional bufferer_task_executor; +}; + +/// MAC–FAPI adaptor configuration. +struct mac_fapi_adaptor_config { + std::vector sectors; +}; + +/// MAC–FAPI adaptor dependencies. +struct mac_fapi_adaptor_dependencies { + std::vector sectors; }; } // namespace fapi_adaptor diff --git a/include/srsran/fapi_adaptor/mac/mac_fapi_sector_adaptor.h b/include/srsran/fapi_adaptor/mac/mac_fapi_sector_adaptor.h new file mode 100644 index 0000000000..141a556c6d --- /dev/null +++ b/include/srsran/fapi_adaptor/mac/mac_fapi_sector_adaptor.h @@ -0,0 +1,78 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN 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. + * + * srsRAN 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/. + * + */ + +#pragma once + +namespace srsran { + +namespace fapi { +class slot_data_message_notifier; +class slot_error_message_notifier; +class slot_time_message_notifier; +} // namespace fapi + +class mac_cell_control_information_handler; +class mac_cell_rach_handler; +class mac_cell_result_notifier; +class mac_cell_slot_handler; +class mac_pdu_handler; + +namespace fapi_adaptor { + +/// \brief MAC–FAPI bidirectional adaptor sector interface. +/// +/// This adaptor is a collection of interfaces to translate FAPI messages into their MAC layer counterpart and vice +/// versa. +/// +/// \note All implementations of this public interface must hold the ownership of all its internal components. +class mac_fapi_sector_adaptor +{ +public: + virtual ~mac_fapi_sector_adaptor() = default; + + /// \brief Returns a reference to the slot time notifier used by the adaptor. + virtual fapi::slot_time_message_notifier& get_slot_time_message_notifier() = 0; + + /// \brief Returns a reference to the slot error notifier used by the adaptor. + virtual fapi::slot_error_message_notifier& get_slot_error_message_notifier() = 0; + + /// \brief Returns a reference to the slot data notifier used by the adaptor. + virtual fapi::slot_data_message_notifier& get_slot_data_message_notifier() = 0; + + /// \brief Returns a reference to the MAC cell results notifier used by the adaptor. + virtual mac_cell_result_notifier& get_cell_result_notifier() = 0; + + /// \brief Configures the MAC cell slot handler to the given one. + virtual void set_cell_slot_handler(mac_cell_slot_handler& mac_slot_handler) = 0; + + /// \brief Configures the MAC cell RACH handler to the given one. + virtual void set_cell_rach_handler(mac_cell_rach_handler& mac_rach_handler) = 0; + + /// \brief Configures the MAC cell PDU handler to the given one. + virtual void set_cell_pdu_handler(mac_pdu_handler& handler) = 0; + + /// \brief Configures the MAC cell CRC handler to the given one. + virtual void set_cell_crc_handler(mac_cell_control_information_handler& handler) = 0; +}; + +} // namespace fapi_adaptor +} // namespace srsran diff --git a/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor.h b/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor.h index 2a8b89be2e..f1bf4ebb44 100644 --- a/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor.h +++ b/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor.h @@ -23,55 +23,18 @@ #pragma once namespace srsran { - -namespace fapi { -class slot_data_message_notifier; -class slot_error_message_notifier; -class slot_last_message_notifier; -class slot_message_gateway; -class slot_time_message_notifier; -} // namespace fapi - -class upper_phy_error_notifier; -class upper_phy_timing_notifier; -class upper_phy_rx_results_notifier; - namespace fapi_adaptor { -/// \brief PHY–FAPI bidirectional adaptor interface. -/// -/// This adaptor is a collection of interfaces to translate FAPI messages into their PHY layer counterpart and vice -/// versa. -/// -/// \note All implementations of this public interface must hold the ownership of all its internal components. +class phy_fapi_sector_adaptor; + +/// PHY–FAPI bidirectional adaptor interface. class phy_fapi_adaptor { public: virtual ~phy_fapi_adaptor() = default; - /// Returns a reference to the error notifier used by the adaptor. - virtual upper_phy_error_notifier& get_error_notifier() = 0; - - /// Returns a reference to the timing notifier used by the adaptor. - virtual upper_phy_timing_notifier& get_timing_notifier() = 0; - - /// Returns a reference to the results notifier used by the adaptor. - virtual upper_phy_rx_results_notifier& get_rx_results_notifier() = 0; - - /// Returns a reference to the slot-based message gateway used by the adaptor. - virtual fapi::slot_message_gateway& get_slot_message_gateway() = 0; - - /// Returns a reference to the slot-based last message notifier used by the adaptor. - virtual fapi::slot_last_message_notifier& get_slot_last_message_notifier() = 0; - - /// Configures the slot-based, time-specific message notifier to the given one. - virtual void set_slot_time_message_notifier(fapi::slot_time_message_notifier& fapi_time_notifier) = 0; - - /// Configures the slot-based, error-specific message notifier to the given one. - virtual void set_slot_error_message_notifier(fapi::slot_error_message_notifier& fapi_error_notifier) = 0; - - /// Configures the slot-based, data-specific message notifier to the given one. - virtual void set_slot_data_message_notifier(fapi::slot_data_message_notifier& fapi_data_notifier) = 0; + /// Returns the PHY-FAPI sector adaptor for the given cell id. + virtual phy_fapi_sector_adaptor& get_sector_adaptor(unsigned cell_id) = 0; }; } // namespace fapi_adaptor diff --git a/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor_config.h b/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor_config.h new file mode 100644 index 0000000000..d3acd71668 --- /dev/null +++ b/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor_config.h @@ -0,0 +1,91 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN 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. + * + * srsRAN 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/. + * + */ + +#pragma once + +#include "srsran/fapi_adaptor/precoding_matrix_repository.h" +#include "srsran/fapi_adaptor/uci_part2_correspondence_repository.h" +#include "srsran/srslog/logger.h" + +namespace srsran { + +class downlink_pdu_validator; +class downlink_processor_pool; +class resource_grid_pool; +class uplink_pdu_validator; +class uplink_request_processor; +class uplink_slot_pdu_repository; + +namespace srs_du { +struct du_cell_config; +} + +namespace fapi_adaptor { + +/// PHY–FAPI sector adaptor configuration. +struct phy_fapi_sector_adaptor_config { + /// Base station sector identifier. + unsigned sector_id; + /// Request headroom size in slots. + unsigned nof_slots_request_headroom; + /// DU cell configuration. + const srs_du::du_cell_config& du_cell; + /// PRACH port list. + std::vector prach_ports; +}; + +/// PHY–FAPI sector adaptor dependencies. +struct phy_fapi_sector_adaptor_dependencies { + /// Logger. + srslog::basic_logger* logger; + /// Downlink processor pool. + downlink_processor_pool* dl_processor_pool; + /// Downlink resource grid pool. + resource_grid_pool* dl_rg_pool; + /// Downlink PDU validator. + const downlink_pdu_validator* dl_pdu_validator; + /// Uplink request processor. + uplink_request_processor* ul_request_processor; + /// Uplink resource grid pool. + resource_grid_pool* ul_rg_pool; + /// Uplink slot PDU repository. + uplink_slot_pdu_repository* ul_pdu_repository; + /// Uplink PDU validator. + const uplink_pdu_validator* ul_pdu_validator; + /// Precoding matrix repository. + std::unique_ptr pm_repo; + /// UCI Part2 correspondence repository. + std::unique_ptr part2_repo; +}; + +/// PHY–FAPI adaptor configuration. +struct phy_fapi_adaptor_config { + std::vector sectors; +}; + +/// PHY–FAPI adaptor dependencies. +struct phy_fapi_adaptor_dependencies { + std::vector sectors; +}; + +} // namespace fapi_adaptor +} // namespace srsran diff --git a/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor_factory.h b/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor_factory.h index 1ea8022938..7917dc6b1a 100644 --- a/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor_factory.h +++ b/include/srsran/fapi_adaptor/phy/phy_fapi_adaptor_factory.h @@ -22,68 +22,11 @@ #pragma once -#include "srsran/fapi/messages.h" -#include "srsran/fapi_adaptor/phy/phy_fapi_adaptor.h" -#include "srsran/fapi_adaptor/precoding_matrix_repository.h" -#include "srsran/fapi_adaptor/uci_part2_correspondence_repository.h" -#include "srsran/ran/subcarrier_spacing.h" -#include "srsran/srslog/logger.h" -#include "srsran/support/executors/task_executor.h" -#include +#include "srsran/fapi_adaptor/phy/phy_fapi_adaptor_config.h" namespace srsran { - -class downlink_pdu_validator; -class downlink_processor_pool; -class resource_grid_pool; -class uplink_pdu_validator; -class uplink_request_processor; -class uplink_slot_pdu_repository; - namespace fapi_adaptor { -/// Configuration parameters for the PHY–FAPI adaptor factory. -struct phy_fapi_adaptor_factory_config { - /// Base station sector identifier. - unsigned sector_id; - /// Request headroom size in slots. - unsigned nof_slots_request_headroom; - /// Subcarrier spacing as per TS38.211 Section 4.2. - subcarrier_spacing scs; - /// Common subcarrier spacing as per TS38.331 Section 6.2.2. - subcarrier_spacing scs_common; - /// PRACH configuration as per SCF-222 v4.0 Section 3.3.2.4 TLV 0x1031. - const fapi::prach_config* prach_cfg; - /// Carrier configuration per SCF-222 v4.0 Section 3.3.2.4 TLV 0x102d. - const fapi::carrier_config* carrier_cfg; - /// PRACH port list. - std::vector prach_ports; -}; - -/// Dependencies for the PHY–FAPI adaptor factory. -struct phy_fapi_adaptor_factory_dependencies { - /// Logger. - srslog::basic_logger* logger; - /// Downlink processor pool. - downlink_processor_pool* dl_processor_pool; - /// Downlink resource grid pool. - resource_grid_pool* dl_rg_pool; - /// Downlink PDU validator. - const downlink_pdu_validator* dl_pdu_validator; - /// Uplink request processor. - uplink_request_processor* ul_request_processor; - /// Uplink resource grid pool. - resource_grid_pool* ul_rg_pool; - /// Uplink slot PDU repository. - uplink_slot_pdu_repository* ul_pdu_repository; - /// Uplink PDU validator. - const uplink_pdu_validator* ul_pdu_validator; - /// Precoding matrix repository. - std::unique_ptr pm_repo; - /// UCI Part2 correspondence repository. - std::unique_ptr part2_repo; -}; - /// Factory to create \c phy_fapi_adaptor objects. class phy_fapi_adaptor_factory { @@ -91,8 +34,8 @@ class phy_fapi_adaptor_factory virtual ~phy_fapi_adaptor_factory() = default; /// Creates a \c phy_fapi_adaptor object using the given configuration and dependencies. - virtual std::unique_ptr create(const phy_fapi_adaptor_factory_config& config, - phy_fapi_adaptor_factory_dependencies&& dependencies) = 0; + virtual std::unique_ptr create(const phy_fapi_adaptor_config& config, + phy_fapi_adaptor_dependencies&& dependencies) = 0; }; /// Creates a \c phy_fapi_adaptor_factory object. diff --git a/include/srsran/fapi_adaptor/phy/phy_fapi_sector_adaptor.h b/include/srsran/fapi_adaptor/phy/phy_fapi_sector_adaptor.h new file mode 100644 index 0000000000..bb8971b1d7 --- /dev/null +++ b/include/srsran/fapi_adaptor/phy/phy_fapi_sector_adaptor.h @@ -0,0 +1,78 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN 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. + * + * srsRAN 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/. + * + */ + +#pragma once + +namespace srsran { + +namespace fapi { +class slot_data_message_notifier; +class slot_error_message_notifier; +class slot_last_message_notifier; +class slot_message_gateway; +class slot_time_message_notifier; +} // namespace fapi + +class upper_phy_error_notifier; +class upper_phy_timing_notifier; +class upper_phy_rx_results_notifier; + +namespace fapi_adaptor { + +/// \brief PHY–FAPI bidirectional sector adaptor interface. +/// +/// This adaptor is a collection of interfaces to translate FAPI messages into their PHY layer counterpart and vice +/// versa. +/// +/// \note All implementations of this public interface must hold the ownership of all its internal components. +class phy_fapi_sector_adaptor +{ +public: + virtual ~phy_fapi_sector_adaptor() = default; + + /// Returns a reference to the error notifier used by the adaptor. + virtual upper_phy_error_notifier& get_error_notifier() = 0; + + /// Returns a reference to the timing notifier used by the adaptor. + virtual upper_phy_timing_notifier& get_timing_notifier() = 0; + + /// Returns a reference to the results notifier used by the adaptor. + virtual upper_phy_rx_results_notifier& get_rx_results_notifier() = 0; + + /// Returns a reference to the slot-based message gateway used by the adaptor. + virtual fapi::slot_message_gateway& get_slot_message_gateway() = 0; + + /// Returns a reference to the slot-based last message notifier used by the adaptor. + virtual fapi::slot_last_message_notifier& get_slot_last_message_notifier() = 0; + + /// Configures the slot-based, time-specific message notifier to the given one. + virtual void set_slot_time_message_notifier(fapi::slot_time_message_notifier& fapi_time_notifier) = 0; + + /// Configures the slot-based, error-specific message notifier to the given one. + virtual void set_slot_error_message_notifier(fapi::slot_error_message_notifier& fapi_error_notifier) = 0; + + /// Configures the slot-based, data-specific message notifier to the given one. + virtual void set_slot_data_message_notifier(fapi::slot_data_message_notifier& fapi_data_notifier) = 0; +}; + +} // namespace fapi_adaptor +} // namespace srsran diff --git a/include/srsran/ngap/ngap_handover.h b/include/srsran/ngap/ngap_handover.h index b7559c1ffa..7d5f6da01e 100644 --- a/include/srsran/ngap/ngap_handover.h +++ b/include/srsran/ngap/ngap_handover.h @@ -26,6 +26,7 @@ #include "srsran/ngap/ngap_types.h" #include "srsran/security/security.h" #include "srsran/support/async/async_task.h" +#include namespace srsran { namespace srs_cu_cp { diff --git a/include/srsran/nrppa/nrppa.h b/include/srsran/nrppa/nrppa.h index 803b9ca7ba..3d4b63a00c 100644 --- a/include/srsran/nrppa/nrppa.h +++ b/include/srsran/nrppa/nrppa.h @@ -25,6 +25,7 @@ #include "srsran/cu_cp/cu_cp_types.h" #include "srsran/rrc/meas_types.h" #include "srsran/support/async/async_task.h" +#include namespace srsran { namespace srs_cu_cp { diff --git a/include/srsran/ran/du_types.h b/include/srsran/ran/du_types.h index 8792818cb5..271bba7ab4 100644 --- a/include/srsran/ran/du_types.h +++ b/include/srsran/ran/du_types.h @@ -22,6 +22,7 @@ #pragma once +#include "srsran/ran/gnb_constants.h" #include #include @@ -38,8 +39,8 @@ enum du_ue_index_t : uint16_t { /// Maximum number of cells supported by DU (implementation-defined). enum du_cell_index_t : uint16_t { MIN_DU_CELL_INDEX = 0, - MAX_DU_CELL_INDEX = 15, - MAX_NOF_DU_CELLS = 16, + MAX_DU_CELL_INDEX = MAX_CELLS_PER_DU - 1, + MAX_NOF_DU_CELLS = MAX_CELLS_PER_DU, INVALID_DU_CELL_INDEX = MAX_NOF_DU_CELLS }; diff --git a/include/srsran/support/dynlink_manager.h b/include/srsran/ran/gnb_constants.h similarity index 59% rename from include/srsran/support/dynlink_manager.h rename to include/srsran/ran/gnb_constants.h index 732dd384ab..668202fa0e 100644 --- a/include/srsran/support/dynlink_manager.h +++ b/include/srsran/ran/gnb_constants.h @@ -22,26 +22,12 @@ #pragma once -#include "srsran/adt/expected.h" -#include "srsran/srslog/logger.h" +#include namespace srsran { -class dynlink_manager -{ -public: - static std::optional create(const std::string& dl_name, srslog::basic_logger& logger_); - expected load_symbol(const std::string& symbol_name); - ~dynlink_manager(); - -private: - explicit dynlink_manager(const std::string& dl_name_, srslog::basic_logger& logger_); - [[nodiscard]] bool open(); - bool close(); - - void* dl_handle = nullptr; - std::string dl_name; - srslog::basic_logger& logger; -}; +/// \brief Defines the maximum number of cells that can be instantiated per srsDU (implementation-defined). +/// \remark TS 38.473 defines an upper limit of maxCellingNBDU=512 for this value. +static constexpr uint16_t MAX_CELLS_PER_DU = 32; } // namespace srsran diff --git a/include/srsran/scheduler/resource_grid_util.h b/include/srsran/scheduler/resource_grid_util.h index 7ddd7d9186..c612358115 100644 --- a/include/srsran/scheduler/resource_grid_util.h +++ b/include/srsran/scheduler/resource_grid_util.h @@ -37,8 +37,8 @@ namespace srsran { /// the numerology mu=0 (SCS=15kHz), it will be also satisfied for the same RING_ALLOCATOR_SIZE and larger numerologies. /// This means that in contexts where mu is not known (e.g. compile time), mu=0 can be used for generality sake, /// at the expense of more memory overhead. -constexpr inline unsigned get_allocator_ring_size_gt_min(unsigned minimum_value, - subcarrier_spacing scs = subcarrier_spacing::kHz15) +constexpr unsigned get_allocator_ring_size_gt_min(unsigned minimum_value, + subcarrier_spacing scs = subcarrier_spacing::kHz15) { auto power2_ceil = [](unsigned x) { if (x <= 1) @@ -56,7 +56,7 @@ constexpr inline unsigned get_allocator_ring_size_gt_min(unsigned mini } /// \brief Retrieves how far in advance the scheduler can allocate resources in the UL resource grid. -constexpr inline unsigned get_max_slot_ul_alloc_delay(unsigned ntn_cs_koffset) +constexpr unsigned get_max_slot_ul_alloc_delay(unsigned ntn_cs_koffset) { return SCHEDULER_MAX_K0 + std::max(SCHEDULER_MAX_K1, SCHEDULER_MAX_K2 + MAX_MSG3_DELTA) + ntn_cs_koffset; } diff --git a/include/srsran/support/compiler.h b/include/srsran/support/compiler.h index 1f637fef33..362e378548 100644 --- a/include/srsran/support/compiler.h +++ b/include/srsran/support/compiler.h @@ -40,6 +40,3 @@ /// Ensures a function is always inlinable. #define SRSRAN_FORCE_INLINE __attribute__((always_inline)) inline - -/// Marks a symbol as weak. -#define SRSRAN_WEAK_SYMB __attribute__((weak)) diff --git a/lib/cu_cp/cell_meas_manager/cell_meas_manager_impl.cpp b/lib/cu_cp/cell_meas_manager/cell_meas_manager_impl.cpp index 85688fc96e..1c0ddba416 100644 --- a/lib/cu_cp/cell_meas_manager/cell_meas_manager_impl.cpp +++ b/lib/cu_cp/cell_meas_manager/cell_meas_manager_impl.cpp @@ -307,7 +307,8 @@ void cell_meas_manager::update_measurement_object(nr_cell_identity ssb_freq_to_meas_object.emplace(ssb_freq, generate_measurement_object(serving_cell_cfg)); } -SRSRAN_WEAK_SYMB void cell_meas_manager::store_measurement_results(ue_index_t ue_index, - const rrc_meas_results& meas_results) -{ -} +#ifndef SRSRAN_HAS_ENTERPRISE + +void cell_meas_manager::store_measurement_results(ue_index_t ue_index, const rrc_meas_results& meas_results) {} + +#endif // SRSRAN_HAS_ENTERPRISE diff --git a/lib/cu_cp/cu_cp_controller/cu_up_connection_manager.h b/lib/cu_cp/cu_cp_controller/cu_up_connection_manager.h index 142a19b910..0a521fa972 100644 --- a/lib/cu_cp/cu_cp_controller/cu_up_connection_manager.h +++ b/lib/cu_cp/cu_cp_controller/cu_up_connection_manager.h @@ -26,6 +26,7 @@ #include "srsran/cu_cp/cu_cp_types.h" #include "srsran/support/executors/task_executor.h" #include +#include namespace srsran { namespace srs_cu_cp { diff --git a/lib/cu_cp/cu_cp_controller/du_connection_manager.h b/lib/cu_cp/cu_cp_controller/du_connection_manager.h index 68dc39d526..91fcdc8adf 100644 --- a/lib/cu_cp/cu_cp_controller/du_connection_manager.h +++ b/lib/cu_cp/cu_cp_controller/du_connection_manager.h @@ -26,6 +26,7 @@ #include "srsran/cu_cp/cu_cp_types.h" #include "srsran/support/executors/task_executor.h" #include +#include namespace srsran { namespace srs_cu_cp { @@ -75,4 +76,4 @@ class du_connection_manager : public cu_cp_f1c_handler }; } // namespace srs_cu_cp -} // namespace srsran \ No newline at end of file +} // namespace srsran diff --git a/lib/cu_cp/cu_cp_impl.cpp b/lib/cu_cp/cu_cp_impl.cpp index 2012b605d4..b246b488f0 100644 --- a/lib/cu_cp/cu_cp_impl.cpp +++ b/lib/cu_cp/cu_cp_impl.cpp @@ -167,12 +167,16 @@ bool cu_cp_impl::amfs_are_connected() return true; }; -SRSRAN_WEAK_SYMB std::unique_ptr +#ifndef SRSRAN_HAS_ENTERPRISE + +std::unique_ptr cu_cp_impl::create_nrppa_entity(const cu_cp_configuration& cu_cp_cfg, nrppa_cu_cp_notifier& cu_cp_notif) { return create_nrppa(cu_cp_cfg, cu_cp_notif); } +#endif // SRSRAN_HAS_ENTERPRISE + void cu_cp_impl::handle_bearer_context_inactivity_notification(const cu_cp_inactivity_notification& msg) { if (msg.ue_inactive) { @@ -613,12 +617,15 @@ ue_index_t cu_cp_impl::handle_ue_index_allocation_request(const nr_cell_global_i return ue_mng.add_ue(du_index, cgi.plmn_id); } -SRSRAN_WEAK_SYMB void cu_cp_impl::handle_dl_ue_associated_nrppa_transport_pdu(ue_index_t ue_index, - const byte_buffer& nrppa_pdu) +#ifndef SRSRAN_HAS_ENTERPRISE + +void cu_cp_impl::handle_dl_ue_associated_nrppa_transport_pdu(ue_index_t ue_index, const byte_buffer& nrppa_pdu) { logger.info("DL UE associated NRPPa messages are not supported"); } +#endif // SRSRAN_HAS_ENTERPRISE + void cu_cp_impl::handle_dl_non_ue_associated_nrppa_transport_pdu(const byte_buffer& nrppa_pdu) { logger.info("DL non UE associated NRPPa messages are not supported"); @@ -629,16 +636,20 @@ void cu_cp_impl::handle_n2_disconnection() // TODO } -SRSRAN_WEAK_SYMB nrppa_cu_cp_ue_notifier* cu_cp_impl::handle_new_nrppa_ue(ue_index_t ue_index) +#ifndef SRSRAN_HAS_ENTERPRISE + +nrppa_cu_cp_ue_notifier* cu_cp_impl::handle_new_nrppa_ue(ue_index_t ue_index) { return nullptr; } -SRSRAN_WEAK_SYMB void cu_cp_impl::handle_ul_nrppa_pdu(const byte_buffer& nrppa_pdu, std::optional ue_index) +void cu_cp_impl::handle_ul_nrppa_pdu(const byte_buffer& nrppa_pdu, std::optional ue_index) { logger.info("UL NRPPa messages are not supported"); } +#endif // SRSRAN_HAS_ENTERPRISE + std::optional cu_cp_impl::handle_measurement_config_request(ue_index_t ue_index, nr_cell_identity nci, diff --git a/lib/cu_cp/cu_up_processor/cu_up_processor_repository.h b/lib/cu_cp/cu_up_processor/cu_up_processor_repository.h index 3a7711fae9..a4068e2eb2 100644 --- a/lib/cu_cp/cu_up_processor/cu_up_processor_repository.h +++ b/lib/cu_cp/cu_up_processor/cu_up_processor_repository.h @@ -26,6 +26,7 @@ #include "cu_up_processor_impl_interface.h" #include "srsran/cu_cp/cu_cp_e1_handler.h" #include "srsran/cu_cp/cu_cp_types.h" +#include #include namespace srsran { diff --git a/lib/cu_cp/routines/amf_connection_removal_routine.cpp b/lib/cu_cp/routines/amf_connection_removal_routine.cpp index c941a82d3b..d4aa52a635 100644 --- a/lib/cu_cp/routines/amf_connection_removal_routine.cpp +++ b/lib/cu_cp/routines/amf_connection_removal_routine.cpp @@ -27,14 +27,18 @@ using namespace srsran; using namespace srs_cu_cp; -SRSRAN_WEAK_SYMB async_task - srsran::srs_cu_cp::start_amf_connection_removal(ngap_repository& ngap_db, +#ifndef SRSRAN_HAS_ENTERPRISE + +async_task +srsran::srs_cu_cp::start_amf_connection_removal(ngap_repository& ngap_db, std::unordered_map>& amfs_connected) { return launch_async(ngap_db.get_ngaps().begin()->second, amfs_connected.begin()->second); } +#endif // SRSRAN_HAS_ENTERPRISE + amf_connection_removal_routine::amf_connection_removal_routine(ngap_interface* ngap_, std::atomic& amf_connected_) : ngap(ngap_), amf_connected(amf_connected_), logger(srslog::fetch_basic_logger("CU-CP")) diff --git a/lib/cu_cp/routines/amf_connection_setup_routine.cpp b/lib/cu_cp/routines/amf_connection_setup_routine.cpp index 11bf223714..c73905475c 100644 --- a/lib/cu_cp/routines/amf_connection_setup_routine.cpp +++ b/lib/cu_cp/routines/amf_connection_setup_routine.cpp @@ -28,14 +28,18 @@ using namespace srsran; using namespace srs_cu_cp; -SRSRAN_WEAK_SYMB async_task - srsran::srs_cu_cp::start_amf_connection_setup(ngap_repository& ngap_db, +#ifndef SRSRAN_HAS_ENTERPRISE + +async_task +srsran::srs_cu_cp::start_amf_connection_setup(ngap_repository& ngap_db, std::unordered_map>& amfs_connected) { amfs_connected.emplace(ngap_db.get_ngaps().begin()->first, false); return launch_async(ngap_db, amfs_connected.begin()->second); } +#endif // SRSRAN_HAS_ENTERPRISE + amf_connection_setup_routine::amf_connection_setup_routine(ngap_repository& ngap_db_, std::atomic& amf_connected_) : ngap_db(ngap_db_), diff --git a/lib/cu_cp/routines/mobility/inter_cu_handover_target_routine.cpp b/lib/cu_cp/routines/mobility/inter_cu_handover_target_routine.cpp index b0aadb43da..913deb910e 100644 --- a/lib/cu_cp/routines/mobility/inter_cu_handover_target_routine.cpp +++ b/lib/cu_cp/routines/mobility/inter_cu_handover_target_routine.cpp @@ -25,8 +25,10 @@ using namespace srsran; using namespace srs_cu_cp; -SRSRAN_WEAK_SYMB async_task - srsran::srs_cu_cp::start_inter_cu_handover_target_routine(const ngap_handover_request& request, +#ifndef SRSRAN_HAS_ENTERPRISE + +async_task +srsran::srs_cu_cp::start_inter_cu_handover_target_routine(const ngap_handover_request& request, e1ap_bearer_context_manager& e1ap_bearer_ctxt_mng, f1ap_ue_context_manager& f1ap_ue_ctxt_mng, cu_cp_ue_removal_handler& ue_removal_handler, @@ -47,3 +49,5 @@ SRSRAN_WEAK_SYMB async_task }; return launch_async(std::move(err_function)); } + +#endif // SRSRAN_HAS_ENTERPRISE diff --git a/lib/cu_cp/task_schedulers/du_task_scheduler.h b/lib/cu_cp/task_schedulers/du_task_scheduler.h index e5d4c4c16a..215466f1c7 100644 --- a/lib/cu_cp/task_schedulers/du_task_scheduler.h +++ b/lib/cu_cp/task_schedulers/du_task_scheduler.h @@ -27,6 +27,7 @@ #include "srsran/support/async/fifo_async_task_scheduler.h" #include "srsran/support/executors/task_executor.h" #include "srsran/support/timers.h" +#include namespace srsran { namespace srs_cu_cp { diff --git a/lib/du/du_high/du_manager/ran_resource_management/ue_capability_manager.cpp b/lib/du/du_high/du_manager/ran_resource_management/ue_capability_manager.cpp index f2444c9134..07a6d8c5e0 100644 --- a/lib/du/du_high/du_manager/ran_resource_management/ue_capability_manager.cpp +++ b/lib/du/du_high/du_manager/ran_resource_management/ue_capability_manager.cpp @@ -62,12 +62,16 @@ srsran::srs_du::decode_ue_nr_cap_container(const byte_buffer& ue_cap_container) return ue_caps; } -SRSRAN_WEAK_SYMB void srsran::srs_du::decode_advanced_ue_nr_caps(ue_capability_summary& ue_capability, - const asn1::rrc_nr::ue_nr_cap_s& ue_caps) +#ifndef SRSRAN_HAS_ENTERPRISE + +void srsran::srs_du::decode_advanced_ue_nr_caps(ue_capability_summary& ue_capability, + const asn1::rrc_nr::ue_nr_cap_s& ue_caps) { // Advanced UE capabilities is not implemented. } +#endif // SRSRAN_HAS_ENTERPRISE + // Configure dedicated UE configuration to set MCS ant CQI tables. static void set_pdsch_mcs_table(serving_cell_config& cell_cfg, pdsch_mcs_table mcs_table) { diff --git a/lib/du/du_high/o_du_high_factory.cpp b/lib/du/du_high/o_du_high_factory.cpp index 6c672c58b2..b627a77cc8 100644 --- a/lib/du/du_high/o_du_high_factory.cpp +++ b/lib/du/du_high/o_du_high_factory.cpp @@ -33,181 +33,53 @@ using namespace srsran; using namespace srs_du; -static std::unique_ptr -build_mac_fapi_adaptor(unsigned sector_id, - subcarrier_spacing scs, - fapi::slot_message_gateway& gateway, - fapi::slot_last_message_notifier& last_msg_notifier, - std::unique_ptr pm_mapper, - std::unique_ptr part2_mapper, - unsigned cell_nof_prbs) +static fapi_adaptor::mac_fapi_adaptor_config generate_fapi_adaptor_config(const o_du_high_config& config) { - std::unique_ptr adaptor_factory = - fapi_adaptor::create_mac_fapi_adaptor_factory(); - report_error_if_not(adaptor_factory, "Invalid MAC adaptor factory."); - - fapi_adaptor::mac_fapi_adaptor_config mac_fapi_config; - mac_fapi_config.sector_id = sector_id; - mac_fapi_config.cell_nof_prbs = cell_nof_prbs; - mac_fapi_config.scs = scs; - - fapi_adaptor::mac_fapi_adaptor_dependencies mac_fapi_deps; - mac_fapi_deps.gateway = &gateway; - mac_fapi_deps.last_msg_notifier = &last_msg_notifier; - mac_fapi_deps.pm_mapper = std::move(pm_mapper); - mac_fapi_deps.part2_mapper = std::move(part2_mapper); - - return adaptor_factory->create(mac_fapi_config, std::move(mac_fapi_deps)); -} - -static std::unique_ptr -build_fapi_adaptor(const du_cell_config& du_cell, const o_du_high_sector_dependencies& dependencies, unsigned sector) -{ - srsran_assert(dependencies.gateway, "Invalid gateway"); - srsran_assert(dependencies.last_msg_notifier, "Invalid last message notifier"); - - const subcarrier_spacing scs = du_cell.scs_common; - auto pm_tools = fapi_adaptor::generate_precoding_matrix_tables(du_cell.dl_carrier.nof_ant); - auto uci_part2_tools = fapi_adaptor::generate_uci_part2_correspondence(1); - - return build_mac_fapi_adaptor( - sector, - scs, - *dependencies.gateway, - *dependencies.last_msg_notifier, - std::move(std::get>(pm_tools)), - std::move(std::get>(uci_part2_tools)), - get_max_Nprb(du_cell.dl_carrier.carrier_bw_mhz, scs, frequency_range::FR1)); -} + fapi_adaptor::mac_fapi_adaptor_config out_config; -namespace { - -/// MAC-FAPI adaptor wrapper that wraps an adaptor and a FAPI decorator. -class mac_fapi_adaptor_wrapper : public fapi_adaptor::mac_fapi_adaptor -{ -public: - mac_fapi_adaptor_wrapper(const du_cell_config& du_cell, - const o_du_high_sector_dependencies& dependencies, - unsigned sector, - std::unique_ptr decorator_) : - decorator(std::move(decorator_)), - adaptor([](const du_cell_config& du_cell_adapt, - unsigned sector_id, - fapi::slot_message_gateway& gateway, - fapi::slot_last_message_notifier& last_msg_notifier) { - o_du_high_sector_dependencies adaptor_dependencies; - adaptor_dependencies.last_msg_notifier = &last_msg_notifier; - adaptor_dependencies.gateway = &gateway; - return build_fapi_adaptor(du_cell_adapt, adaptor_dependencies, sector_id); - }(du_cell, - sector, - decorator ? decorator->get_slot_message_gateway() : *dependencies.gateway, - decorator ? decorator->get_slot_last_message_notifier() : *dependencies.last_msg_notifier)) - { - if (decorator) { - decorator->set_slot_data_message_notifier(adaptor->get_slot_data_message_notifier()); - decorator->set_slot_error_message_notifier(adaptor->get_slot_error_message_notifier()); - decorator->set_slot_time_message_notifier(adaptor->get_slot_time_message_notifier()); - } + for (unsigned i = 0, e = config.du_hi.ran.cells.size(); i != e; ++i) { + const auto& du_cell = config.du_hi.ran.cells[i]; + unsigned nof_prb = get_max_Nprb(du_cell.dl_carrier.carrier_bw_mhz, du_cell.scs_common, frequency_range::FR1); + out_config.sectors.push_back( + {i, nof_prb, du_cell.scs_common, config.fapi.log_level, config.fapi.l2_nof_slots_ahead}); } - // See interface for documentation. - fapi::slot_time_message_notifier& get_slot_time_message_notifier() override - { - return decorator ? decorator->get_slot_time_message_notifier() : adaptor->get_slot_time_message_notifier(); - } - - // See interface for documentation. - fapi::slot_error_message_notifier& get_slot_error_message_notifier() override - { - return decorator ? decorator->get_slot_error_message_notifier() : adaptor->get_slot_error_message_notifier(); - } - - // See interface for documentation. - fapi::slot_data_message_notifier& get_slot_data_message_notifier() override - { - return decorator ? decorator->get_slot_data_message_notifier() : adaptor->get_slot_data_message_notifier(); - } - - // See interface for documentation. - mac_cell_result_notifier& get_cell_result_notifier() override { return adaptor->get_cell_result_notifier(); } - - // See interface for documentation. - void set_cell_slot_handler(mac_cell_slot_handler& mac_slot_handler) override - { - adaptor->set_cell_slot_handler(mac_slot_handler); - } - - // See interface for documentation. - void set_cell_rach_handler(mac_cell_rach_handler& mac_rach_handler) override - { - adaptor->set_cell_rach_handler(mac_rach_handler); - } - - // See interface for documentation. - void set_cell_pdu_handler(mac_pdu_handler& handler) override { adaptor->set_cell_pdu_handler(handler); } - - // See interface for documentation. - void set_cell_crc_handler(mac_cell_control_information_handler& handler) override - { - adaptor->set_cell_crc_handler(handler); - } - -private: - std::unique_ptr decorator; - std::unique_ptr adaptor; -}; - -} // namespace + return out_config; +} -static o_du_high_impl_dependencies -resolve_o_du_high_impl_dependencies(const o_du_high_config& config, - span odu_dependencies) +static fapi_adaptor::mac_fapi_adaptor_dependencies +generate_fapi_adaptor_dependencies(const o_du_high_config& config, o_du_high_dependencies& odu_dependencies) { - srsran_assert(config.du_hi.ran.cells.size() == odu_dependencies.size(), - "DU high number of cells '{}' does not match number sectors '{}' in O-DU dependencies", - config.du_hi.ran.cells.size(), - odu_dependencies.size()); - - o_du_high_impl_dependencies dependencies; - dependencies.logger = &srslog::fetch_basic_logger("DU"); - - for (unsigned i = 0, e = odu_dependencies.size(); i != e; ++i) { - fapi::decorator_config decorator_cfg; - - if (config.fapi.log_level == srslog::basic_levels::debug) { - decorator_cfg.logging_cfg.emplace(fapi::logging_decorator_config{srslog::fetch_basic_logger("FAPI", true), - *odu_dependencies[i].gateway, - *odu_dependencies[i].last_msg_notifier}); - } - - if (config.fapi.l2_nof_slots_ahead != 0) { - srsran_assert(odu_dependencies[i].fapi_executor, "Invalid executor for the FAPI message bufferer decorator"); - decorator_cfg.bufferer_cfg.emplace( - fapi::message_bufferer_decorator_config{config.fapi.l2_nof_slots_ahead, - config.du_hi.ran.cells[i].scs_common, - *odu_dependencies[i].fapi_executor.value(), - *odu_dependencies[i].gateway, - *odu_dependencies[i].last_msg_notifier}); - } - - dependencies.du_high_adaptor.push_back(std::make_unique( - config.du_hi.ran.cells[i], odu_dependencies[i], i, fapi::create_decorators(decorator_cfg))); + fapi_adaptor::mac_fapi_adaptor_dependencies out_dependencies; + + for (unsigned i = 0, e = config.du_hi.ran.cells.size(); i != e; ++i) { + auto& sector_dependencies = odu_dependencies.sectors[i]; + out_dependencies.sectors.push_back( + {sector_dependencies.gateway, + sector_dependencies.last_msg_notifier, + std::move(std::get>( + fapi_adaptor::generate_precoding_matrix_tables(config.du_hi.ran.cells[i].dl_carrier.nof_ant))), + std::move(std::get>( + fapi_adaptor::generate_uci_part2_correspondence(1))), + sector_dependencies.fapi_executor}); } - return dependencies; + return out_dependencies; } std::unique_ptr srsran::srs_du::make_o_du_high(const o_du_high_config& config, o_du_high_dependencies&& odu_dependencies) { - o_du_high_impl_dependencies dependencies = resolve_o_du_high_impl_dependencies(config, odu_dependencies.sectors); + o_du_high_impl_dependencies dependencies; + dependencies.logger = &srslog::fetch_basic_logger("DU"); + dependencies.du_high_adaptor = fapi_adaptor::create_mac_fapi_adaptor_factory()->create( + generate_fapi_adaptor_config(config), generate_fapi_adaptor_dependencies(config, odu_dependencies)); dependencies.logger->debug("FAPI adaptors created successfully"); srs_du::du_high_configuration du_hi_cfg = config.du_hi; - auto odu = std::make_unique(std::move(dependencies)); + auto odu = std::make_unique(config.du_hi.ran.cells.size(), std::move(dependencies)); // Instantiate DU-high. odu_dependencies.du_hi.phy_adapter = &odu->get_mac_result_notifier(); diff --git a/lib/du/du_high/o_du_high_impl.cpp b/lib/du/du_high/o_du_high_impl.cpp index 06cd07e530..8f1b2ee0f9 100644 --- a/lib/du/du_high/o_du_high_impl.cpp +++ b/lib/du/du_high/o_du_high_impl.cpp @@ -21,6 +21,8 @@ */ #include "o_du_high_impl.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_adaptor.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_sector_adaptor.h" using namespace srsran; using namespace srs_du; @@ -42,19 +44,20 @@ class phy_dummy : public mac_result_notifier } // namespace -o_du_high_impl::o_du_high_impl(o_du_high_impl_dependencies&& du_dependencies) : +o_du_high_impl::o_du_high_impl(unsigned nof_cells_, o_du_high_impl_dependencies&& du_dependencies) : + nof_cells(nof_cells_), logger(*du_dependencies.logger), du_high_adaptor(std::move(du_dependencies.du_high_adaptor)), - du_high_result_notifier([](span> fapi_adaptors) { + du_high_result_notifier([](fapi_adaptor::mac_fapi_adaptor& fapi_adaptor, unsigned num_cells) { std::vector> cells; - for (unsigned i = 0, e = fapi_adaptors.size(); i != e; ++i) { - cells.push_back(std::ref(fapi_adaptors[i]->get_cell_result_notifier())); + for (unsigned i = 0; i != num_cells; ++i) { + cells.push_back(std::ref(fapi_adaptor.get_sector_adaptor(i).get_cell_result_notifier())); } return std::make_unique(std::move(cells)); - }(du_high_adaptor)) + }(*du_high_adaptor, nof_cells)) { - srsran_assert(!du_high_adaptor.empty(), "Invalid FAPI MAC adaptor"); + srsran_assert(du_high_adaptor, "Invalid FAPI MAC adaptor"); } void o_du_high_impl::start() @@ -69,12 +72,13 @@ void o_du_high_impl::start() } // Configure the FAPI -> DU interface. - for (unsigned i = 0, e = du_high_adaptor.size(); i != e; ++i) { - du_cell_index_t cell_id = to_du_cell_index(i); - du_high_adaptor[i]->set_cell_slot_handler(du_hi->get_slot_handler(cell_id)); - du_high_adaptor[i]->set_cell_rach_handler(du_hi->get_rach_handler(cell_id)); - du_high_adaptor[i]->set_cell_pdu_handler(du_hi->get_pdu_handler()); - du_high_adaptor[i]->set_cell_crc_handler(du_hi->get_control_info_handler(cell_id)); + for (unsigned i = 0; i != nof_cells; ++i) { + du_cell_index_t cell_id = to_du_cell_index(i); + fapi_adaptor::mac_fapi_sector_adaptor& sector_adaptor = du_high_adaptor->get_sector_adaptor(i); + sector_adaptor.set_cell_slot_handler(du_hi->get_slot_handler(cell_id)); + sector_adaptor.set_cell_rach_handler(du_hi->get_rach_handler(cell_id)); + sector_adaptor.set_cell_pdu_handler(du_hi->get_pdu_handler()); + sector_adaptor.set_cell_crc_handler(du_hi->get_control_info_handler(cell_id)); } logger.info("DU started successfully"); @@ -93,6 +97,11 @@ void o_du_high_impl::stop() logger.info("DU stopped successfully"); } +fapi_adaptor::mac_fapi_adaptor& o_du_high_impl::get_mac_fapi_adaptor() +{ + return *du_high_adaptor; +} + du_high& o_du_high_impl::get_du_high() { return *du_hi; @@ -109,33 +118,3 @@ void o_du_high_impl::set_e2_agent(std::unique_ptr agent) e2agent = std::move(agent); srsran_assert(e2agent, "Invalid E2 agent"); } - -fapi::slot_data_message_notifier& o_du_high_impl::get_slot_data_message_notifier(unsigned cell_id) -{ - srsran_assert(cell_id < du_high_adaptor.size(), - "Invalid cell index '{}'. Valid cell indexes [0-{})", - cell_id, - du_high_adaptor.size()); - - return du_high_adaptor[cell_id]->get_slot_data_message_notifier(); -} - -fapi::slot_error_message_notifier& o_du_high_impl::get_slot_error_message_notifier(unsigned cell_id) -{ - srsran_assert(cell_id < du_high_adaptor.size(), - "Invalid cell index '{}'. Valid cell indexes [0-{})", - cell_id, - du_high_adaptor.size()); - - return du_high_adaptor[cell_id]->get_slot_error_message_notifier(); -} - -fapi::slot_time_message_notifier& o_du_high_impl::get_slot_time_message_notifier(unsigned cell_id) -{ - srsran_assert(cell_id < du_high_adaptor.size(), - "Invalid cell index '{}'. Valid cell indexes [0-{})", - cell_id, - du_high_adaptor.size()); - - return du_high_adaptor[cell_id]->get_slot_time_message_notifier(); -} diff --git a/lib/du/du_high/o_du_high_impl.h b/lib/du/du_high/o_du_high_impl.h index e077edba1e..f239ab10dd 100644 --- a/lib/du/du_high/o_du_high_impl.h +++ b/lib/du/du_high/o_du_high_impl.h @@ -27,22 +27,22 @@ #include "srsran/du/du_power_controller.h" #include "srsran/du/o_du_config.h" #include "srsran/e2/e2.h" -#include "srsran/fapi_adaptor/mac/mac_fapi_adaptor.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_sector_adaptor.h" namespace srsran { namespace srs_du { /// O-RAN DU high implementation dependencies. struct o_du_high_impl_dependencies { - srslog::basic_logger* logger; - std::vector> du_high_adaptor; + srslog::basic_logger* logger; + std::unique_ptr du_high_adaptor; }; /// O-RAN DU high implementation. class o_du_high_impl : public o_du_high, public du_power_controller { public: - explicit o_du_high_impl(o_du_high_impl_dependencies&& du_dependencies); + o_du_high_impl(unsigned nof_cells_, o_du_high_impl_dependencies&& du_dependencies); // See interface for documentation. du_power_controller& get_power_controller() override { return *this; } @@ -54,13 +54,7 @@ class o_du_high_impl : public o_du_high, public du_power_controller void stop() override; // See interface for documentation. - fapi::slot_data_message_notifier& get_slot_data_message_notifier(unsigned cell_id) override; - - // See interface for documentation. - fapi::slot_error_message_notifier& get_slot_error_message_notifier(unsigned cell_id) override; - - // See interface for documentation. - fapi::slot_time_message_notifier& get_slot_time_message_notifier(unsigned cell_id) override; + fapi_adaptor::mac_fapi_adaptor& get_mac_fapi_adaptor() override; // See interface for documentation. du_high& get_du_high() override; @@ -75,11 +69,12 @@ class o_du_high_impl : public o_du_high, public du_power_controller mac_result_notifier& get_mac_result_notifier() { return *du_high_result_notifier; } private: - srslog::basic_logger& logger; - std::vector> du_high_adaptor; - std::unique_ptr du_high_result_notifier; - std::unique_ptr du_hi; - std::unique_ptr e2agent; + const unsigned nof_cells; + srslog::basic_logger& logger; + std::unique_ptr du_high_adaptor; + std::unique_ptr du_high_result_notifier; + std::unique_ptr du_hi; + std::unique_ptr e2agent; }; } // namespace srs_du diff --git a/lib/du/du_high/test_mode/CMakeLists.txt b/lib/du/du_high/test_mode/CMakeLists.txt index 1afeaed144..dcaf6a2e7c 100644 --- a/lib/du/du_high/test_mode/CMakeLists.txt +++ b/lib/du/du_high/test_mode/CMakeLists.txt @@ -21,5 +21,6 @@ add_library(srsran_du_high_adapters mac_test_mode_adapter.cpp f1ap_test_mode_adapter.cpp - mac_test_mode_helpers.cpp) + mac_test_mode_helpers.cpp + mac_test_mode_ue_repository.cpp) target_link_libraries(srsran_du_high_adapters srslog srsran_support srsran_du_manager srsran_mac srsran_f1ap_du) diff --git a/lib/du/du_high/test_mode/mac_test_mode_adapter.cpp b/lib/du/du_high/test_mode/mac_test_mode_adapter.cpp index 75e80b77eb..debad29b30 100644 --- a/lib/du/du_high/test_mode/mac_test_mode_adapter.cpp +++ b/lib/du/du_high/test_mode/mac_test_mode_adapter.cpp @@ -67,50 +67,16 @@ class test_ue_mac_sdu_tx_builder_adapter : public mac_sdu_tx_builder size_t get_ring_size(const mac_cell_creation_request& cell_cfg) { + // Estimation of the time it takes the UL lower-layers to process and forward CRC/UCI indications. + constexpr static unsigned MAX_UL_PHY_DELAY = 40; // Note: The history ring size has to be a multiple of the TDD frame size in slots. // Number of slots managed by this container. - return get_allocator_ring_size_gt_min(get_max_slot_ul_alloc_delay(cell_cfg.sched_req.ntn_cs_koffset)); + return get_allocator_ring_size_gt_min(get_max_slot_ul_alloc_delay(cell_cfg.sched_req.ntn_cs_koffset) + + MAX_UL_PHY_DELAY); } } // namespace -test_ue_info_manager::test_ue_info_manager(rnti_t rnti_start_, uint16_t nof_ues_, uint16_t nof_cells_) : - rnti_start(rnti_start_), nof_ues(nof_ues_), nof_cells(nof_cells_), pending_tasks(128) -{ -} - -void test_ue_info_manager::add_ue(rnti_t rnti, du_ue_index_t ue_idx, const sched_ue_config_request& sched_ue_cfg_req) -{ - // Dispatch creation of UE to du_cell thread. - while (not pending_tasks.try_push([this, rnti, ue_idx, sched_ue_cfg_req]() { - rnti_to_ue_info_lookup[rnti] = - test_ue_info{.ue_idx = ue_idx, .sched_ue_cfg_req = sched_ue_cfg_req, .msg4_rx_flag = false}; - })) { - srslog::fetch_basic_logger("MAC").warning("Failed to add test mode UE. Retrying..."); - } -} - -void test_ue_info_manager::remove_ue(rnti_t rnti) -{ - while (not pending_tasks.try_push([this, rnti]() { - if (rnti_to_ue_info_lookup.count(rnti) > 0) { - rnti_to_ue_info_lookup.erase(rnti); - } - })) { - srslog::fetch_basic_logger("MAC").warning("Failed to remove test mode UE. Retrying..."); - } -} - -void test_ue_info_manager::process_pending_tasks() -{ - unique_task task; - while (pending_tasks.try_pop(task)) { - task(); - } -} - -// ---- - mac_test_mode_cell_adapter::mac_test_mode_cell_adapter( const srs_du::du_test_mode_config::test_mode_ue_config& test_ue_cfg_, const mac_cell_creation_request& cell_cfg, @@ -119,7 +85,8 @@ mac_test_mode_cell_adapter::mac_test_mode_cell_adapter( mac_cell_slot_handler& slot_handler_, mac_cell_result_notifier& result_notifier_, std::function dl_bs_notifier_, - test_ue_info_manager& ue_info_mgr_) : + mac_test_mode_ue_repository& ue_info_mgr_) : + cell_index(cell_cfg.cell_index), test_ue_cfg(test_ue_cfg_), adapted(adapted_), pdu_handler(pdu_handler_), @@ -225,7 +192,7 @@ void mac_test_mode_cell_adapter::handle_crc(const mac_crc_indication_message& ms if (entry.slot == msg.sl_rx) { // Forward CRC to MAC, but remove the UCI for the test mode UE. for (mac_crc_pdu& crc : msg_copy.crcs) { - if (ue_info_mgr.is_test_ue(crc.rnti)) { + if (ue_info_mgr.is_cell_test_ue(cell_index, crc.rnti)) { // test mode UE case. // Find respective PUSCH PDU that was previously scheduled. @@ -253,10 +220,11 @@ void mac_test_mode_cell_adapter::handle_crc(const mac_crc_indication_message& ms } } else { // In case of auto-ACK mode, test mode UEs are removed from CRC. - msg_copy.crcs.erase(std::remove_if(msg_copy.crcs.begin(), - msg_copy.crcs.end(), - [this](const auto& crc) { return ue_info_mgr.is_test_ue(crc.rnti); }), - msg_copy.crcs.end()); + msg_copy.crcs.erase( + std::remove_if(msg_copy.crcs.begin(), + msg_copy.crcs.end(), + [this](const auto& crc) { return ue_info_mgr.is_cell_test_ue(cell_index, crc.rnti); }), + msg_copy.crcs.end()); } // Forward resulting CRC indication to real MAC. @@ -287,7 +255,7 @@ void mac_test_mode_cell_adapter::forward_crc_ind_to_mac(const mac_crc_indication } for (const mac_crc_pdu& pdu : crc_msg.crcs) { - if (not ue_info_mgr.is_test_ue(pdu.rnti)) { + if (not ue_info_mgr.is_cell_test_ue(cell_index, pdu.rnti)) { continue; } @@ -311,7 +279,7 @@ void mac_test_mode_cell_adapter::handle_uci(const mac_uci_indication_message& ms if (entry.slot == msg_copy.sl_rx) { // Forward UCI to MAC, but alter the UCI for the test mode UE. for (mac_uci_pdu& test_uci : msg_copy.ucis) { - if (ue_info_mgr.is_test_ue(test_uci.rnti)) { + if (ue_info_mgr.is_cell_test_ue(cell_index, test_uci.rnti)) { bool entry_found = false; if (std::holds_alternative(test_uci.pdu)) { for (const ul_sched_info& pusch : entry.puschs) { @@ -348,10 +316,11 @@ void mac_test_mode_cell_adapter::handle_uci(const mac_uci_indication_message& ms } } else { // In case of auto-ACK mode, test mode UEs are removed from UCI. - msg_copy.ucis.erase(std::remove_if(msg_copy.ucis.begin(), - msg_copy.ucis.end(), - [this](const auto& u) { return ue_info_mgr.is_test_ue(u.rnti); }), - msg_copy.ucis.end()); + msg_copy.ucis.erase( + std::remove_if(msg_copy.ucis.begin(), + msg_copy.ucis.end(), + [this](const auto& u) { return ue_info_mgr.is_cell_test_ue(cell_index, u.rnti); }), + msg_copy.ucis.end()); } // Forward UCI indication to real MAC. @@ -368,7 +337,7 @@ void mac_test_mode_cell_adapter::on_new_downlink_scheduler_results(const mac_dl_ { if (last_slot_ind != dl_res.slot) { // Process any pending tasks for the test mode UE manager asynchronously. - ue_info_mgr.process_pending_tasks(); + ue_info_mgr.process_pending_tasks(cell_index); last_slot_ind = dl_res.slot; } @@ -381,7 +350,7 @@ void mac_test_mode_cell_adapter::on_new_uplink_scheduler_results(const mac_ul_sc { if (last_slot_ind != ul_res.slot) { // Process any pending tasks for the test mode UE manager asynchronously. - ue_info_mgr.process_pending_tasks(); + ue_info_mgr.process_pending_tasks(cell_index); last_slot_ind = ul_res.slot; } @@ -396,12 +365,12 @@ void mac_test_mode_cell_adapter::on_new_uplink_scheduler_results(const mac_ul_sc // Fill the ring element with the scheduler decisions. for (const pucch_info& pucch : ul_res.ul_res->pucchs) { - if (ue_info_mgr.is_test_ue(pucch.crnti)) { + if (ue_info_mgr.is_cell_test_ue(cell_index, pucch.crnti)) { entry.pucchs.push_back(pucch); } } for (const ul_sched_info& pusch : ul_res.ul_res->puschs) { - if (ue_info_mgr.is_test_ue(pusch.pusch_cfg.rnti)) { + if (ue_info_mgr.is_cell_test_ue(cell_index, pusch.pusch_cfg.rnti)) { entry.puschs.push_back(pusch); } } @@ -409,7 +378,7 @@ void mac_test_mode_cell_adapter::on_new_uplink_scheduler_results(const mac_ul_sc if (ul_res.ul_res != nullptr and not ul_res.ul_res->pucchs.empty()) { for (const pucch_info& pucch : ul_res.ul_res->pucchs) { - if (not ue_info_mgr.is_test_ue(pucch.crnti) or ue_info_mgr.is_msg4_rxed(pucch.crnti)) { + if (not ue_info_mgr.is_cell_test_ue(cell_index, pucch.crnti) or ue_info_mgr.is_msg4_rxed(pucch.crnti)) { // UE is not test mode or it has already received Msg4. continue; } diff --git a/lib/du/du_high/test_mode/mac_test_mode_adapter.h b/lib/du/du_high/test_mode/mac_test_mode_adapter.h index b7595b19f1..755fb6abc3 100644 --- a/lib/du/du_high/test_mode/mac_test_mode_adapter.h +++ b/lib/du/du_high/test_mode/mac_test_mode_adapter.h @@ -22,8 +22,7 @@ #pragma once -#include "srsran/adt/mpmc_queue.h" -#include "srsran/adt/unique_function.h" +#include "mac_test_mode_ue_repository.h" #include "srsran/du/du_high/du_test_mode_config.h" #include "srsran/mac/mac.h" #include "srsran/mac/mac_cell_result.h" @@ -31,83 +30,10 @@ #include "srsran/scheduler/result/pusch_info.h" #include "srsran/srslog/srslog.h" #include -#include namespace srsran { namespace srs_du { -/// \brief Handles information related to the test UE(s). -class test_ue_info_manager -{ -public: - test_ue_info_manager(rnti_t rnti_start_, uint16_t nof_ues_, uint16_t nof_cells_); - - du_ue_index_t rnti_to_du_ue_idx(rnti_t rnti) const - { - if (rnti_to_ue_info_lookup.count(rnti) == 0) { - return INVALID_DU_UE_INDEX; - } - return rnti_to_ue_info_lookup.at(rnti).ue_idx; - } - - bool is_test_ue(du_ue_index_t ue_idx) const { return ue_idx < nof_ues; } - - bool is_test_ue(rnti_t rnti) const - { - return (rnti >= rnti_start) and (rnti < to_rnti(to_value(rnti_start) + nof_ues * nof_cells)); - } - - void add_ue(rnti_t rnti, du_ue_index_t ue_idx_, const sched_ue_config_request& sched_ue_cfg_req_); - - void remove_ue(rnti_t rnti); - - const sched_ue_config_request& get_sched_ue_cfg_request(rnti_t rnti) const - { - return rnti_to_ue_info_lookup.at(rnti).sched_ue_cfg_req; - } - - const sched_ue_config_request* find_sched_ue_cfg_request(rnti_t rnti) const - { - auto it = rnti_to_ue_info_lookup.find(rnti); - return it != rnti_to_ue_info_lookup.end() ? &it->second.sched_ue_cfg_req : nullptr; - } - - bool is_msg4_rxed(rnti_t rnti) const - { - if (rnti_to_ue_info_lookup.count(rnti) > 0) { - return rnti_to_ue_info_lookup.at(rnti).msg4_rx_flag; - } - return false; - } - - void msg4_rxed(rnti_t rnti, bool msg4_rx_flag_) - { - if (rnti_to_ue_info_lookup.count(rnti) > 0) { - rnti_to_ue_info_lookup.at(rnti).msg4_rx_flag = msg4_rx_flag_; - } - } - - void process_pending_tasks(); - -private: - struct test_ue_info { - du_ue_index_t ue_idx; - sched_ue_config_request sched_ue_cfg_req; - bool msg4_rx_flag; - }; - - // Parameters received from configuration. - rnti_t rnti_start; - uint16_t nof_ues; - uint16_t nof_cells; - - // Mapping between UE RNTI and test UE information. - std::unordered_map rnti_to_ue_info_lookup; - - concurrent_queue - pending_tasks; -}; - class phy_test_mode_adapter : public mac_result_notifier { public: @@ -149,7 +75,7 @@ class mac_test_mode_cell_adapter : public mac_cell_control_information_handler, mac_cell_slot_handler& slot_handler_, mac_cell_result_notifier& result_notifier_, std::function dl_bs_notifier_, - test_ue_info_manager& ue_info_mgr_); + mac_test_mode_ue_repository& ue_info_mgr_); void on_new_downlink_scheduler_results(const mac_dl_sched_result& dl_res) override; @@ -188,6 +114,7 @@ class mac_test_mode_cell_adapter : public mac_cell_control_information_handler, size_t get_ring_idx(slot_point sl) const { return sl.to_uint() % sched_decision_history.size(); } + const du_cell_index_t cell_index; const srs_du::du_test_mode_config::test_mode_ue_config& test_ue_cfg; mac_cell_control_information_handler& adapted; mac_pdu_handler& pdu_handler; @@ -198,7 +125,7 @@ class mac_test_mode_cell_adapter : public mac_cell_control_information_handler, std::vector sched_decision_history; - test_ue_info_manager& ue_info_mgr; + mac_test_mode_ue_repository& ue_info_mgr; slot_point last_slot_ind; }; @@ -265,7 +192,7 @@ class mac_test_mode_adapter final : public mac_interface, srs_du::du_test_mode_config::test_mode_ue_config test_ue; std::unique_ptr mac_adapted; - test_ue_info_manager ue_info_mgr; + mac_test_mode_ue_repository ue_info_mgr; std::unique_ptr phy_notifier; diff --git a/lib/du/du_high/test_mode/mac_test_mode_ue_repository.cpp b/lib/du/du_high/test_mode/mac_test_mode_ue_repository.cpp new file mode 100644 index 0000000000..89074a10d0 --- /dev/null +++ b/lib/du/du_high/test_mode/mac_test_mode_ue_repository.cpp @@ -0,0 +1,136 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN 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. + * + * srsRAN 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 "mac_test_mode_ue_repository.h" +#include "srsran/srslog/srslog.h" +#include "srsran/support/srsran_assert.h" + +using namespace srsran; + +mac_test_mode_ue_repository::mac_test_mode_ue_repository(rnti_t rnti_start_, uint16_t nof_ues_, uint16_t nof_cells) : + rnti_start(static_cast(rnti_start_)), nof_ues(nof_ues_), rnti_end(rnti_start + nof_ues * nof_cells) +{ + cells.reserve(nof_cells); + for (unsigned i = 0, e = nof_cells; i < e; ++i) { + cells.emplace_back(std::make_unique(128U)); + } +} + +unsigned mac_test_mode_ue_repository::get_cell_index(du_ue_index_t ue_index) const +{ + unsigned cell_idx = static_cast(ue_index) / nof_ues; + srsran_assert(cell_idx < cells.size(), "Invalid UE index {}", fmt::underlying(ue_index)); + return cell_idx; +} + +unsigned mac_test_mode_ue_repository::get_cell_index(rnti_t rnti) const +{ + unsigned rnti_idx = static_cast(rnti) - static_cast(rnti_start); + unsigned cell_idx = rnti_idx / nof_ues; + srsran_assert(cell_idx < cells.size(), "Invalid RNTI {}", rnti); + return cell_idx; +} + +du_ue_index_t mac_test_mode_ue_repository::rnti_to_du_ue_idx(rnti_t rnti) const +{ + unsigned cell_idx = get_cell_index(rnti); + auto it = cells[cell_idx]->rnti_to_ue_info_lookup.find(rnti); + if (it == cells[cell_idx]->rnti_to_ue_info_lookup.end()) { + return INVALID_DU_UE_INDEX; + } + return it->second.ue_idx; +} + +const sched_ue_config_request& mac_test_mode_ue_repository::get_sched_ue_cfg_request(rnti_t rnti) const +{ + return cells[get_cell_index(rnti)]->rnti_to_ue_info_lookup.at(rnti).sched_ue_cfg_req; +} + +const sched_ue_config_request* mac_test_mode_ue_repository::find_sched_ue_cfg_request(rnti_t rnti) const +{ + unsigned cell_idx = get_cell_index(rnti); + auto it = cells[cell_idx]->rnti_to_ue_info_lookup.find(rnti); + return it != cells[cell_idx]->rnti_to_ue_info_lookup.end() ? &it->second.sched_ue_cfg_req : nullptr; +} + +bool mac_test_mode_ue_repository::is_msg4_rxed(rnti_t rnti) const +{ + unsigned cell_idx = get_cell_index(rnti); + if (cells[cell_idx]->rnti_to_ue_info_lookup.count(rnti) > 0) { + return cells[cell_idx]->rnti_to_ue_info_lookup.at(rnti).msg4_rx_flag; + } + return false; +} + +void mac_test_mode_ue_repository::msg4_rxed(rnti_t rnti, bool msg4_rx_flag_) +{ + unsigned cell_idx = get_cell_index(rnti); + if (cells[cell_idx]->rnti_to_ue_info_lookup.count(rnti) > 0) { + cells[cell_idx]->rnti_to_ue_info_lookup.at(rnti).msg4_rx_flag = msg4_rx_flag_; + } +} + +void mac_test_mode_ue_repository::add_ue(rnti_t rnti, + du_ue_index_t ue_idx, + const sched_ue_config_request& sched_ue_cfg_req) +{ + if (not is_test_ue(rnti) or not is_test_ue(ue_idx)) { + return; + } + unsigned rnti_idx = static_cast(rnti) - static_cast(rnti_start); + srsran_assert(rnti_idx == static_cast(ue_idx), + "rnti={}, ue={}: Invalid test mode UE identifiers", + rnti, + fmt::underlying(ue_idx)); + + unsigned cell_idx = get_cell_index(ue_idx); + + // Dispatch creation of UE to du_cell thread. + while (not cells[cell_idx]->pending_tasks.try_push([this, rnti, ue_idx, sched_ue_cfg_req]() { + unsigned idx = get_cell_index(ue_idx); + cells[idx]->rnti_to_ue_info_lookup[rnti] = + test_ue_info{.ue_idx = ue_idx, .sched_ue_cfg_req = sched_ue_cfg_req, .msg4_rx_flag = false}; + })) { + srslog::fetch_basic_logger("MAC").warning("Failed to add test mode UE. Retrying..."); + } +} + +void mac_test_mode_ue_repository::remove_ue(rnti_t rnti) +{ + unsigned cell_idx = get_cell_index(rnti); + while (not cells[cell_idx]->pending_tasks.try_push([this, rnti]() { + unsigned idx = get_cell_index(rnti); + if (cells[idx]->rnti_to_ue_info_lookup.count(rnti) > 0) { + cells[idx]->rnti_to_ue_info_lookup.erase(rnti); + } + })) { + srslog::fetch_basic_logger("MAC").warning("Failed to remove test mode UE. Retrying..."); + } +} + +void mac_test_mode_ue_repository::process_pending_tasks(du_cell_index_t cell_index) +{ + unique_task task; + while (cells[cell_index]->pending_tasks.try_pop(task)) { + task(); + } +} diff --git a/lib/du/du_high/test_mode/mac_test_mode_ue_repository.h b/lib/du/du_high/test_mode/mac_test_mode_ue_repository.h new file mode 100644 index 0000000000..e558640a5c --- /dev/null +++ b/lib/du/du_high/test_mode/mac_test_mode_ue_repository.h @@ -0,0 +1,102 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN 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. + * + * srsRAN 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/. + * + */ + +#pragma once + +#include "srsran/adt/mpmc_queue.h" +#include "srsran/adt/unique_function.h" +#include "srsran/ran/du_types.h" +#include "srsran/ran/rnti.h" +#include "srsran/scheduler/scheduler_configurator.h" +#include +#include + +namespace srsran { + +/// \brief Handles information related to the test UE(s). +class mac_test_mode_ue_repository +{ +public: + mac_test_mode_ue_repository(rnti_t rnti_start_, uint16_t nof_ues_, uint16_t nof_cells_); + + bool is_test_ue(du_ue_index_t ue_idx) const { return ue_idx < nof_ues * cells.size(); } + + bool is_test_ue(rnti_t rnti) const + { + uint16_t rnti_val = static_cast(rnti); + return rnti_val >= rnti_start and rnti_val < rnti_end; + } + + bool is_cell_test_ue(du_cell_index_t cell_idx, rnti_t rnti) const + { + unsigned rnti_val = static_cast(rnti) - rnti_start; + return rnti_val / nof_ues == cell_idx; + } + + const sched_ue_config_request& get_sched_ue_cfg_request(rnti_t rnti) const; + + const sched_ue_config_request* find_sched_ue_cfg_request(rnti_t rnti) const; + + bool is_msg4_rxed(rnti_t rnti) const; + + void msg4_rxed(rnti_t rnti, bool msg4_rx_flag_); + + void add_ue(rnti_t rnti, du_ue_index_t ue_idx_, const sched_ue_config_request& sched_ue_cfg_req_); + + void remove_ue(rnti_t rnti); + + void process_pending_tasks(du_cell_index_t cell_index); + + du_ue_index_t rnti_to_du_ue_idx(rnti_t rnti) const; + +private: + using cell_event_queue = + concurrent_queue; + + struct test_ue_info { + du_ue_index_t ue_idx; + sched_ue_config_request sched_ue_cfg_req; + bool msg4_rx_flag; + }; + + struct cell_info { + cell_event_queue pending_tasks; + // Mapping between UE RNTI and test UE information. + std::unordered_map rnti_to_ue_info_lookup; + + cell_info(unsigned qsize) : pending_tasks(qsize) {} + }; + + unsigned get_cell_index(du_ue_index_t ue_index) const; + unsigned get_cell_index(rnti_t rnti) const; + + // Parameters received from configuration. + const uint16_t rnti_start; + const uint16_t nof_ues; + + // Derived + uint16_t rnti_end; + + std::vector> cells; +}; + +} // namespace srsran diff --git a/lib/du/du_low/du_low_impl.cpp b/lib/du/du_low/du_low_impl.cpp index 3f58d2624f..618f988a73 100644 --- a/lib/du/du_low/du_low_impl.cpp +++ b/lib/du/du_low/du_low_impl.cpp @@ -46,7 +46,3 @@ void du_low_impl::stop() cell->stop(); } } -span du_low_impl::get_all_upper_phys() -{ - return upper_ptrs; -} diff --git a/lib/du/du_low/du_low_impl.h b/lib/du/du_low/du_low_impl.h index 81a52410fe..f7c4aef497 100644 --- a/lib/du/du_low/du_low_impl.h +++ b/lib/du/du_low/du_low_impl.h @@ -42,14 +42,11 @@ class du_low_impl final : public du_low, public du_power_controller du_power_controller& get_power_controller() override { return *this; } // See interface for documentation. - void start() override{}; + void start() override {} // See interface for documentation. void stop() override; - // See interface for documentation. - span get_all_upper_phys() override; - private: std::vector> upper; std::vector upper_ptrs; diff --git a/lib/du/du_low/o_du_low_factory.cpp b/lib/du/du_low/o_du_low_factory.cpp index 1aac478842..b072d2d919 100644 --- a/lib/du/du_low/o_du_low_factory.cpp +++ b/lib/du/du_low/o_du_low_factory.cpp @@ -33,98 +33,48 @@ using namespace srsran; using namespace srs_du; -static fapi::prach_config generate_prach_config_tlv(const du_cell_config& cell_cfg) +static fapi_adaptor::phy_fapi_adaptor_config generate_fapi_adaptor_config(const o_du_low_config& odu_low_cfg, + span du_cell) { - fapi::prach_config config = {}; - config.prach_res_config_index = 0; - config.prach_sequence_length = fapi::prach_sequence_length_type::long_sequence; - config.prach_scs = prach_subcarrier_spacing::kHz1_25; - config.prach_ul_bwp_pusch_scs = cell_cfg.scs_common; - config.restricted_set = restricted_set_config::UNRESTRICTED; - config.num_prach_fd_occasions = cell_cfg.ul_cfg_common.init_ul_bwp.rach_cfg_common.value().rach_cfg_generic.msg1_fdm; - config.prach_config_index = - cell_cfg.ul_cfg_common.init_ul_bwp.rach_cfg_common.value().rach_cfg_generic.prach_config_index; - config.prach_format = prach_format_type::zero; - config.num_prach_td_occasions = 1; - config.num_preambles = 1; - config.start_preamble_index = 0; - - // Add FD occasion info. - fapi::prach_fd_occasion_config& fd_occasion = config.fd_occasions.emplace_back(); - fd_occasion.prach_root_sequence_index = - cell_cfg.ul_cfg_common.init_ul_bwp.rach_cfg_common.value().prach_root_seq_index; - fd_occasion.prach_freq_offset = - cell_cfg.ul_cfg_common.init_ul_bwp.rach_cfg_common.value().rach_cfg_generic.msg1_frequency_start; - fd_occasion.prach_zero_corr_conf = - cell_cfg.ul_cfg_common.init_ul_bwp.rach_cfg_common.value().rach_cfg_generic.zero_correlation_zone_config; - - return config; -} - -static fapi::carrier_config generate_carrier_config_tlv(const du_cell_config& du_cell) -{ - // Deduce common numerology and grid size for DL and UL. - unsigned numerology = to_numerology_value(du_cell.scs_common); - unsigned grid_size_bw_prb = - band_helper::get_n_rbs_from_bw(MHz_to_bs_channel_bandwidth(du_cell.dl_carrier.carrier_bw_mhz), - du_cell.scs_common, - band_helper::get_freq_range(du_cell.dl_carrier.band)); - - fapi::carrier_config fapi_config = {}; - - // NOTE; for now we only need to fill the nof_prb_ul_grid and nof_prb_dl_grid for the common SCS. - fapi_config.dl_grid_size = {}; - fapi_config.dl_grid_size[numerology] = grid_size_bw_prb; - fapi_config.ul_grid_size = {}; - fapi_config.ul_grid_size[numerology] = grid_size_bw_prb; - - // Number of transmit and receive antenna ports. - fapi_config.num_tx_ant = du_cell.dl_carrier.nof_ant; - fapi_config.num_rx_ant = du_cell.ul_carrier.nof_ant; + fapi_adaptor::phy_fapi_adaptor_config out_config; + + for (unsigned i = 0, e = du_cell.size(); i != e; ++i) { + const upper_phy_config& upper_cfg = odu_low_cfg.du_low_cfg.cells[i].upper_phy_cfg; + const du_cell_config& cell_cfg = du_cell[i]; + out_config.sectors.push_back( + {upper_cfg.sector_id, + upper_cfg.nof_slots_request_headroom, + cell_cfg, + std::vector(odu_low_cfg.prach_ports[i].begin(), odu_low_cfg.prach_ports[i].end())}); + } - return fapi_config; + return out_config; } -static std::unique_ptr create_phy_fapi_adaptor(upper_phy& upper, - const upper_phy_config& upper_cfg, - const du_cell_config& du_cell, - span prach_ports) +static fapi_adaptor::phy_fapi_adaptor_dependencies +generate_fapi_adaptor_dependencies(du_low& du_low, span du_cell) { - const subcarrier_spacing scs = du_cell.scs_common; - auto pm_tools = fapi_adaptor::generate_precoding_matrix_tables(du_cell.dl_carrier.nof_ant); - auto uci_part2_tools = fapi_adaptor::generate_uci_part2_correspondence(1); - - std::unique_ptr adaptor_factory = - fapi_adaptor::create_phy_fapi_adaptor_factory(); - report_error_if_not(adaptor_factory, "Invalid PHY adaptor factory."); - - auto prach_tlv = generate_prach_config_tlv(du_cell); - auto carrier_tlv = generate_carrier_config_tlv(du_cell); - - fapi_adaptor::phy_fapi_adaptor_factory_config phy_fapi_config; - phy_fapi_config.sector_id = upper_cfg.sector_id; - phy_fapi_config.nof_slots_request_headroom = upper_cfg.nof_slots_request_headroom; - phy_fapi_config.scs = scs; - phy_fapi_config.scs_common = scs; - phy_fapi_config.prach_cfg = &prach_tlv; - phy_fapi_config.carrier_cfg = &carrier_tlv; - phy_fapi_config.prach_ports = std::vector(prach_ports.begin(), prach_ports.end()); - - fapi_adaptor::phy_fapi_adaptor_factory_dependencies phy_fapi_dependencies; - phy_fapi_dependencies.logger = &srslog::fetch_basic_logger("FAPI"); - phy_fapi_dependencies.dl_processor_pool = &upper.get_downlink_processor_pool(); - phy_fapi_dependencies.dl_rg_pool = &upper.get_downlink_resource_grid_pool(); - phy_fapi_dependencies.dl_pdu_validator = &upper.get_downlink_pdu_validator(); - phy_fapi_dependencies.ul_request_processor = &upper.get_uplink_request_processor(); - phy_fapi_dependencies.ul_rg_pool = &upper.get_uplink_resource_grid_pool(); - phy_fapi_dependencies.ul_pdu_repository = &upper.get_uplink_slot_pdu_repository(); - phy_fapi_dependencies.ul_pdu_validator = &upper.get_uplink_pdu_validator(); - phy_fapi_dependencies.pm_repo = - std::move(std::get>(pm_tools)); - phy_fapi_dependencies.part2_repo = - std::move(std::get>(uci_part2_tools)); + fapi_adaptor::phy_fapi_adaptor_dependencies out_dependencies; + + for (unsigned i = 0, e = du_cell.size(); i != e; ++i) { + auto& dependencies = out_dependencies.sectors.emplace_back(); + upper_phy& upper = du_low.get_upper_phy(i); + + dependencies.logger = &srslog::fetch_basic_logger("FAPI"); + dependencies.dl_processor_pool = &upper.get_downlink_processor_pool(); + dependencies.dl_rg_pool = &upper.get_downlink_resource_grid_pool(); + dependencies.dl_pdu_validator = &upper.get_downlink_pdu_validator(); + dependencies.ul_request_processor = &upper.get_uplink_request_processor(); + dependencies.ul_rg_pool = &upper.get_uplink_resource_grid_pool(); + dependencies.ul_pdu_repository = &upper.get_uplink_slot_pdu_repository(); + dependencies.ul_pdu_validator = &upper.get_uplink_pdu_validator(); + dependencies.pm_repo = std::move(std::get>( + fapi_adaptor::generate_precoding_matrix_tables(du_cell[i].dl_carrier.nof_ant))); + dependencies.part2_repo = std::move(std::get>( + fapi_adaptor::generate_uci_part2_correspondence(1))); + } - return adaptor_factory->create(phy_fapi_config, std::move(phy_fapi_dependencies)); + return out_dependencies; } std::unique_ptr srsran::srs_du::make_o_du_low(const o_du_low_config& config, @@ -145,16 +95,8 @@ std::unique_ptr srsran::srs_du::make_o_du_low(const o_du_low_config& report_error_if_not(du_lo != nullptr, "Unable to create DU low."); logger.debug("DU low created successfully"); - // Instantiate adaptor of FAPI to DU-low. - std::vector> fapi_adaptors(config.du_low_cfg.cells.size()); - for (unsigned i = 0, e = config.du_low_cfg.cells.size(); i != e; ++i) { - fapi_adaptors[i] = create_phy_fapi_adaptor( - du_lo->get_upper_phy(i), config.du_low_cfg.cells[i].upper_phy_cfg, du_cells[i], config.prach_ports[i]); - - report_error_if_not(fapi_adaptors[i], "Unable to create PHY adaptor for cell '{}'", i); - } - - logger.debug("O-DU low created successfully"); + auto fapi_adaptor = fapi_adaptor::create_phy_fapi_adaptor_factory()->create( + generate_fapi_adaptor_config(config, du_cells), generate_fapi_adaptor_dependencies(*du_lo, du_cells)); - return std::make_unique(std::move(du_lo), std::move(fapi_adaptors)); + return std::make_unique(std::move(du_lo), std::move(fapi_adaptor), du_cells.size()); } diff --git a/lib/du/du_low/o_du_low_impl.cpp b/lib/du/du_low/o_du_low_impl.cpp index 732ac0c365..6a83dd1e20 100644 --- a/lib/du/du_low/o_du_low_impl.cpp +++ b/lib/du/du_low/o_du_low_impl.cpp @@ -21,23 +21,28 @@ */ #include "o_du_low_impl.h" +#include "srsran/fapi_adaptor/phy/phy_fapi_sector_adaptor.h" #include "srsran/phy/upper/upper_phy.h" #include "srsran/support/srsran_assert.h" using namespace srsran; using namespace srs_du; -o_du_low_impl::o_du_low_impl(std::unique_ptr du_lo_, - std::vector> fapi_adaptors_) : - du_lo(std::move(du_lo_)), fapi_adaptors(std::move(fapi_adaptors_)) +o_du_low_impl::o_du_low_impl(std::unique_ptr du_lo_, + std::unique_ptr fapi_adaptor_, + unsigned nof_cells) : + du_lo(std::move(du_lo_)), fapi_adaptor(std::move(fapi_adaptor_)) { srsran_assert(du_lo, "Invalid upper PHY"); - srsran_assert(!fapi_adaptors.empty(), "Invalid FAPI adaptor"); + srsran_assert(fapi_adaptor, "Invalid FAPI adaptor"); - for (unsigned i = 0, e = fapi_adaptors.size(); i != e; ++i) { - du_lo->get_upper_phy(i).set_rx_results_notifier(fapi_adaptors[i]->get_rx_results_notifier()); - du_lo->get_upper_phy(i).set_timing_notifier(fapi_adaptors[i]->get_timing_notifier()); - du_lo->get_upper_phy(i).set_error_notifier(fapi_adaptors[i]->get_error_notifier()); + for (unsigned i = 0; i != nof_cells; ++i) { + upper_phy& upper = du_lo->get_upper_phy(i); + fapi_adaptor::phy_fapi_sector_adaptor& sector_adaptor = fapi_adaptor->get_sector_adaptor(i); + + upper.set_rx_results_notifier(sector_adaptor.get_rx_results_notifier()); + upper.set_timing_notifier(sector_adaptor.get_timing_notifier()); + upper.set_error_notifier(sector_adaptor.get_error_notifier()); } } @@ -46,55 +51,7 @@ du_low& o_du_low_impl::get_du_low() return *du_lo; } -fapi::slot_message_gateway& o_du_low_impl::get_slot_message_gateway(unsigned cell_id) -{ - srsran_assert(cell_id < fapi_adaptors.size(), - "Invalid cell index '{}'. Valid cell indexes [0-{})", - cell_id, - fapi_adaptors.size()); - - return fapi_adaptors[cell_id]->get_slot_message_gateway(); -} - -fapi::slot_last_message_notifier& o_du_low_impl::get_slot_last_message_notifier(unsigned cell_id) -{ - srsran_assert(cell_id < fapi_adaptors.size(), - "Invalid cell index '{}'. Valid cell indexes [0-{})", - cell_id, - fapi_adaptors.size()); - - return fapi_adaptors[cell_id]->get_slot_last_message_notifier(); -} - -void o_du_low_impl::set_slot_time_message_notifier(unsigned cell_id, - fapi::slot_time_message_notifier& fapi_time_notifier) +fapi_adaptor::phy_fapi_adaptor& o_du_low_impl::get_phy_fapi_adaptor() { - srsran_assert(cell_id < fapi_adaptors.size(), - "Invalid cell index '{}'. Valid cell indexes [0-{})", - cell_id, - fapi_adaptors.size()); - - fapi_adaptors[cell_id]->set_slot_time_message_notifier(fapi_time_notifier); -} - -void o_du_low_impl::set_slot_error_message_notifier(unsigned cell_id, - fapi::slot_error_message_notifier& fapi_error_notifier) -{ - srsran_assert(cell_id < fapi_adaptors.size(), - "Invalid cell index '{}'. Valid cell indexes [0-{})", - cell_id, - fapi_adaptors.size()); - - fapi_adaptors[cell_id]->set_slot_error_message_notifier(fapi_error_notifier); -} - -void o_du_low_impl::set_slot_data_message_notifier(unsigned cell_id, - fapi::slot_data_message_notifier& fapi_data_notifier) -{ - srsran_assert(cell_id < fapi_adaptors.size(), - "Invalid cell index '{}'. Valid cell indexes [0-{})", - cell_id, - fapi_adaptors.size()); - - fapi_adaptors[cell_id]->set_slot_data_message_notifier(fapi_data_notifier); + return *fapi_adaptor; } diff --git a/lib/du/du_low/o_du_low_impl.h b/lib/du/du_low/o_du_low_impl.h index 228484fa01..d3bba29cf9 100644 --- a/lib/du/du_low/o_du_low_impl.h +++ b/lib/du/du_low/o_du_low_impl.h @@ -26,7 +26,6 @@ #include "srsran/du/du_low/o_du_low.h" #include "srsran/fapi_adaptor/phy/phy_fapi_adaptor.h" #include -#include namespace srsran { namespace srs_du { @@ -34,31 +33,19 @@ namespace srs_du { class o_du_low_impl final : public o_du_low { public: - o_du_low_impl(std::unique_ptr du_lo_, - std::vector> fapi_adaptors_); + o_du_low_impl(std::unique_ptr du_lo_, + std::unique_ptr fapi_adaptor_, + unsigned nof_cells); // See interface for documentation. du_low& get_du_low() override; // See interface for documentation. - fapi::slot_message_gateway& get_slot_message_gateway(unsigned cell_id) override; - - // See interface for documentation. - fapi::slot_last_message_notifier& get_slot_last_message_notifier(unsigned cell_id) override; - - // See interface for documentation. - void set_slot_time_message_notifier(unsigned cell_id, fapi::slot_time_message_notifier& fapi_time_notifier) override; - - // See interface for documentation. - void set_slot_error_message_notifier(unsigned cell_id, - fapi::slot_error_message_notifier& fapi_error_notifier) override; - - // See interface for documentation. - void set_slot_data_message_notifier(unsigned cell_id, fapi::slot_data_message_notifier& fapi_data_notifier) override; + fapi_adaptor::phy_fapi_adaptor& get_phy_fapi_adaptor() override; private: - std::unique_ptr du_lo; - std::vector> fapi_adaptors; + std::unique_ptr du_lo; + std::unique_ptr fapi_adaptor; }; } // namespace srs_du diff --git a/lib/du/o_du_factory.cpp b/lib/du/o_du_factory.cpp index c9f02e2c03..3eb737a614 100644 --- a/lib/du/o_du_factory.cpp +++ b/lib/du/o_du_factory.cpp @@ -28,31 +28,6 @@ using namespace srsran; using namespace srs_du; -std::unique_ptr srsran::srs_du::make_o_du(const o_du_config& du_cfg, o_du_dependencies&& dependencies) -{ - o_du_impl_dependencies o_du_deps; - - // Create DU low. - o_du_deps.du_lo = make_o_du_low(du_cfg.du_low_cfg, du_cfg.du_high_cfg.du_hi.ran.cells); - - // Fill O-DU high dependencies. - srsran_assert(du_cfg.du_low_cfg.du_low_cfg.cells.size() == dependencies.du_high_deps.sectors.size(), - "DU low number of cells '{}' does not match the number of cells of the DU high dependencies '{}'", - du_cfg.du_low_cfg.du_low_cfg.cells.size(), - dependencies.du_high_deps.sectors.size()); - for (unsigned i = 0, e = du_cfg.du_low_cfg.du_low_cfg.cells.size(); i != e; ++i) { - o_du_high_sector_dependencies& deps = dependencies.du_high_deps.sectors[i]; - deps.gateway = &o_du_deps.du_lo->get_slot_message_gateway(i); - deps.last_msg_notifier = &o_du_deps.du_lo->get_slot_last_message_notifier(i); - } - - o_du_deps.du_hi = make_o_du_high(du_cfg.du_high_cfg, std::move(dependencies.du_high_deps)); - - srslog::fetch_basic_logger("DU").info("O-DU created successfully"); - - return std::make_unique(std::move(o_du_deps)); -} - std::unique_ptr srs_du::make_o_du(std::unique_ptr odu_hi, std::unique_ptr odu_lo) { srsran_assert(odu_hi, "Invalid O-DU high"); diff --git a/lib/du/o_du_impl.cpp b/lib/du/o_du_impl.cpp index 2e2622d7da..ccf3d34299 100644 --- a/lib/du/o_du_impl.cpp +++ b/lib/du/o_du_impl.cpp @@ -23,6 +23,9 @@ #include "o_du_impl.h" #include "srsran/du/du_high/o_du_high.h" #include "srsran/du/du_low/du_low.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_sector_adaptor.h" +#include "srsran/fapi_adaptor/phy/phy_fapi_adaptor.h" +#include "srsran/fapi_adaptor/phy/phy_fapi_sector_adaptor.h" #include "srsran/support/srsran_assert.h" using namespace srsran; @@ -33,13 +36,6 @@ o_du_impl::o_du_impl(o_du_impl_dependencies&& dependencies) : { srsran_assert(du_lo, "Invalid DU low"); srsran_assert(du_hi, "Invalid DU high"); - - // Connect O-DU low with O-DU high. - for (unsigned i = 0, e = du_lo->get_du_low().get_all_upper_phys().size(); i != e; ++i) { - du_lo->set_slot_time_message_notifier(i, du_hi->get_slot_time_message_notifier(i)); - du_lo->set_slot_error_message_notifier(i, du_hi->get_slot_error_message_notifier(i)); - du_lo->set_slot_data_message_notifier(i, du_hi->get_slot_data_message_notifier(i)); - } } void o_du_impl::start() diff --git a/lib/e2/procedures/e2_subscription_delete_procedure.h b/lib/e2/procedures/e2_subscription_delete_procedure.h index e940f5d696..faceba02fc 100644 --- a/lib/e2/procedures/e2_subscription_delete_procedure.h +++ b/lib/e2/procedures/e2_subscription_delete_procedure.h @@ -52,12 +52,12 @@ class e2_subscription_delete_procedure void send_e2_subscription_delete_response(const e2_subscribe_delete_response_message& response); void send_e2_subscription_delete_failure(const e2_subscribe_delete_response_message& failure); - const asn1::e2ap::ric_sub_delete_request_s& request; - e2_event_manager& event_manager; - srslog::basic_logger& logger; - e2_message_notifier& ric_notif; - e2_subscription_proc& subscription_mngr; - timer_factory timers; + const asn1::e2ap::ric_sub_delete_request_s request; + e2_event_manager& event_manager; + srslog::basic_logger& logger; + e2_message_notifier& ric_notif; + e2_subscription_proc& subscription_mngr; + timer_factory timers; }; } // namespace srsran diff --git a/lib/e2/procedures/e2_subscription_setup_procedure.cpp b/lib/e2/procedures/e2_subscription_setup_procedure.cpp index 582dd74ccc..82dec862f4 100644 --- a/lib/e2/procedures/e2_subscription_setup_procedure.cpp +++ b/lib/e2/procedures/e2_subscription_setup_procedure.cpp @@ -84,7 +84,9 @@ void e2_subscription_setup_procedure::send_e2_subscription_setup_failure(const e auto& sub_fail = msg.pdu.unsuccessful_outcome().value.ric_sub_fail(); sub_fail->ric_request_id.ric_instance_id = failure.request_id.ric_instance_id; sub_fail->ric_request_id.ric_requestor_id = failure.request_id.ric_requestor_id; - sub_fail->cause = failure.cause; + sub_fail->ran_function_id = failure.ran_function_id; + sub_fail->crit_diagnostics_present = false; + sub_fail->cause.set_misc(); ric_notif.on_new_message(msg); logger.info("E2AP: Sending subscription failure"); } diff --git a/lib/e2/procedures/e2_subscription_setup_procedure.h b/lib/e2/procedures/e2_subscription_setup_procedure.h index 912f6ac80a..493de7f25e 100644 --- a/lib/e2/procedures/e2_subscription_setup_procedure.h +++ b/lib/e2/procedures/e2_subscription_setup_procedure.h @@ -52,12 +52,12 @@ class e2_subscription_setup_procedure void send_e2_subscription_setup_response(const e2_subscribe_reponse_message& response); void send_e2_subscription_setup_failure(const e2_subscribe_reponse_message& failure); - const asn1::e2ap::ric_sub_request_s& request; - e2_event_manager& event_manager; - srslog::basic_logger& logger; - e2_message_notifier& ric_notif; - e2_subscription_proc& subscription_mngr; - timer_factory timers; + const asn1::e2ap::ric_sub_request_s request; + e2_event_manager& event_manager; + srslog::basic_logger& logger; + e2_message_notifier& ric_notif; + e2_subscription_proc& subscription_mngr; + timer_factory timers; }; } // namespace srsran diff --git a/lib/fapi_adaptor/mac/CMakeLists.txt b/lib/fapi_adaptor/mac/CMakeLists.txt index 4a4b8d35ee..7ac86fdf0d 100644 --- a/lib/fapi_adaptor/mac/CMakeLists.txt +++ b/lib/fapi_adaptor/mac/CMakeLists.txt @@ -32,5 +32,5 @@ set(SOURCES add_library(srsran_fapi_to_mac_translator STATIC ${SOURCES}) target_link_libraries(srsran_fapi_to_mac_translator srsvec srsran_support) -add_library(srsran_mac_fapi_adaptor STATIC mac_fapi_adaptor_impl.cpp mac_fapi_adaptor_factory_impl.cpp) +add_library(srsran_mac_fapi_adaptor STATIC mac_fapi_sector_adaptor_impl.cpp mac_fapi_adaptor_impl.cpp mac_fapi_adaptor_factory_impl.cpp) target_link_libraries(srsran_mac_fapi_adaptor srsran_mac_to_fapi_translator srsran_fapi_to_mac_translator) diff --git a/lib/fapi_adaptor/mac/mac_fapi_adaptor_factory_impl.cpp b/lib/fapi_adaptor/mac/mac_fapi_adaptor_factory_impl.cpp index 20c2792c4c..e66b0b8c83 100644 --- a/lib/fapi_adaptor/mac/mac_fapi_adaptor_factory_impl.cpp +++ b/lib/fapi_adaptor/mac/mac_fapi_adaptor_factory_impl.cpp @@ -22,17 +22,118 @@ #include "mac_fapi_adaptor_factory_impl.h" #include "mac_fapi_adaptor_impl.h" +#include "mac_fapi_sector_adaptor_impl.h" +#include "srsran/fapi/decorator.h" +#include "srsran/fapi/decorator_factory.h" +#include "srsran/srslog/srslog.h" using namespace srsran; using namespace fapi_adaptor; +namespace { + +/// MAC-FAPI adaptor wrapper that wraps an adaptor and a FAPI decorator. +class mac_fapi_adaptor_wrapper : public mac_fapi_sector_adaptor +{ +public: + mac_fapi_adaptor_wrapper(std::unique_ptr adaptor_, + std::unique_ptr decorator_) : + decorator(std::move(decorator_)), adaptor(std::move(adaptor_)) + { + srsran_assert(adaptor, "Invalid MAC-FAPI sector adaptor"); + + if (decorator) { + decorator->set_slot_data_message_notifier(adaptor->get_slot_data_message_notifier()); + decorator->set_slot_error_message_notifier(adaptor->get_slot_error_message_notifier()); + decorator->set_slot_time_message_notifier(adaptor->get_slot_time_message_notifier()); + } + } + + // See interface for documentation. + fapi::slot_time_message_notifier& get_slot_time_message_notifier() override + { + return decorator ? decorator->get_slot_time_message_notifier() : adaptor->get_slot_time_message_notifier(); + } + + // See interface for documentation. + fapi::slot_error_message_notifier& get_slot_error_message_notifier() override + { + return decorator ? decorator->get_slot_error_message_notifier() : adaptor->get_slot_error_message_notifier(); + } + + // See interface for documentation. + fapi::slot_data_message_notifier& get_slot_data_message_notifier() override + { + return decorator ? decorator->get_slot_data_message_notifier() : adaptor->get_slot_data_message_notifier(); + } + + // See interface for documentation. + mac_cell_result_notifier& get_cell_result_notifier() override { return adaptor->get_cell_result_notifier(); } + + // See interface for documentation. + void set_cell_slot_handler(mac_cell_slot_handler& mac_slot_handler) override + { + adaptor->set_cell_slot_handler(mac_slot_handler); + } + + // See interface for documentation. + void set_cell_rach_handler(mac_cell_rach_handler& mac_rach_handler) override + { + adaptor->set_cell_rach_handler(mac_rach_handler); + } + + // See interface for documentation. + void set_cell_pdu_handler(mac_pdu_handler& handler) override { adaptor->set_cell_pdu_handler(handler); } + + // See interface for documentation. + void set_cell_crc_handler(mac_cell_control_information_handler& handler) override + { + adaptor->set_cell_crc_handler(handler); + } + +private: + std::unique_ptr decorator; + std::unique_ptr adaptor; +}; + +} // namespace + std::unique_ptr mac_fapi_adaptor_factory_impl::create(const mac_fapi_adaptor_config& config, mac_fapi_adaptor_dependencies&& dependencies) { - srsran_assert(dependencies.gateway, "Invalid FAPI slot message gateway"); - srsran_assert(dependencies.last_msg_notifier, "Invalid FAPI last message notifier"); + std::vector> sectors; + for (unsigned i = 0, e = config.sectors.size(); i != e; ++i) { + const auto& sector_cfg = config.sectors[i]; + auto& sector_dependencies = dependencies.sectors[i]; + + srsran_assert(sector_dependencies.gateway, "Invalid FAPI slot message gateway"); + srsran_assert(sector_dependencies.last_msg_notifier, "Invalid FAPI last message notifier"); + + // Create FAPI decorators configuration. + fapi::decorator_config decorator_cfg; + if (sector_cfg.log_level == srslog::basic_levels::debug) { + decorator_cfg.logging_cfg.emplace(fapi::logging_decorator_config{srslog::fetch_basic_logger("FAPI", true), + *sector_dependencies.gateway, + *sector_dependencies.last_msg_notifier}); + } + if (sector_cfg.l2_nof_slots_ahead != 0) { + srsran_assert(sector_dependencies.bufferer_task_executor, + "Invalid executor for the FAPI message bufferer decorator"); + decorator_cfg.bufferer_cfg.emplace( + fapi::message_bufferer_decorator_config{sector_cfg.l2_nof_slots_ahead, + sector_cfg.scs, + *sector_dependencies.bufferer_task_executor.value(), + *sector_dependencies.gateway, + *sector_dependencies.last_msg_notifier}); + } + auto decorators = fapi::create_decorators(decorator_cfg); + + auto sector_adaptor = std::make_unique(sector_cfg, std::move(sector_dependencies)); + + sectors.push_back(std::make_unique(std::move(sector_adaptor), std::move(decorators))); + } - return std::make_unique(config, std::move(dependencies)); + return std::make_unique(std::move(sectors)); } std::unique_ptr srsran::fapi_adaptor::create_mac_fapi_adaptor_factory() diff --git a/lib/fapi_adaptor/mac/mac_fapi_adaptor_impl.cpp b/lib/fapi_adaptor/mac/mac_fapi_adaptor_impl.cpp index 396cb337e2..071d22a828 100644 --- a/lib/fapi_adaptor/mac/mac_fapi_adaptor_impl.cpp +++ b/lib/fapi_adaptor/mac/mac_fapi_adaptor_impl.cpp @@ -21,62 +21,23 @@ */ #include "mac_fapi_adaptor_impl.h" -#include "srsran/srslog/srslog.h" +#include "srsran/support/srsran_assert.h" using namespace srsran; using namespace fapi_adaptor; -mac_fapi_adaptor_impl::mac_fapi_adaptor_impl(const mac_fapi_adaptor_config& config, - mac_fapi_adaptor_dependencies&& dependencies) : - mac_translator(srslog::fetch_basic_logger("FAPI"), - *dependencies.gateway, - *dependencies.last_msg_notifier, - std::move(dependencies.pm_mapper), - std::move(dependencies.part2_mapper), - config.cell_nof_prbs), - fapi_data_translator(config.scs, config.sector_id), - fapi_time_translator(config.scs), - fapi_error_translator(config.scs) +mac_fapi_adaptor_impl::mac_fapi_adaptor_impl(std::vector> sector_adaptors_) : + sector_adaptors(std::move(sector_adaptors_)) { + srsran_assert(!sector_adaptors.empty(), "Cannot create a MAC FAPI adaptor with zero cells"); } -fapi::slot_time_message_notifier& mac_fapi_adaptor_impl::get_slot_time_message_notifier() +mac_fapi_sector_adaptor& mac_fapi_adaptor_impl::get_sector_adaptor(unsigned cell_id) { - return fapi_time_translator; -} - -fapi::slot_error_message_notifier& mac_fapi_adaptor_impl::get_slot_error_message_notifier() -{ - return fapi_error_translator; -} - -fapi::slot_data_message_notifier& mac_fapi_adaptor_impl::get_slot_data_message_notifier() -{ - return fapi_data_translator; -} - -mac_cell_result_notifier& mac_fapi_adaptor_impl::get_cell_result_notifier() -{ - return mac_translator; -} + srsran_assert(cell_id < sector_adaptors.size(), + "Invalid cell identifier '{}'. Valid cell id range '[0-{})'", + cell_id, + sector_adaptors.size()); -void mac_fapi_adaptor_impl::set_cell_slot_handler(mac_cell_slot_handler& mac_slot_handler) -{ - fapi_time_translator.set_cell_slot_handler(mac_slot_handler); - fapi_error_translator.set_cell_slot_handler(mac_slot_handler); -} - -void mac_fapi_adaptor_impl::set_cell_rach_handler(mac_cell_rach_handler& mac_rach_handler) -{ - fapi_data_translator.set_cell_rach_handler(mac_rach_handler); -} - -void mac_fapi_adaptor_impl::set_cell_pdu_handler(mac_pdu_handler& handler) -{ - fapi_data_translator.set_cell_pdu_handler(handler); -} - -void mac_fapi_adaptor_impl::set_cell_crc_handler(mac_cell_control_information_handler& handler) -{ - fapi_data_translator.set_cell_crc_handler(handler); + return *sector_adaptors[cell_id]; } diff --git a/lib/fapi_adaptor/mac/mac_fapi_adaptor_impl.h b/lib/fapi_adaptor/mac/mac_fapi_adaptor_impl.h index b6ca8a87ae..47b80185de 100644 --- a/lib/fapi_adaptor/mac/mac_fapi_adaptor_impl.h +++ b/lib/fapi_adaptor/mac/mac_fapi_adaptor_impl.h @@ -22,56 +22,25 @@ #pragma once -#include "fapi_to_mac_data_msg_translator.h" -#include "fapi_to_mac_error_msg_translator.h" -#include "fapi_to_mac_time_msg_translator.h" -#include "mac_to_fapi_translator.h" #include "srsran/fapi_adaptor/mac/mac_fapi_adaptor.h" -#include "srsran/fapi_adaptor/mac/mac_fapi_adaptor_config.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_sector_adaptor.h" +#include +#include namespace srsran { namespace fapi_adaptor { -/// \brief MAC–FAPI bidirectional adaptor implementation. +/// MAC/FAPI adaptor implementation. class mac_fapi_adaptor_impl : public mac_fapi_adaptor { public: - /// Constructor for the MAC–FAPI bidirectional adaptor. - mac_fapi_adaptor_impl(const mac_fapi_adaptor_config& config, mac_fapi_adaptor_dependencies&& dependencies); + explicit mac_fapi_adaptor_impl(std::vector> sector_adaptors_); // See interface for documentation. - fapi::slot_time_message_notifier& get_slot_time_message_notifier() override; - - // See interface for documentation. - fapi::slot_error_message_notifier& get_slot_error_message_notifier() override; - - // See interface for documentation. - fapi::slot_data_message_notifier& get_slot_data_message_notifier() override; - - // See interface for documentation. - mac_cell_result_notifier& get_cell_result_notifier() override; - - // See interface for documentation. - void set_cell_slot_handler(mac_cell_slot_handler& mac_slot_handler) override; - - // See interface for documentation. - void set_cell_rach_handler(mac_cell_rach_handler& mac_rach_handler) override; - - // See interface for documentation. - void set_cell_pdu_handler(mac_pdu_handler& handler) override; - - // See interface for documentation. - void set_cell_crc_handler(mac_cell_control_information_handler& handler) override; + mac_fapi_sector_adaptor& get_sector_adaptor(unsigned cell_id) override; private: - /// MAC-to-FAPI data translator. - mac_to_fapi_translator mac_translator; - /// FAPI-to-MAC data-specific message translator. - fapi_to_mac_data_msg_translator fapi_data_translator; - /// FAPI-to-MAC time-specific message translator. - fapi_to_mac_time_msg_translator fapi_time_translator; - /// FAPI-to-MAC error-specific message translator. - fapi_to_mac_error_msg_translator fapi_error_translator; + std::vector> sector_adaptors; }; } // namespace fapi_adaptor diff --git a/lib/fapi_adaptor/mac/mac_fapi_sector_adaptor_impl.cpp b/lib/fapi_adaptor/mac/mac_fapi_sector_adaptor_impl.cpp new file mode 100644 index 0000000000..3a39419f46 --- /dev/null +++ b/lib/fapi_adaptor/mac/mac_fapi_sector_adaptor_impl.cpp @@ -0,0 +1,82 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN 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. + * + * srsRAN 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 "mac_fapi_sector_adaptor_impl.h" +#include "srsran/srslog/srslog.h" + +using namespace srsran; +using namespace fapi_adaptor; + +mac_fapi_sector_adaptor_impl::mac_fapi_sector_adaptor_impl(const mac_fapi_sector_adaptor_config& config, + mac_fapi_sector_adaptor_dependencies&& dependencies) : + mac_translator(srslog::fetch_basic_logger("FAPI"), + *dependencies.gateway, + *dependencies.last_msg_notifier, + std::move(dependencies.pm_mapper), + std::move(dependencies.part2_mapper), + config.cell_nof_prbs), + fapi_data_translator(config.scs, config.sector_id), + fapi_time_translator(config.scs), + fapi_error_translator(config.scs) +{ +} + +fapi::slot_time_message_notifier& mac_fapi_sector_adaptor_impl::get_slot_time_message_notifier() +{ + return fapi_time_translator; +} + +fapi::slot_error_message_notifier& mac_fapi_sector_adaptor_impl::get_slot_error_message_notifier() +{ + return fapi_error_translator; +} + +fapi::slot_data_message_notifier& mac_fapi_sector_adaptor_impl::get_slot_data_message_notifier() +{ + return fapi_data_translator; +} + +mac_cell_result_notifier& mac_fapi_sector_adaptor_impl::get_cell_result_notifier() +{ + return mac_translator; +} + +void mac_fapi_sector_adaptor_impl::set_cell_slot_handler(mac_cell_slot_handler& mac_slot_handler) +{ + fapi_time_translator.set_cell_slot_handler(mac_slot_handler); + fapi_error_translator.set_cell_slot_handler(mac_slot_handler); +} + +void mac_fapi_sector_adaptor_impl::set_cell_rach_handler(mac_cell_rach_handler& mac_rach_handler) +{ + fapi_data_translator.set_cell_rach_handler(mac_rach_handler); +} + +void mac_fapi_sector_adaptor_impl::set_cell_pdu_handler(mac_pdu_handler& handler) +{ + fapi_data_translator.set_cell_pdu_handler(handler); +} + +void mac_fapi_sector_adaptor_impl::set_cell_crc_handler(mac_cell_control_information_handler& handler) +{ + fapi_data_translator.set_cell_crc_handler(handler); +} diff --git a/lib/fapi_adaptor/mac/mac_fapi_sector_adaptor_impl.h b/lib/fapi_adaptor/mac/mac_fapi_sector_adaptor_impl.h new file mode 100644 index 0000000000..f811189daa --- /dev/null +++ b/lib/fapi_adaptor/mac/mac_fapi_sector_adaptor_impl.h @@ -0,0 +1,79 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN 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. + * + * srsRAN 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/. + * + */ + +#pragma once + +#include "fapi_to_mac_data_msg_translator.h" +#include "fapi_to_mac_error_msg_translator.h" +#include "fapi_to_mac_time_msg_translator.h" +#include "mac_to_fapi_translator.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_adaptor_config.h" +#include "srsran/fapi_adaptor/mac/mac_fapi_sector_adaptor.h" + +namespace srsran { +namespace fapi_adaptor { + +/// \brief MAC–FAPI bidirectional sector adaptor implementation. +class mac_fapi_sector_adaptor_impl : public mac_fapi_sector_adaptor +{ +public: + /// Constructor for the MAC–FAPI bidirectional sector adaptor. + mac_fapi_sector_adaptor_impl(const mac_fapi_sector_adaptor_config& config, + mac_fapi_sector_adaptor_dependencies&& dependencies); + + // See interface for documentation. + fapi::slot_time_message_notifier& get_slot_time_message_notifier() override; + + // See interface for documentation. + fapi::slot_error_message_notifier& get_slot_error_message_notifier() override; + + // See interface for documentation. + fapi::slot_data_message_notifier& get_slot_data_message_notifier() override; + + // See interface for documentation. + mac_cell_result_notifier& get_cell_result_notifier() override; + + // See interface for documentation. + void set_cell_slot_handler(mac_cell_slot_handler& mac_slot_handler) override; + + // See interface for documentation. + void set_cell_rach_handler(mac_cell_rach_handler& mac_rach_handler) override; + + // See interface for documentation. + void set_cell_pdu_handler(mac_pdu_handler& handler) override; + + // See interface for documentation. + void set_cell_crc_handler(mac_cell_control_information_handler& handler) override; + +private: + /// MAC-to-FAPI data translator. + mac_to_fapi_translator mac_translator; + /// FAPI-to-MAC data-specific message translator. + fapi_to_mac_data_msg_translator fapi_data_translator; + /// FAPI-to-MAC time-specific message translator. + fapi_to_mac_time_msg_translator fapi_time_translator; + /// FAPI-to-MAC error-specific message translator. + fapi_to_mac_error_msg_translator fapi_error_translator; +}; + +} // namespace fapi_adaptor +} // namespace srsran diff --git a/lib/fapi_adaptor/phy/CMakeLists.txt b/lib/fapi_adaptor/phy/CMakeLists.txt index b5eb61a3ae..215b2f4a52 100644 --- a/lib/fapi_adaptor/phy/CMakeLists.txt +++ b/lib/fapi_adaptor/phy/CMakeLists.txt @@ -34,5 +34,5 @@ set(SOURCES add_library(srsran_phy_to_fapi_translator STATIC ${SOURCES}) target_link_libraries(srsran_phy_to_fapi_translator srslog) -add_library(srsran_phy_fapi_adaptor STATIC phy_fapi_adaptor_impl.cpp phy_fapi_adaptor_factory_impl.cpp) +add_library(srsran_phy_fapi_adaptor STATIC phy_fapi_sector_adaptor_impl.cpp phy_fapi_adaptor_impl.cpp phy_fapi_adaptor_factory_impl.cpp) target_link_libraries(srsran_phy_fapi_adaptor srsran_fapi_to_phy_translator srsran_phy_to_fapi_translator) diff --git a/lib/fapi_adaptor/phy/fapi_to_phy_translator.cpp b/lib/fapi_adaptor/phy/fapi_to_phy_translator.cpp index 51fcd33e5f..953d39e6d8 100644 --- a/lib/fapi_adaptor/phy/fapi_to_phy_translator.cpp +++ b/lib/fapi_adaptor/phy/fapi_to_phy_translator.cpp @@ -107,8 +107,8 @@ fapi_to_phy_translator::fapi_to_phy_translator(const fapi_to_phy_translator_conf error_notifier(dummy_error_notifier), scs(config.scs), scs_common(config.scs_common), - prach_cfg(*config.prach_cfg), - carrier_cfg(*config.carrier_cfg), + prach_cfg(config.prach_cfg), + carrier_cfg(config.carrier_cfg), prach_ports(config.prach_ports.begin(), config.prach_ports.end()) { srsran_assert(pm_repo, "Invalid precoding matrix repository"); diff --git a/lib/fapi_adaptor/phy/fapi_to_phy_translator.h b/lib/fapi_adaptor/phy/fapi_to_phy_translator.h index 11beece849..7d54107acb 100644 --- a/lib/fapi_adaptor/phy/fapi_to_phy_translator.h +++ b/lib/fapi_adaptor/phy/fapi_to_phy_translator.h @@ -55,9 +55,9 @@ struct fapi_to_phy_translator_config { /// Common subcarrier spacing as per TS38.331 Section 6.2.2. subcarrier_spacing scs_common; /// FAPI PRACH configuration TLV as per SCF-222 v4.0 section 3.3.2.4. - const fapi::prach_config* prach_cfg; + fapi::prach_config prach_cfg; /// FAPI carrier configuration TLV as per SCF-222 v4.0 section 3.3.2.4. - const fapi::carrier_config* carrier_cfg; + fapi::carrier_config carrier_cfg; /// PRACH port list. std::vector prach_ports; }; diff --git a/lib/fapi_adaptor/phy/phy_fapi_adaptor_factory_impl.cpp b/lib/fapi_adaptor/phy/phy_fapi_adaptor_factory_impl.cpp index fe0d13a01b..4230019e6e 100644 --- a/lib/fapi_adaptor/phy/phy_fapi_adaptor_factory_impl.cpp +++ b/lib/fapi_adaptor/phy/phy_fapi_adaptor_factory_impl.cpp @@ -22,36 +22,97 @@ #include "phy_fapi_adaptor_factory_impl.h" #include "phy_fapi_adaptor_impl.h" +#include "phy_fapi_sector_adaptor_impl.h" +#include "srsran/du/du_cell_config.h" using namespace srsran; using namespace fapi_adaptor; -std::unique_ptr -phy_fapi_adaptor_factory_impl::create(const phy_fapi_adaptor_factory_config& config, - phy_fapi_adaptor_factory_dependencies&& dependencies) +static fapi::prach_config generate_prach_config_tlv(const srs_du::du_cell_config& cell_cfg) { - phy_fapi_adaptor_impl_config adaptor_config; - adaptor_config.sector_id = config.sector_id; - adaptor_config.nof_slots_request_headroom = config.nof_slots_request_headroom; - adaptor_config.scs = config.scs; - adaptor_config.scs_common = config.scs_common; - adaptor_config.prach_cfg = config.prach_cfg; - adaptor_config.carrier_cfg = config.carrier_cfg; - adaptor_config.prach_ports = config.prach_ports; - - phy_fapi_adaptor_impl_dependencies adaptor_dependencies; - adaptor_dependencies.logger = dependencies.logger; - adaptor_dependencies.dl_processor_pool = dependencies.dl_processor_pool; - adaptor_dependencies.dl_rg_pool = dependencies.dl_rg_pool; - adaptor_dependencies.dl_pdu_validator = dependencies.dl_pdu_validator; - adaptor_dependencies.ul_request_processor = dependencies.ul_request_processor; - adaptor_dependencies.ul_rg_pool = dependencies.ul_rg_pool; - adaptor_dependencies.ul_pdu_repository = dependencies.ul_pdu_repository; - adaptor_dependencies.ul_pdu_validator = dependencies.ul_pdu_validator; - adaptor_dependencies.pm_repo = std::move(dependencies.pm_repo); - adaptor_dependencies.part2_repo = std::move(dependencies.part2_repo); - - return std::make_unique(adaptor_config, std::move(adaptor_dependencies)); + fapi::prach_config config = {}; + config.prach_res_config_index = 0; + config.prach_sequence_length = fapi::prach_sequence_length_type::long_sequence; + config.prach_scs = prach_subcarrier_spacing::kHz1_25; + config.prach_ul_bwp_pusch_scs = cell_cfg.scs_common; + config.restricted_set = restricted_set_config::UNRESTRICTED; + config.num_prach_fd_occasions = cell_cfg.ul_cfg_common.init_ul_bwp.rach_cfg_common.value().rach_cfg_generic.msg1_fdm; + config.prach_config_index = + cell_cfg.ul_cfg_common.init_ul_bwp.rach_cfg_common.value().rach_cfg_generic.prach_config_index; + config.prach_format = prach_format_type::zero; + config.num_prach_td_occasions = 1; + config.num_preambles = 1; + config.start_preamble_index = 0; + + // Add FD occasion info. + fapi::prach_fd_occasion_config& fd_occasion = config.fd_occasions.emplace_back(); + fd_occasion.prach_root_sequence_index = + cell_cfg.ul_cfg_common.init_ul_bwp.rach_cfg_common.value().prach_root_seq_index; + fd_occasion.prach_freq_offset = + cell_cfg.ul_cfg_common.init_ul_bwp.rach_cfg_common.value().rach_cfg_generic.msg1_frequency_start; + fd_occasion.prach_zero_corr_conf = + cell_cfg.ul_cfg_common.init_ul_bwp.rach_cfg_common.value().rach_cfg_generic.zero_correlation_zone_config; + + return config; +} + +static fapi::carrier_config generate_carrier_config_tlv(const srs_du::du_cell_config& du_cell) +{ + // Deduce common numerology and grid size for DL and UL. + unsigned numerology = to_numerology_value(du_cell.scs_common); + unsigned grid_size_bw_prb = + band_helper::get_n_rbs_from_bw(MHz_to_bs_channel_bandwidth(du_cell.dl_carrier.carrier_bw_mhz), + du_cell.scs_common, + band_helper::get_freq_range(du_cell.dl_carrier.band)); + + fapi::carrier_config fapi_config = {}; + + // NOTE; for now we only need to fill the nof_prb_ul_grid and nof_prb_dl_grid for the common SCS. + fapi_config.dl_grid_size = {}; + fapi_config.dl_grid_size[numerology] = grid_size_bw_prb; + fapi_config.ul_grid_size = {}; + fapi_config.ul_grid_size[numerology] = grid_size_bw_prb; + + // Number of transmit and receive antenna ports. + fapi_config.num_tx_ant = du_cell.dl_carrier.nof_ant; + fapi_config.num_rx_ant = du_cell.ul_carrier.nof_ant; + + return fapi_config; +} + +std::unique_ptr phy_fapi_adaptor_factory_impl::create(const phy_fapi_adaptor_config& config, + phy_fapi_adaptor_dependencies&& dependencies) +{ + std::vector> sectors; + for (unsigned i = 0, e = config.sectors.size(); i != e; ++i) { + const auto& sector_cfg = config.sectors[i]; + auto& sector_dependencies = dependencies.sectors[i]; + + phy_fapi_sector_adaptor_impl_config adaptor_config; + adaptor_config.sector_id = sector_cfg.sector_id; + adaptor_config.nof_slots_request_headroom = sector_cfg.nof_slots_request_headroom; + adaptor_config.scs = sector_cfg.du_cell.scs_common; + adaptor_config.scs_common = sector_cfg.du_cell.scs_common; + adaptor_config.prach_cfg = generate_prach_config_tlv(sector_cfg.du_cell); + adaptor_config.carrier_cfg = generate_carrier_config_tlv(sector_cfg.du_cell); + adaptor_config.prach_ports = sector_cfg.prach_ports; + + phy_fapi_sector_adaptor_impl_dependencies adaptor_dependencies; + adaptor_dependencies.logger = sector_dependencies.logger; + adaptor_dependencies.dl_processor_pool = sector_dependencies.dl_processor_pool; + adaptor_dependencies.dl_rg_pool = sector_dependencies.dl_rg_pool; + adaptor_dependencies.dl_pdu_validator = sector_dependencies.dl_pdu_validator; + adaptor_dependencies.ul_request_processor = sector_dependencies.ul_request_processor; + adaptor_dependencies.ul_rg_pool = sector_dependencies.ul_rg_pool; + adaptor_dependencies.ul_pdu_repository = sector_dependencies.ul_pdu_repository; + adaptor_dependencies.ul_pdu_validator = sector_dependencies.ul_pdu_validator; + adaptor_dependencies.pm_repo = std::move(sector_dependencies.pm_repo); + adaptor_dependencies.part2_repo = std::move(sector_dependencies.part2_repo); + + sectors.push_back(std::make_unique(adaptor_config, std::move(adaptor_dependencies))); + } + + return std::make_unique(std::move(sectors)); } std::unique_ptr srsran::fapi_adaptor::create_phy_fapi_adaptor_factory() diff --git a/lib/fapi_adaptor/phy/phy_fapi_adaptor_factory_impl.h b/lib/fapi_adaptor/phy/phy_fapi_adaptor_factory_impl.h index 032728e74b..725e31866f 100644 --- a/lib/fapi_adaptor/phy/phy_fapi_adaptor_factory_impl.h +++ b/lib/fapi_adaptor/phy/phy_fapi_adaptor_factory_impl.h @@ -22,7 +22,9 @@ #pragma once +#include "srsran/fapi_adaptor/phy/phy_fapi_adaptor.h" #include "srsran/fapi_adaptor/phy/phy_fapi_adaptor_factory.h" +#include namespace srsran { @@ -33,8 +35,8 @@ class phy_fapi_adaptor_factory_impl : public phy_fapi_adaptor_factory { public: // See interface for documentation. - std::unique_ptr create(const phy_fapi_adaptor_factory_config& config, - phy_fapi_adaptor_factory_dependencies&& dependencies) override; + std::unique_ptr create(const phy_fapi_adaptor_config& config, + phy_fapi_adaptor_dependencies&& dependencies) override; }; } // namespace fapi_adaptor diff --git a/lib/fapi_adaptor/phy/phy_fapi_adaptor_impl.cpp b/lib/fapi_adaptor/phy/phy_fapi_adaptor_impl.cpp index f18f4603e6..c84f48ac0b 100644 --- a/lib/fapi_adaptor/phy/phy_fapi_adaptor_impl.cpp +++ b/lib/fapi_adaptor/phy/phy_fapi_adaptor_impl.cpp @@ -21,106 +21,23 @@ */ #include "phy_fapi_adaptor_impl.h" -#include "srsran/fapi/slot_last_message_notifier.h" +#include "srsran/support/srsran_assert.h" using namespace srsran; using namespace fapi_adaptor; -namespace { - -/// Slot last message notifier dummy implementation. -class slot_last_message_notifier_dummy : public fapi::slot_last_message_notifier -{ -public: - void on_last_message(slot_point slot) override {} -}; - -} // namespace - -static slot_last_message_notifier_dummy dummy_notifier; - -/// Generates and returns a FAPI-to-PHY translator configuration from the given PHY adaptor configuration. -static fapi_to_phy_translator_config generate_fapi_to_phy_translator_config(const phy_fapi_adaptor_impl_config& config) -{ - fapi_to_phy_translator_config fapi_config; - - fapi_config.sector_id = config.sector_id; - fapi_config.nof_slots_request_headroom = config.nof_slots_request_headroom; - fapi_config.scs = config.scs; - fapi_config.scs_common = config.scs_common; - fapi_config.prach_cfg = config.prach_cfg; - fapi_config.carrier_cfg = config.carrier_cfg; - fapi_config.prach_ports = config.prach_ports; - - return fapi_config; -} - -/// Generates and returns a FAPI-to-PHY translator dependencies from the given PHY adaptor dependencies. -static fapi_to_phy_translator_dependencies -generate_fapi_to_phy_translator_dependencies(phy_fapi_adaptor_impl_dependencies&& dependencies) +phy_fapi_adaptor_impl::phy_fapi_adaptor_impl(std::vector> sector_adaptors_) : + sector_adaptors(std::move(sector_adaptors_)) { - fapi_to_phy_translator_dependencies fapi_dependencies; - - fapi_dependencies.logger = dependencies.logger; - fapi_dependencies.dl_processor_pool = dependencies.dl_processor_pool; - fapi_dependencies.dl_rg_pool = dependencies.dl_rg_pool; - fapi_dependencies.dl_pdu_validator = dependencies.dl_pdu_validator; - fapi_dependencies.ul_request_processor = dependencies.ul_request_processor; - fapi_dependencies.ul_rg_pool = dependencies.ul_rg_pool; - fapi_dependencies.ul_pdu_repository = dependencies.ul_pdu_repository; - fapi_dependencies.ul_pdu_validator = dependencies.ul_pdu_validator; - fapi_dependencies.pm_repo = std::move(dependencies.pm_repo); - fapi_dependencies.part2_repo = std::move(dependencies.part2_repo); - - return fapi_dependencies; + srsran_assert(!sector_adaptors.empty(), "Cannot create a PHY-FAPI adaptor with zero cells"); } -phy_fapi_adaptor_impl::phy_fapi_adaptor_impl(const phy_fapi_adaptor_impl_config& config, - phy_fapi_adaptor_impl_dependencies&& dependencies) : - results_translator(*dependencies.logger), - fapi_translator(generate_fapi_to_phy_translator_config(config), - generate_fapi_to_phy_translator_dependencies(std::move(dependencies))), - time_translator(fapi_translator) +phy_fapi_sector_adaptor& phy_fapi_adaptor_impl::get_sector_adaptor(unsigned cell_id) { -} + srsran_assert(cell_id < sector_adaptors.size(), + "Invalid cell identifier '{}'. Valid cell id range '[0-{})'", + cell_id, + sector_adaptors.size()); -upper_phy_timing_notifier& phy_fapi_adaptor_impl::get_timing_notifier() -{ - return time_translator; -} - -void phy_fapi_adaptor_impl::set_slot_time_message_notifier(fapi::slot_time_message_notifier& fapi_time_slot_notifier) -{ - time_translator.set_slot_time_message_notifier(fapi_time_slot_notifier); -} - -void phy_fapi_adaptor_impl::set_slot_error_message_notifier(fapi::slot_error_message_notifier& fapi_error_notifier) -{ - fapi_translator.set_slot_error_message_notifier(fapi_error_notifier); - error_translator.set_slot_error_message_notifier(fapi_error_notifier); -} - -void phy_fapi_adaptor_impl::set_slot_data_message_notifier(fapi::slot_data_message_notifier& fapi_data_notifier) -{ - results_translator.set_slot_data_message_notifier(fapi_data_notifier); -} - -fapi::slot_last_message_notifier& phy_fapi_adaptor_impl::get_slot_last_message_notifier() -{ - return dummy_notifier; -} - -fapi::slot_message_gateway& phy_fapi_adaptor_impl::get_slot_message_gateway() -{ - return fapi_translator; -} - -upper_phy_rx_results_notifier& phy_fapi_adaptor_impl::get_rx_results_notifier() -{ - return results_translator; -} - -upper_phy_error_notifier& phy_fapi_adaptor_impl::get_error_notifier() -{ - return error_translator; + return *sector_adaptors[cell_id]; } diff --git a/lib/fapi_adaptor/phy/phy_fapi_adaptor_impl.h b/lib/fapi_adaptor/phy/phy_fapi_adaptor_impl.h index c5c6d545ce..6d14bcc2b1 100644 --- a/lib/fapi_adaptor/phy/phy_fapi_adaptor_impl.h +++ b/lib/fapi_adaptor/phy/phy_fapi_adaptor_impl.h @@ -22,103 +22,23 @@ #pragma once -#include "fapi_to_phy_translator.h" -#include "phy_to_fapi_error_event_translator.h" -#include "phy_to_fapi_results_event_translator.h" -#include "phy_to_fapi_time_event_translator.h" #include "srsran/fapi_adaptor/phy/phy_fapi_adaptor.h" +#include "srsran/fapi_adaptor/phy/phy_fapi_sector_adaptor.h" +#include +#include namespace srsran { -class uplink_request_processor; - -namespace fapi { -struct carrier_config; -struct prach_config; -} // namespace fapi - namespace fapi_adaptor { -/// PHY/FAPI adaptor implementation configuration. -struct phy_fapi_adaptor_impl_config { - /// Base station sector identifier. - unsigned sector_id; - /// Request headroom size in slots. - unsigned nof_slots_request_headroom; - /// Subcarrier spacing as per TS38.211 Section 4.2. - subcarrier_spacing scs; - /// Common subcarrier spacing, as per TS38.331 Section 6.2.2. - subcarrier_spacing scs_common; - /// FAPI PRACH configuration TLV as per SCF-222 v4.0 section 3.3.2.4. - const fapi::prach_config* prach_cfg; - /// FAPI carrier configuration TLV as per SCF-222 v4.0 section 3.3.2.4. - const fapi::carrier_config* carrier_cfg; - /// PRACH port list. - std::vector prach_ports; -}; - -/// PHY/FAPI adaptor implementation dependencies. -struct phy_fapi_adaptor_impl_dependencies { - /// Logger. - srslog::basic_logger* logger; - /// Downlink processor pool. - downlink_processor_pool* dl_processor_pool; - /// Downlink resource grid pool. - resource_grid_pool* dl_rg_pool; - /// Downlink PDU validator. - const downlink_pdu_validator* dl_pdu_validator; - /// Uplink request processor. - uplink_request_processor* ul_request_processor; - /// Uplink resource grid pool. - resource_grid_pool* ul_rg_pool; - /// Uplink slot PDU repository. - uplink_slot_pdu_repository* ul_pdu_repository; - /// Uplink PDU validator. - const uplink_pdu_validator* ul_pdu_validator; - /// Precoding matrix repository. - std::unique_ptr pm_repo; - /// UCI Part2 correspondence repository. - std::unique_ptr part2_repo; -}; - -/// \brief PHY–FAPI bidirectional adaptor implementation. class phy_fapi_adaptor_impl : public phy_fapi_adaptor { public: - /// Constructor for the PHY–FAPI bidirectional adaptor. - phy_fapi_adaptor_impl(const phy_fapi_adaptor_impl_config& config, phy_fapi_adaptor_impl_dependencies&& dependencies); - - upper_phy_error_notifier& get_error_notifier() override; - - // See interface for documentation. - upper_phy_timing_notifier& get_timing_notifier() override; - - // See interface for documentation. - fapi::slot_message_gateway& get_slot_message_gateway() override; - - // See interface for documentation. - upper_phy_rx_results_notifier& get_rx_results_notifier() override; - - // See interface for documentation. - void set_slot_time_message_notifier(fapi::slot_time_message_notifier& fapi_time_notifier) override; - - // See interface for documentation. - void set_slot_error_message_notifier(fapi::slot_error_message_notifier& fapi_error_notifier) override; - - // See interface for documentation. - void set_slot_data_message_notifier(fapi::slot_data_message_notifier& fapi_data_notifier) override; + explicit phy_fapi_adaptor_impl(std::vector> sector_adaptors_); - // See interface for documentation. - fapi::slot_last_message_notifier& get_slot_last_message_notifier() override; + phy_fapi_sector_adaptor& get_sector_adaptor(unsigned cell_id) override; private: - /// PHY-to-FAPI uplink results events translator. - phy_to_fapi_results_event_translator results_translator; - /// FAPI-to-PHY message translator. - fapi_to_phy_translator fapi_translator; - /// PHY-to-FAPI time events translator. - phy_to_fapi_time_event_translator time_translator; - /// PHY-to-FAPI error events translator. - phy_to_fapi_error_event_translator error_translator; + std::vector> sector_adaptors; }; } // namespace fapi_adaptor diff --git a/lib/fapi_adaptor/phy/phy_fapi_sector_adaptor_impl.cpp b/lib/fapi_adaptor/phy/phy_fapi_sector_adaptor_impl.cpp new file mode 100644 index 0000000000..ac7c56e4c7 --- /dev/null +++ b/lib/fapi_adaptor/phy/phy_fapi_sector_adaptor_impl.cpp @@ -0,0 +1,129 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN 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. + * + * srsRAN 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 "phy_fapi_sector_adaptor_impl.h" +#include "srsran/fapi/slot_last_message_notifier.h" + +using namespace srsran; +using namespace fapi_adaptor; + +namespace { + +/// Slot last message notifier dummy implementation. +class slot_last_message_notifier_dummy : public fapi::slot_last_message_notifier +{ +public: + void on_last_message(slot_point slot) override {} +}; + +} // namespace + +static slot_last_message_notifier_dummy dummy_notifier; + +/// Generates and returns a FAPI-to-PHY translator configuration from the given PHY adaptor configuration. +static fapi_to_phy_translator_config +generate_fapi_to_phy_translator_config(const phy_fapi_sector_adaptor_impl_config& config) +{ + fapi_to_phy_translator_config fapi_config; + + fapi_config.sector_id = config.sector_id; + fapi_config.nof_slots_request_headroom = config.nof_slots_request_headroom; + fapi_config.scs = config.scs; + fapi_config.scs_common = config.scs_common; + fapi_config.prach_cfg = config.prach_cfg; + fapi_config.carrier_cfg = config.carrier_cfg; + fapi_config.prach_ports = config.prach_ports; + + return fapi_config; +} + +/// Generates and returns a FAPI-to-PHY translator dependencies from the given PHY adaptor dependencies. +static fapi_to_phy_translator_dependencies +generate_fapi_to_phy_translator_dependencies(phy_fapi_sector_adaptor_impl_dependencies&& dependencies) +{ + fapi_to_phy_translator_dependencies fapi_dependencies; + + fapi_dependencies.logger = dependencies.logger; + fapi_dependencies.dl_processor_pool = dependencies.dl_processor_pool; + fapi_dependencies.dl_rg_pool = dependencies.dl_rg_pool; + fapi_dependencies.dl_pdu_validator = dependencies.dl_pdu_validator; + fapi_dependencies.ul_request_processor = dependencies.ul_request_processor; + fapi_dependencies.ul_rg_pool = dependencies.ul_rg_pool; + fapi_dependencies.ul_pdu_repository = dependencies.ul_pdu_repository; + fapi_dependencies.ul_pdu_validator = dependencies.ul_pdu_validator; + fapi_dependencies.pm_repo = std::move(dependencies.pm_repo); + fapi_dependencies.part2_repo = std::move(dependencies.part2_repo); + + return fapi_dependencies; +} + +phy_fapi_sector_adaptor_impl::phy_fapi_sector_adaptor_impl(const phy_fapi_sector_adaptor_impl_config& config, + phy_fapi_sector_adaptor_impl_dependencies&& dependencies) : + results_translator(*dependencies.logger), + fapi_translator(generate_fapi_to_phy_translator_config(config), + generate_fapi_to_phy_translator_dependencies(std::move(dependencies))), + time_translator(fapi_translator) +{ +} + +upper_phy_timing_notifier& phy_fapi_sector_adaptor_impl::get_timing_notifier() +{ + return time_translator; +} + +void phy_fapi_sector_adaptor_impl::set_slot_time_message_notifier( + fapi::slot_time_message_notifier& fapi_time_slot_notifier) +{ + time_translator.set_slot_time_message_notifier(fapi_time_slot_notifier); +} + +void phy_fapi_sector_adaptor_impl::set_slot_error_message_notifier( + fapi::slot_error_message_notifier& fapi_error_notifier) +{ + fapi_translator.set_slot_error_message_notifier(fapi_error_notifier); + error_translator.set_slot_error_message_notifier(fapi_error_notifier); +} + +void phy_fapi_sector_adaptor_impl::set_slot_data_message_notifier(fapi::slot_data_message_notifier& fapi_data_notifier) +{ + results_translator.set_slot_data_message_notifier(fapi_data_notifier); +} + +fapi::slot_last_message_notifier& phy_fapi_sector_adaptor_impl::get_slot_last_message_notifier() +{ + return dummy_notifier; +} + +fapi::slot_message_gateway& phy_fapi_sector_adaptor_impl::get_slot_message_gateway() +{ + return fapi_translator; +} + +upper_phy_rx_results_notifier& phy_fapi_sector_adaptor_impl::get_rx_results_notifier() +{ + return results_translator; +} + +upper_phy_error_notifier& phy_fapi_sector_adaptor_impl::get_error_notifier() +{ + return error_translator; +} diff --git a/lib/fapi_adaptor/phy/phy_fapi_sector_adaptor_impl.h b/lib/fapi_adaptor/phy/phy_fapi_sector_adaptor_impl.h new file mode 100644 index 0000000000..f3735a029d --- /dev/null +++ b/lib/fapi_adaptor/phy/phy_fapi_sector_adaptor_impl.h @@ -0,0 +1,126 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN 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. + * + * srsRAN 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/. + * + */ + +#pragma once + +#include "fapi_to_phy_translator.h" +#include "phy_to_fapi_error_event_translator.h" +#include "phy_to_fapi_results_event_translator.h" +#include "phy_to_fapi_time_event_translator.h" +#include "srsran/fapi_adaptor/phy/phy_fapi_sector_adaptor.h" + +namespace srsran { +class uplink_request_processor; + +namespace fapi { +struct carrier_config; +struct prach_config; +} // namespace fapi + +namespace fapi_adaptor { + +/// PHY/FAPI sector adaptor implementation configuration. +struct phy_fapi_sector_adaptor_impl_config { + /// Base station sector identifier. + unsigned sector_id; + /// Request headroom size in slots. + unsigned nof_slots_request_headroom; + /// Subcarrier spacing as per TS38.211 Section 4.2. + subcarrier_spacing scs; + /// Common subcarrier spacing, as per TS38.331 Section 6.2.2. + subcarrier_spacing scs_common; + /// FAPI PRACH configuration TLV as per SCF-222 v4.0 section 3.3.2.4. + fapi::prach_config prach_cfg; + /// FAPI carrier configuration TLV as per SCF-222 v4.0 section 3.3.2.4. + fapi::carrier_config carrier_cfg; + /// PRACH port list. + std::vector prach_ports; +}; + +/// PHY/FAPI sector adaptor implementation dependencies. +struct phy_fapi_sector_adaptor_impl_dependencies { + /// Logger. + srslog::basic_logger* logger; + /// Downlink processor pool. + downlink_processor_pool* dl_processor_pool; + /// Downlink resource grid pool. + resource_grid_pool* dl_rg_pool; + /// Downlink PDU validator. + const downlink_pdu_validator* dl_pdu_validator; + /// Uplink request processor. + uplink_request_processor* ul_request_processor; + /// Uplink resource grid pool. + resource_grid_pool* ul_rg_pool; + /// Uplink slot PDU repository. + uplink_slot_pdu_repository* ul_pdu_repository; + /// Uplink PDU validator. + const uplink_pdu_validator* ul_pdu_validator; + /// Precoding matrix repository. + std::unique_ptr pm_repo; + /// UCI Part2 correspondence repository. + std::unique_ptr part2_repo; +}; + +/// \brief PHY–FAPI bidirectional adaptor sector implementation. +class phy_fapi_sector_adaptor_impl : public phy_fapi_sector_adaptor +{ +public: + /// Constructor for the PHY–FAPI bidirectional sector adaptor. + phy_fapi_sector_adaptor_impl(const phy_fapi_sector_adaptor_impl_config& config, + phy_fapi_sector_adaptor_impl_dependencies&& dependencies); + + upper_phy_error_notifier& get_error_notifier() override; + + // See interface for documentation. + upper_phy_timing_notifier& get_timing_notifier() override; + + // See interface for documentation. + fapi::slot_message_gateway& get_slot_message_gateway() override; + + // See interface for documentation. + upper_phy_rx_results_notifier& get_rx_results_notifier() override; + + // See interface for documentation. + void set_slot_time_message_notifier(fapi::slot_time_message_notifier& fapi_time_notifier) override; + + // See interface for documentation. + void set_slot_error_message_notifier(fapi::slot_error_message_notifier& fapi_error_notifier) override; + + // See interface for documentation. + void set_slot_data_message_notifier(fapi::slot_data_message_notifier& fapi_data_notifier) override; + + // See interface for documentation. + fapi::slot_last_message_notifier& get_slot_last_message_notifier() override; + +private: + /// PHY-to-FAPI uplink results events translator. + phy_to_fapi_results_event_translator results_translator; + /// FAPI-to-PHY message translator. + fapi_to_phy_translator fapi_translator; + /// PHY-to-FAPI time events translator. + phy_to_fapi_time_event_translator time_translator; + /// PHY-to-FAPI error events translator. + phy_to_fapi_error_event_translator error_translator; +}; + +} // namespace fapi_adaptor +} // namespace srsran diff --git a/lib/hal/dpdk/bbdev/bbdev_acc_factory.cpp b/lib/hal/dpdk/bbdev/bbdev_acc_factory.cpp index 95f70e1baa..8331774932 100644 --- a/lib/hal/dpdk/bbdev/bbdev_acc_factory.cpp +++ b/lib/hal/dpdk/bbdev/bbdev_acc_factory.cpp @@ -25,10 +25,14 @@ using namespace srsran; using namespace dpdk; -SRSRAN_WEAK_SYMB std::shared_ptr srsran::dpdk::create_bbdev_acc(const bbdev_acc_configuration& cfg, - srslog::basic_logger& logger) +#ifndef SRSRAN_HAS_ENTERPRISE + +std::shared_ptr srsran::dpdk::create_bbdev_acc(const bbdev_acc_configuration& cfg, + srslog::basic_logger& logger) { logger.error("[bbdev] bbdev accelerator creation failed. Cause: hardware-acceleration is not supported."); return nullptr; } + +#endif // SRSRAN_HAS_ENTERPRISE diff --git a/lib/hal/phy/upper/channel_processors/hw_accelerator_factories.cpp b/lib/hal/phy/upper/channel_processors/hw_accelerator_factories.cpp index 7e2fb04f64..08c787faf4 100644 --- a/lib/hal/phy/upper/channel_processors/hw_accelerator_factories.cpp +++ b/lib/hal/phy/upper/channel_processors/hw_accelerator_factories.cpp @@ -25,8 +25,12 @@ using namespace srsran; using namespace hal; -SRSRAN_WEAK_SYMB std::shared_ptr +#ifndef SRSRAN_HAS_ENTERPRISE + +std::shared_ptr srsran::hal::create_bbdev_pdsch_enc_acc_factory(const bbdev_hwacc_pdsch_enc_factory_configuration& accelerator_config) { return nullptr; } + +#endif // SRSRAN_HAS_ENTERPRISE diff --git a/lib/hal/phy/upper/channel_processors/pusch/hw_accelerator_factories.cpp b/lib/hal/phy/upper/channel_processors/pusch/hw_accelerator_factories.cpp index 20c6f5ae30..885d5c04cf 100644 --- a/lib/hal/phy/upper/channel_processors/pusch/hw_accelerator_factories.cpp +++ b/lib/hal/phy/upper/channel_processors/pusch/hw_accelerator_factories.cpp @@ -25,8 +25,12 @@ using namespace srsran; using namespace hal; -SRSRAN_WEAK_SYMB std::shared_ptr +#ifndef SRSRAN_HAS_ENTERPRISE + +std::shared_ptr srsran::hal::create_bbdev_pusch_dec_acc_factory(const bbdev_hwacc_pusch_dec_factory_configuration& accelerator_config) { return nullptr; } + +#endif // SRSRAN_HAS_ENTERPRISE diff --git a/lib/mac/mac_sched/uci_cell_decoder.cpp b/lib/mac/mac_sched/uci_cell_decoder.cpp index 0c83fad0f2..ae32d784d1 100644 --- a/lib/mac/mac_sched/uci_cell_decoder.cpp +++ b/lib/mac/mac_sched/uci_cell_decoder.cpp @@ -33,7 +33,8 @@ uci_cell_decoder::uci_cell_decoder(const sched_cell_configuration_request_messag rnti_table(rnti_table_), cell_index(cell_cfg.cell_index), rlf_handler(rlf_hdlr_), - logger(srslog::fetch_basic_logger("MAC")) + logger(srslog::fetch_basic_logger("MAC")), + expected_uci_report_grid(MAX_GRID_SIZE) { } diff --git a/lib/mac/mac_sched/uci_cell_decoder.h b/lib/mac/mac_sched/uci_cell_decoder.h index e40c393533..bc9e38444c 100644 --- a/lib/mac/mac_sched/uci_cell_decoder.h +++ b/lib/mac/mac_sched/uci_cell_decoder.h @@ -67,7 +67,7 @@ class uci_cell_decoder rlf_detector& rlf_handler; srslog::basic_logger& logger; - std::array, MAX_GRID_SIZE> expected_uci_report_grid; + std::vector> expected_uci_report_grid; }; } // namespace srsran diff --git a/lib/ngap/ngap_impl.cpp b/lib/ngap/ngap_impl.cpp index d6b48374b1..4e25e2ae60 100644 --- a/lib/ngap/ngap_impl.cpp +++ b/lib/ngap/ngap_impl.cpp @@ -785,18 +785,21 @@ void ngap_impl::handle_handover_request(const asn1::ngap::ho_request_s& msg) } } -SRSRAN_WEAK_SYMB void -ngap_impl::handle_dl_ue_associated_nrppa_transport(const asn1::ngap::dl_ue_associated_nrppa_transport_s& msg) +#ifndef SRSRAN_HAS_ENTERPRISE + +void ngap_impl::handle_dl_ue_associated_nrppa_transport(const asn1::ngap::dl_ue_associated_nrppa_transport_s& msg) { logger.info("DL UE associated NRPPa messages are not supported"); } -SRSRAN_WEAK_SYMB void -ngap_impl::handle_dl_non_ue_associated_nrppa_transport(const asn1::ngap::dl_non_ue_associated_nrppa_transport_s& msg) +void ngap_impl::handle_dl_non_ue_associated_nrppa_transport( + const asn1::ngap::dl_non_ue_associated_nrppa_transport_s& msg) { logger.info("DL non UE associated NRPPa messages are not supported"); } +#endif // SRSRAN_HAS_ENTERPRISE + void ngap_impl::handle_error_indication(const asn1::ngap::error_ind_s& msg) { amf_ue_id_t amf_ue_id = amf_ue_id_t::invalid; @@ -1004,12 +1007,15 @@ void ngap_impl::handle_inter_cu_ho_rrc_recfg_complete(const ue_index_t tx_pdu_notifier->on_new_message(ngap_msg); } -SRSRAN_WEAK_SYMB void ngap_impl::handle_ul_ue_associated_nrppa_transport(ue_index_t ue_index, - const byte_buffer& nrppa_pdu) +#ifndef SRSRAN_HAS_ENTERPRISE + +void ngap_impl::handle_ul_ue_associated_nrppa_transport(ue_index_t ue_index, const byte_buffer& nrppa_pdu) { logger.info("UL UE associated NRPPa messages are not supported"); } +#endif // SRSRAN_HAS_ENTERPRISE + void ngap_impl::remove_ue_context(ue_index_t ue_index) { if (!ue_ctxt_list.contains(ue_index)) { diff --git a/lib/ngap/procedures/ngap_handover_preparation_procedure.cpp b/lib/ngap/procedures/ngap_handover_preparation_procedure.cpp index b3b84f2090..f3d5b5bb23 100644 --- a/lib/ngap/procedures/ngap_handover_preparation_procedure.cpp +++ b/lib/ngap/procedures/ngap_handover_preparation_procedure.cpp @@ -26,8 +26,10 @@ using namespace srsran; using namespace srsran::srs_cu_cp; using namespace asn1::ngap; -SRSRAN_WEAK_SYMB async_task - srsran::srs_cu_cp::start_ngap_handover_preparation(const ngap_handover_preparation_request& req, +#ifndef SRSRAN_HAS_ENTERPRISE + +async_task +srsran::srs_cu_cp::start_ngap_handover_preparation(const ngap_handover_preparation_request& req, const plmn_identity& serving_plmn, const ngap_ue_ids& ue_ids, ngap_message_notifier& amf_notifier, @@ -44,3 +46,5 @@ SRSRAN_WEAK_SYMB async_task }; return launch_async(std::move(err_function)); } + +#endif // SRSRAN_HAS_ENTERPRISE diff --git a/lib/ngap/procedures/ngap_handover_resource_allocation_procedure.cpp b/lib/ngap/procedures/ngap_handover_resource_allocation_procedure.cpp index c6fb155cde..6dbf1ddae6 100644 --- a/lib/ngap/procedures/ngap_handover_resource_allocation_procedure.cpp +++ b/lib/ngap/procedures/ngap_handover_resource_allocation_procedure.cpp @@ -25,15 +25,16 @@ using namespace srsran; using namespace srsran::srs_cu_cp; -SRSRAN_WEAK_SYMB async_task - srsran::srs_cu_cp::start_ngap_handover_resource_allocation(const ngap_handover_request& request, - const amf_ue_id_t amf_ue_id, - ngap_ue_context_list& ue_ctxt_list, - ngap_cu_cp_notifier& cu_cp_notifier, - ngap_message_notifier& amf_notifier, - timer_manager& timers, - task_executor& task_exec, - srslog::basic_logger& logger) +#ifndef SRSRAN_HAS_ENTERPRISE + +async_task srsran::srs_cu_cp::start_ngap_handover_resource_allocation(const ngap_handover_request& request, + const amf_ue_id_t amf_ue_id, + ngap_ue_context_list& ue_ctxt_list, + ngap_cu_cp_notifier& cu_cp_notifier, + ngap_message_notifier& amf_notifier, + timer_manager& timers, + task_executor& task_exec, + srslog::basic_logger& logger) { logger.error("NG Handover resource allocation failed. Cause: NG handover not supported"); auto err_function = [](coro_context>& ctx) { @@ -42,3 +43,5 @@ SRSRAN_WEAK_SYMB async_task }; return launch_async(std::move(err_function)); } + +#endif // SRSRAN_HAS_ENTERPRISE diff --git a/lib/phy/upper/channel_processors/pusch/pusch_processor_phy_capabilities.cpp b/lib/phy/upper/channel_processors/pusch/pusch_processor_phy_capabilities.cpp index 74fc85bf7c..0bff9866cd 100644 --- a/lib/phy/upper/channel_processors/pusch/pusch_processor_phy_capabilities.cpp +++ b/lib/phy/upper/channel_processors/pusch/pusch_processor_phy_capabilities.cpp @@ -25,7 +25,11 @@ using namespace srsran; -SRSRAN_WEAK_SYMB pusch_processor_phy_capabilities srsran::get_pusch_processor_phy_capabilities() +#ifndef PUSCH_PROCESSOR_MAX_NOF_LAYERS +#define PUSCH_PROCESSOR_MAX_NOF_LAYERS 1 +#endif // PUSCH_PROCESSOR_MAX_NOF_LAYERS + +pusch_processor_phy_capabilities srsran::get_pusch_processor_phy_capabilities() { - return {.max_nof_layers = 1}; + return {.max_nof_layers = PUSCH_PROCESSOR_MAX_NOF_LAYERS}; } \ No newline at end of file diff --git a/lib/phy/upper/equalization/channel_equalizer_generic_impl.cpp b/lib/phy/upper/equalization/channel_equalizer_generic_impl.cpp index c8c0f22331..55487fdc4c 100644 --- a/lib/phy/upper/equalization/channel_equalizer_generic_impl.cpp +++ b/lib/phy/upper/equalization/channel_equalizer_generic_impl.cpp @@ -221,72 +221,98 @@ void equalize_mmse_single_tx_layer<1>(unsigned /**/, equalize_mmse_1xn<1>(eq_symbols, eq_noise_vars, ch_symbols, ch_estimates, noise_var, tx_scaling); } -SRSRAN_WEAK_SYMB void -channel_equalizer_generic_impl::equalize_zf_3x4(span /* eq_symbols */, - span /* noise_vars */, - const re_buffer_reader& /* ch_symbols */, - const channel_equalizer::ch_est_list& /* ch_estimates */, - float /* noise_var_est */, - float /* tx_scaling */) +#ifndef SRSRAN_HAS_ENTERPRISE +void channel_equalizer_generic_impl::equalize_zf_3x4(span /* eq_symbols */, + span /* noise_vars */, + const re_buffer_reader& /* ch_symbols */, + const channel_equalizer::ch_est_list& /* ch_estimates */, + float /* noise_var_est */, + float /* tx_scaling */) { srsran_assertion_failure("Equalizer not implemented for 3x4 ZF algorithm."); } -SRSRAN_WEAK_SYMB void -channel_equalizer_generic_impl::equalize_zf_4x4(span /* eq_symbols */, - span /* noise_vars */, - const re_buffer_reader& /* ch_symbols */, - const channel_equalizer::ch_est_list& /* ch_estimates */, - float /* noise_var_est */, - float /* tx_scaling */) +void channel_equalizer_generic_impl::equalize_zf_4x4(span /* eq_symbols */, + span /* noise_vars */, + const re_buffer_reader& /* ch_symbols */, + const channel_equalizer::ch_est_list& /* ch_estimates */, + float /* noise_var_est */, + float /* tx_scaling */) { srsran_assertion_failure("Equalizer not implemented for 4x4 ZF algorithm."); } -SRSRAN_WEAK_SYMB void -channel_equalizer_generic_impl::equalize_mmse_2x2(span /* eq_symbols */, - span /* noise_vars */, - const re_buffer_reader& /* ch_symbols */, - const channel_equalizer::ch_est_list& /* ch_estimates */, - float /* noise_var_est */, - float /* tx_scaling */) +void channel_equalizer_generic_impl::equalize_mmse_2x2(span /* eq_symbols */, + span /* noise_vars */, + const re_buffer_reader& /* ch_symbols */, + const channel_equalizer::ch_est_list& /* ch_estimates */, + float /* noise_var_est */, + float /* tx_scaling */) { srsran_assertion_failure("Equalizer not implemented for 2x2 MMSE algorithm."); } -SRSRAN_WEAK_SYMB void -channel_equalizer_generic_impl::equalize_mmse_2x4(span /* eq_symbols */, - span /* noise_vars */, - const re_buffer_reader& /* ch_symbols */, - const channel_equalizer::ch_est_list& /* ch_estimates */, - float /* noise_var_est */, - float /* tx_scaling */) +void channel_equalizer_generic_impl::equalize_mmse_2x4(span /* eq_symbols */, + span /* noise_vars */, + const re_buffer_reader& /* ch_symbols */, + const channel_equalizer::ch_est_list& /* ch_estimates */, + float /* noise_var_est */, + float /* tx_scaling */) { srsran_assertion_failure("Equalizer not implemented for 2x4 MMSE algorithm."); } -SRSRAN_WEAK_SYMB void -channel_equalizer_generic_impl::equalize_mmse_3x4(span /* eq_symbols */, - span /* noise_vars */, - const re_buffer_reader& /* ch_symbols */, - const channel_equalizer::ch_est_list& /* ch_estimates */, - float /* noise_var_est */, - float /* tx_scaling */) +void channel_equalizer_generic_impl::equalize_mmse_3x4(span /* eq_symbols */, + span /* noise_vars */, + const re_buffer_reader& /* ch_symbols */, + const channel_equalizer::ch_est_list& /* ch_estimates */, + float /* noise_var_est */, + float /* tx_scaling */) { srsran_assertion_failure("Equalizer not implemented for 3x4 MMSE algorithm."); } -SRSRAN_WEAK_SYMB void -channel_equalizer_generic_impl::equalize_mmse_4x4(span /* eq_symbols */, - span /* noise_vars */, - const re_buffer_reader& /* ch_symbols */, - const channel_equalizer::ch_est_list& /* ch_estimates */, - float /* noise_var_est */, - float /* tx_scaling */) +void channel_equalizer_generic_impl::equalize_mmse_4x4(span /* eq_symbols */, + span /* noise_vars */, + const re_buffer_reader& /* ch_symbols */, + const channel_equalizer::ch_est_list& /* ch_estimates */, + float /* noise_var_est */, + float /* tx_scaling */) { srsran_assertion_failure("Equalizer not implemented for 4x4 MMSE algorithm."); } +bool channel_equalizer_generic_impl::is_supported(channel_equalizer_algorithm_type type, + unsigned nof_ports, + unsigned nof_layers) +{ + // Only one, two and four ports are currently supported. + if ((nof_ports != 1) && (nof_ports != 2) && (nof_ports != 4)) { + return false; + } + + // The number of layers cannot be greater than the number of ports. + if (nof_ports < nof_layers) { + return false; + } + + // ZF algorithm supports from one to two layers. + static constexpr interval zf_nof_layers_range(1, 2); + if ((type == channel_equalizer_algorithm_type::zf) && !zf_nof_layers_range.contains(nof_layers)) { + return false; + } + + // MMSE algorithm supports only one layer. + if ((type == channel_equalizer_algorithm_type::mmse) && (nof_layers != 1)) { + return false; + } + + // Otherwise it is supported. + return true; +} + +#endif // SRSRAN_HAS_ENTERPRISE + bool channel_equalizer_generic_impl::is_supported(unsigned nof_ports, unsigned nof_layers) { return is_supported(type, nof_ports, nof_layers); @@ -385,32 +411,3 @@ void channel_equalizer_generic_impl::equalize(span e ch_estimates.get_nof_tx_layers(), to_string(type)); } - -SRSRAN_WEAK_SYMB bool channel_equalizer_generic_impl::is_supported(channel_equalizer_algorithm_type type, - unsigned nof_ports, - unsigned nof_layers) -{ - // Only one, two and four ports are currently supported. - if ((nof_ports != 1) && (nof_ports != 2) && (nof_ports != 4)) { - return false; - } - - // The number of layers cannot be greater than the number of ports. - if (nof_ports < nof_layers) { - return false; - } - - // ZF algorithm supports from one to two layers. - static constexpr interval zf_nof_layers_range(1, 2); - if ((type == channel_equalizer_algorithm_type::zf) && !zf_nof_layers_range.contains(nof_layers)) { - return false; - } - - // MMSE algorithm supports only one layer. - if ((type == channel_equalizer_algorithm_type::mmse) && (nof_layers != 1)) { - return false; - } - - // Otherwise it is supported. - return true; -} diff --git a/lib/phy/upper/signal_processors/port_channel_estimator_average_impl.cpp b/lib/phy/upper/signal_processors/port_channel_estimator_average_impl.cpp index 410ec025fc..bcc21f1396 100644 --- a/lib/phy/upper/signal_processors/port_channel_estimator_average_impl.cpp +++ b/lib/phy/upper/signal_processors/port_channel_estimator_average_impl.cpp @@ -37,6 +37,8 @@ using namespace srsran; +#ifndef SRSRAN_HAS_ENTERPRISE + /// \brief Extracts channel observations corresponding to DM-RS pilots from the resource grid for one layer, one hop /// and for the selected port. /// \param[out] rx_symbols Symbol buffer destination. @@ -80,7 +82,6 @@ static float estimate_noise(const dmrs_symbol_list& pilots, unsigned last_hop_symbol, unsigned hop_offset); -SRSRAN_WEAK_SYMB void port_channel_estimator_average_impl::do_compute(channel_estimate& estimate, const resource_grid_reader& grid, unsigned port, @@ -159,7 +160,6 @@ void port_channel_estimator_average_impl::do_compute(channel_estimate& estimate.set_snr((noise_var != 0) ? datarp / noise_var : 1000, port, layer0); } -SRSRAN_WEAK_SYMB void port_channel_estimator_average_impl::compute_hop(srsran::channel_estimate& estimate, const srsran::resource_grid_reader& grid, unsigned port, @@ -296,20 +296,6 @@ void port_channel_estimator_average_impl::compute_hop(srsran::channel_estimate& hop_offset); } -void port_channel_estimator_average_impl::initialize_symbol_start_epochs(cyclic_prefix cp, subcarrier_spacing scs) -{ - unsigned nof_symbols_slot = get_nsymb_per_slot(cp); - symbol_start_epochs = span(aux_symbol_start_epochs).first(nof_symbols_slot); - - // Compute cumulative duration of CPs. - symbol_start_epochs[0] = cp.get_length(0, scs).to_seconds() * scs_to_khz(scs) * 1000; - for (unsigned i_cp = 1; i_cp != nof_symbols_slot; ++i_cp) { - symbol_start_epochs[i_cp] = - symbol_start_epochs[i_cp - 1] + cp.get_length(i_cp, scs).to_seconds() * scs_to_khz(scs) * 1000 + 1.0F; - } -} - -SRSRAN_WEAK_SYMB std::optional port_channel_estimator_average_impl::preprocess_pilots_and_cfo(const dmrs_symbol_list& pilots, const bounded_bitset& dmrs_mask, @@ -484,3 +470,18 @@ static float estimate_noise(const dmrs_symbol_list& pilots, return noise_energy; } + +#endif // SRSRAN_HAS_ENTERPRISE + +void port_channel_estimator_average_impl::initialize_symbol_start_epochs(cyclic_prefix cp, subcarrier_spacing scs) +{ + unsigned nof_symbols_slot = get_nsymb_per_slot(cp); + symbol_start_epochs = span(aux_symbol_start_epochs).first(nof_symbols_slot); + + // Compute cumulative duration of CPs. + symbol_start_epochs[0] = cp.get_length(0, scs).to_seconds() * scs_to_khz(scs) * 1000; + for (unsigned i_cp = 1; i_cp != nof_symbols_slot; ++i_cp) { + symbol_start_epochs[i_cp] = + symbol_start_epochs[i_cp - 1] + cp.get_length(i_cp, scs).to_seconds() * scs_to_khz(scs) * 1000 + 1.0F; + } +} diff --git a/lib/ran/pusch/pusch_antenna_port_mapping.cpp b/lib/ran/pusch/pusch_antenna_port_mapping.cpp index 1d5decb017..3396a519af 100644 --- a/lib/ran/pusch/pusch_antenna_port_mapping.cpp +++ b/lib/ran/pusch/pusch_antenna_port_mapping.cpp @@ -24,13 +24,15 @@ using namespace srsran; +#ifndef SRSRAN_HAS_ENTERPRISE + // Current range of supported number of layers. static constexpr interval nof_layers_range(1, 1); -SRSRAN_WEAK_SYMB unsigned srsran::get_pusch_antenna_port_mapping_row_index(unsigned nof_layers, - bool transform_precoder, - dmrs_config_type dmrs_cfg_type, - dmrs_max_length dmrs_max_len) +unsigned srsran::get_pusch_antenna_port_mapping_row_index(unsigned nof_layers, + bool transform_precoder, + dmrs_config_type dmrs_cfg_type, + dmrs_max_length dmrs_max_len) { srsran_assert(nof_layers_range.contains(nof_layers), "The number of layers (i.e., {}) is out of the range {}.", @@ -50,14 +52,13 @@ SRSRAN_WEAK_SYMB unsigned srsran::get_pusch_antenna_port_mapping_row_index(unsig return 2; } -SRSRAN_WEAK_SYMB unsigned -srsran::get_pusch_precoding_info_row_index(unsigned nof_layers, - unsigned max_rank, - srs_resource_configuration::one_two_four_enum nof_srs_ports, - bool transform_precoder, - dmrs_config_type dmrs_cfg_type, - dmrs_max_length dmrs_max_len, - unsigned tpmi) +unsigned srsran::get_pusch_precoding_info_row_index(unsigned nof_layers, + unsigned max_rank, + srs_resource_configuration::one_two_four_enum nof_srs_ports, + bool transform_precoder, + dmrs_config_type dmrs_cfg_type, + dmrs_max_length dmrs_max_len, + unsigned tpmi) { static constexpr interval max_rank_range(1, 4); srsran_assert( @@ -123,3 +124,4 @@ srsran::get_pusch_precoding_info_row_index(unsigned // Unhandled case. return 0; } +#endif // SRSRAN_HAS_ENTERPRISE diff --git a/lib/scheduler/logging/scheduler_metric_handler.cpp b/lib/scheduler/logging/scheduler_metric_handler.cpp index c4c72a6287..bb10a4723f 100644 --- a/lib/scheduler/logging/scheduler_metric_handler.cpp +++ b/lib/scheduler/logging/scheduler_metric_handler.cpp @@ -422,7 +422,7 @@ cell_metrics_handler* scheduler_metrics_handler::add_cell(const cell_configurati return nullptr; } - cells.emplace(cell_cfg.cell_index, report_period, notifier, cell_cfg); + cells.emplace(cell_cfg.cell_index, std::make_unique(report_period, notifier, cell_cfg)); - return &cells[cell_cfg.cell_index]; + return cells[cell_cfg.cell_index].get(); } diff --git a/lib/scheduler/logging/scheduler_metrics_handler.h b/lib/scheduler/logging/scheduler_metrics_handler.h index 5da7c2e8a2..c5bb5ab2df 100644 --- a/lib/scheduler/logging/scheduler_metrics_handler.h +++ b/lib/scheduler/logging/scheduler_metrics_handler.h @@ -204,13 +204,13 @@ class scheduler_metrics_handler cell_metrics_handler* add_cell(const cell_configuration& cell_cfg); - cell_metrics_handler& at(du_cell_index_t cell_idx) { return cells[cell_idx]; } + cell_metrics_handler& at(du_cell_index_t cell_idx) { return *cells[cell_idx]; } private: scheduler_metrics_notifier& notifier; const std::chrono::milliseconds report_period; - slotted_array cells; + slotted_array, MAX_NOF_DU_CELLS> cells; }; } // namespace srsran diff --git a/lib/scheduler/scheduler_impl.h b/lib/scheduler/scheduler_impl.h index f61f119341..8bcab8cacb 100644 --- a/lib/scheduler/scheduler_impl.h +++ b/lib/scheduler/scheduler_impl.h @@ -24,9 +24,7 @@ #include "cell_scheduler.h" #include "config/sched_config_manager.h" -#include "logging/scheduler_event_logger.h" #include "logging/scheduler_metrics_handler.h" -#include "logging/scheduler_result_logger.h" #include "ue_scheduling/ue_scheduler.h" #include "srsran/scheduler/config/scheduler_expert_config.h" #include "srsran/scheduler/mac_scheduler.h" diff --git a/lib/scheduler/support/ul_power_controller.cpp b/lib/scheduler/support/ul_power_controller.cpp index 4d8229e0be..b1884b90a8 100644 --- a/lib/scheduler/support/ul_power_controller.cpp +++ b/lib/scheduler/support/ul_power_controller.cpp @@ -70,14 +70,6 @@ void ul_power_controller::reconfigure(const ue_cell_configuration& ue_cell_cfg) } } -SRSRAN_WEAK_SYMB void ul_power_controller::handle_phr(const cell_ph_report& phr, slot_point slot_rx) -{ - if (not pusch_pwr_ctrl.has_value()) { - return; - } - latest_phr.emplace(ue_phr_report{phr, std::nullopt}); -} - void ul_power_controller::update_pusch_pw_ctrl_state(slot_point slot_rx, unsigned nof_prbs) { const int latest_f_cl_pw_control = @@ -86,15 +78,27 @@ void ul_power_controller::update_pusch_pw_ctrl_state(slot_point slot_rx, unsigne pusch_pw_ctrl_grid[grid_idx] = {slot_rx, nof_prbs, latest_f_cl_pw_control}; } -SRSRAN_WEAK_SYMB unsigned ul_power_controller::adapt_pusch_prbs_to_phr(unsigned nof_prbs) const +#ifndef SRSRAN_HAS_ENTERPRISE + +void ul_power_controller::handle_phr(const cell_ph_report& phr, slot_point slot_rx) +{ + if (not pusch_pwr_ctrl.has_value()) { + return; + } + latest_phr.emplace(ue_phr_report{phr, std::nullopt}); +} + +unsigned ul_power_controller::adapt_pusch_prbs_to_phr(unsigned nof_prbs) const { // Dummy function. This feature is only available in the SRSRAN 5G Enterprise version. return nof_prbs; } -SRSRAN_WEAK_SYMB uint8_t ul_power_controller::compute_tpc_command(slot_point pusch_slot) +uint8_t ul_power_controller::compute_tpc_command(slot_point pusch_slot) { // Dummy function. This feature is only available in the SRSRAN 5G Enterprise version. static constexpr uint8_t default_tpc = 1; return default_tpc; } + +#endif // SRSRAN_HAS_ENTERPRISE diff --git a/lib/scheduler/ue_context/ue_channel_state_manager.cpp b/lib/scheduler/ue_context/ue_channel_state_manager.cpp index 439e2e528f..ef954ff329 100644 --- a/lib/scheduler/ue_context/ue_channel_state_manager.cpp +++ b/lib/scheduler/ue_context/ue_channel_state_manager.cpp @@ -89,12 +89,16 @@ void ue_channel_state_manager::update_srs_channel_matrix(const srs_channel_matri get_tpmi_select_info(channel_matrix, noise_var, codebook_cfg.max_rank.value(), codebook_cfg.codebook_subset); } -SRSRAN_WEAK_SYMB unsigned ue_channel_state_manager::get_nof_ul_layers() const +#ifndef SRSRAN_HAS_ENTERPRISE + +unsigned ue_channel_state_manager::get_nof_ul_layers() const { return 1; } -SRSRAN_WEAK_SYMB unsigned ue_channel_state_manager::get_recommended_pusch_tpmi(unsigned nof_layers) const +#endif // SRSRAN_HAS_ENTERPRISE + +unsigned ue_channel_state_manager::get_recommended_pusch_tpmi(unsigned nof_layers) const { if (last_pusch_tpmi_select_info.has_value() && (nof_layers <= last_pusch_tpmi_select_info.value().get_max_nof_layers())) { diff --git a/lib/support/CMakeLists.txt b/lib/support/CMakeLists.txt index b5adfe388e..17eeade299 100644 --- a/lib/support/CMakeLists.txt +++ b/lib/support/CMakeLists.txt @@ -41,7 +41,6 @@ set(SOURCES sysinfo.cpp timers.cpp math_utils.cpp - dynlink_manager.cpp ) add_library(srsran_support STATIC ${SOURCES}) diff --git a/lib/support/dynlink_manager.cpp b/lib/support/dynlink_manager.cpp deleted file mode 100644 index 4c8804d6ae..0000000000 --- a/lib/support/dynlink_manager.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * Copyright 2021-2024 Software Radio Systems Limited - * - * This file is part of srsRAN. - * - * srsRAN 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. - * - * srsRAN 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 "srsran/support/dynlink_manager.h" -#include -#include - -using namespace srsran; - -std::optional dynlink_manager::create(const std::string& dl_name, srslog::basic_logger& logger) -{ - dynlink_manager mng(dl_name, logger); - if (not mng.open()) { - return {}; - } - return mng; -} - -dynlink_manager::dynlink_manager(const std::string& dl_name_, srslog::basic_logger& logger_) : - dl_name(dl_name_), logger(logger_) -{ -} - -dynlink_manager::~dynlink_manager() -{ - close(); -} - -bool dynlink_manager::open() -{ - char* err = nullptr; - - dl_handle = ::dlopen(dl_name.c_str(), RTLD_NOW + RTLD_DEEPBIND + RTLD_GLOBAL); - if (dl_handle == nullptr) { - err = ::dlerror(); - if (err != nullptr) { - logger.error("Failed to load library {}: {}", dl_name, err); - } else { - logger.error("Failed to load library {}", dl_name); - } - return false; - } - logger.debug("Opened library: {}", dl_name); - return true; -} - -expected dynlink_manager::load_symbol(const std::string& symbol_name) -{ - if (dl_handle == nullptr) { - return make_unexpected(default_error_t{}); - } - - void* symb = ::dlsym(dl_handle, symbol_name.c_str()); - - // Handle an error loading the symbol. - char* err = nullptr; - if (symb == nullptr) { - err = ::dlerror(); - if (err != nullptr) { - logger.error("Error loading symbol {} in {}: {}\n", symbol_name, dl_name, err); - } else { - logger.error("Error loading symbol {} in {}:\n", symbol_name, dl_name); - } - return make_unexpected(default_error_t{}); - } - logger.debug("Loaded symbol: {}", symbol_name); - return symb; -} - -bool dynlink_manager::close() -{ - if (dl_handle == nullptr) { - return false; - } - - if (::dlclose(dl_handle) != 0) { - char* err = ::dlerror(); - if (err != nullptr) { - logger.error("Failed to close dynamic link handle: {}", err); - } else { - logger.error("Failed to close dynamic link handle"); - } - return false; - } - logger.debug("Closed library"); - return true; -} diff --git a/tests/e2e/tests/iperf.py b/tests/e2e/tests/iperf.py index 82e468b241..9221e8eed1 100644 --- a/tests/e2e/tests/iperf.py +++ b/tests/e2e/tests/iperf.py @@ -273,7 +273,7 @@ def test_ric( sample_rate=11520000, iperf_duration=SHORT_DURATION, protocol=protocol, - bitrate=MEDIUM_BITRATE, + bitrate=LOW_BITRATE, direction=direction, global_timing_advance=-1, time_alignment_calibration=0, diff --git a/tests/e2e/tests/ping.py b/tests/e2e/tests/ping.py index 357b084ebd..11a5025151 100644 --- a/tests/e2e/tests/ping.py +++ b/tests/e2e/tests/ping.py @@ -204,10 +204,7 @@ def test_android_hp( ) @mark.parametrize( "band, common_scs, bandwidth", - ( - param(3, 15, 10, id="band:%s-scs:%s-bandwidth:%s"), - param(78, 30, 20, id="band:%s-scs:%s-bandwidth:%s"), - ), + (param(3, 15, 10, id="band:%s-scs:%s-bandwidth:%s"),), ) @mark.android_drx @mark.flaky( diff --git a/tests/e2e/tests/steps/stub.py b/tests/e2e/tests/steps/stub.py index d96b7f13e4..7fbd2589c7 100644 --- a/tests/e2e/tests/steps/stub.py +++ b/tests/e2e/tests/steps/stub.py @@ -266,9 +266,9 @@ def start_rc_xapp(ric: NearRtRicStub, control_service_style: int = 2, action_id: xapp_request.parameters[10].name = "SD" xapp_request.parameters[10].value = 1 xapp_request.parameters[11].name = "Min PRB Policy Ratio" - xapp_request.parameters[11].value = 20 + xapp_request.parameters[11].value = 10 xapp_request.parameters[12].name = "Max PRB Policy Ratio" - xapp_request.parameters[12].value = 60 + xapp_request.parameters[12].value = 90 xapp_request.parameters[13].name = "Dedicated PRB Policy Ratio" xapp_request.parameters[13].value = 80 ric.StartRcXapp(xapp_request) diff --git a/tests/e2e/tests/viavi.py b/tests/e2e/tests/viavi.py index 156c3b8cf3..eaa64caf4e 100644 --- a/tests/e2e/tests/viavi.py +++ b/tests/e2e/tests/viavi.py @@ -359,6 +359,7 @@ def _test_viavi( "band": 78, "bandwidth": 100, "common_scs": 30, + "inactivity_timer": 7200, "tac": 7, "pci": 1, "prach_config_index": 159, diff --git a/tests/unittests/e1ap/common/e1ap_cu_cp_test_messages.h b/tests/unittests/e1ap/common/e1ap_cu_cp_test_messages.h index 3a620f9695..4acc1aebe1 100644 --- a/tests/unittests/e1ap/common/e1ap_cu_cp_test_messages.h +++ b/tests/unittests/e1ap/common/e1ap_cu_cp_test_messages.h @@ -27,6 +27,7 @@ #include "srsran/e1ap/cu_cp/e1ap_cu_cp.h" #include "srsran/ran/cu_types.h" #include "srsran/ran/rb_id.h" +#include namespace srsran { namespace srs_cu_cp { diff --git a/tests/unittests/fapi_adaptor/phy/fapi_to_phy_translator_test.cpp b/tests/unittests/fapi_adaptor/phy/fapi_to_phy_translator_test.cpp index 2b19da1f42..5b489dab2f 100644 --- a/tests/unittests/fapi_adaptor/phy/fapi_to_phy_translator_test.cpp +++ b/tests/unittests/fapi_adaptor/phy/fapi_to_phy_translator_test.cpp @@ -178,7 +178,7 @@ class fapi_to_phy_translator_fixture : public ::testing::Test uplink_pdu_validator_dummy ul_pdu_validator; slot_error_message_notifier_spy error_notifier_spy; manual_task_worker worker; - fapi_to_phy_translator_config config = {sector_id, headroom_in_slots, scs, scs, &prach_cfg, &carrier_cfg, {0}}; + fapi_to_phy_translator_config config = {sector_id, headroom_in_slots, scs, scs, prach_cfg, carrier_cfg, {0}}; fapi_to_phy_translator_dependencies dependencies = { &srslog::fetch_basic_logger("FAPI"), &dl_processor_pool, diff --git a/tests/unittests/srslog/CMakeLists.txt b/tests/unittests/srslog/CMakeLists.txt index 514a737810..1efff1f012 100644 --- a/tests/unittests/srslog/CMakeLists.txt +++ b/tests/unittests/srslog/CMakeLists.txt @@ -18,61 +18,70 @@ # and at http://www.gnu.org/licenses/. # -include_directories(../../..) +add_executable(srslog_backend_throughput benchmarks/backend_throughput.cpp) +target_include_directories(srslog_backend_throughput PRIVATE ${CMAKE_SOURCE_DIR}) +target_link_libraries(srslog_backend_throughput srslog) add_executable(srslog_frontend_latency benchmarks/frontend_latency.cpp) +target_include_directories(srslog_frontend_latency PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(srslog_frontend_latency srslog) add_executable(srslog_test srslog_test.cpp) +target_include_directories(srslog_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(srslog_test srslog) add_test(srslog_test srslog_test) add_executable(log_channel_test log_channel_test.cpp) +target_include_directories(log_channel_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(log_channel_test srslog) add_test(log_channel_test log_channel_test) add_executable(log_backend_test log_backend_test.cpp) -target_include_directories(log_backend_test PUBLIC ../../) +target_include_directories(log_backend_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(log_backend_test srslog) add_test(log_backend_test log_backend_test) add_executable(logger_test logger_test.cpp) +target_include_directories(logger_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(logger_test srslog) add_test(logger_test logger_test) add_executable(any_test any_test.cpp) +target_include_directories(any_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(any_test srslog) add_test(any_test any_test) add_executable(file_sink_test file_sink_test.cpp) -target_include_directories(file_sink_test PUBLIC ../../) +target_include_directories(file_sink_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(file_sink_test srslog) add_test(file_sink_test file_sink_test) add_executable(syslog_sink_test syslog_sink_test.cpp) -target_include_directories(syslog_sink_test PUBLIC ../../) +target_include_directories(syslog_sink_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(syslog_sink_test srslog) add_executable(file_utils_test file_utils_test.cpp) -target_include_directories(file_utils_test PUBLIC ../../) +target_include_directories(file_utils_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(file_utils_test srslog) add_test(file_utils_test file_utils_test) add_executable(tracer_test event_trace_test.cpp) +target_include_directories(tracer_test PRIVATE ${CMAKE_SOURCE_DIR}) add_definitions(-DENABLE_SRSLOG_EVENT_TRACE) target_link_libraries(tracer_test srslog) add_test(tracer_test tracer_test) add_executable(text_formatter_test text_formatter_test.cpp) -target_include_directories(text_formatter_test PUBLIC ../../) +target_include_directories(text_formatter_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(text_formatter_test srslog) add_test(text_formatter_test text_formatter_test) add_executable(json_formatter_test json_formatter_test.cpp) -target_include_directories(json_formatter_test PUBLIC ../../) +target_include_directories(json_formatter_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(json_formatter_test srslog) add_test(json_formatter_test json_formatter_test) add_executable(context_test context_test.cpp) +target_include_directories(context_test PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(context_test srslog) add_test(context_test context_test) diff --git a/tests/unittests/srslog/benchmarks/backend_throughput.cpp b/tests/unittests/srslog/benchmarks/backend_throughput.cpp new file mode 100644 index 0000000000..54f838c91f --- /dev/null +++ b/tests/unittests/srslog/benchmarks/backend_throughput.cpp @@ -0,0 +1,52 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN 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. + * + * srsRAN 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 "srsran/srslog/srslog.h" + +using namespace srslog; + +static constexpr unsigned num_iterations = 4000000; + +int main() +{ + auto& s = srslog::fetch_file_sink("srslog_latency_benchmark.txt"); + auto& channel = srslog::fetch_log_channel("bench", s, {}); + + srslog::init(srslog::backend_priority::high); + + auto begin = std::chrono::steady_clock::now(); + for (unsigned i = 0; i != num_iterations; ++i) { + double d = i; + channel("SRSLOG backend benchmark: int: {}, double: {}", i, d); + } + srslog::flush(); + auto end = std::chrono::steady_clock::now(); + + fmt::print("SRSLOG Backend throughput Benchmark:\n" + " benchmark run for {} ms and logged {} times\n" + " {:.1f} million logs/sec", + std::chrono::duration_cast(end - begin).count(), + num_iterations, + num_iterations / std::chrono::duration_cast>(end - begin).count() / 1e6); + + return 0; +} diff --git a/tests/unittests/srslog/benchmarks/frontend_latency.cpp b/tests/unittests/srslog/benchmarks/frontend_latency.cpp index 16b4c6564f..3ddf527b63 100644 --- a/tests/unittests/srslog/benchmarks/frontend_latency.cpp +++ b/tests/unittests/srslog/benchmarks/frontend_latency.cpp @@ -79,7 +79,7 @@ static void run_thread(log_channel& c, std::vector& results, std::atom auto begin = std::chrono::steady_clock::now(); for (unsigned entry_num = 0; entry_num != num_entries_per_iter; ++entry_num) { double d = entry_num; - c("SRSLOG latency benchmark: int: {}, double: {}, string: {}", iter, d, "test"); + c("SRSLOG latency benchmark: int: {}, double: {}", iter, d); } auto end = std::chrono::steady_clock::now();