Skip to content

Commit f8faa95

Browse files
carlo-galcodebot
authored andcommitted
sched: fix failing unittests and remove verbose logs
Signed-off-by: Carlo Galiotto <[email protected]>
1 parent 7b03b20 commit f8faa95

File tree

3 files changed

+41
-29
lines changed

3 files changed

+41
-29
lines changed

lib/scheduler/ue_scheduling/ue_fallback_scheduler.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ void ue_fallback_scheduler::run_slot(cell_resource_allocator& res_alloc)
4646
// retransmitted.
4747
update_ongoing_ue_retxs();
4848

49+
// Reset the scheduling attempt counter; this takes into account retxs and new txs.
50+
sched_attempts_cnt = 0;
51+
4952
if (ues.empty()) {
5053
return;
5154
}
@@ -109,7 +112,6 @@ void ue_fallback_scheduler::run_slot(cell_resource_allocator& res_alloc)
109112
if (u.has_pending_dl_newtx_bytes(LCID_SRB1) and schedule_srb(res_alloc, u, false, nullptr, most_recent_tx_ack)) {
110113
// If all bytes of SRB1 are scheduled, remove UE.
111114
if (not u.has_pending_dl_newtx_bytes(LCID_SRB1)) {
112-
logger.debug("rnti={}: Removing UE from list, as SRB1 buffer is empty.", u.crnti);
113115
next_ue = pending_ues.erase(next_ue);
114116
}
115117
// Don't increase the iterator here, as we give priority to the same UE, if there are still some SRB1 bytes left
@@ -167,9 +169,6 @@ bool ue_fallback_scheduler::schedule_srb(cell_resource_allocator& res_allo
167169
return false;
168170
}
169171

170-
// We keep track of the number of scheduling attempts for the given UE.
171-
unsigned sched_attempts_cnt = 0;
172-
173172
// \ref starting_slot is the slot from which the SRB0 starts scheduling this given UE. Assuming the UE was assigned a
174173
// PDSCH grant for SRB1 that was fragmented, we want to avoid allocating the second part of SRB1 in a PDSCH that is
175174
// scheduled for an earlier slot than the PDSCH of the first part of the SRB1.
@@ -187,7 +186,7 @@ bool ue_fallback_scheduler::schedule_srb(cell_resource_allocator& res_allo
187186

188187
for (unsigned time_res_idx = 0; time_res_idx != bwp_cfg_common.pdsch_common.pdsch_td_alloc_list.size();
189188
++time_res_idx) {
190-
if (sched_attempts_cnt >= max_sched_attempts_per_ue) {
189+
if (sched_attempts_cnt >= max_sched_attempts) {
191190
return false;
192191
}
193192

@@ -221,7 +220,7 @@ bool ue_fallback_scheduler::schedule_srb(cell_resource_allocator& res_allo
221220

222221
// Verify there is space in PDSCH and PDCCH result lists for new allocations.
223222
if (pdcch_alloc.result.dl.dl_pdcchs.full() or pdsch_alloc.result.dl.ue_grants.full()) {
224-
logger.debug("rnti={}: Failed to allocate PDSCH for {}. Cause: No space available in scheduler output list.",
223+
logger.debug("rnti={}: Failed to allocate PDSCH for {}. Cause: No space available in scheduler output list",
225224
u.crnti,
226225
is_srb0 ? "SRB0" : "SRB1");
227226
return false;
@@ -248,8 +247,6 @@ bool ue_fallback_scheduler::schedule_srb(cell_resource_allocator& res_allo
248247
if (not is_retx) {
249248
store_harq_tx(u.ue_index, candidate_h_dl, is_srb0);
250249
}
251-
logger.debug(
252-
"rnti={}: PDSCH space for SRB{} scheduled for slot:{}", u.crnti, is_srb0 ? "0" : "1", pdsch_alloc.slot);
253250
return true;
254251
}
255252

@@ -259,11 +256,11 @@ bool ue_fallback_scheduler::schedule_srb(cell_resource_allocator& res_allo
259256

260257
// No resource found in UE's carriers and Search spaces.
261258
slot_point pdcch_slot = res_alloc[0].slot;
262-
logger.debug("rnti={}: Not enough PDSCH space for {} message found in any of the slots:[{},{})",
259+
logger.debug("rnti={}: Not enough PDCCH/PDSCH/PUCCH resources for {} message found in any of the slots:[{},{})",
263260
u.crnti,
264261
is_srb0 ? "SRB0" : "SRB1",
265262
pdcch_slot,
266-
pdcch_slot + max_dl_slots_ahead_sched);
263+
pdcch_slot + max_dl_slots_ahead_sched + 1);
267264
return false;
268265
}
269266

lib/scheduler/ue_scheduling/ue_fallback_scheduler.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,13 @@ class ue_fallback_scheduler
129129
// Set the max number of slots the scheduler can look ahead in the resource grid (with respect to the current slot) to
130130
// find PDSCH space for SRB0 or SRB1.
131131
const unsigned max_dl_slots_ahead_sched = 10U;
132-
// Set the max number of attempt the scheduler can do while running through the nested loops over the PDSCH time
133-
// allocation indices and the ahead slots. This is to avoid excessive long iterations in case of a large number of
134-
// PDSCH time allocation indices.
135-
const unsigned max_sched_attempts_per_ue = 10U;
132+
// Set the max number of attempts the scheduler can do while running through the nested loops over the PDSCH time
133+
// allocation indices and the ahead slots for all UEs. This is to avoid excessive long iterations in case many UEs.
134+
// NOTE: max_sched_attempts = (max_dl_slots_ahead_sched + 1) * max_pdsch_time_res guarantees that at 1 UE will be
135+
// allocated in a TDD period of 10 slots.
136+
const unsigned max_sched_attempts = 22U;
137+
// Counter for the scheduling attempts per function call.
138+
unsigned sched_attempts_cnt = 0;
136139
pdcch_resource_allocator& pdcch_sch;
137140
pucch_allocator& pucch_alloc;
138141
ue_repository& ues;

tests/unittests/scheduler/ue_scheduling/fallback_scheduler_test.cpp

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class base_fallback_tester
180180
bench->pucch_alloc.slot_indication(current_slot);
181181
}
182182

183-
void run_slot(bool disabled_csi_rs = false)
183+
void run_slot()
184184
{
185185
++current_slot;
186186

@@ -192,9 +192,7 @@ class base_fallback_tester
192192
bench->pdcch_sch.slot_indication(current_slot);
193193
bench->pucch_alloc.slot_indication(current_slot);
194194

195-
if (not disabled_csi_rs) {
196-
bench->csi_rs_sched.run_slot(bench->res_grid[0]);
197-
}
195+
bench->csi_rs_sched.run_slot(bench->res_grid[0]);
198196

199197
bench->fallback_sched.run_slot(bench->res_grid);
200198

@@ -318,18 +316,19 @@ TEST_P(fallback_scheduler_tester, successfully_allocated_resources)
318316
{
319317
setup_sched(create_expert_config(2), create_custom_cell_config_request(params.k0));
320318
// Add UE.
321-
add_ue(to_rnti(0x4601), to_du_ue_index(0));
319+
const du_ue_index_t ue_idx = to_du_ue_index(0);
320+
add_ue(to_rnti(0x4601), ue_idx);
322321
// Notify about SRB0 message in DL of size 101 bytes.
323322
const unsigned mac_srb0_sdu_size = 101;
324-
push_buffer_state_to_dl_ue(to_du_ue_index(0), mac_srb0_sdu_size);
323+
push_buffer_state_to_dl_ue(ue_idx, mac_srb0_sdu_size);
325324

326-
const unsigned exp_size = get_pending_bytes(to_du_ue_index(0));
325+
const unsigned exp_size = get_pending_bytes(ue_idx);
327326

328327
// Test the following:
329328
// 1. Check for DCI_1_0 allocation for SRB0 on PDCCH.
330329
// 2. Check for PDSCH allocation.
331330
// 3. Check whether CW TB bytes matches with pending bytes to be sent.
332-
const auto& test_ue = get_ue(to_du_ue_index(0));
331+
const auto& test_ue = get_ue(ue_idx);
333332
bool is_ue_allocated_pdcch{false};
334333
bool is_ue_allocated_pdsch{false};
335334
for (unsigned sl_idx = 0; sl_idx < bench->max_test_run_slots_per_ue * (1U << current_slot.numerology()); sl_idx++) {
@@ -344,6 +343,7 @@ TEST_P(fallback_scheduler_tester, successfully_allocated_resources)
344343
}
345344
ASSERT_TRUE(is_ue_allocated_pdcch);
346345
ASSERT_TRUE(is_ue_allocated_pdsch);
346+
ASSERT_FALSE(test_ue.has_pending_dl_newtx_bytes(LCID_SRB0));
347347
}
348348

349349
TEST_P(fallback_scheduler_tester, failed_allocating_resources)
@@ -377,14 +377,15 @@ TEST_P(fallback_scheduler_tester, test_large_srb0_buffer_size)
377377
{
378378
setup_sched(create_expert_config(27), create_custom_cell_config_request(params.k0));
379379
// Add UE.
380-
add_ue(to_rnti(0x4601), to_du_ue_index(0));
380+
const du_ue_index_t ue_idx = to_du_ue_index(0);
381+
add_ue(to_rnti(0x4601), ue_idx);
381382
// Notify about SRB0 message in DL of size 458 bytes.
382383
const unsigned mac_srb0_sdu_size = 458;
383-
push_buffer_state_to_dl_ue(to_du_ue_index(0), mac_srb0_sdu_size);
384+
push_buffer_state_to_dl_ue(ue_idx, mac_srb0_sdu_size);
384385

385-
const unsigned exp_size = get_pending_bytes(to_du_ue_index(0));
386+
const unsigned exp_size = get_pending_bytes(ue_idx);
386387

387-
const auto& test_ue = get_ue(to_du_ue_index(0));
388+
const auto& test_ue = get_ue(ue_idx);
388389
bool is_ue_allocated_pdcch{false};
389390
bool is_ue_allocated_pdsch{false};
390391
for (unsigned sl_idx = 0; sl_idx < bench->max_test_run_slots_per_ue * (1U << current_slot.numerology()); sl_idx++) {
@@ -399,6 +400,8 @@ TEST_P(fallback_scheduler_tester, test_large_srb0_buffer_size)
399400
}
400401
ASSERT_TRUE(is_ue_allocated_pdcch);
401402
ASSERT_TRUE(is_ue_allocated_pdsch);
403+
404+
ASSERT_FALSE(test_ue.has_pending_dl_newtx_bytes(LCID_SRB0));
402405
}
403406

404407
TEST_P(fallback_scheduler_tester, test_srb0_buffer_size_exceeding_max_msg4_mcs_index)
@@ -424,7 +427,8 @@ TEST_P(fallback_scheduler_tester, sanity_check_with_random_max_mcs_and_payload_s
424427
const sch_mcs_index max_msg4_mcs = get_random_uint(0, 27);
425428
setup_sched(create_expert_config(max_msg4_mcs), create_custom_cell_config_request(params.k0));
426429
// Add UE.
427-
add_ue(to_rnti(0x4601), to_du_ue_index(0));
430+
const du_ue_index_t ue_idx = to_du_ue_index(0);
431+
add_ue(to_rnti(0x4601), ue_idx);
428432
// Random payload size.
429433
const unsigned mac_srb0_sdu_size = get_random_uint(1, 458);
430434
push_buffer_state_to_dl_ue(to_du_ue_index(0), mac_srb0_sdu_size);
@@ -444,7 +448,7 @@ class fallback_scheduler_tdd_tester : public base_fallback_tester, public ::test
444448
TEST_F(fallback_scheduler_tdd_tester, test_allocation_in_appropriate_slots_in_tdd)
445449
{
446450
const unsigned k0 = 0;
447-
const sch_mcs_index max_msg4_mcs_index = 1;
451+
const sch_mcs_index max_msg4_mcs_index = 5;
448452
auto cell_cfg = create_custom_cell_config_request(k0);
449453
setup_sched(create_expert_config(max_msg4_mcs_index), cell_cfg);
450454

@@ -477,6 +481,11 @@ TEST_F(fallback_scheduler_tdd_tester, test_allocation_in_appropriate_slots_in_td
477481
}
478482
}
479483
}
484+
485+
for (unsigned ue_idx = 0; ue_idx < MAX_UES; ue_idx++) {
486+
const auto& test_ue = get_ue(to_du_ue_index(ue_idx));
487+
ASSERT_FALSE(test_ue.has_pending_dl_newtx_bytes(LCID_SRB0)) << "UE " << ue_idx << " has still pending DL bytes";
488+
}
480489
}
481490

482491
TEST_F(fallback_scheduler_tdd_tester, test_allocation_in_partial_slots_tdd)
@@ -493,6 +502,9 @@ TEST_F(fallback_scheduler_tdd_tester, test_allocation_in_partial_slots_tdd)
493502
// Generate PDSCH Time domain allocation based on the partial slot TDD configuration.
494503
cell_cfg.dl_cfg_common.init_dl_bwp.pdsch_common.pdsch_td_alloc_list = config_helpers::make_pdsch_time_domain_resource(
495504
cell_cfg.searchspace0, cell_cfg.dl_cfg_common.init_dl_bwp.pdcch_common, nullopt, cell_cfg.tdd_ul_dl_cfg_common);
505+
// Disabled CSI-RS resources, as this test uses a TDD configuration that is not compatible with CSI-RS scheduling.
506+
cell_cfg.nzp_csi_rs_res_list.clear();
507+
cell_cfg.zp_csi_rs_list.clear();
496508
setup_sched(create_expert_config(max_msg4_mcs_index), cell_cfg);
497509

498510
const unsigned MAX_TEST_RUN_SLOTS = 40;
@@ -502,7 +514,7 @@ TEST_F(fallback_scheduler_tdd_tester, test_allocation_in_partial_slots_tdd)
502514
add_ue(to_rnti(0x4601), to_du_ue_index(0));
503515

504516
for (unsigned idx = 0; idx < MAX_TEST_RUN_SLOTS * (1U << current_slot.numerology()); idx++) {
505-
run_slot(true);
517+
run_slot();
506518
// Notify about SRB0 message in DL one slot before partial slot in order for it to be scheduled in the next
507519
// (partial) slot.
508520
if (bench->cell_cfg.is_dl_enabled(current_slot + 1) and

0 commit comments

Comments
 (0)