diff --git a/lib/cu_cp/adapters/ngap_adapters.h b/lib/cu_cp/adapters/ngap_adapters.h index ce76b4c140..ee34620221 100644 --- a/lib/cu_cp/adapters/ngap_adapters.h +++ b/lib/cu_cp/adapters/ngap_adapters.h @@ -32,12 +32,6 @@ class ngap_cu_cp_adapter : public ngap_cu_cp_du_repository_notifier, public ngap cu_cp_handler = &cu_cp_handler_; } - ue_index_t request_new_ue_index_allocation(nr_cell_global_id_t cgi) override - { - srsran_assert(du_repository_handler != nullptr, "CU-CP Paging handler must not be nullptr"); - return du_repository_handler->handle_ue_index_allocation_request(cgi); - } - void on_paging_message(cu_cp_paging_message& msg) override { srsran_assert(du_repository_handler != nullptr, "CU-CP Paging handler must not be nullptr"); @@ -103,6 +97,12 @@ class ngap_cu_cp_adapter : public ngap_cu_cp_du_repository_notifier, public ngap return cu_cp_handler->handle_new_handover_command(ue_index, std::move(command)); } + ue_index_t request_new_ue_index_allocation(nr_cell_global_id_t cgi) override + { + srsran_assert(cu_cp_handler != nullptr, "CU-CP NGAP handler must not be nullptr"); + return cu_cp_handler->handle_ue_index_allocation_request(cgi); + } + void on_n2_disconnection() override { srsran_assert(cu_cp_handler != nullptr, "CU-CP NGAP handler must not be nullptr"); diff --git a/lib/cu_cp/cu_cp_impl.cpp b/lib/cu_cp/cu_cp_impl.cpp index 257cdae383..5cb8060456 100644 --- a/lib/cu_cp/cu_cp_impl.cpp +++ b/lib/cu_cp/cu_cp_impl.cpp @@ -497,6 +497,16 @@ async_task cu_cp_impl::handle_new_handover_command(ue_index_t ue_index, by }); } +ue_index_t cu_cp_impl::handle_ue_index_allocation_request(const nr_cell_global_id_t& cgi) +{ + du_index_t du_index = du_db.find_du(cgi); + if (du_index == du_index_t::invalid) { + logger.warning("Could not find DU for CGI={}", cgi.nci); + return ue_index_t::invalid; + } + return ue_mng.add_ue(du_index); +} + void cu_cp_impl::handle_n2_disconnection() { // TODO diff --git a/lib/cu_cp/cu_cp_impl.h b/lib/cu_cp/cu_cp_impl.h index e14a14272b..1eeeef27cc 100644 --- a/lib/cu_cp/cu_cp_impl.h +++ b/lib/cu_cp/cu_cp_impl.h @@ -81,6 +81,7 @@ class cu_cp_impl final : public cu_cp, async_task handle_ngap_handover_request(const ngap_handover_request& request) override; async_task handle_new_handover_command(ue_index_t ue_index, byte_buffer command) override; + ue_index_t handle_ue_index_allocation_request(const nr_cell_global_id_t& cgi) override; void handle_n2_disconnection() override; // cu_cp_measurement_handler diff --git a/lib/cu_cp/cu_cp_impl_interface.h b/lib/cu_cp/cu_cp_impl_interface.h index 63fd8931e6..16f4489975 100644 --- a/lib/cu_cp/cu_cp_impl_interface.h +++ b/lib/cu_cp/cu_cp_impl_interface.h @@ -93,6 +93,9 @@ class cu_cp_ngap_handler : public cu_cp_ue_context_release_handler, public cu_cp /// \returns True if the Handover Command was successfully handled, false otherwise. virtual async_task handle_new_handover_command(ue_index_t ue_index, byte_buffer command) = 0; + /// \brief Handles UE index allocation request for N2 handover at target gNB + virtual ue_index_t handle_ue_index_allocation_request(const nr_cell_global_id_t& cgi) = 0; + /// \brief Handle N2 AMF connection drop. virtual void handle_n2_disconnection() = 0; }; diff --git a/lib/cu_cp/du_processor/du_processor.h b/lib/cu_cp/du_processor/du_processor.h index 512af3957d..718a34c148 100644 --- a/lib/cu_cp/du_processor/du_processor.h +++ b/lib/cu_cp/du_processor/du_processor.h @@ -290,9 +290,6 @@ class du_repository_ngap_handler /// \brief Handles a Paging message notification. virtual void handle_paging_message(cu_cp_paging_message& msg) = 0; - - /// \brief Handles UE index allocation request for N2 handover at target gNB - virtual ue_index_t handle_ue_index_allocation_request(const nr_cell_global_id_t& cgi) = 0; }; /// Methods to get statistics of the DU processor. diff --git a/lib/cu_cp/du_processor/du_processor_repository.cpp b/lib/cu_cp/du_processor/du_processor_repository.cpp index 195870ac81..47409dff69 100644 --- a/lib/cu_cp/du_processor/du_processor_repository.cpp +++ b/lib/cu_cp/du_processor/du_processor_repository.cpp @@ -114,8 +114,21 @@ du_index_t du_processor_repository::find_du(pci_t pci) { du_index_t index = du_index_t::invalid; for (const auto& du : du_db) { - if (du.second.processor->has_cell(pci)) + if (du.second.processor->has_cell(pci)) { return du.first; + } + } + + return index; +} + +du_index_t du_processor_repository::find_du(const nr_cell_global_id_t& cgi) +{ + du_index_t index = du_index_t::invalid; + for (const auto& du : du_db) { + if (du.second.processor->has_cell(cgi)) { + return du.first; + } } return index; @@ -136,17 +149,6 @@ void du_processor_repository::handle_paging_message(cu_cp_paging_message& msg) } } -ue_index_t du_processor_repository::handle_ue_index_allocation_request(const nr_cell_global_id_t& cgi) -{ - for (auto& du : du_db) { - if (du.second.processor->has_cell(cgi)) { - return cfg.ue_mng.add_ue(du.first); - } - } - logger.debug("No DU with plmn={} and cell_id={} found.", cgi.plmn_id, cgi.nci); - return ue_index_t::invalid; -} - std::vector du_processor_repository::handle_du_metrics_report_request() const { std::vector du_reports; diff --git a/lib/cu_cp/du_processor/du_processor_repository.h b/lib/cu_cp/du_processor/du_processor_repository.h index 34738e37b4..8f82115c7d 100644 --- a/lib/cu_cp/du_processor/du_processor_repository.h +++ b/lib/cu_cp/du_processor/du_processor_repository.h @@ -48,15 +48,19 @@ class du_processor_repository : public du_repository_ngap_handler, public du_rep explicit du_processor_repository(du_repository_config cfg_); /// \brief Checks whether a cell with the specified PCI is served by any of the connected DUs. - /// \param[out] The index of the DU serving the given PCI. + /// \param[in] pci The serving cell PCI. + /// \return The index of the DU serving the given PCI. du_index_t find_du(pci_t pci); + /// \brief Checks whether a cell with the specified CGI is served by any of the connected DUs. + /// \param[in] cgi The serving cell CGI. + /// \return The index of the DU serving the given CGI. + du_index_t find_du(const nr_cell_global_id_t& cgi); + du_processor& get_du_processor(du_index_t du_index); void handle_paging_message(cu_cp_paging_message& msg) override; - ue_index_t handle_ue_index_allocation_request(const nr_cell_global_id_t& nci) override; - std::vector handle_du_metrics_report_request() const override; size_t get_nof_f1ap_ues();