Skip to content

Commit 538e355

Browse files
committed
mac: handle the case when the configuration of a UE in the scheduler fails
1 parent 245270c commit 538e355

File tree

15 files changed

+146
-92
lines changed

15 files changed

+146
-92
lines changed

include/srsran/scheduler/scheduler_configurator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ class scheduler_ue_configurator
159159
class sched_configuration_notifier
160160
{
161161
public:
162-
virtual ~sched_configuration_notifier() = default;
163-
virtual void on_ue_config_complete(du_ue_index_t ue_index) = 0;
164-
virtual void on_ue_delete_response(du_ue_index_t ue_index) = 0;
162+
virtual ~sched_configuration_notifier() = default;
163+
virtual void on_ue_config_complete(du_ue_index_t ue_index, bool success) = 0;
164+
virtual void on_ue_delete_response(du_ue_index_t ue_index) = 0;
165165
};
166166

167167
} // namespace srsran

lib/mac/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ target_link_libraries(mac_configuration_helpers srsran_support srsran_ran)
1212
set(SOURCES mac_factory.cpp
1313
mac_impl.cpp
1414
mac_ctrl/mac_controller.cpp
15+
mac_ctrl/ue_creation_procedure.cpp
1516
mac_ctrl/ue_reconfiguration_procedure.cpp
17+
mac_ctrl/ue_delete_procedure.cpp
1618
mac_dl/mac_dl_processor.cpp
1719
mac_dl/mac_cell_processor.cpp
1820
mac_dl/rar_pdu_assembler.cpp
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 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 "ue_creation_procedure.h"
12+
#include "../../ran/gnb_format.h"
13+
14+
using namespace srsran;
15+
16+
void mac_ue_create_request_procedure::operator()(coro_context<async_task<mac_ue_create_response>>& ctx)
17+
{
18+
CORO_BEGIN(ctx);
19+
log_proc_started(logger, req.ue_index, req.crnti, name());
20+
21+
// > Create UE in MAC CTRL.
22+
crnti_assigned = ctrl_unit.add_ue(req.ue_index, req.cell_index, req.crnti);
23+
if (crnti_assigned == INVALID_RNTI) {
24+
CORO_EARLY_RETURN(handle_mac_ue_create_result(false));
25+
}
26+
27+
// > Update C-RNTI of the UE if it changed.
28+
req.crnti = crnti_assigned;
29+
30+
// > Create UE UL context and channels.
31+
CORO_AWAIT_VALUE(add_ue_result, ul_unit.add_ue(req));
32+
if (not add_ue_result) {
33+
CORO_EARLY_RETURN(handle_mac_ue_create_result(false));
34+
}
35+
36+
// > Create UE DL context and channels.
37+
CORO_AWAIT_VALUE(add_ue_result, dl_unit.add_ue(req));
38+
if (not add_ue_result) {
39+
// >> Revert creation of UE in MAC UL.
40+
CORO_AWAIT(ul_unit.remove_ue(mac_ue_delete_request{req.cell_index, req.ue_index, req.crnti}));
41+
42+
// >> Terminate procedure.
43+
CORO_EARLY_RETURN(handle_mac_ue_create_result(false));
44+
}
45+
46+
// > Create UE context in Scheduler.
47+
CORO_AWAIT_VALUE(add_ue_result, sched_configurator.handle_ue_creation_request(req));
48+
if (not add_ue_result) {
49+
// >> Revert creation of UE in MAC UL and MAC DL.
50+
CORO_AWAIT(ul_unit.remove_ue(mac_ue_delete_request{req.cell_index, req.ue_index, req.crnti}));
51+
CORO_AWAIT(dl_unit.remove_ue(mac_ue_delete_request{req.cell_index, req.ue_index, req.crnti}));
52+
53+
// >> Terminate procedure.
54+
CORO_EARLY_RETURN(handle_mac_ue_create_result(false));
55+
}
56+
57+
// > After UE insertion in scheduler, send response to DU manager.
58+
CORO_RETURN(handle_mac_ue_create_result(add_ue_result));
59+
}
60+
61+
mac_ue_create_response mac_ue_create_request_procedure::handle_mac_ue_create_result(bool result)
62+
{
63+
if (result) {
64+
log_proc_completed(logger, req.ue_index, req.crnti, name());
65+
} else {
66+
log_proc_failure(logger, req.ue_index, req.crnti, name());
67+
}
68+
69+
if (not result and crnti_assigned != INVALID_RNTI) {
70+
// Remove created UE object
71+
ctrl_unit.remove_ue(req.ue_index);
72+
}
73+
74+
// Respond back to DU manager with result
75+
mac_ue_create_response resp{};
76+
resp.ue_index = req.ue_index;
77+
resp.cell_index = req.cell_index;
78+
resp.allocated_crnti = result ? crnti_assigned : INVALID_RNTI;
79+
return resp;
80+
}

lib/mac/mac_ctrl/ue_creation_procedure.h

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#pragma once
1212

13-
#include "../../ran/gnb_format.h"
1413
#include "../mac_config_interfaces.h"
1514
#include "mac_config.h"
1615
#include "mac_scheduler_configurator.h"
@@ -39,59 +38,12 @@ class mac_ue_create_request_procedure
3938
{
4039
}
4140

42-
void operator()(coro_context<async_task<mac_ue_create_response>>& ctx)
43-
{
44-
CORO_BEGIN(ctx);
45-
log_proc_started(logger, req.ue_index, req.crnti, "UE Create Request");
46-
47-
// > Create UE in MAC CTRL.
48-
crnti_assigned = ctrl_unit.add_ue(req.ue_index, req.cell_index, req.crnti);
49-
if (crnti_assigned == INVALID_RNTI) {
50-
CORO_EARLY_RETURN(handle_mac_ue_create_result(false));
51-
}
52-
53-
// > Update C-RNTI of the UE if it changed.
54-
req.crnti = crnti_assigned;
55-
56-
// > Create UE UL context and channels.
57-
CORO_AWAIT_VALUE(add_ue_result, ul_unit.add_ue(req));
58-
if (not add_ue_result) {
59-
CORO_EARLY_RETURN(handle_mac_ue_create_result(false));
60-
}
61-
62-
// > Create UE DL context and channels.
63-
CORO_AWAIT_VALUE(add_ue_result, dl_unit.add_ue(req));
64-
65-
// > Create UE context in Scheduler.
66-
CORO_AWAIT(sched_configurator.handle_ue_creation_request(req));
67-
68-
// > After UE insertion in scheduler, send response to DU manager.
69-
CORO_RETURN(handle_mac_ue_create_result(add_ue_result));
70-
}
41+
void operator()(coro_context<async_task<mac_ue_create_response>>& ctx);
7142

7243
static const char* name() { return "UE Create Request"; }
7344

7445
private:
75-
mac_ue_create_response handle_mac_ue_create_result(bool result)
76-
{
77-
if (result) {
78-
log_proc_completed(logger, req.ue_index, req.crnti, "UE Create Request");
79-
} else {
80-
log_proc_failure(logger, req.ue_index, req.crnti, "UE Create Request");
81-
}
82-
83-
if (not result and crnti_assigned != INVALID_RNTI) {
84-
// Remove created UE object
85-
ctrl_unit.remove_ue(req.ue_index);
86-
}
87-
88-
// Respond back to DU manager with result
89-
mac_ue_create_response resp{};
90-
resp.ue_index = req.ue_index;
91-
resp.cell_index = req.cell_index;
92-
resp.allocated_crnti = result ? crnti_assigned : INVALID_RNTI;
93-
return resp;
94-
}
46+
mac_ue_create_response handle_mac_ue_create_result(bool result);
9547

9648
mac_ue_create_request req;
9749
mac_control_config& cfg;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 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 "ue_delete_procedure.h"
12+
#include "../../ran/gnb_format.h"
13+
14+
using namespace srsran;
15+
16+
void mac_ue_delete_procedure::operator()(coro_context<async_task<mac_ue_delete_response>>& ctx)
17+
{
18+
CORO_BEGIN(ctx);
19+
20+
log_proc_started(logger, req.ue_index, req.rnti, name());
21+
22+
// 1. Remove UE from scheduler.
23+
// Note: Removing the UE from the scheduler before the MAC avoids potential race conditions (assuming the scheduler
24+
// doesn't allocate UEs after being removed).
25+
CORO_AWAIT(sched_configurator.handle_ue_removal_request(req));
26+
27+
// 2. Remove UE and associated DL channels from the MAC DL.
28+
CORO_AWAIT(dl_mac.remove_ue(req));
29+
30+
// 3. Remove UE associated UL channels from the MAC UL.
31+
CORO_AWAIT(ul_mac.remove_ue(req));
32+
33+
// 4. Enqueue UE deletion
34+
ctrl_mac.remove_ue(req.ue_index);
35+
36+
log_proc_completed(logger, req.ue_index, req.rnti, "UE Delete Request");
37+
38+
// 4. Signal end of procedure and pass response
39+
CORO_RETURN(mac_ue_delete_response{true});
40+
}

lib/mac/mac_ctrl/ue_delete_procedure.h

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "../mac_config_interfaces.h"
1414
#include "mac_config.h"
15+
#include "mac_scheduler_configurator.h"
1516

1617
namespace srsran {
1718

@@ -34,31 +35,7 @@ class mac_ue_delete_procedure
3435
{
3536
}
3637

37-
void operator()(coro_context<async_task<mac_ue_delete_response>>& ctx)
38-
{
39-
CORO_BEGIN(ctx);
40-
41-
log_proc_started(logger, req.ue_index, req.rnti, name());
42-
43-
// 1. Remove UE from scheduler.
44-
// Note: Removing the UE from the scheduler before the MAC avoids potential race conditions (assuming the scheduler
45-
// doesn't allocate UEs after being removed).
46-
CORO_AWAIT(sched_configurator.handle_ue_removal_request(req));
47-
48-
// 2. Remove UE and associated DL channels from the MAC DL.
49-
CORO_AWAIT(dl_mac.remove_ue(req));
50-
51-
// 3. Remove UE associated UL channels from the MAC UL.
52-
CORO_AWAIT(ul_mac.remove_ue(req));
53-
54-
// 4. Enqueue UE deletion
55-
ctrl_mac.remove_ue(req.ue_index);
56-
57-
log_proc_completed(logger, req.ue_index, req.rnti, "UE Delete Request");
58-
59-
// 4. Signal end of procedure and pass response
60-
CORO_RETURN(mac_ue_delete_response{true});
61-
}
38+
void operator()(coro_context<async_task<mac_ue_delete_response>>& ctx);
6239

6340
static const char* name() { return "UE Delete Request"; }
6441

lib/mac/mac_sched/srsran_scheduler_adapter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,14 @@ const sched_result& srsran_scheduler_adapter::slot_indication(slot_point slot_tx
194194
return res;
195195
}
196196

197-
void srsran_scheduler_adapter::sched_config_notif_adapter::on_ue_config_complete(du_ue_index_t ue_index)
197+
void srsran_scheduler_adapter::sched_config_notif_adapter::on_ue_config_complete(du_ue_index_t ue_index, bool success)
198198
{
199199
srsran_sanity_check(is_du_ue_index_valid(ue_index), "Invalid ue index={}", ue_index);
200200

201201
// Remove continuation of task in ctrl executor.
202202
if (not parent.ctrl_exec.defer(
203-
[this, ue_index]() { parent.sched_cfg_notif_map[ue_index].ue_config_ready.set(true); })) {
204-
parent.logger.error("Unable to finish configuration of ue={}. Cause: DU task queue is full.", ue_index);
203+
[this, ue_index, success]() { parent.sched_cfg_notif_map[ue_index].ue_config_ready.set(success); })) {
204+
parent.logger.error("ue={}: Unable to finish UE configuration. Cause: DU task queue is full.", ue_index);
205205
}
206206
}
207207

@@ -212,7 +212,7 @@ void srsran_scheduler_adapter::sched_config_notif_adapter::on_ue_delete_response
212212
// Continuation of ue remove task dispatched to the ctrl executor.
213213
if (not parent.ctrl_exec.defer(
214214
[this, ue_index]() { parent.sched_cfg_notif_map[ue_index].ue_config_ready.set(true); })) {
215-
parent.logger.error("Unable to remove ue={}. Cause: DU task queue is full.", ue_index);
215+
parent.logger.error("ue={}: Unable to remove UE. Cause: DU task queue is full.", ue_index);
216216
}
217217
}
218218

lib/mac/mac_sched/srsran_scheduler_adapter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class srsran_scheduler_adapter final : public mac_scheduler_adapter
9696
{
9797
public:
9898
explicit sched_config_notif_adapter(srsran_scheduler_adapter& parent_) : parent(parent_) {}
99-
void on_ue_config_complete(du_ue_index_t ue_index) override;
99+
void on_ue_config_complete(du_ue_index_t ue_index, bool success) override;
100100
void on_ue_delete_response(du_ue_index_t ue_index) override;
101101

102102
private:

lib/scheduler/scheduler_impl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ void scheduler_impl::handle_ue_creation_request(const sched_ue_creation_request_
5757
error_type<std::string> result =
5858
config_validators::validate_sched_ue_creation_request_message(ue_request, cells[pcell_index]->cell_cfg);
5959
if (result.is_error()) {
60-
report_fatal_error("Invalid rnti={:#x} creation request message. Cause: {}", ue_request.crnti, result.error());
60+
report_fatal_error(
61+
"ue={} rnti={:#x}: Discarding invalid UE creation request. Cause: {}", ue_request.crnti, result.error());
62+
config_notifier.on_ue_config_complete(ue_request.ue_index, false);
6163
}
6264

6365
ue_to_cell_group_index.emplace(ue_request.ue_index, cells[pcell_index]->cell_cfg.cell_group_index);

lib/scheduler/ue_scheduling/ue_event_manager.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void ue_event_manager::handle_ue_creation_request(const sched_ue_creation_reques
5151
inserted_ue.ue_index, inserted_ue.crnti, inserted_ue.get_pcell().cfg().cell_cfg_common.pci);
5252

5353
// Notify Scheduler UE configuration is complete.
54-
mac_notifier.on_ue_config_complete(ueidx);
54+
mac_notifier.on_ue_config_complete(ueidx, true);
5555
});
5656
}
5757

@@ -60,6 +60,7 @@ void ue_event_manager::handle_ue_reconfiguration_request(const sched_ue_reconfig
6060
common_events.emplace(ue_request.ue_index, [this, ue_request]() {
6161
if (not ue_db.contains(ue_request.ue_index)) {
6262
log_invalid_ue_index(ue_request.ue_index, "UE Reconfig Request");
63+
mac_notifier.on_ue_config_complete(ue_request.ue_index, false);
6364
return;
6465
}
6566
// Configure existing UE.
@@ -69,7 +70,7 @@ void ue_event_manager::handle_ue_reconfiguration_request(const sched_ue_reconfig
6970
ev_logger.enqueue(ue_request);
7071

7172
// Notify Scheduler UE configuration is complete.
72-
mac_notifier.on_ue_config_complete(ue_request.ue_index);
73+
mac_notifier.on_ue_config_complete(ue_request.ue_index, true);
7374
});
7475
}
7576

0 commit comments

Comments
 (0)