Skip to content

Commit 8651df5

Browse files
herlesupreethcodebot
authored andcommitted
sched: allocate PUSCH only in cell grid allocator at the slot give in PUSCH grant
1 parent 8e6ebd8 commit 8651df5

File tree

4 files changed

+68
-39
lines changed

4 files changed

+68
-39
lines changed

lib/scheduler/ue_scheduling/ue_cell_grid_allocator.cpp

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,11 @@ alloc_result ue_cell_grid_allocator::allocate_ul_grant(const ue_pusch_grant& gra
554554
return {alloc_status::invalid_params};
555555
}
556556

557+
slot_point pusch_slot = grant.pusch_slot;
558+
557559
// Create PUSCH param candidate search object.
558560
ue_pusch_alloc_param_candidate_searcher candidates{
559-
u, grant.cell_index, h_ul, pdcch_alloc.slot, slots_with_no_pusch_space};
561+
u, grant.cell_index, h_ul, pdcch_alloc.slot, slots_with_no_pusch_space, pusch_slot};
560562
if (candidates.is_empty()) {
561563
// The conditions for a new PUSCH allocation for this UE were not met (e.g. lack of available SearchSpaces).
562564
return {alloc_status::skip_ue};
@@ -582,17 +584,15 @@ alloc_result ue_cell_grid_allocator::allocate_ul_grant(const ue_pusch_grant& gra
582584
// transmission starting in symbol j by a PDCCH ending in symbol i, the UE is not expected to be scheduled to
583585
// transmit a PUSCH starting earlier than the end of the first PUSCH by a PDCCH that ends later than symbol i".
584586
if (ue_cc->last_pusch_allocated_slot.valid() and pusch_alloc.slot <= ue_cc->last_pusch_allocated_slot) {
585-
// Try next candidate.
586-
continue;
587+
return {alloc_status::skip_ue};
587588
}
588589

589590
// Check if there is space in PUSCH resource grid.
590591
const bool is_pusch_full =
591592
std::find(slots_with_no_pusch_space.begin(), slots_with_no_pusch_space.end(), pusch_alloc.slot) !=
592593
slots_with_no_pusch_space.end();
593594
if (is_pusch_full) {
594-
// Try next candidate.
595-
continue;
595+
return {alloc_status::skip_slot};
596596
}
597597

598598
if (not cell_cfg.is_ul_enabled(pusch_alloc.slot)) {
@@ -602,8 +602,7 @@ alloc_result ue_cell_grid_allocator::allocate_ul_grant(const ue_pusch_grant& gra
602602
u.crnti,
603603
pusch_alloc.slot,
604604
final_k2);
605-
// Try next candidate.
606-
continue;
605+
return {alloc_status::skip_slot};
607606
}
608607

609608
// When checking the number of remaining grants for PUSCH, take into account that the PUCCH grants for this UE will
@@ -625,8 +624,7 @@ alloc_result ue_cell_grid_allocator::allocate_ul_grant(const ue_pusch_grant& gra
625624
pusch_alloc.slot,
626625
expert_cfg.max_puschs_per_slot);
627626
}
628-
// Try next candidate.
629-
continue;
627+
return {alloc_status::skip_slot};
630628
}
631629

632630
// [Implementation-defined] We skip allocation of PUSCH if there is already a PUCCH grant scheduled using common
@@ -637,8 +635,7 @@ alloc_result ue_cell_grid_allocator::allocate_ul_grant(const ue_pusch_grant& gra
637635
u.ue_index,
638636
u.crnti,
639637
pusch_alloc.slot);
640-
// Try next candidate.
641-
continue;
638+
return {alloc_status::skip_ue};
642639
}
643640

644641
const unsigned start_ul_symbols =
@@ -664,16 +661,14 @@ alloc_result ue_cell_grid_allocator::allocate_ul_grant(const ue_pusch_grant& gra
664661
pusch_alloc.slot,
665662
start_rb,
666663
end_rb);
667-
// Try next candidate.
668-
continue;
664+
return {alloc_status::skip_slot};
669665
}
670666

671667
const crb_interval ul_crb_lims = {start_rb, end_rb};
672668
const prb_bitmap used_crbs = pusch_alloc.ul_res_grid.used_crbs(scs, ul_crb_lims, pusch_td_cfg.symbols);
673669
if (used_crbs.all()) {
674670
slots_with_no_pusch_space.push_back(pusch_alloc.slot);
675-
// Try next candidate.
676-
continue;
671+
return {alloc_status::skip_slot};
677672
}
678673

679674
// Compute the MCS and the number of PRBs, depending on the pending bytes to transmit.
@@ -733,8 +728,7 @@ alloc_result ue_cell_grid_allocator::allocate_ul_grant(const ue_pusch_grant& gra
733728
u.ue_index,
734729
u.crnti,
735730
pusch_alloc.slot);
736-
// Try next candidate.
737-
continue;
731+
return {alloc_status::skip_slot};
738732
}
739733

740734
// In case of Retx, the #CRBs need to stay the same.
@@ -745,8 +739,7 @@ alloc_result ue_cell_grid_allocator::allocate_ul_grant(const ue_pusch_grant& gra
745739
u.crnti,
746740
pusch_alloc.slot,
747741
h_ul.id);
748-
// Try next candidate.
749-
continue;
742+
return {alloc_status::skip_ue};
750743
}
751744

752745
// Verify there is no RB collision.
@@ -758,8 +751,7 @@ alloc_result ue_cell_grid_allocator::allocate_ul_grant(const ue_pusch_grant& gra
758751
pusch_alloc.slot,
759752
crbs.start(),
760753
crbs.stop());
761-
// Try next candidate.
762-
continue;
754+
return {alloc_status::invalid_params};
763755
}
764756

765757
const aggregation_level aggr_lvl =

lib/scheduler/ue_scheduling/ue_pusch_alloc_param_candidate_searcher.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,15 @@ class ue_pusch_alloc_param_candidate_searcher
157157
du_cell_index_t cell_index,
158158
ul_harq_process& ul_harq_,
159159
slot_point pdcch_slot_,
160-
span<const slot_point> slots_with_no_pusch_space_) :
160+
span<const slot_point> slots_with_no_pusch_space_,
161+
slot_point pusch_slot_) :
161162
ue_ref(ue_ref_),
162163
ue_cc(ue_ref.find_cell(cell_index)),
163164
slots_with_no_pusch_space(slots_with_no_pusch_space_),
164165
ul_harq(ul_harq_),
165166
is_retx(not ul_harq.empty()),
166-
pdcch_slot(pdcch_slot_)
167+
pdcch_slot(pdcch_slot_),
168+
pusch_slot(pusch_slot_)
167169
{
168170
// Cell is not part of UE configured cells.
169171
if (ue_cc == nullptr) {
@@ -233,12 +235,11 @@ class ue_pusch_alloc_param_candidate_searcher
233235
}
234236

235237
// Check whether PUSCH Time Domain resource index is valid.
236-
if (current.time_res >= (*current.ss_it)->pusch_time_domain_list.size()) {
238+
if ((current.time_res >= (*current.ss_it)->pusch_time_domain_list.size()) or
239+
(pdcch_slot + current.pusch_td_res().k2 != pusch_slot)) {
237240
return false;
238241
}
239242

240-
const slot_point pusch_slot = pdcch_slot + current.pusch_td_res().k2;
241-
242243
// Check whether PUSCH slot is UL enabled.
243244
if (not ue_cc->cfg().cell_cfg_common.is_ul_enabled(pusch_slot)) {
244245
return false;
@@ -310,8 +311,10 @@ class ue_pusch_alloc_param_candidate_searcher
310311
// RNTI type used to generate ss_candidate_list.
311312
std::optional<dci_ul_rnti_config_type> preferred_rnti_type;
312313

313-
// PDCCH slot point used to verify if the PUSCH fits a UL slot.
314+
// Slot at which UL PDCCH is scheduled if valid PUSCH allocation candidate is found.
314315
slot_point pdcch_slot;
316+
// Slot at which PUSCH needs to be scheduled.
317+
slot_point pusch_slot;
315318
};
316319

317320
} // namespace srsran

tests/unittests/scheduler/ue_scheduling/ue_grid_allocator_test.cpp

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ class ue_grid_allocator_tester : public ::testing::TestWithParam<duplex_mode>
5656
alloc.add_cell(to_du_cell_index(0), pdcch_alloc, uci_alloc, res_grid);
5757
}
5858

59+
slot_point get_next_ul_slot(const slot_point starting_slot) const
60+
{
61+
slot_point next_slot = starting_slot + cfg_builder_params.min_k2;
62+
while (not cell_cfg.is_fully_ul_enabled(next_slot)) {
63+
++next_slot;
64+
}
65+
return next_slot;
66+
}
67+
5968
void run_slot()
6069
{
6170
++current_slot;
@@ -232,6 +241,7 @@ TEST_P(ue_grid_allocator_tester, allocates_pusch_restricted_to_recommended_max_n
232241
const ue_pusch_grant grant1{.user = &slice_ues[u1.ue_index],
233242
.cell_index = to_du_cell_index(0),
234243
.h_id = to_harq_id(0),
244+
.pusch_slot = get_next_ul_slot(current_slot),
235245
.recommended_nof_bytes = recommended_nof_bytes_to_schedule,
236246
.max_nof_rbs = max_nof_rbs_to_schedule};
237247

@@ -255,6 +265,7 @@ TEST_P(ue_grid_allocator_tester, does_not_allocate_pusch_with_all_remaining_rbs_
255265
const ue_pusch_grant grant1{.user = &slice_ues[u1.ue_index],
256266
.cell_index = to_du_cell_index(0),
257267
.h_id = to_harq_id(0),
268+
.pusch_slot = get_next_ul_slot(current_slot),
258269
.recommended_nof_bytes = u1.pending_ul_newtx_bytes()};
259270

260271
const crb_interval cell_crbs = {cell_cfg.ul_cfg_common.init_ul_bwp.generic_params.crbs.start(),
@@ -307,16 +318,20 @@ TEST_P(ue_grid_allocator_tester, no_two_puschs_are_allocated_in_same_slot_for_a_
307318

308319
const ue& u = add_ue(ue_creation_req);
309320

321+
slot_point pusch_slot = get_next_ul_slot(current_slot);
322+
310323
// First PUSCH grant for the UE.
311324
const ue_pusch_grant grant1{.user = &slice_ues[u.ue_index],
312325
.cell_index = to_du_cell_index(0),
313326
.h_id = to_harq_id(0),
327+
.pusch_slot = pusch_slot,
314328
.recommended_nof_bytes = nof_bytes_to_schedule};
315329

316330
// Second PUSCH grant for the UE.
317331
const ue_pusch_grant grant2{.user = &slice_ues[u.ue_index],
318332
.cell_index = to_du_cell_index(0),
319333
.h_id = to_harq_id(1),
334+
.pusch_slot = pusch_slot,
320335
.recommended_nof_bytes = nof_bytes_to_schedule};
321336

322337
ASSERT_TRUE(run_until([&]() {
@@ -338,29 +353,30 @@ TEST_P(ue_grid_allocator_tester, consecutive_puschs_for_a_ue_are_allocated_in_in
338353

339354
const ue& u = add_ue(ue_creation_req);
340355

356+
slot_point pusch_slot = get_next_ul_slot(current_slot);
357+
341358
// First PUSCH grant for the UE.
342359
const ue_pusch_grant grant1{.user = &slice_ues[u.ue_index],
343360
.cell_index = to_du_cell_index(0),
344361
.h_id = to_harq_id(0),
362+
.pusch_slot = pusch_slot,
345363
.recommended_nof_bytes = nof_bytes_to_schedule};
346364

347365
ASSERT_TRUE(
348366
run_until([&]() { return alloc.allocate_ul_grant(grant1, dummy_slice_id).status == alloc_status::success; }));
349367
ASSERT_TRUE(run_until([&]() { return find_ue_pusch(u.crnti, res_grid[0].result.ul) != nullptr; }));
350-
slot_point last_pusch_alloc_slot = current_slot;
351368

352369
run_slot();
353370

354-
// Second PUSCH grant for the UE.
371+
// Second PUSCH grant for the UE trying to allocate PUSCH in a slot previous to grant1.
355372
const ue_pusch_grant grant2{.user = &slice_ues[u.ue_index],
356373
.cell_index = to_du_cell_index(0),
357374
.h_id = to_harq_id(1),
375+
.pusch_slot = pusch_slot - 1,
358376
.recommended_nof_bytes = nof_bytes_to_schedule};
359377

360-
ASSERT_TRUE(
378+
ASSERT_FALSE(
361379
run_until([&]() { return alloc.allocate_ul_grant(grant2, dummy_slice_id).status == alloc_status::success; }));
362-
ASSERT_TRUE(run_until([&]() { return find_ue_pusch(u.crnti, res_grid[0].result.ul) != nullptr; }));
363-
ASSERT_GT(current_slot, last_pusch_alloc_slot);
364380
}
365381

366382
TEST_P(ue_grid_allocator_tester, consecutive_pdschs_for_a_ue_are_allocated_in_increasing_order_of_time)
@@ -493,6 +509,7 @@ TEST_P(ue_grid_allocator_tester, successfully_allocated_pusch_even_with_large_ga
493509
const ue_pusch_grant grant1{.user = &slice_ues[u.ue_index],
494510
.cell_index = to_du_cell_index(0),
495511
.h_id = to_harq_id(0),
512+
.pusch_slot = get_next_ul_slot(current_slot),
496513
.recommended_nof_bytes = nof_bytes_to_schedule};
497514

498515
ASSERT_TRUE(
@@ -509,6 +526,7 @@ TEST_P(ue_grid_allocator_tester, successfully_allocated_pusch_even_with_large_ga
509526
const ue_pusch_grant grant2{.user = &slice_ues[u.ue_index],
510527
.cell_index = to_du_cell_index(0),
511528
.h_id = to_harq_id(1),
529+
.pusch_slot = get_next_ul_slot(current_slot),
512530
.recommended_nof_bytes = nof_bytes_to_schedule};
513531

514532
ASSERT_TRUE(
@@ -588,15 +606,18 @@ TEST_P(ue_grid_allocator_remaining_rbs_alloc_tester, remaining_ul_rbs_are_alloca
588606

589607
const unsigned recommended_nof_bytes_to_schedule = 200U;
590608

591-
const crb_interval cell_crbs = {cell_cfg.ul_cfg_common.init_ul_bwp.generic_params.crbs.start(),
592-
cell_cfg.ul_cfg_common.init_ul_bwp.generic_params.crbs.stop()};
609+
const crb_interval cell_crbs = {cell_cfg.ul_cfg_common.init_ul_bwp.generic_params.crbs.start(),
610+
cell_cfg.ul_cfg_common.init_ul_bwp.generic_params.crbs.stop()};
611+
slot_point pusch_to_alloc_slot = get_next_ul_slot(current_slot);
593612
const ue_pusch_grant grant1{.user = &slice_ues[u1.ue_index],
594613
.cell_index = to_du_cell_index(0),
595614
.h_id = to_harq_id(0),
615+
.pusch_slot = pusch_to_alloc_slot,
596616
.recommended_nof_bytes = recommended_nof_bytes_to_schedule};
597617
const ue_pusch_grant grant2{.user = &slice_ues[u2.ue_index],
598618
.cell_index = to_du_cell_index(0),
599619
.h_id = to_harq_id(0),
620+
.pusch_slot = pusch_to_alloc_slot,
600621
.recommended_nof_bytes = recommended_nof_bytes_to_schedule};
601622

602623
ASSERT_TRUE(run_until([&]() {
@@ -700,6 +721,7 @@ TEST_P(ue_grid_allocator_expert_cfg_pxsch_nof_rbs_limits_tester,
700721
const ue_pusch_grant grant1{.user = &slice_ues[u1.ue_index],
701722
.cell_index = to_du_cell_index(0),
702723
.h_id = to_harq_id(0),
724+
.pusch_slot = get_next_ul_slot(current_slot),
703725
.recommended_nof_bytes = recommended_nof_bytes_to_schedule,
704726
.max_nof_rbs = max_nof_rbs_to_schedule};
705727

@@ -727,6 +749,7 @@ TEST_P(ue_grid_allocator_expert_cfg_pxsch_nof_rbs_limits_tester,
727749
const ue_pusch_grant grant1{.user = &slice_ues[u1.ue_index],
728750
.cell_index = to_du_cell_index(0),
729751
.h_id = to_harq_id(0),
752+
.pusch_slot = get_next_ul_slot(current_slot),
730753
.recommended_nof_bytes = recommended_nof_bytes_to_schedule,
731754
.max_nof_rbs = max_nof_rbs_to_schedule};
732755

@@ -787,7 +810,7 @@ TEST_P(ue_grid_allocator_expert_cfg_pxsch_crb_limits_tester, allocates_pdsch_wit
787810
ASSERT_EQ(find_ue_pdsch(u1.crnti, res_grid[0].result.dl.ue_grants)->pdsch_cfg.rbs.type1(), pdsch_vrb_limits);
788811
}
789812

790-
TEST_P(ue_grid_allocator_expert_cfg_pxsch_crb_limits_tester, allocates_pdsch_within_expert_cfg_pusch_rb_limits)
813+
TEST_P(ue_grid_allocator_expert_cfg_pxsch_crb_limits_tester, allocates_pusch_within_expert_cfg_pusch_rb_limits)
791814
{
792815
sched_ue_creation_request_message ue_creation_req =
793816
test_helpers::create_default_sched_ue_creation_request(this->cfg_builder_params);
@@ -802,6 +825,7 @@ TEST_P(ue_grid_allocator_expert_cfg_pxsch_crb_limits_tester, allocates_pdsch_wit
802825
const ue_pusch_grant grant1{.user = &slice_ues[u1.ue_index],
803826
.cell_index = to_du_cell_index(0),
804827
.h_id = to_harq_id(0),
828+
.pusch_slot = get_next_ul_slot(current_slot),
805829
.recommended_nof_bytes = recommended_nof_bytes_to_schedule,
806830
.max_nof_rbs = max_nof_rbs_to_schedule};
807831

tests/unittests/scheduler/ue_scheduling/ue_pxsch_alloc_param_candidate_searcher_test.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ class ue_pxsch_alloc_param_candidate_searcher_test : public ::testing::Test
4444
ue_cc = &ue_ptr->get_cell(to_ue_cell_index(0));
4545
}
4646

47+
slot_point get_next_ul_slot(slot_point start_slot)
48+
{
49+
slot_point next_ul_slot = start_slot + sched_cfg.ue.min_k1;
50+
while (not cell_cfg.is_fully_ul_enabled(next_ul_slot)) {
51+
++next_ul_slot;
52+
}
53+
return next_ul_slot;
54+
}
55+
4756
void run_slot() { next_slot++; }
4857

4958
const scheduler_expert_config sched_cfg = config_helpers::make_default_scheduler_expert_config();
@@ -63,11 +72,12 @@ class ue_pxsch_alloc_param_candidate_searcher_test : public ::testing::Test
6372

6473
TEST_F(ue_pxsch_alloc_param_candidate_searcher_test, only_searchspaces_in_ue_dedicated_cfg_is_considered)
6574
{
66-
const harq_id_t h_id = to_harq_id(0);
75+
const harq_id_t h_id = to_harq_id(0);
76+
const slot_point pdcch_slot{0, 0};
6777
span<const search_space_configuration> ss_list = ue_cc->cfg().cfg_dedicated().init_dl_bwp.pdcch_cfg->search_spaces;
6878

6979
ue_pdsch_alloc_param_candidate_searcher dl_searcher(
70-
*ue_ptr, to_du_cell_index(0), ue_cc->harqs.dl_harq(h_id), slot_point{0, 0}, {});
80+
*ue_ptr, to_du_cell_index(0), ue_cc->harqs.dl_harq(h_id), pdcch_slot, {});
7181
ASSERT_TRUE(not dl_searcher.is_empty());
7282
for (const auto& candidate : dl_searcher) {
7383
bool ss_present_in_ue_ded_cfg =
@@ -77,8 +87,8 @@ TEST_F(ue_pxsch_alloc_param_candidate_searcher_test, only_searchspaces_in_ue_ded
7787
ASSERT_TRUE(ss_present_in_ue_ded_cfg);
7888
}
7989
ue_pusch_alloc_param_candidate_searcher ul_searcher(
80-
*ue_ptr, to_du_cell_index(0), ue_cc->harqs.ul_harq(h_id), slot_point{0, 0}, {});
81-
ASSERT_TRUE(not dl_searcher.is_empty());
90+
*ue_ptr, to_du_cell_index(0), ue_cc->harqs.ul_harq(h_id), pdcch_slot, {}, get_next_ul_slot(pdcch_slot));
91+
ASSERT_TRUE(not ul_searcher.is_empty());
8292
for (const auto& candidate : ul_searcher) {
8393
bool ss_present_in_ue_ded_cfg =
8494
std::find_if(ss_list.begin(), ss_list.end(), [&candidate](const search_space_configuration& ss_cfg) {

0 commit comments

Comments
 (0)