Skip to content

Commit 471fda8

Browse files
carlo-galcodebot
authored andcommitted
sched: move last pucch alloc tracker to pucch res mng
Signed-off-by: Carlo Galiotto <[email protected]>
1 parent 7308b57 commit 471fda8

File tree

8 files changed

+149
-84
lines changed

8 files changed

+149
-84
lines changed

include/srsran/scheduler/scheduler_pucch_format.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ struct pucch_resources {
4444
prb_interval prbs;
4545
ofdm_symbol_range symbols;
4646
prb_interval second_hop_prbs{0U, 0U};
47-
48-
bool operator==(const pucch_resources& rhs) const
49-
{
50-
return prbs != rhs.prbs && symbols == rhs.symbols && second_hop_prbs == rhs.second_hop_prbs;
51-
}
5247
};
5348

5449
/// Scheduler output for PUCCH Format 0.

include/srsran/scheduler/scheduler_slot_handler.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,12 @@ struct prach_occasion_info {
482482

483483
/// Info about PUCCH used resource.
484484
struct pucch_info {
485-
/// This information only is used by the scheduler.
485+
/// This information only is used by the scheduler and not passed to the PHY.
486486
struct context {
487+
/// Identifier of the PUCCH PDU within the list of PUCCH PDUs for a given slot. The ID is only meaningful for a
488+
/// given UE; i.e., different UEs can reuse the same ID, but a UE cannot reuse the same ID for different PDUs.
487489
unsigned id = MAX_PUCCH_PDUS_PER_SLOT;
490+
/// Determines whether the PUCCH PDU uses common resources.
488491
bool is_common = false;
489492
};
490493

lib/du_manager/ran_resource_management/du_pucch_resource_manager.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,10 @@ bool du_pucch_resource_manager::alloc_resources(cell_group_config& cell_grp_cfg)
289289
}
290290

291291
// Update the PUCCH max payload.
292+
// With Format 1, we can have up to 2 HARQ-ACK bits (SR doesn't count as part of the payload).
293+
constexpr static unsigned pucch_f1_max_harq_payload = 2U;
292294
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.pucch_cfg.value().format_max_payload[pucch_format_to_uint(
293-
pucch_format::FORMAT_1)] = 2U;
295+
pucch_format::FORMAT_1)] = pucch_f1_max_harq_payload;
294296
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.pucch_cfg.value().format_max_payload[pucch_format_to_uint(
295297
pucch_format::FORMAT_2)] =
296298
get_pucch_format2_max_payload(user_defined_pucch_cfg.f2_params.max_nof_rbs,

lib/scheduler/config/serving_cell_config_factory.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,9 @@ uplink_config srsran::config_helpers::make_default_ue_uplink_config(const cell_c
647647
}
648648

649649
// Compute the max UCI payload per format.
650-
pucch_cfg.format_max_payload[pucch_format_to_uint(pucch_format::FORMAT_1)] = 2U;
650+
// With Format 1, we can have up to 2 HARQ-ACK bits (SR doesn't count as part of the payload).
651+
constexpr static unsigned pucch_f1_max_harq_payload = 2U;
652+
pucch_cfg.format_max_payload[pucch_format_to_uint(pucch_format::FORMAT_1)] = pucch_f1_max_harq_payload;
651653
const auto& res_f2 = std::get<pucch_format_2_3_cfg>(res_basic_f2.format_params);
652654
pucch_cfg.format_max_payload[pucch_format_to_uint(pucch_format::FORMAT_2)] = get_pucch_format2_max_payload(
653655
res_f2.nof_prbs, res_f2.nof_symbols, to_max_code_rate_float(pucch_cfg.format_2_common_param.value().max_c_rate));

lib/scheduler/pucch_scheduling/pucch_allocator_impl.cpp

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ pucch_allocator_impl::pucch_allocator_impl(const cell_configuration& cell_cfg_,
9999
cell_cfg(cell_cfg_),
100100
max_pucch_grants_per_slot(max_pucchs_per_slot),
101101
max_ul_grants_per_slot(max_ul_grants_per_slot_),
102-
garbage_collector(resource_manager),
103102
logger(srslog::fetch_basic_logger("SCHED"))
104103
{
105104
}
@@ -137,7 +136,7 @@ std::optional<unsigned> pucch_allocator_impl::alloc_common_pucch_harq_ack_ue(cel
137136
grants_ue_it != pucch_grants_slot.end() and grants_ue_it->pucch_grants.harq_resource.has_value();
138137
const bool has_existing_common_grants = grants_ue_it != pucch_grants_slot.end() and grants_ue_it->has_common_pucch;
139138
if (has_existing_ded_harq_grants or has_existing_common_grants) {
140-
logger.debug("tc-rnti={}: PUCCH common not allocated for slot={}. Cause: a PUCCH grant with HARQ-ACK bits "
139+
logger.debug("tc-rnti={}: PUCCH common not allocated for slot={}. Cause: A PUCCH grant with HARQ-ACK bits "
141140
"already exists in the same slot",
142141
tcrnti,
143142
pucch_slot_alloc.slot);
@@ -264,7 +263,7 @@ std::optional<unsigned> pucch_allocator_impl::alloc_ded_pucch_harq_ack_ue(cell_r
264263
// Get the slot allocation grid considering the PDSCH delay (k0) and the PUCCH delay wrt PDSCH (k1).
265264
cell_slot_resource_allocator& pucch_slot_alloc = res_alloc[k0 + k1 + res_alloc.cfg.ntn_cs_koffset];
266265

267-
garbage_collector.reset();
266+
resource_manager.reset_last_ue_allocation();
268267

269268
slot_point sl_ack = pucch_slot_alloc.slot;
270269

@@ -281,7 +280,7 @@ std::optional<unsigned> pucch_allocator_impl::alloc_ded_pucch_harq_ack_ue(cell_r
281280
std::optional<unsigned> pucch_res_ind =
282281
multiplex_and_allocate_pucch(pucch_slot_alloc, new_bits, *existing_grant_it, ue_cell_cfg);
283282
if (not pucch_res_ind) {
284-
garbage_collector.release_resource(sl_ack, crnti, ue_cell_cfg);
283+
resource_manager.cancel_last_ue_allocations(sl_ack, crnti, ue_cell_cfg);
285284
}
286285
return pucch_res_ind;
287286
} else {
@@ -369,7 +368,7 @@ void pucch_allocator_impl::pucch_allocate_csi_opportunity(cell_slot_resource_all
369368
{
370369
const slot_point sl_tx = pucch_slot_alloc.slot;
371370

372-
garbage_collector.reset();
371+
resource_manager.reset_last_ue_allocation();
373372

374373
// [Implementation-defined] We only allow a max number of PUCCH + PUSCH grants per slot.
375374
if (pucch_slot_alloc.result.ul.pucchs.size() >=
@@ -405,7 +404,7 @@ void pucch_allocator_impl::pucch_allocate_csi_opportunity(cell_slot_resource_all
405404
bits_for_uci.csi_part1_nof_bits = csi_part1_nof_bits;
406405
auto alloc_outcome = multiplex_and_allocate_pucch(pucch_slot_alloc, bits_for_uci, *existing_grant_it, ue_cell_cfg);
407406
if (not alloc_outcome.has_value()) {
408-
garbage_collector.release_resource(sl_tx, crnti, ue_cell_cfg);
407+
resource_manager.cancel_last_ue_allocations(sl_tx, crnti, ue_cell_cfg);
409408
}
410409
}
411410

@@ -740,35 +739,6 @@ void existing_pucch_pdus_handler::update_harq_pdu_bits(unsigned harq_ack_bits
740739
}
741740
}
742741

743-
void pucch_allocator_impl::res_manager_garbage_collector::reset()
744-
{
745-
harq_set_0 = false;
746-
harq_set_1 = false;
747-
csi = false;
748-
sr = false;
749-
}
750-
751-
void pucch_allocator_impl::res_manager_garbage_collector::release_resource(slot_point slot_tx,
752-
rnti_t crnti,
753-
const ue_cell_configuration& ue_cell_cfg)
754-
{
755-
if (harq_set_0) {
756-
res_manager.release_harq_f1_resource(
757-
slot_tx, crnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
758-
}
759-
if (harq_set_1) {
760-
res_manager.release_harq_f2_resource(
761-
slot_tx, crnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
762-
}
763-
if (sr) {
764-
res_manager.release_sr_resource(
765-
slot_tx, crnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
766-
}
767-
if (csi) {
768-
res_manager.release_csi_resource(slot_tx, crnti, ue_cell_cfg);
769-
}
770-
}
771-
772742
////////////// Private functions //////////////
773743

774744
// The function returns an available common PUCCH resource (i.e., not used by other UEs); it returns a null optional
@@ -1018,7 +988,7 @@ pucch_allocator_impl::find_common_and_ded_harq_res_available(cell_slot_resource_
1018988
// As per Section 9.2.1, TS 38.213, this is the max value of \f$\Delta_{PRI}\f$, which is a 3-bit unsigned.
1019989
const unsigned max_d_pri = 7;
1020990
for (unsigned d_pri = 0; d_pri != max_d_pri + 1; ++d_pri) {
1021-
garbage_collector.reset();
991+
resource_manager.reset_last_ue_allocation();
1022992

1023993
// r_PUCCH, as per Section 9.2.1, TS 38.213.
1024994
const unsigned r_pucch = get_pucch_default_resource_index(start_cce_idx, nof_coreset_cces, d_pri);
@@ -1038,7 +1008,7 @@ pucch_allocator_impl::find_common_and_ded_harq_res_available(cell_slot_resource_
10381008
if (ded_resource == nullptr) {
10391009
continue;
10401010
}
1041-
garbage_collector.harq_set_0 = true;
1011+
resource_manager.set_new_resource_allocation(rnti, pucch_resource_usage::HARQ_F1);
10421012

10431013
// Add a current grant entry with the PUCCH resource indicator found above; this will force the function that
10441014
// multiplexes the resources to use the specific resource with the given PUCCH resource indicator (it could be
@@ -1060,7 +1030,7 @@ pucch_allocator_impl::find_common_and_ded_harq_res_available(cell_slot_resource_
10601030
pucch_res_ind = multiplex_and_allocate_pucch(pucch_alloc, bits_for_uci, existing_grants, ue_cell_cfg, true);
10611031

10621032
if (not pucch_res_ind.has_value()) {
1063-
garbage_collector.release_resource(pucch_alloc.slot, rnti, ue_cell_cfg);
1033+
resource_manager.cancel_last_ue_allocations(pucch_alloc.slot, rnti, ue_cell_cfg);
10641034
continue;
10651035
}
10661036

@@ -1307,7 +1277,8 @@ void pucch_allocator_impl::remove_unsed_pucch_res(slot_point s
13071277

13081278
// This is a special case, in which the PUCCH from resource set 0 is first reserved, but later it is converted into a
13091279
// PUCCH from resource set 1 due to the multiplexing process.
1310-
if (garbage_collector.harq_set_1 and garbage_collector.harq_set_0) {
1280+
if (resource_manager.is_resource_allocated(existing_pucchs.rnti, pucch_resource_usage::HARQ_F2) and
1281+
resource_manager.is_resource_allocated(existing_pucchs.rnti, pucch_resource_usage::HARQ_F1)) {
13111282
resource_manager.release_harq_f1_resource(
13121283
sl_tx, existing_pucchs.rnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
13131284
}
@@ -1345,9 +1316,9 @@ pucch_allocator_impl::get_pucch_res_pre_multiplexing(slot_point
13451316
: resource_manager.reserve_next_f2_harq_res_available(sl_tx, ue_current_grants.rnti, pucch_cfg);
13461317
// Save the resources that have been generated; if at some point the allocation fails, we need to release them.
13471318
if (pucch_set_idx == pucch_res_set_idx::set_0) {
1348-
garbage_collector.harq_set_0 = true;
1319+
resource_manager.set_new_resource_allocation(ue_current_grants.rnti, pucch_resource_usage::HARQ_F1);
13491320
} else {
1350-
garbage_collector.harq_set_1 = true;
1321+
resource_manager.set_new_resource_allocation(ue_current_grants.rnti, pucch_resource_usage::HARQ_F2);
13511322
}
13521323
if (harq_resource.pucch_res == nullptr) {
13531324
return std::nullopt;
@@ -1377,7 +1348,7 @@ pucch_allocator_impl::get_pucch_res_pre_multiplexing(slot_point
13771348
const pucch_resource* sr_resource =
13781349
resource_manager.reserve_sr_res_available(sl_tx, ue_current_grants.rnti, pucch_cfg);
13791350
// Save the resources that have been generated; if at some point the allocation fails, we need to release them.
1380-
garbage_collector.sr = true;
1351+
resource_manager.set_new_resource_allocation(ue_current_grants.rnti, pucch_resource_usage::SR);
13811352
if (sr_resource == nullptr) {
13821353
return std::nullopt;
13831354
}
@@ -1404,7 +1375,7 @@ pucch_allocator_impl::get_pucch_res_pre_multiplexing(slot_point
14041375
const pucch_resource* csi_resource =
14051376
resource_manager.reserve_csi_resource(sl_tx, ue_current_grants.rnti, ue_cell_cfg);
14061377
// Save the resources that have been generated; if at some point the allocation fails, we need to release them.
1407-
garbage_collector.csi = true;
1378+
resource_manager.set_new_resource_allocation(ue_current_grants.rnti, pucch_resource_usage::CSI);
14081379
if (csi_resource == nullptr) {
14091380
return std::nullopt;
14101381
}
@@ -1477,7 +1448,7 @@ pucch_allocator_impl::merge_pucch_resources(span<const pucch_allocator_impl::puc
14771448
else if (preserve_res_indicator) {
14781449
const pucch_resource* pucch_res = resource_manager.reserve_f2_res_by_res_indicator(
14791450
slot_harq, crnti, r_harq.harq_id.pucch_res_ind, pucch_cfg);
1480-
garbage_collector.harq_set_1 = true;
1451+
resource_manager.set_new_resource_allocation(crnti, pucch_resource_usage::HARQ_F2);
14811452
if (pucch_res != nullptr) {
14821453
return std::nullopt;
14831454
}
@@ -1490,7 +1461,7 @@ pucch_allocator_impl::merge_pucch_resources(span<const pucch_allocator_impl::puc
14901461
else {
14911462
pucch_harq_resource_alloc_record res_alloc =
14921463
resource_manager.reserve_next_f2_harq_res_available(slot_harq, crnti, pucch_cfg);
1493-
garbage_collector.harq_set_1 = true;
1464+
resource_manager.set_new_resource_allocation(crnti, pucch_resource_usage::HARQ_F2);
14941465
if (res_alloc.pucch_res != nullptr) {
14951466
return std::nullopt;
14961467
}
@@ -1551,7 +1522,7 @@ pucch_allocator_impl::merge_pucch_resources(span<const pucch_allocator_impl::puc
15511522
else if (preserve_res_indicator) {
15521523
const pucch_resource* pucch_res =
15531524
resource_manager.reserve_f2_res_by_res_indicator(slot_harq, crnti, r_harq.harq_id.pucch_res_ind, pucch_cfg);
1554-
garbage_collector.harq_set_1 = true;
1525+
resource_manager.set_new_resource_allocation(crnti, pucch_resource_usage::HARQ_F2);
15551526
if (pucch_res == nullptr) {
15561527
return std::nullopt;
15571528
}
@@ -1564,7 +1535,7 @@ pucch_allocator_impl::merge_pucch_resources(span<const pucch_allocator_impl::puc
15641535
else {
15651536
pucch_harq_resource_alloc_record res_alloc =
15661537
resource_manager.reserve_next_f2_harq_res_available(slot_harq, crnti, pucch_cfg);
1567-
garbage_collector.harq_set_1 = true;
1538+
resource_manager.set_new_resource_allocation(crnti, pucch_resource_usage::HARQ_F2);
15681539
if (res_alloc.pucch_res == nullptr) {
15691540
return std::nullopt;
15701541
}
@@ -1624,7 +1595,7 @@ pucch_allocator_impl::merge_pucch_resources(span<const pucch_allocator_impl::puc
16241595
} else {
16251596
pucch_harq_resource_alloc_record res_alloc =
16261597
resource_manager.reserve_next_f2_harq_res_available(slot_harq, crnti, pucch_cfg);
1627-
garbage_collector.harq_set_1 = true;
1598+
resource_manager.set_new_resource_allocation(crnti, pucch_resource_usage::HARQ_F2);
16281599
if (res_alloc.pucch_res == nullptr) {
16291600
return std::nullopt;
16301601
}
@@ -1730,7 +1701,7 @@ pucch_allocator_impl::multiplex_resources(slot_point sl_tx,
17301701
resource_set_q.front().bits.sr_bits != sr_nof_bits::no_sr) {
17311702
const pucch_resource* sr_res = resource_manager.reserve_sr_res_available(
17321703
sl_tx, crnti, ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
1733-
garbage_collector.sr = true;
1704+
resource_manager.set_new_resource_allocation(crnti, pucch_resource_usage::SR);
17341705
if (sr_res == nullptr) {
17351706
logger.error("This is not expected");
17361707
}

lib/scheduler/pucch_scheduling/pucch_allocator_impl.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,6 @@ class pucch_allocator_impl final : public pucch_allocator
143143

144144
using slot_pucch_grants = static_vector<ue_grants, MAX_PUCCH_PDUS_PER_SLOT>;
145145

146-
/// \brief Collects the information of what PUCCH cell resources have been allocated to a UE at given slot.
147-
/// This info is only used during the allocation, and the PUCCH allocator is called for a new UE or new allocation.
148-
struct res_manager_garbage_collector {
149-
bool harq_set_0 = false;
150-
bool harq_set_1 = false;
151-
bool csi = false;
152-
bool sr = false;
153-
pucch_resource_manager& res_manager;
154-
155-
res_manager_garbage_collector(pucch_resource_manager& res_manager_) : res_manager(res_manager_){};
156-
void reset();
157-
void release_resource(slot_point slot_tx, rnti_t crnti, const ue_cell_configuration& ue_cell_cfg);
158-
};
159-
160146
/// //////////// Main private functions //////////////
161147

162148
// Allocates the PUCCH (common) resource for HARQ-(N)-ACK.
@@ -251,13 +237,12 @@ class pucch_allocator_impl final : public pucch_allocator
251237
// \brief Ring of PUCCH allocations indexed by slot.
252238
circular_array<slot_pucch_grants, cell_resource_allocator::RING_ALLOCATOR_SIZE> pucch_grants_alloc_grid;
253239

254-
const unsigned PUCCH_FORMAT_1_NOF_PRBS{1};
240+
constexpr static unsigned PUCCH_FORMAT_1_NOF_PRBS{1};
255241
const cell_configuration& cell_cfg;
256242
const unsigned max_pucch_grants_per_slot;
257243
const unsigned max_ul_grants_per_slot;
258244
slot_point last_sl_ind;
259245
pucch_resource_manager resource_manager;
260-
res_manager_garbage_collector garbage_collector;
261246

262247
srslog::basic_logger& logger;
263248
};

0 commit comments

Comments
 (0)