Skip to content

Commit 6a4e206

Browse files
frankistcodebot
authored andcommitted
f1ap-cu: make creation of a ue in the cu-cp during the initial ul rrc message into a single step
1 parent 4e2e694 commit 6a4e206

File tree

14 files changed

+88
-114
lines changed

14 files changed

+88
-114
lines changed

include/srsran/cu_cp/cu_cp_ue_messages.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct rrc_ue_transfer_context {
3434
/// \brief The UE creation is triggered from the F1AP.
3535
/// It carries an RRC container and the C-RNTI if the DU sent an Initial UL RRC transfer. If the user is created
3636
/// during handover the RNTI is only allocated after the Random Access.
37-
struct cu_cp_ue_creation_message {
37+
struct cu_cp_ue_creation_request {
3838
ue_index_t ue_index = ue_index_t::invalid;
3939
nr_cell_global_id_t cgi;
4040
uint32_t tac;

include/srsran/f1ap/cu_cp/f1ap_cu.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,8 @@ class f1ap_rrc_message_notifier
9999
virtual void on_ul_dcch_pdu(const srb_id_t srb_id, byte_buffer pdu) = 0;
100100
};
101101

102-
struct f1ap_srb_creation_message {
103-
ue_index_t ue_index = ue_index_t::invalid;
104-
srb_id_t srb_id = srb_id_t::nulltype;
105-
};
106-
107-
struct ue_creation_complete_message {
102+
/// Response provided by the CU-CP to the F1AP-CU when a UE context creation in the CU-CP is requested.
103+
struct cu_cp_ue_creation_response {
108104
ue_index_t ue_index = ue_index_t::invalid;
109105
f1ap_rrc_message_notifier* f1ap_rrc_notifier = nullptr;
110106
};
@@ -129,13 +125,10 @@ class f1ap_du_processor_notifier : public du_setup_notifier
129125
public:
130126
virtual ~f1ap_du_processor_notifier() = default;
131127

132-
/// \brief Request allocation of a new UE index.
133-
virtual ue_index_t on_new_ue_index_required() = 0;
134-
135128
/// \brief Notifies the DU processor to create a UE.
136129
/// \param[in] msg The ue creation message.
137130
/// \return Returns a UE creation complete message containing the index of the created UE and its SRB notifiers.
138-
virtual ue_creation_complete_message on_create_ue(const cu_cp_ue_creation_message& msg) = 0;
131+
virtual cu_cp_ue_creation_response on_ue_creation_request(const cu_cp_ue_creation_request& msg) = 0;
139132

140133
/// \brief Indicates the reception of a UE Context Release Request (gNB-DU initiated) as per TS 38.473
141134
/// section 8.3.2.

lib/cu_cp/adapters/f1ap_adapters.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,7 @@ class f1ap_du_processor_adapter : public f1ap_du_processor_notifier
6969

7070
du_index_t get_du_index() override { return du_f1ap_handler->get_du_index(); }
7171

72-
ue_index_t on_new_ue_index_required() override
73-
{
74-
srsran_assert(du_f1ap_handler != nullptr, "F1AP handler must not be nullptr");
75-
return du_f1ap_handler->get_new_ue_index();
76-
}
77-
78-
ue_creation_complete_message on_create_ue(const cu_cp_ue_creation_message& msg) override
72+
cu_cp_ue_creation_response on_ue_creation_request(const cu_cp_ue_creation_request& msg) override
7973
{
8074
srsran_assert(du_f1ap_handler != nullptr, "F1AP handler must not be nullptr");
8175
return du_f1ap_handler->handle_ue_creation_request(msg);

lib/cu_cp/du_processor/du_processor_impl.cpp

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -245,55 +245,59 @@ bool du_processor_impl::create_rrc_ue(du_ue& ue,
245245
return true;
246246
}
247247

248-
ue_creation_complete_message du_processor_impl::handle_ue_creation_request(const cu_cp_ue_creation_message& msg)
248+
cu_cp_ue_creation_response du_processor_impl::handle_ue_creation_request(const cu_cp_ue_creation_request& msg)
249249
{
250-
srsran_assert(msg.ue_index != ue_index_t::invalid, "Invalid UE index", msg.ue_index);
251-
srsran_assert(srsran::config_helpers::is_valid(msg.cgi), "ue={}: Invalid CGI", msg.ue_index);
250+
srsran_assert(config_helpers::is_valid(msg.cgi), "ue={}: Invalid CGI", msg.ue_index);
252251
srsran_assert(msg.c_rnti != rnti_t::INVALID_RNTI, "ue={}: Invalid C-RNTI", msg.ue_index);
253252

254-
ue_creation_complete_message ue_creation_complete_msg = {};
255-
ue_creation_complete_msg.ue_index = ue_index_t::invalid;
256-
257253
// Check that creation message is valid
258254
du_cell_index_t pcell_index = find_cell(msg.cgi.nci);
259255
if (pcell_index == du_cell_index_t::invalid) {
260256
logger.warning("ue={}: Could not find cell with cell_id={}", msg.ue_index, msg.cgi.nci);
261-
return ue_creation_complete_msg;
257+
return {};
262258
}
263-
264-
// Check that the PCI is valid
265-
pci_t pci = cell_db.at(pcell_index).pci;
266-
if (pci == INVALID_PCI) {
267-
logger.warning("ue={} pci={}: Invalid PCI", msg.ue_index, pci);
268-
return ue_creation_complete_msg;
259+
const pci_t pci = cell_db.at(pcell_index).pci;
260+
261+
// Allocate new UE index.
262+
ue_index_t ue_index = msg.ue_index;
263+
if (ue_index == ue_index_t::invalid) {
264+
// It's a new UE. Allocate new UE index.
265+
ue_index = get_new_ue_index();
266+
if (ue_index == ue_index_t::invalid) {
267+
logger.warning("ue={}: Could not create UE context", ue_index);
268+
return {};
269+
}
269270
}
270271

271272
// Create new UE context
272-
du_ue* ue = ue_manager.add_ue(msg.ue_index, context.id, pci, msg.c_rnti);
273+
du_ue* ue = ue_manager.add_ue(ue_index, context.id, pci, msg.c_rnti);
273274
if (ue == nullptr) {
274-
logger.warning("ue={}: Could not create UE context", msg.ue_index);
275-
return ue_creation_complete_msg;
275+
logger.warning("ue={}: Could not create UE context", ue_index);
276+
return {};
276277
}
277278

278279
// Set parameters from creation message
279280
ue->set_pcell_index(pcell_index);
280281

281282
// Create RRC UE. If the DU-to-CU-RRC-Container is empty, the UE will be rejected.
282-
if (create_rrc_ue(*ue, msg.c_rnti, msg.cgi, msg.du_to_cu_rrc_container.copy(), std::move(msg.rrc_context)) == false) {
283-
logger.warning("ue={}: Could not create RRC UE object", msg.ue_index);
284-
return ue_creation_complete_msg;
283+
if (not create_rrc_ue(*ue, msg.c_rnti, msg.cgi, msg.du_to_cu_rrc_container.copy(), std::move(msg.rrc_context))) {
284+
logger.warning("ue={}: Could not create RRC UE object", ue_index);
285+
ue_manager.remove_ue(ue_index);
286+
return {};
285287
}
286-
rrc_ue_interface* rrc_ue = rrc->find_ue(msg.ue_index);
287-
f1ap_rrc_ue_adapters[msg.ue_index] = {};
288-
f1ap_rrc_ue_adapters.at(msg.ue_index)
289-
.connect_rrc_ue(rrc_ue->get_ul_ccch_pdu_handler(), rrc_ue->get_ul_dcch_pdu_handler());
290-
ue_creation_complete_msg.f1ap_rrc_notifier = &f1ap_rrc_ue_adapters.at(msg.ue_index);
288+
rrc_ue_interface* rrc_ue = rrc->find_ue(ue_index);
289+
f1ap_rrc_ue_adapters[ue_index] = {};
290+
f1ap_rrc_ue_adapters.at(ue_index).connect_rrc_ue(rrc_ue->get_ul_ccch_pdu_handler(),
291+
rrc_ue->get_ul_dcch_pdu_handler());
291292

292-
logger.info("ue={} c-rnti={}: UE created", ue->get_ue_index(), msg.c_rnti);
293+
// Signal back to F1AP that the UE was successfully created.
294+
cu_cp_ue_creation_response response;
295+
response.ue_index = ue_index;
296+
response.f1ap_rrc_notifier = &f1ap_rrc_ue_adapters.at(ue_index);
293297

294-
ue_creation_complete_msg.ue_index = ue->get_ue_index();
298+
logger.info("ue={} c-rnti={}: UE created", ue->get_ue_index(), msg.c_rnti);
295299

296-
return ue_creation_complete_msg;
300+
return response;
297301
}
298302

299303
ue_update_complete_message du_processor_impl::handle_ue_update_request(const ue_update_message& msg)

lib/cu_cp/du_processor/du_processor_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ class du_processor_impl : public du_processor_impl_interface, public du_setup_ha
5555
size_t get_nof_ues() const override { return ue_manager.get_nof_du_ues(context.du_index); };
5656

5757
// du_processor_f1ap_interface
58-
du_setup_result handle_du_setup_request(const du_setup_request& req) override;
59-
ue_index_t get_new_ue_index() override;
60-
ue_creation_complete_message handle_ue_creation_request(const cu_cp_ue_creation_message& msg) override;
58+
du_setup_result handle_du_setup_request(const du_setup_request& req) override;
59+
ue_index_t get_new_ue_index() override;
60+
cu_cp_ue_creation_response handle_ue_creation_request(const cu_cp_ue_creation_request& msg) override;
6161
void handle_du_initiated_ue_context_release_request(const f1ap_ue_context_release_request& request) override;
6262
ue_update_complete_message handle_ue_update_request(const ue_update_message& msg) override;
6363

lib/cu_cp/du_processor/du_processor_impl_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class du_processor_f1ap_interface
4646
/// \brief Create a new UE context.
4747
/// \param[in] msg The UE creation message.
4848
/// \return Returns a UE creation complete message containing the index of the created UE and its SRB notifiers.
49-
virtual ue_creation_complete_message handle_ue_creation_request(const cu_cp_ue_creation_message& msg) = 0;
49+
virtual cu_cp_ue_creation_response handle_ue_creation_request(const cu_cp_ue_creation_request& msg) = 0;
5050

5151
/// \brief Update existing UE object.
5252
virtual ue_update_complete_message handle_ue_update_request(const ue_update_message& msg) = 0;

lib/f1ap/cu_cp/f1ap_cu_impl.cpp

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ f1ap_cu_impl::f1ap_cu_impl(f1ap_message_notifier& f1ap_pdu_notifier_,
3535
pdu_notifier(f1ap_pdu_notifier_),
3636
du_processor_notifier(f1ap_du_processor_notifier_),
3737
du_management_notifier(f1ap_du_management_notifier_),
38-
cu_cp_notifier(f1ap_cu_cp_notifier_),
3938
ctrl_exec(ctrl_exec_)
4039
{
4140
}
@@ -224,75 +223,68 @@ void f1ap_cu_impl::handle_f1_setup_request(const f1_setup_request_s& request)
224223

225224
void f1ap_cu_impl::handle_initial_ul_rrc_message(const init_ul_rrc_msg_transfer_s& msg)
226225
{
226+
const gnb_du_ue_f1ap_id_t du_ue_id = int_to_gnb_du_ue_f1ap_id(msg->gnb_du_ue_f1ap_id);
227+
227228
nr_cell_global_id_t cgi = cgi_from_asn1(msg->nr_cgi);
228-
if (not srsran::config_helpers::is_valid(cgi)) {
229-
logger.warning("du_ue_f1ap_id={}: Dropping InitialUlRrcMessageTransfer. Invalid CGI", msg->gnb_du_ue_f1ap_id);
229+
if (not config_helpers::is_valid(cgi)) {
230+
logger.warning("du_ue_f1ap_id={}: Dropping InitialULRRCMessageTransfer. Invalid CGI", du_ue_id);
230231
return;
231232
}
232233

233234
rnti_t crnti = to_rnti(msg->c_rnti);
234235
if (crnti == rnti_t::INVALID_RNTI) {
235-
logger.warning("du_ue_f1ap_id={}: Dropping InitialUlRrcMessageTransfer. Invalid RNTI", msg->gnb_du_ue_f1ap_id);
236+
logger.warning("du_ue_f1ap_id={}: Dropping InitialULRRCMessageTransfer. Cause: Invalid C-RNTI", du_ue_id);
236237
return;
237238
}
238239

239-
logger.debug("du_ue_f1ap_id={} nci={} crnti={} plmn={}: Received InitialUlRrcMessageTransfer",
240-
msg->gnb_du_ue_f1ap_id,
240+
logger.debug("du_ue_f1ap_id={} nci={} crnti={} plmn={}: Received InitialULRRCMessageTransfer",
241+
du_ue_id,
241242
cgi.nci,
242243
crnti,
243244
cgi.plmn);
244245

245246
if (msg->sul_access_ind_present) {
246-
logger.debug("du_ue_f1ap_id={}: Ignoring SUL access indicator", msg->gnb_du_ue_f1ap_id);
247+
logger.debug("du_ue_f1ap_id={}: Ignoring SUL access indicator", du_ue_id);
247248
}
248249

249-
gnb_cu_ue_f1ap_id_t cu_ue_f1ap_id = ue_ctxt_list.next_gnb_cu_ue_f1ap_id();
250+
const gnb_cu_ue_f1ap_id_t cu_ue_f1ap_id = ue_ctxt_list.next_gnb_cu_ue_f1ap_id();
250251
if (cu_ue_f1ap_id == gnb_cu_ue_f1ap_id_t::invalid) {
251-
logger.warning("du_ue_f1ap_id={}: Dropping InitialUlRrcMessageTransfer. No CU UE F1AP ID available",
252-
msg->gnb_du_ue_f1ap_id);
253-
return;
254-
}
255-
256-
// Request UE index allocation
257-
ue_index_t ue_index = du_processor_notifier.on_new_ue_index_required();
258-
if (ue_index == ue_index_t::invalid) {
259-
logger.warning("du_ue_f1ap_id={}: Dropping InitialUlRrcMessageTransfer. No UE Index available",
260-
msg->gnb_du_ue_f1ap_id);
252+
logger.warning("du_ue_f1ap_id={}: Dropping InitialULRRCMessageTransfer. Cause: Failed to allocate CU-UE-F1AP-ID",
253+
du_ue_id);
261254
return;
262255
}
263256

264-
// Request UE creation
265-
cu_cp_ue_creation_message ue_creation_msg = {};
266-
ue_creation_msg.ue_index = ue_index;
257+
// Request UE context creation to CU-CP.
258+
cu_cp_ue_creation_request ue_creation_msg = {};
259+
ue_creation_msg.cgi = cgi;
267260
ue_creation_msg.c_rnti = crnti;
268-
ue_creation_msg.cgi = cgi_from_asn1(msg->nr_cgi);
269261
if (msg->du_to_cu_rrc_container_present) {
270262
ue_creation_msg.du_to_cu_rrc_container = byte_buffer(msg->du_to_cu_rrc_container);
271263
} else {
272264
// Assume the DU can't serve the UE, so the CU-CP should reject the UE, see TS 38.473 section 8.4.1.2.
273265
// We will forward an empty container to the RRC UE, that will trigger an RRC Reject
274266
logger.debug("du_ue_f1ap_id={}: Forwarding InitialUlRrcMessageTransfer to RRC to reject the UE. Cause: Missing DU "
275267
"to CU container",
276-
msg->gnb_du_ue_f1ap_id);
268+
du_ue_id);
277269
ue_creation_msg.du_to_cu_rrc_container = byte_buffer{};
278270
}
279271

280-
ue_creation_complete_message ue_creation_complete_msg = du_processor_notifier.on_create_ue(ue_creation_msg);
272+
// Request the creation of a UE context in the CU-CP.
273+
const cu_cp_ue_creation_response cu_cp_resp = du_processor_notifier.on_ue_creation_request(ue_creation_msg);
281274

282275
// Remove the UE if the creation was not successful
283-
if (ue_creation_complete_msg.ue_index == ue_index_t::invalid) {
276+
if (cu_cp_resp.ue_index == ue_index_t::invalid) {
284277
logger.warning("du_ue_f1ap_id={}: Removing the UE. UE creation failed", msg->gnb_du_ue_f1ap_id);
285-
cu_cp_notifier.on_ue_removal_required(ue_index);
286278
return;
287279
}
288280

289281
// Create UE context and store it
290-
ue_ctxt_list.add_ue(ue_index, cu_ue_f1ap_id);
291-
ue_ctxt_list.add_du_ue_f1ap_id(cu_ue_f1ap_id, int_to_gnb_du_ue_f1ap_id(msg->gnb_du_ue_f1ap_id));
292-
ue_ctxt_list.add_rrc_notifier(ue_creation_complete_msg.ue_index, ue_creation_complete_msg.f1ap_rrc_notifier);
282+
ue_ctxt_list.add_ue(cu_cp_resp.ue_index, cu_ue_f1ap_id);
283+
ue_ctxt_list.add_du_ue_f1ap_id(cu_ue_f1ap_id, du_ue_id);
284+
ue_ctxt_list.add_rrc_notifier(cu_cp_resp.ue_index, cu_cp_resp.f1ap_rrc_notifier);
293285
f1ap_ue_context& ue_ctxt = ue_ctxt_list[cu_ue_f1ap_id];
294286

295-
ue_ctxt.logger.log_debug("Added UE context");
287+
ue_ctxt.logger.log_info("Added UE context");
296288

297289
// Forward RRC container
298290
if (msg->rrc_container_rrc_setup_complete_present) {
@@ -302,7 +294,7 @@ void f1ap_cu_impl::handle_initial_ul_rrc_message(const init_ul_rrc_msg_transfer_
302294
return;
303295
}
304296

305-
// Pass container to RRC
297+
// Pass RRC container to RRC
306298
ue_ctxt_list[cu_ue_f1ap_id].rrc_notifier->on_ul_ccch_pdu(msg->rrc_container.copy());
307299
}
308300

lib/f1ap/cu_cp/f1ap_cu_impl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ class f1ap_cu_impl final : public f1ap_cu
114114
f1ap_message_notifier& pdu_notifier;
115115
f1ap_du_processor_notifier& du_processor_notifier;
116116
f1ap_du_management_notifier& du_management_notifier;
117-
f1ap_ue_removal_notifier& cu_cp_notifier;
118117
task_executor& ctrl_exec;
119118

120119
unsigned current_transaction_id = 0; // store current F1AP transaction id

lib/f1ap/cu_cp/procedures/ue_context_setup_procedure.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ bool ue_context_setup_procedure::create_ue_context(const f1ap_ue_context_setup_r
102102
{
103103
// Request UE creation in target cell.
104104

105-
cu_cp_ue_creation_message ue_creation_msg;
105+
cu_cp_ue_creation_request ue_creation_msg;
106106
ue_creation_msg.ue_index = ue_ctxt_setup_resp.ue_index;
107107
ue_creation_msg.c_rnti = ue_ctxt_setup_resp.c_rnti.value();
108108
ue_creation_msg.cgi = request.sp_cell_id;
109109
ue_creation_msg.du_to_cu_rrc_container = ue_ctxt_setup_resp.du_to_cu_rrc_info.cell_group_cfg.copy();
110110
ue_creation_msg.rrc_context = std::move(rrc_context);
111111

112-
ue_creation_complete_message ue_creation_complete_msg = du_processor_notifier.on_create_ue(ue_creation_msg);
112+
cu_cp_ue_creation_response ue_creation_complete_msg = du_processor_notifier.on_ue_creation_request(ue_creation_msg);
113113
if (ue_creation_complete_msg.ue_index == ue_index_t::invalid) {
114114
logger.warning("Couldn't create UE in target cell");
115115
return false;

0 commit comments

Comments
 (0)