Skip to content

Commit 0475ba4

Browse files
carlo-galcodebot
authored andcommitted
sched: refactor implementation of pucch_res_maneger
Signed-off-by: Carlo Galiotto <[email protected]>
1 parent 58cc36b commit 0475ba4

File tree

8 files changed

+329
-323
lines changed

8 files changed

+329
-323
lines changed

lib/scheduler/pucch_scheduling/pucch_allocator.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ class pucch_allocator
9999
/// \param[in] pucch_cfg User's PUCCH configuration.
100100
/// \return struct with the number of HARQ-ACK and CSI info bits from the removed PUCCH grants. If there was no PUCCH
101101
/// to be removed, return 0 for both HARQ-ACK and CSI info bits.
102-
virtual pucch_uci_bits
103-
remove_ue_uci_from_pucch(cell_slot_resource_allocator& slot_alloc, rnti_t crnti, const pucch_config& pucch_cfg) = 0;
102+
virtual pucch_uci_bits remove_ue_uci_from_pucch(cell_slot_resource_allocator& slot_alloc,
103+
rnti_t crnti,
104+
const ue_cell_configuration& ue_cell_cfg) = 0;
104105
};
105106

106107
} // namespace srsran

lib/scheduler/pucch_scheduling/pucch_allocator_impl.cpp

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,11 @@ pucch_harq_ack_grant pucch_allocator_impl::alloc_ded_pucch_harq_ack_ue(cell_reso
330330

331331
// Case 2-B)
332332
return update_existing_pucch_harq_grant(
333-
*existing_grants.format1_harq_grant, existing_grants.format1_sr_grant, crnti, pucch_slot_alloc.slot);
333+
*existing_grants.format1_harq_grant,
334+
existing_grants.format1_sr_grant,
335+
crnti,
336+
pucch_slot_alloc.slot,
337+
ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
334338
}
335339

336340
// Case C) If there is no existing HARQ_ACK grant, allocate a new one and update the SR grant, if present.
@@ -437,7 +441,7 @@ void pucch_allocator_impl::pucch_allocate_csi_opportunity(cell_slot_resource_all
437441

438442
pucch_uci_bits pucch_allocator_impl::remove_ue_uci_from_pucch(cell_slot_resource_allocator& slot_alloc,
439443
rnti_t crnti,
440-
const pucch_config& pucch_cfg)
444+
const ue_cell_configuration& ue_cell_cfg)
441445
{
442446
pucch_uci_bits removed_uci_info;
443447

@@ -451,15 +455,17 @@ pucch_uci_bits pucch_allocator_impl::remove_ue_uci_from_pucch(cell_slot_resource
451455
(pucch.format == pucch_format::FORMAT_2));
452456
});
453457

458+
const pucch_config& pucch_cfg = ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value();
459+
454460
if (it != pucchs.end()) {
455461
// Search for Format 2 first; if present, then remove only that resource and exit.
456462
if (it->format == pucch_format::FORMAT_2) {
457463
removed_uci_info.harq_ack_nof_bits = it->format_2.harq_ack_nof_bits;
458464
removed_uci_info.sr_bits = it->format_2.sr_bits;
459465
removed_uci_info.csi_part1_bits = it->format_2.csi_part1_bits;
460466
pucchs.erase(it);
461-
resource_manager.release_format2_resource(slot_alloc.slot, crnti, pucch_cfg);
462-
resource_manager.release_csi_resource(slot_alloc.slot, crnti);
467+
resource_manager.release_harq_f2_resource(slot_alloc.slot, crnti, pucch_cfg);
468+
resource_manager.release_csi_resource(slot_alloc.slot, crnti, ue_cell_cfg);
463469
// If there is a PUCCH resource Format 2, then no Format 1 should be present.
464470
return removed_uci_info;
465471
}
@@ -468,7 +474,7 @@ pucch_uci_bits pucch_allocator_impl::remove_ue_uci_from_pucch(cell_slot_resource
468474
// Only remove HARQ-ACK grant, handle SR grant separately.
469475
removed_uci_info.harq_ack_nof_bits = it->format_1.harq_ack_nof_bits;
470476
pucchs.erase(it);
471-
resource_manager.release_harq_resource(slot_alloc.slot, crnti, pucch_cfg);
477+
resource_manager.release_harq_f1_resource(slot_alloc.slot, crnti, pucch_cfg);
472478
}
473479
}
474480

@@ -480,7 +486,7 @@ pucch_uci_bits pucch_allocator_impl::remove_ue_uci_from_pucch(cell_slot_resource
480486
if (it != pucchs.end()) {
481487
removed_uci_info.sr_bits = it->format_1.sr_bits;
482488
pucchs.erase(it);
483-
resource_manager.release_sr_resource(slot_alloc.slot, crnti);
489+
resource_manager.release_sr_resource(slot_alloc.slot, crnti, pucch_cfg);
484490
}
485491

486492
return removed_uci_info;
@@ -674,7 +680,7 @@ pucch_harq_ack_grant pucch_allocator_impl::allocate_new_pucch_harq_grant(cell_sl
674680
return pucch_harq_ack_output;
675681
}
676682

677-
const pucch_harq_resource_alloc_record pucch_harq_res_info = resource_manager.reserve_next_harq_res_available(
683+
const pucch_harq_resource_alloc_record pucch_harq_res_info = resource_manager.reserve_next_f1_harq_res_available(
678684
pucch_slot_alloc.slot, crnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
679685
if (pucch_harq_res_info.pucch_res == nullptr) {
680686
logger.debug("PUCCH HARQ-ACK allocation for RNTI {:#x} for slot={} skipped due to PUCCH ded. resources "
@@ -714,6 +720,8 @@ pucch_harq_ack_grant pucch_allocator_impl::convert_to_format2(cell_slot_resource
714720

715721
const unsigned curr_harq_bits = existing_harq_grant != nullptr ? existing_harq_grant->format_1.harq_ack_nof_bits : 0;
716722

723+
const pucch_config& pucch_cfg = ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value();
724+
717725
// Get a PUCCH Format 2 resource.
718726
pucch_harq_resource_alloc_record format2_res{.pucch_res = nullptr, .pucch_res_indicator = 0};
719727
// Case A) If for CSI report and NOT for HARQ-ACK, get the resource specific for with CSI.
@@ -723,7 +731,7 @@ pucch_harq_ack_grant pucch_allocator_impl::convert_to_format2(cell_slot_resource
723731
// Case B) If there is a Format 1 present with HARQ, get the PUCCH F2 resource with the same PUCCH resource
724732
// indicator as for existing F1.
725733
else if (csi_part1_nof_bits > 0 and curr_harq_bits > 0) {
726-
const int f1_pucch_res_ind = resource_manager.fetch_f1_pucch_res_indic(pucch_slot_alloc.slot, rnti);
734+
const int f1_pucch_res_ind = resource_manager.fetch_f1_pucch_res_indic(pucch_slot_alloc.slot, rnti, pucch_cfg);
727735
if (f1_pucch_res_ind >= 0) {
728736
format2_res.pucch_res = resource_manager.reserve_specific_format2_res(
729737
pucch_slot_alloc.slot,
@@ -735,8 +743,7 @@ pucch_harq_ack_grant pucch_allocator_impl::convert_to_format2(cell_slot_resource
735743
}
736744
// Case C) In any other case, just get any available PUCCH resource 2.
737745
else {
738-
format2_res = resource_manager.reserve_next_format2_res_available(
739-
pucch_slot_alloc.slot, rnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
746+
format2_res = resource_manager.reserve_next_f2_harq_res_available(pucch_slot_alloc.slot, rnti, pucch_cfg);
740747
}
741748

742749
if (format2_res.pucch_res == nullptr) {
@@ -820,12 +827,11 @@ pucch_harq_ack_grant pucch_allocator_impl::change_format2_resource(cell_slot_res
820827
{
821828
pucch_harq_ack_grant output;
822829

823-
const pucch_harq_resource_alloc_record format2_res = resource_manager.reserve_next_format2_res_available(
830+
const pucch_harq_resource_alloc_record format2_res = resource_manager.reserve_next_f2_harq_res_available(
824831
pucch_slot_alloc.slot, rnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
825832

826833
if (format2_res.pucch_res == nullptr) {
827-
remove_format2_csi_from_grants(
828-
pucch_slot_alloc, rnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
834+
remove_format2_csi_from_grants(pucch_slot_alloc, rnti, ue_cell_cfg);
829835
logger.debug(
830836
"No available PUCCH Format2 resources to allocate UCI for RNTI {:#x} on slot={}.", rnti, pucch_slot_alloc.slot);
831837
return output;
@@ -865,8 +871,7 @@ pucch_harq_ack_grant pucch_allocator_impl::change_format2_resource(cell_slot_res
865871
max_pucch_code_rate);
866872

867873
// Remove the previously allocated PUCCH format-1 resource.
868-
remove_format2_csi_from_grants(
869-
pucch_slot_alloc, rnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
874+
remove_format2_csi_from_grants(pucch_slot_alloc, rnti, ue_cell_cfg);
870875

871876
// Allocate PUCCH SR grant only.
872877
if (pucch_slot_alloc.result.ul.pucchs.full()) {
@@ -898,14 +903,15 @@ pucch_harq_ack_grant pucch_allocator_impl::change_format2_resource(cell_slot_res
898903
return output;
899904
}
900905

901-
pucch_harq_ack_grant pucch_allocator_impl::update_existing_pucch_harq_grant(pucch_info& existing_harq_grant,
902-
pucch_info* existing_sr_grant,
903-
rnti_t rnti,
904-
slot_point sl_tx)
906+
pucch_harq_ack_grant pucch_allocator_impl::update_existing_pucch_harq_grant(pucch_info& existing_harq_grant,
907+
pucch_info* existing_sr_grant,
908+
rnti_t rnti,
909+
slot_point sl_tx,
910+
const pucch_config& pucch_cfg)
905911
{
906912
pucch_harq_ack_grant output;
907913

908-
const int pucch_res_idx = resource_manager.fetch_f1_pucch_res_indic(sl_tx, rnti);
914+
const int pucch_res_idx = resource_manager.fetch_f1_pucch_res_indic(sl_tx, rnti, pucch_cfg);
909915
if (pucch_res_idx < 0) {
910916
srsran_assert(pucch_res_idx >= 0, "PUCCH resource index should not be negative.");
911917
return output;
@@ -939,7 +945,7 @@ void pucch_allocator_impl::remove_pucch_format1_from_grants(cell_slot_resource_a
939945

940946
if (it != pucchs.end()) {
941947
pucchs.erase(it);
942-
resource_manager.release_harq_resource(slot_alloc.slot, crnti, pucch_cfg);
948+
resource_manager.release_harq_f1_resource(slot_alloc.slot, crnti, pucch_cfg);
943949
}
944950

945951
// Remove SR grant, if any.
@@ -949,13 +955,13 @@ void pucch_allocator_impl::remove_pucch_format1_from_grants(cell_slot_resource_a
949955

950956
if (it != pucchs.end()) {
951957
pucchs.erase(it);
952-
resource_manager.release_sr_resource(slot_alloc.slot, crnti);
958+
resource_manager.release_sr_resource(slot_alloc.slot, crnti, pucch_cfg);
953959
}
954960
}
955961

956962
void pucch_allocator_impl::remove_format2_csi_from_grants(cell_slot_resource_allocator& slot_alloc,
957963
rnti_t crnti,
958-
const pucch_config& pucch_cfg)
964+
const ue_cell_configuration& ue_cell_cfg)
959965
{
960966
auto& pucchs = slot_alloc.result.ul.pucchs;
961967

@@ -966,7 +972,7 @@ void pucch_allocator_impl::remove_format2_csi_from_grants(cell_slot_resource_all
966972

967973
if (it != pucchs.end()) {
968974
pucchs.erase(it);
969-
resource_manager.release_csi_resource(slot_alloc.slot, crnti);
975+
resource_manager.release_csi_resource(slot_alloc.slot, crnti, ue_cell_cfg);
970976
}
971977
}
972978

@@ -993,7 +999,7 @@ pucch_harq_ack_grant pucch_allocator_impl::allocate_new_format2_grant(cell_slot_
993999
if (csi_part1_bits > 0) {
9941000
format2_res.pucch_res = resource_manager.reserve_csi_resource(pucch_slot_alloc.slot, crnti, ue_cell_cfg);
9951001
} else {
996-
format2_res = resource_manager.reserve_next_format2_res_available(
1002+
format2_res = resource_manager.reserve_next_f2_harq_res_available(
9971003
pucch_slot_alloc.slot, crnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
9981004
}
9991005

@@ -1078,7 +1084,10 @@ pucch_harq_ack_grant pucch_allocator_impl::update_format2_grant(pucch_info&
10781084

10791085
const int res_indicator = current_csi_part1_bits > 0 and current_harq_ack_bits == 0
10801086
? 0
1081-
: resource_manager.fetch_f2_pucch_res_indic(sl_tx, existing_f2_grant.crnti);
1087+
: resource_manager.fetch_f2_pucch_res_indic(
1088+
sl_tx,
1089+
existing_f2_grant.crnti,
1090+
ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
10821091
srsran_sanity_check(res_indicator >= 0,
10831092
"The resource indicator for the allocated PUCCH Format 2 grant is expected to be non-negative");
10841093

lib/scheduler/pucch_scheduling/pucch_allocator_impl.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class pucch_allocator_impl final : public pucch_allocator
4949

5050
pucch_uci_bits remove_ue_uci_from_pucch(cell_slot_resource_allocator& slot_alloc,
5151
rnti_t crnti,
52-
const pucch_config& pucch_cfg) override;
52+
const ue_cell_configuration& ue_cell_cfg) override;
5353

5454
/// Updates the internal slot_point and tracking of PUCCH resource usage over time.
5555
void slot_indication(slot_point sl_tx);
@@ -79,10 +79,11 @@ class pucch_allocator_impl final : public pucch_allocator
7979
pucch_info* existing_sr_grant);
8080

8181
// Helper that updates an existing PUCCH HARQ grant (Format 1).
82-
pucch_harq_ack_grant update_existing_pucch_harq_grant(pucch_info& existing_harq_grant,
83-
pucch_info* existing_sr_grant,
84-
rnti_t rnti,
85-
slot_point sl_tx);
82+
pucch_harq_ack_grant update_existing_pucch_harq_grant(pucch_info& existing_harq_grant,
83+
pucch_info* existing_sr_grant,
84+
rnti_t rnti,
85+
slot_point sl_tx,
86+
const pucch_config& pucch_cfg);
8687

8788
// Helper that allocates a NEW PUCCH HARQ grant (Format 2).
8889
pucch_harq_ack_grant allocate_new_format2_grant(cell_slot_resource_allocator& pucch_slot_alloc,
@@ -123,8 +124,9 @@ class pucch_allocator_impl final : public pucch_allocator
123124
const pucch_config& pucch_cfg);
124125

125126
// Helper that removes the existing PUCCH Format 1 grants (both HARQ-ACK and SR).
126-
void
127-
remove_format2_csi_from_grants(cell_slot_resource_allocator& slot_alloc, rnti_t crnti, const pucch_config& pucch_cfg);
127+
void remove_format2_csi_from_grants(cell_slot_resource_allocator& slot_alloc,
128+
rnti_t crnti,
129+
const ue_cell_configuration& ue_cell_cfg);
128130

129131
// Fills the PUCCH HARQ grant for common resources.
130132
void fill_pucch_harq_common_grant(pucch_info& pucch_info, rnti_t rnti, const pucch_res_alloc_cfg& pucch_res);

0 commit comments

Comments
 (0)