Skip to content

Commit 66c2388

Browse files
frankistcodebot
authored andcommitted
mac: remove RNTI manager duplicate from MAC
1 parent 3546fa1 commit 66c2388

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

lib/mac/mac_sched/srsran_scheduler_adapter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void srsran_scheduler_adapter::cell_handler::handle_rach_indication(const mac_ra
265265
sched_occasion.start_symbol = occasion.start_symbol;
266266
sched_occasion.frequency_index = occasion.frequency_index;
267267
for (const auto& preamble : occasion.preambles) {
268-
rnti_t alloc_tc_rnti = parent->rnti_alloc.allocate();
268+
rnti_t alloc_tc_rnti = parent->rnti_mng.allocate();
269269
if (alloc_tc_rnti == rnti_t::INVALID_RNTI) {
270270
parent->logger.warning(
271271
"cell={} preamble id={}: Ignoring PRACH. Cause: Failed to allocate TC-RNTI.", cell_idx, preamble.index);

lib/mac/mac_sched/srsran_scheduler_adapter.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ class srsran_scheduler_adapter final : public mac_scheduler_adapter
109109
srsran_scheduler_adapter& parent;
110110
};
111111

112+
// Allocator for TC-RNTIs.
112113
rnti_manager& rnti_mng;
114+
113115
/// Detector of UE RLFs.
114116
rlf_detector rlf_handler;
115117
task_executor& ctrl_exec;
@@ -121,9 +123,6 @@ class srsran_scheduler_adapter final : public mac_scheduler_adapter
121123
/// srsGNB scheduler.
122124
std::unique_ptr<mac_scheduler> sched_impl;
123125

124-
/// Allocator of TC-RNTI values.
125-
rnti_manager rnti_alloc;
126-
127126
/// List of event flags used by scheduler to notify that the configuration is complete.
128127
struct ue_notification_context {
129128
manual_event<bool> ue_config_ready;

tests/unittests/mac/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ add_executable(mac_test
2121
mac_cell_processor_test.cpp
2222
dl_sch_pdu_assembler_test.cpp
2323
mac_rar_pdu_assembler_test.cpp
24+
rnti_manager_test.cpp
2425
mac_dl_cfg_test.cpp)
2526
target_link_libraries(mac_test
2627
srsran_pcap
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 "lib/mac/rnti_manager.h"
12+
#include <gtest/gtest.h>
13+
14+
using namespace srsran;
15+
16+
TEST(rnti_manager_test, when_allocate_rnti_called_multiple_times_then_rntis_are_unique)
17+
{
18+
rnti_manager rnti_db;
19+
20+
unsigned max_count = 100;
21+
std::set<rnti_t> prev_rntis;
22+
for (unsigned count = 0; count != max_count; ++count) {
23+
rnti_t rnti = rnti_db.allocate();
24+
ASSERT_EQ(prev_rntis.count(rnti), 0);
25+
prev_rntis.insert(rnti);
26+
}
27+
28+
ASSERT_EQ(rnti_db.nof_ues(), 0) << "No UE should have been added";
29+
}
30+
31+
TEST(rnti_manager_test, when_ue_added_then_allocate_rnti_does_not_repeat_rnti)
32+
{
33+
rnti_manager rnti_db;
34+
35+
rnti_t rnti1 = rnti_db.allocate();
36+
ASSERT_TRUE(rnti_db.add_ue(rnti1, to_du_ue_index(0)));
37+
38+
rnti_t rnti2 = rnti_db.allocate();
39+
ASSERT_NE(rnti1, rnti2);
40+
41+
ASSERT_EQ(rnti_db.nof_ues(), 1);
42+
}

0 commit comments

Comments
 (0)