Skip to content

Commit 7d44671

Browse files
committed
cu_cp_unit: added a CU-CP wrapper to store objects related to the CU-CP. Moved the n2 clients to this wrapper and removed them from the gNB and CU applications
1 parent 2a685e4 commit 7d44671

File tree

7 files changed

+147
-43
lines changed

7 files changed

+147
-43
lines changed

apps/cu/cu.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,18 +313,8 @@ int main(int argc, char** argv)
313313
cu_cp_dependencies.cu_cp_executor = workers.cu_cp_exec;
314314
cu_cp_dependencies.cu_cp_e2_exec = workers.cu_cp_e2_exec;
315315
cu_cp_dependencies.timers = cu_timers;
316-
317-
// Create N2 Client Gateways.
318-
cu_cp_dependencies.n2_clients.push_back(srs_cu_cp::create_n2_connection_client(
319-
generate_n2_client_config(cu_cp_app_unit->get_cu_cp_unit_config().amf_config.no_core,
320-
cu_cp_app_unit->get_cu_cp_unit_config().amf_config.amf,
321-
*cu_cp_dlt_pcaps.ngap,
322-
*epoll_broker)));
323-
324-
for (const auto& amf : cu_cp_app_unit->get_cu_cp_unit_config().extra_amfs) {
325-
cu_cp_dependencies.n2_clients.push_back(srs_cu_cp::create_n2_connection_client(generate_n2_client_config(
326-
cu_cp_app_unit->get_cu_cp_unit_config().amf_config.no_core, amf, *cu_cp_dlt_pcaps.ngap, *epoll_broker)));
327-
}
316+
cu_cp_dependencies.ngap_pcap = cu_cp_dlt_pcaps.ngap.get();
317+
cu_cp_dependencies.broker = epoll_broker.get();
328318

329319
// create CU-CP.
330320
auto cu_cp_obj_and_cmds = cu_cp_app_unit->create_cu_cp(cu_cp_dependencies);

apps/gnb/gnb.cpp

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,6 @@ int main(int argc, char** argv)
360360

361361
e2_metric_connector_manager e2_metric_connectors(du_app_unit->get_du_high_unit_config().cells_cfg.size());
362362

363-
// Create CU-CP config.
364-
cu_cp_build_dependencies cu_cp_dependencies;
365-
cu_cp_dependencies.cu_cp_executor = workers.cu_cp_exec;
366-
cu_cp_dependencies.cu_cp_e2_exec = workers.cu_cp_e2_exec;
367-
cu_cp_dependencies.timers = cu_timers;
368-
369363
// Load CU-CP plugins if enabled
370364
std::optional<dynlink_manager> ng_handover_plugin =
371365
cu_cp_app_unit->get_cu_cp_unit_config().load_plugins
@@ -404,23 +398,13 @@ int main(int argc, char** argv)
404398
cu_cp_app_unit->get_cu_cp_unit_config().disconnect_amfs_func_ptr = disconnect_amfs.value();
405399
}
406400

407-
// Create N2 Client Gateways.
408-
cu_cp_dependencies.n2_clients.push_back(srs_cu_cp::create_n2_connection_client(
409-
generate_n2_client_config(cu_cp_app_unit->get_cu_cp_unit_config().amf_config.no_core,
410-
cu_cp_app_unit->get_cu_cp_unit_config().amf_config.amf,
411-
*cu_cp_dlt_pcaps.ngap,
412-
*epoll_broker)));
413-
414-
for (const auto& amf : cu_cp_app_unit->get_cu_cp_unit_config().extra_amfs) {
415-
cu_cp_dependencies.n2_clients.push_back(srs_cu_cp::create_n2_connection_client(generate_n2_client_config(
416-
cu_cp_app_unit->get_cu_cp_unit_config().amf_config.no_core, amf, *cu_cp_dlt_pcaps.ngap, *epoll_broker)));
417-
}
418-
419-
// E2AP configuration.
420-
srsran::sctp_network_connector_config e2_du_nw_config = generate_e2ap_nw_config(gnb_cfg, E2_DU_PPID);
421-
422-
// Create E2AP GW remote connector.
423-
e2_gateway_remote_connector e2_gw{*epoll_broker, e2_du_nw_config, *du_pcaps.e2ap};
401+
// Create CU-CP dependencies.
402+
cu_cp_build_dependencies cu_cp_dependencies;
403+
cu_cp_dependencies.cu_cp_executor = workers.cu_cp_exec;
404+
cu_cp_dependencies.cu_cp_e2_exec = workers.cu_cp_e2_exec;
405+
cu_cp_dependencies.timers = cu_timers;
406+
cu_cp_dependencies.ngap_pcap = cu_cp_dlt_pcaps.ngap.get();
407+
cu_cp_dependencies.broker = epoll_broker.get();
424408

425409
// create CU-CP.
426410
auto cu_cp_obj_and_cmds = cu_cp_app_unit->create_cu_cp(cu_cp_dependencies);
@@ -438,6 +422,12 @@ int main(int argc, char** argv)
438422

439423
std::unique_ptr<srs_cu_up::cu_up_interface> cu_up_obj = cu_up_app_unit->create_cu_up_unit(cu_up_unit_deps);
440424

425+
// E2AP configuration.
426+
sctp_network_connector_config e2_du_nw_config = generate_e2ap_nw_config(gnb_cfg, E2_DU_PPID);
427+
428+
// Create E2AP GW remote connector.
429+
e2_gateway_remote_connector e2_gw{*epoll_broker, e2_du_nw_config, *du_pcaps.e2ap};
430+
441431
// Instantiate one DU.
442432
app_services::metrics_notifier_proxy_impl metrics_notifier_forwarder;
443433
du_unit_dependencies du_dependencies;

apps/units/cu_cp/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ set(SOURCES
1212
cu_cp_unit_config_cli11_schema.cpp
1313
cu_cp_config_translators.cpp
1414
cu_cp_unit_config_validator.cpp
15-
cu_cp_unit_config_yaml_writer.cpp)
15+
cu_cp_unit_config_yaml_writer.cpp
16+
cu_cp_wrapper.cpp)
1617

1718
add_library(srsran_cu_cp_app_unit STATIC ${SOURCES})
1819
target_include_directories(srsran_cu_cp_app_unit PRIVATE ${CMAKE_SOURCE_DIR})

apps/units/cu_cp/cu_cp_builder.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "cu_cp_builder.h"
1212
#include "cu_cp_commands.h"
1313
#include "cu_cp_config_translators.h"
14+
#include "cu_cp_unit_config.h"
15+
#include "cu_cp_wrapper.h"
1416
#include "srsran/cu_cp/cu_cp_factory.h"
1517

1618
using namespace srsran;
@@ -20,18 +22,33 @@ cu_cp_unit srsran::build_cu_cp(const cu_cp_unit_config& cu_cp_unit_cfg, cu_cp_bu
2022
srsran_assert(dependencies.cu_cp_executor, "Invalid CU-CP executor");
2123
srsran_assert(dependencies.cu_cp_e2_exec, "Invalid E2 executor");
2224
srsran_assert(dependencies.cu_cp_e2_exec, "Invalid E2 executor");
25+
srsran_assert(dependencies.ngap_pcap, "Invalid NGAP PCAP");
26+
srsran_assert(dependencies.broker, "Invalid IO broker");
2327

2428
srs_cu_cp::cu_cp_configuration cu_cp_cfg = generate_cu_cp_config(cu_cp_unit_cfg);
2529
cu_cp_cfg.services.cu_cp_executor = dependencies.cu_cp_executor;
2630
cu_cp_cfg.services.cu_cp_e2_exec = dependencies.cu_cp_e2_exec;
2731
cu_cp_cfg.services.timers = dependencies.timers;
2832

29-
for (unsigned pos = 0; pos < dependencies.n2_clients.size(); pos++) {
30-
cu_cp_cfg.ngaps[pos].n2_gw = dependencies.n2_clients[pos].get();
33+
// Create N2 Client Gateways.
34+
std::vector<std::unique_ptr<srs_cu_cp::n2_connection_client>> n2_clients;
35+
n2_clients.push_back(
36+
srs_cu_cp::create_n2_connection_client(generate_n2_client_config(cu_cp_unit_cfg.amf_config.no_core,
37+
cu_cp_unit_cfg.amf_config.amf,
38+
*dependencies.ngap_pcap,
39+
*dependencies.broker)));
40+
41+
for (const auto& amf : cu_cp_unit_cfg.extra_amfs) {
42+
n2_clients.push_back(srs_cu_cp::create_n2_connection_client(generate_n2_client_config(
43+
cu_cp_unit_cfg.amf_config.no_core, amf, *dependencies.ngap_pcap, *dependencies.broker)));
44+
}
45+
46+
for (unsigned pos = 0; pos < n2_clients.size(); pos++) {
47+
cu_cp_cfg.ngaps[pos].n2_gw = n2_clients[pos].get();
3148
}
3249

3350
cu_cp_unit cu_cmd_wrapper;
34-
cu_cmd_wrapper.unit = create_cu_cp(cu_cp_cfg);
51+
cu_cmd_wrapper.unit = std::make_unique<cu_cp_wrapper>(std::move(n2_clients), create_cu_cp(cu_cp_cfg));
3552

3653
// Add the commands;
3754
cu_cmd_wrapper.commands.push_back(std::make_unique<handover_app_command>(cu_cmd_wrapper.unit->get_command_handler()));

apps/units/cu_cp/cu_cp_builder.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
namespace srsran {
1717

18+
class dlt_pcap;
19+
class io_broker;
1820
struct cu_cp_unit_config;
1921
struct worker_manager;
2022

@@ -24,10 +26,11 @@ class n2_connection_client;
2426

2527
/// CU-CP build dependencies.
2628
struct cu_cp_build_dependencies {
27-
task_executor* cu_cp_executor = nullptr;
28-
task_executor* cu_cp_e2_exec = nullptr;
29-
std::vector<std::unique_ptr<srs_cu_cp::n2_connection_client>> n2_clients;
30-
timer_manager* timers = nullptr;
29+
task_executor* cu_cp_executor = nullptr;
30+
task_executor* cu_cp_e2_exec = nullptr;
31+
timer_manager* timers = nullptr;
32+
dlt_pcap* ngap_pcap = nullptr;
33+
io_broker* broker = nullptr;
3134
};
3235

3336
/// Wraps the CU-CP and its supported application commands.

apps/units/cu_cp/cu_cp_wrapper.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
*
3+
* Copyright 2021-2024 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#include "cu_cp_wrapper.h"
12+
13+
using namespace srsran;
14+
using namespace srs_cu_cp;
15+
16+
cu_cp_wrapper::cu_cp_wrapper(std::vector<std::unique_ptr<srs_cu_cp::n2_connection_client>> n2_clients_,
17+
std::unique_ptr<srs_cu_cp::cu_cp> cu_cp_) :
18+
n2_clients(std::move(n2_clients_)), cu_cp(std::move(cu_cp_))
19+
{
20+
srsran_assert(cu_cp, "Invalid CU-CP object");
21+
}
22+
23+
cu_cp_f1c_handler& cu_cp_wrapper::get_f1c_handler()
24+
{
25+
return cu_cp->get_f1c_handler();
26+
}
27+
28+
cu_cp_e1_handler& cu_cp_wrapper::get_e1_handler()
29+
{
30+
return cu_cp->get_e1_handler();
31+
}
32+
33+
cu_cp_ng_handler& cu_cp_wrapper::get_ng_handler()
34+
{
35+
return cu_cp->get_ng_handler();
36+
}
37+
38+
cu_cp_command_handler& cu_cp_wrapper::get_command_handler()
39+
{
40+
return cu_cp->get_command_handler();
41+
}
42+
43+
metrics_handler& cu_cp_wrapper::get_metrics_handler()
44+
{
45+
return cu_cp->get_metrics_handler();
46+
}
47+
48+
bool cu_cp_wrapper::start()
49+
{
50+
return cu_cp->start();
51+
}
52+
53+
void cu_cp_wrapper::stop()
54+
{
55+
cu_cp->stop();
56+
}

apps/units/cu_cp/cu_cp_wrapper.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
*
3+
* Copyright 2021-2024 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#pragma once
12+
13+
#include "srsran/cu_cp/cu_cp.h"
14+
#include "srsran/ngap/gateways/n2_connection_client.h"
15+
16+
namespace srsran {
17+
18+
/// \brief CU-CP wrapper implementation.
19+
///
20+
/// The purpose of this wrapper is to keep the life cycle of the objects related only to the CU-CP.
21+
class cu_cp_wrapper : public srs_cu_cp::cu_cp
22+
{
23+
public:
24+
cu_cp_wrapper(std::vector<std::unique_ptr<srs_cu_cp::n2_connection_client>> n2_clients_,
25+
std::unique_ptr<srs_cu_cp::cu_cp> cu_cp_);
26+
27+
// See interface for documentation.
28+
srs_cu_cp::cu_cp_f1c_handler& get_f1c_handler() override;
29+
// See interface for documentation.
30+
srs_cu_cp::cu_cp_e1_handler& get_e1_handler() override;
31+
// See interface for documentation.
32+
srs_cu_cp::cu_cp_ng_handler& get_ng_handler() override;
33+
// See interface for documentation.
34+
srs_cu_cp::cu_cp_command_handler& get_command_handler() override;
35+
// See interface for documentation.
36+
srs_cu_cp::metrics_handler& get_metrics_handler() override;
37+
// See interface for documentation.
38+
bool start() override;
39+
// See interface for documentation.
40+
void stop() override;
41+
42+
private:
43+
std::vector<std::unique_ptr<srs_cu_cp::n2_connection_client>> n2_clients;
44+
std::unique_ptr<srs_cu_cp::cu_cp> cu_cp;
45+
};
46+
47+
} // namespace srsran

0 commit comments

Comments
 (0)