Skip to content

Commit a85034f

Browse files
FabianEckermannFabian Eckermann
authored andcommitted
cu_cp,rrc: refactor rrc setup procedure
1 parent b86a3e8 commit a85034f

File tree

4 files changed

+46
-53
lines changed

4 files changed

+46
-53
lines changed

lib/rrc/ue/procedures/rrc_reestablishment_procedure.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,14 @@ void rrc_reestablishment_procedure::operator()(coro_context<async_task<void>>& c
124124

125125
async_task<void> rrc_reestablishment_procedure::handle_rrc_reestablishment_fallback()
126126
{
127+
context.connection_cause.value = asn1::rrc_nr::establishment_cause_e::mt_access;
128+
127129
return launch_async([this](coro_context<async_task<void>>& ctx) mutable {
128130
CORO_BEGIN(ctx);
129131

130132
// Reject RRC Reestablishment Request by sending RRC Setup
131-
CORO_AWAIT(launch_async<rrc_setup_procedure>(context,
132-
asn1::rrc_nr::establishment_cause_e::mt_access,
133-
du_to_cu_container,
134-
rrc_ue_setup_notifier,
135-
srb_notifier,
136-
nas_notifier,
137-
event_mng,
138-
logger));
133+
CORO_AWAIT(launch_async<rrc_setup_procedure>(
134+
context, du_to_cu_container, rrc_ue_setup_notifier, srb_notifier, nas_notifier, event_mng, logger));
139135

140136
if (old_ue_reest_context.ue_index != ue_index_t::invalid and !old_ue_reest_context.old_ue_fully_attached) {
141137
// The UE exists but still has not established an SRB2 and DRB. Request the release of the old UE.

lib/rrc/ue/procedures/rrc_setup_procedure.cpp

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ using namespace srsran;
1616
using namespace srsran::srs_cu_cp;
1717
using namespace asn1::rrc_nr;
1818

19-
rrc_setup_procedure::rrc_setup_procedure(rrc_ue_context_t& context_,
20-
const asn1::rrc_nr::establishment_cause_e& cause_,
21-
const byte_buffer& du_to_cu_container_,
22-
rrc_ue_setup_proc_notifier& rrc_ue_notifier_,
23-
rrc_ue_srb_handler& srb_notifier_,
24-
rrc_ue_nas_notifier& nas_notifier_,
25-
rrc_ue_event_manager& event_mng_,
26-
rrc_ue_logger& logger_) :
19+
rrc_setup_procedure::rrc_setup_procedure(rrc_ue_context_t& context_,
20+
const byte_buffer& du_to_cu_container_,
21+
rrc_ue_setup_proc_notifier& rrc_ue_notifier_,
22+
rrc_ue_srb_handler& srb_notifier_,
23+
rrc_ue_nas_notifier& nas_notifier_,
24+
rrc_ue_event_manager& event_mng_,
25+
rrc_ue_logger& logger_) :
2726
context(context_),
28-
cause(cause_),
2927
du_to_cu_container(du_to_cu_container_),
3028
rrc_ue(rrc_ue_notifier_),
3129
srb_notifier(srb_notifier_),
@@ -52,18 +50,19 @@ void rrc_setup_procedure::operator()(coro_context<async_task<void>>& ctx)
5250
// Await UE response
5351
CORO_AWAIT(transaction);
5452

55-
if (transaction.has_response()) {
56-
logger.log_debug("\"{}\" finished successfully", name());
57-
context.state = rrc_state::connected;
58-
send_initial_ue_msg(transaction.response().msg.c1().rrc_setup_complete());
59-
} else if (transaction.failure_cause() == protocol_transaction_failure::timeout) {
60-
logger.log_warning("\"{}\" timed out after {}ms", name(), context.cfg.rrc_procedure_timeout_ms);
61-
rrc_ue.on_ue_release_required(cause_protocol_t::unspecified);
62-
} else {
63-
logger.log_warning("\"{}\" cancelled", name());
64-
// Do nothing. We are likely shutting down the DU processor.
53+
if (!transaction.has_response()) {
54+
if (transaction.failure_cause() == protocol_transaction_failure::timeout) {
55+
logger.log_warning("\"{}\" timed out after {}ms", name(), context.cfg.rrc_procedure_timeout_ms);
56+
rrc_ue.on_ue_release_required(cause_protocol_t::unspecified);
57+
} else {
58+
logger.log_warning("\"{}\" cancelled", name());
59+
// Do nothing. We are likely shutting down the DU processor.
60+
}
61+
CORO_EARLY_RETURN();
6562
}
6663

64+
send_initial_ue_msg(transaction.response().msg.c1().rrc_setup_complete());
65+
6766
CORO_RETURN();
6867
}
6968

@@ -89,12 +88,16 @@ void rrc_setup_procedure::send_rrc_setup()
8988
rrc_ue.on_new_dl_ccch(dl_ccch_msg);
9089
}
9190

92-
void rrc_setup_procedure::send_initial_ue_msg(const asn1::rrc_nr::rrc_setup_complete_s& rrc_setup_complete_msg)
91+
void rrc_setup_procedure::send_initial_ue_msg(const asn1::rrc_nr::rrc_setup_complete_s& rrc_setup_complete)
9392
{
94-
cu_cp_initial_ue_message init_ue_msg = {};
93+
cu_cp_initial_ue_message init_ue_msg = {};
94+
95+
logger.log_debug("\"{}\" finished successfully", name());
96+
context.state = rrc_state::connected;
97+
9598
init_ue_msg.ue_index = context.ue_index;
96-
init_ue_msg.nas_pdu = rrc_setup_complete_msg.crit_exts.rrc_setup_complete().ded_nas_msg.copy();
97-
init_ue_msg.establishment_cause = static_cast<establishment_cause_t>(cause.value);
99+
init_ue_msg.nas_pdu = rrc_setup_complete.crit_exts.rrc_setup_complete().ded_nas_msg.copy();
100+
init_ue_msg.establishment_cause = static_cast<establishment_cause_t>(context.connection_cause.value);
98101
init_ue_msg.user_location_info.nr_cgi = context.cell.cgi;
99102
init_ue_msg.user_location_info.tai.plmn_id = context.cell.cgi.plmn_id;
100103
init_ue_msg.user_location_info.tai.tac = context.cell.tac;
@@ -106,9 +109,9 @@ void rrc_setup_procedure::send_initial_ue_msg(const asn1::rrc_nr::rrc_setup_comp
106109
init_ue_msg.five_g_s_tmsi = five_g_s_tmsi;
107110
}
108111

109-
if (rrc_setup_complete_msg.crit_exts.rrc_setup_complete().registered_amf_present) {
112+
if (rrc_setup_complete.crit_exts.rrc_setup_complete().registered_amf_present) {
110113
cu_cp_amf_identifier_t amf_id =
111-
asn1_to_amf_identifier(rrc_setup_complete_msg.crit_exts.rrc_setup_complete().registered_amf.amf_id);
114+
asn1_to_amf_identifier(rrc_setup_complete.crit_exts.rrc_setup_complete().registered_amf.amf_id);
112115

113116
init_ue_msg.amf_set_id = amf_id.amf_set_id;
114117
// TODO: Handle PLMN ID

lib/rrc/ue/procedures/rrc_setup_procedure.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "../rrc_ue_context.h"
1414
#include "../rrc_ue_logger.h"
1515
#include "rrc_ue_event_manager.h"
16+
#include "srsran/asn1/rrc_nr/ul_dcch_msg_ies.h"
1617
#include "srsran/rrc/rrc_du.h"
1718
#include "srsran/rrc/rrc_ue.h"
1819
#include "srsran/support/async/async_task.h"
@@ -56,14 +57,13 @@ namespace srs_cu_cp {
5657
class rrc_setup_procedure
5758
{
5859
public:
59-
rrc_setup_procedure(rrc_ue_context_t& context_,
60-
const asn1::rrc_nr::establishment_cause_e& cause_,
61-
const byte_buffer& du_to_cu_container_,
62-
rrc_ue_setup_proc_notifier& rrc_ue_notifier_,
63-
rrc_ue_srb_handler& srb_notifier_,
64-
rrc_ue_nas_notifier& nas_notifier_,
65-
rrc_ue_event_manager& ev_mng_,
66-
rrc_ue_logger& logger_);
60+
rrc_setup_procedure(rrc_ue_context_t& context_,
61+
const byte_buffer& du_to_cu_container_,
62+
rrc_ue_setup_proc_notifier& rrc_ue_notifier_,
63+
rrc_ue_srb_handler& srb_notifier_,
64+
rrc_ue_nas_notifier& nas_notifier_,
65+
rrc_ue_event_manager& ev_mng_,
66+
rrc_ue_logger& logger_);
6767

6868
void operator()(coro_context<async_task<void>>& ctx);
6969

@@ -73,15 +73,14 @@ class rrc_setup_procedure
7373
/// Instruct DU processor to create SRB1 bearer.
7474
void create_srb1();
7575

76-
/// \remark Send RRC Setup, see section 5.3.3 in TS 36.331
76+
/// \remark Send RRC Setup, see section 5.3.3 in TS 36.331.
7777
void send_rrc_setup();
7878

7979
/// \remark Forward the Initial UE Message to the NGAP
8080
void send_initial_ue_msg(const asn1::rrc_nr::rrc_setup_complete_s& rrc_setup_complete_msg);
8181

82-
rrc_ue_context_t& context;
83-
const asn1::rrc_nr::establishment_cause_e cause;
84-
const byte_buffer& du_to_cu_container;
82+
rrc_ue_context_t& context;
83+
const byte_buffer& du_to_cu_container;
8584

8685
rrc_ue_setup_proc_notifier& rrc_ue; // handler to the parent RRC UE object
8786
rrc_ue_srb_handler& srb_notifier; // for creation of SRBs

lib/rrc/ue/rrc_ue_message_handlers.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,13 @@ void rrc_ue_impl::handle_rrc_setup_request(const asn1::rrc_nr::rrc_setup_request
9797
context.connection_cause.value = request_ies.establishment_cause.value;
9898

9999
// Launch RRC setup procedure
100-
cu_cp_ue_notifier.schedule_async_task(launch_async<rrc_setup_procedure>(context,
101-
request_ies.establishment_cause.value,
102-
du_to_cu_container,
103-
*this,
104-
get_rrc_ue_srb_handler(),
105-
nas_notifier,
106-
*event_mng,
107-
logger));
100+
cu_cp_ue_notifier.schedule_async_task(launch_async<rrc_setup_procedure>(
101+
context, du_to_cu_container, *this, get_rrc_ue_srb_handler(), nas_notifier, *event_mng, logger));
108102
}
109103

110104
void rrc_ue_impl::handle_rrc_reest_request(const asn1::rrc_nr::rrc_reest_request_s& msg)
111105
{
106+
// Launch RRC re-establishment procedure
112107
cu_cp_ue_notifier.schedule_async_task(launch_async<rrc_reestablishment_procedure>(msg,
113108
context,
114109
du_to_cu_container,

0 commit comments

Comments
 (0)