Skip to content

Commit 76f109e

Browse files
committed
sched: add option to automatically forward UCI/CRC indications to scheduler in tests
1 parent a6c1840 commit 76f109e

File tree

3 files changed

+92
-25
lines changed

3 files changed

+92
-25
lines changed

tests/unittests/scheduler/scheduler_tdd_test.cpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ struct tdd_test_params {
3131
class base_scheduler_tdd_tester : public scheduler_test_simulator
3232
{
3333
protected:
34-
base_scheduler_tdd_tester(const tdd_test_params& testparams) : scheduler_test_simulator(4, testparams.tdd_cfg.ref_scs)
34+
base_scheduler_tdd_tester(const tdd_test_params& testparams) :
35+
scheduler_test_simulator(
36+
scheduler_test_sim_config{.max_scs = testparams.tdd_cfg.ref_scs, .auto_uci = true, .auto_crc = true})
3537
{
3638
params = cell_config_builder_profiles::tdd(testparams.tdd_cfg.ref_scs);
3739
params.csi_rs_enabled = testparams.csi_rs_enabled;
@@ -100,16 +102,6 @@ TEST_P(scheduler_dl_tdd_tester, all_dl_slots_are_scheduled)
100102
ASSERT_FALSE(this->last_sched_res_list[to_du_cell_index(0)]->dl.ue_grants.empty()) << fmt::format(
101103
"The UE configuration is leading to slot {} not having DL UE grant scheduled", this->last_result_slot());
102104
}
103-
104-
for (const pucch_info& pucch : this->last_sched_res_list[to_du_cell_index(0)]->ul.pucchs) {
105-
if (pucch.format() == pucch_format::FORMAT_1 and pucch.uci_bits.sr_bits != sr_nof_bits::no_sr) {
106-
// Skip SRs for this test.
107-
continue;
108-
}
109-
110-
uci_indication uci_ind = test_helper::create_uci_indication(this->last_result_slot(), ue_idx, pucch);
111-
this->sched->handle_uci_indication(uci_ind);
112-
}
113105
}
114106
}
115107

@@ -127,19 +119,6 @@ class scheduler_ul_tdd_tester : public base_scheduler_tdd_tester, public ::testi
127119
unsigned tdd_period = nof_slots_per_tdd_period(*cell_cfg_list[0].tdd_cfg_common);
128120
for (unsigned i = 0; i != 2 * tdd_period; ++i) {
129121
run_slot();
130-
131-
for (const ul_sched_info& pusch : this->last_sched_res_list[to_du_cell_index(0)]->ul.puschs) {
132-
ul_crc_indication crc{};
133-
crc.cell_index = to_du_cell_index(0);
134-
crc.sl_rx = this->last_result_slot();
135-
crc.crcs.resize(1);
136-
crc.crcs[0].ue_index = ue_idx;
137-
crc.crcs[0].rnti = ue_rnti;
138-
crc.crcs[0].harq_id = to_harq_id(pusch.pusch_cfg.harq_id);
139-
crc.crcs[0].tb_crc_success = true;
140-
crc.crcs[0].ul_sinr_dB = 100.0F;
141-
this->sched->handle_crc_indication(crc);
142-
}
143122
}
144123
}
145124
};

tests/unittests/scheduler/test_utils/scheduler_test_simulator.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include "scheduler_test_simulator.h"
12+
#include "../test_utils/indication_generators.h"
1213
#include "config_generators.h"
1314
#include "sched_random_utils.h"
1415
#include "scheduler_test_suite.h"
@@ -50,6 +51,13 @@ scheduler_test_simulator::scheduler_test_simulator(unsigned tx_rx_dela
5051
{
5152
}
5253

54+
scheduler_test_simulator::scheduler_test_simulator(const scheduler_test_sim_config& cfg) :
55+
scheduler_test_simulator(cfg.sched_cfg, cfg.tx_rx_delay, cfg.max_scs)
56+
{
57+
auto_uci = cfg.auto_uci;
58+
auto_crc = cfg.auto_crc;
59+
}
60+
5361
scheduler_test_simulator::~scheduler_test_simulator()
5462
{
5563
// Let any pending allocations complete.
@@ -79,11 +87,18 @@ void scheduler_test_simulator::add_ue(const sched_ue_creation_request_message& u
7987
run_slot();
8088
}
8189
}
90+
rnti_to_ue_index.insert(std::make_pair(ue_request.crnti, ue_request.ue_index));
8291
}
8392

8493
void scheduler_test_simulator::rem_ue(du_ue_index_t ue_index)
8594
{
8695
sched->handle_ue_removal_request(ue_index);
96+
for (auto it = rnti_to_ue_index.begin(); it != rnti_to_ue_index.end(); ++it) {
97+
if (it->second == ue_index) {
98+
rnti_to_ue_index.erase(it);
99+
break;
100+
}
101+
}
87102
}
88103

89104
void scheduler_test_simulator::push_dl_buffer_state(const dl_buffer_state_indication_message& upd)
@@ -114,7 +129,12 @@ void scheduler_test_simulator::run_slot(du_cell_index_t cell_idx)
114129

115130
last_sched_res_list[cell_idx] = &sched->slot_indication(next_slot, cell_idx);
116131

132+
// Ensure the scheduler result is consistent with the cell configuration and there are no collisions.
117133
test_scheduler_result_consistency(cell_cfg_list[cell_idx], next_slot, *last_sched_res_list[cell_idx]);
134+
135+
// In case auto-feedback is enabled, handle it.
136+
handle_auto_feedback(cell_idx);
137+
118138
++next_slot;
119139
}
120140

@@ -129,3 +149,51 @@ bool scheduler_test_simulator::run_slot_until(const std::function<bool()>& cond_
129149
}
130150
return count < slot_timeout;
131151
}
152+
153+
void scheduler_test_simulator::handle_auto_feedback(du_cell_index_t cell_idx)
154+
{
155+
if (not auto_uci and not auto_crc) {
156+
return;
157+
}
158+
// Note: next_slot hasn't been incremented yet.
159+
slot_point sl_rx = next_slot;
160+
161+
uci_indication uci_ind;
162+
uci_ind.cell_index = cell_idx;
163+
uci_ind.slot_rx = sl_rx;
164+
ul_crc_indication crc_ind;
165+
crc_ind.cell_index = cell_idx;
166+
crc_ind.sl_rx = sl_rx;
167+
168+
if (auto_uci) {
169+
// Handle PUCCHs.
170+
for (const pucch_info& pucch : this->last_sched_res_list[cell_idx]->ul.pucchs) {
171+
if (pucch.format() == pucch_format::FORMAT_1 and pucch.uci_bits.sr_bits != sr_nof_bits::no_sr) {
172+
// Skip SRs.
173+
continue;
174+
}
175+
176+
const du_ue_index_t ue_idx = rnti_to_ue_index.at(pucch.crnti);
177+
uci_ind.ucis.push_back(test_helper::create_uci_indication_pdu(ue_idx, pucch));
178+
}
179+
}
180+
181+
for (const auto& pusch : this->last_sched_res_list[cell_idx]->ul.puschs) {
182+
if (auto_uci and pusch.uci.has_value()) {
183+
const du_ue_index_t ue_idx = pusch.context.ue_index;
184+
uci_ind.ucis.push_back(test_helper::create_uci_indication_pdu(pusch.pusch_cfg.rnti, ue_idx, pusch.uci.value()));
185+
}
186+
187+
if (auto_crc) {
188+
crc_ind.crcs.push_back(test_helper::create_crc_pdu_indication(pusch));
189+
}
190+
}
191+
192+
// Forward indications to the scheduler.
193+
if (not uci_ind.ucis.empty()) {
194+
this->sched->handle_uci_indication(uci_ind);
195+
}
196+
if (not crc_ind.crcs.empty()) {
197+
this->sched->handle_crc_indication(crc_ind);
198+
}
199+
}

tests/unittests/scheduler/test_utils/scheduler_test_simulator.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,28 @@
1010

1111
#pragma once
1212

13+
#include "config_generators.h"
1314
#include "dummy_test_components.h"
1415
#include "lib/scheduler/config/cell_configuration.h"
1516
#include "result_test_helpers.h"
1617
#include "srsran/du/du_cell_config_helpers.h"
17-
#include "srsran/scheduler/scheduler_configurator.h"
1818
#include "srsran/scheduler/scheduler_factory.h"
1919

2020
namespace srsran {
2121

2222
scheduler_expert_config make_custom_scheduler_expert_config(bool enable_csi_rs_pdsch_multiplexing);
2323

24+
/// Configuration of the scheduler test simulator.
25+
struct scheduler_test_sim_config {
26+
scheduler_expert_config sched_cfg = config_helpers::make_default_scheduler_expert_config();
27+
unsigned tx_rx_delay = 4;
28+
subcarrier_spacing max_scs = subcarrier_spacing::kHz15;
29+
/// Whether to automatically respond to UCI grants with UCI indications.
30+
bool auto_uci = false;
31+
/// Whether to automatically respond to PUSCH grants with CRC indications.
32+
bool auto_crc = false;
33+
};
34+
2435
/// Helper class to help setup a scheduler unit test.
2536
class scheduler_test_simulator
2637
{
@@ -31,6 +42,7 @@ class scheduler_test_simulator
3142
explicit scheduler_test_simulator(const scheduler_expert_config& sched_cfg_,
3243
unsigned tx_rx_delay_ = 4,
3344
subcarrier_spacing max_scs = subcarrier_spacing::kHz15);
45+
explicit scheduler_test_simulator(const scheduler_test_sim_config& cfg);
3446
~scheduler_test_simulator();
3547

3648
slot_point next_slot_rx() const { return next_slot - tx_rx_delay; }
@@ -71,6 +83,8 @@ class scheduler_test_simulator
7183
}
7284

7385
const unsigned tx_rx_delay;
86+
bool auto_uci = false;
87+
bool auto_crc = false;
7488
srslog::basic_logger& logger;
7589
srslog::basic_logger& test_logger;
7690
const scheduler_expert_config sched_cfg;
@@ -82,6 +96,12 @@ class scheduler_test_simulator
8296

8397
slot_point next_slot;
8498
static_vector<const sched_result*, MAX_NOF_DU_CELLS> last_sched_res_list;
99+
100+
private:
101+
/// Handle automatic feedback (UCI/CRC) if enabled.
102+
void handle_auto_feedback(du_cell_index_t cell_idx);
103+
104+
std::unordered_map<rnti_t, du_ue_index_t> rnti_to_ue_index;
85105
};
86106

87107
} // namespace srsran

0 commit comments

Comments
 (0)