Skip to content

Commit 234c7fe

Browse files
carlo-galcodebot
authored andcommitted
sched: improve comments in PUCCH allocator
Signed-off-by: Carlo Galiotto <[email protected]>
1 parent 782d9c0 commit 234c7fe

File tree

6 files changed

+54
-27
lines changed

6 files changed

+54
-27
lines changed

include/srsran/ran/pucch/pucch_configuration.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ struct pucch_config {
202202
static_vector<uint8_t, 8> dl_data_to_ul_ack;
203203

204204
/// PUCCH resource max UCI payload, depending on the format. The index defines the format.
205-
/// \remark All the resources of the same format are configured with the same max UCI payload.
205+
/// \remark The UCI payload is the same for all UE's PUCCH resources belonging to the same format, regardless of
206+
/// whether they are used for HARQ-ACK or CSI.
206207
/// \remark For Format 0 and 1, only the max number of HARQ-ACK bits are considered.
207208
static_vector<unsigned, 5> format_max_payload{0, 0, 0, 0, 0};
208209

lib/du_manager/ran_resource_management/du_pucch_resource_manager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ 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).
292+
// As per TS 38.231, Section 9.2.1, with PUCCH Format 1, we can have up to 2 HARQ-ACK bits (SR doesn't count as part
293+
// of the payload).
293294
constexpr static unsigned pucch_f1_max_harq_payload = 2U;
294295
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.pucch_cfg.value().format_max_payload[pucch_format_to_uint(
295296
pucch_format::FORMAT_1)] = pucch_f1_max_harq_payload;

lib/scheduler/config/serving_cell_config_factory.cpp

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

649649
// Compute the max UCI payload per format.
650-
// With Format 1, we can have up to 2 HARQ-ACK bits (SR doesn't count as part of the payload).
650+
// As per TS 38.231, Section 9.2.1, with PUCCH Format 1, we can have up to 2 HARQ-ACK bits (SR doesn't count as part
651+
// of the payload).
651652
constexpr static unsigned pucch_f1_max_harq_payload = 2U;
652653
pucch_cfg.format_max_payload[pucch_format_to_uint(pucch_format::FORMAT_1)] = pucch_f1_max_harq_payload;
653654
const auto& res_f2 = std::get<pucch_format_2_3_cfg>(res_basic_f2.format_params);

lib/scheduler/pucch_scheduling/pucch_allocator_impl.cpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ std::optional<unsigned> pucch_allocator_impl::alloc_ded_pucch_harq_ack_ue(cell_r
263263
// Get the slot allocation grid considering the PDSCH delay (k0) and the PUCCH delay wrt PDSCH (k1).
264264
cell_slot_resource_allocator& pucch_slot_alloc = res_alloc[k0 + k1 + res_alloc.cfg.ntn_cs_koffset];
265265

266-
resource_manager.reset_last_ue_allocation();
266+
// The PUCCH allocation may result in a temporary reservation of PUCCH resources, which need to be released in case of
267+
// failure or in case the multiplexing results in a different final PUCCH resource. If we don't reset the previous
268+
// record, we could release the resources that have been allocated for other UEs of allocated for this UE in a
269+
// different slot.
270+
resource_manager.reset_latest_reserved_res_tracker();
267271

268272
slot_point sl_ack = pucch_slot_alloc.slot;
269273

@@ -280,7 +284,7 @@ std::optional<unsigned> pucch_allocator_impl::alloc_ded_pucch_harq_ack_ue(cell_r
280284
std::optional<unsigned> pucch_res_ind =
281285
multiplex_and_allocate_pucch(pucch_slot_alloc, new_bits, *existing_grant_it, ue_cell_cfg);
282286
if (not pucch_res_ind) {
283-
resource_manager.cancel_last_ue_allocations(sl_ack, crnti, ue_cell_cfg);
287+
resource_manager.cancel_last_ue_res_reservations(sl_ack, crnti, ue_cell_cfg);
284288
}
285289
return pucch_res_ind;
286290
} else {
@@ -304,7 +308,7 @@ void pucch_allocator_impl::pucch_allocate_sr_opportunity(cell_slot_resource_allo
304308
}
305309

306310
if (pucch_grants_alloc_grid[sl_tx.to_uint()].full()) {
307-
logger.info("rnti={}: PUCCH HARQ-ACK allocation for slot={} skipped. Cause: scheduler cache full",
311+
logger.info("rnti={}: PUCCH HARQ-ACK allocation for slot={} skipped. Cause: PUCCH allocator grant list is full",
308312
crnti,
309313
pucch_slot_alloc.slot);
310314
return;
@@ -368,7 +372,11 @@ void pucch_allocator_impl::pucch_allocate_csi_opportunity(cell_slot_resource_all
368372
{
369373
const slot_point sl_tx = pucch_slot_alloc.slot;
370374

371-
resource_manager.reset_last_ue_allocation();
375+
// The PUCCH allocation may result in a temporary reservation of PUCCH resources, which need to be released in case of
376+
// failure or in case the multiplexing results in a different final PUCCH resource. If we don't reset the previous
377+
// record, we could release the resources that have been allocated for other UEs of allocated for this UE in a
378+
// different slot.
379+
resource_manager.reset_latest_reserved_res_tracker();
372380

373381
// [Implementation-defined] We only allow a max number of PUCCH + PUSCH grants per slot.
374382
if (pucch_slot_alloc.result.ul.pucchs.size() >=
@@ -392,19 +400,20 @@ void pucch_allocator_impl::pucch_allocate_csi_opportunity(cell_slot_resource_all
392400
if (existing_grant_it != pucch_grants_alloc_grid[sl_tx.to_uint()].end() and existing_grant_it->has_common_pucch) {
393401
// Allocation of dedicated + common resources are handled by allocating PUCCH common on existing CSI, not the other
394402
// way around. If the function enters the path, it means it too early to start scheduling the CSI.
395-
logger.info("rnti={}: CSI occasion allocation for slot={} skipped. Cause: existing PUCCH common grant",
403+
logger.info("rnti={}: CSI occasion allocation for slot={} skipped. Cause: There is a PUCCH common grant"
404+
"allocated at this slot",
396405
crnti,
397406
pucch_slot_alloc.slot);
398407
return;
399408
}
400409

401410
// Handle case of existing PUCCHs with possible multiplexing.
402411
pucch_uci_bits bits_for_uci = existing_grant_it->pucch_grants.get_uci_bits();
403-
srsran_assert(bits_for_uci.csi_part1_nof_bits == 0, "PUCCH grant for CSI already been allocated");
412+
srsran_assert(bits_for_uci.csi_part1_nof_bits == 0, "PUCCH grant for CSI has already been allocated");
404413
bits_for_uci.csi_part1_nof_bits = csi_part1_nof_bits;
405414
auto alloc_outcome = multiplex_and_allocate_pucch(pucch_slot_alloc, bits_for_uci, *existing_grant_it, ue_cell_cfg);
406415
if (not alloc_outcome.has_value()) {
407-
resource_manager.cancel_last_ue_allocations(sl_tx, crnti, ue_cell_cfg);
416+
resource_manager.cancel_last_ue_res_reservations(sl_tx, crnti, ue_cell_cfg);
408417
}
409418
}
410419

@@ -988,7 +997,12 @@ pucch_allocator_impl::find_common_and_ded_harq_res_available(cell_slot_resource_
988997
// 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.
989998
const unsigned max_d_pri = 7;
990999
for (unsigned d_pri = 0; d_pri != max_d_pri + 1; ++d_pri) {
991-
resource_manager.reset_last_ue_allocation();
1000+
// The PUCCH allocation may result in a temporary reservation of PUCCH resources, which need to be released in case
1001+
// of failure or in case the multiplexing results in a different final PUCCH resource. If we don't reset the
1002+
// previous record, we could release the resources that have been allocated for other UEs of allocated for this UE
1003+
// in a different slot.
1004+
// Reset at each iteration, as a new iteration indicates that the previous allocation failed.
1005+
resource_manager.reset_latest_reserved_res_tracker();
9921006

9931007
// r_PUCCH, as per Section 9.2.1, TS 38.213.
9941008
const unsigned r_pucch = get_pucch_default_resource_index(start_cce_idx, nof_coreset_cces, d_pri);
@@ -1030,7 +1044,7 @@ pucch_allocator_impl::find_common_and_ded_harq_res_available(cell_slot_resource_
10301044
pucch_res_ind = multiplex_and_allocate_pucch(pucch_alloc, bits_for_uci, existing_grants, ue_cell_cfg, true);
10311045

10321046
if (not pucch_res_ind.has_value()) {
1033-
resource_manager.cancel_last_ue_allocations(pucch_alloc.slot, rnti, ue_cell_cfg);
1047+
resource_manager.cancel_last_ue_res_reservations(pucch_alloc.slot, rnti, ue_cell_cfg);
10341048
continue;
10351049
}
10361050

@@ -1057,7 +1071,7 @@ std::optional<unsigned> pucch_allocator_impl::allocate_harq_grant(cell_slot_reso
10571071
}
10581072

10591073
if (pucch_grants_alloc_grid[sl_tx.to_uint()].full()) {
1060-
logger.info("rnti={}: PUCCH HARQ-ACK allocation for slot={} skipped. Cause: scheduler cache full",
1074+
logger.info("rnti={}: PUCCH HARQ-ACK allocation for slot={} skipped. Cause: PUCCH allocator grant list is full",
10611075
crnti,
10621076
pucch_slot_alloc.slot);
10631077
return std::nullopt;
@@ -1108,7 +1122,7 @@ void pucch_allocator_impl::allocate_csi_grant(cell_slot_resource_allocator& pucc
11081122
}
11091123

11101124
if (pucch_grants_alloc_grid[sl_tx.to_uint()].full()) {
1111-
logger.info("rnti={}: PUCCH HARQ-ACK allocation for slot={} skipped. Cause: scheduler cache full",
1125+
logger.info("rnti={}: PUCCH HARQ-ACK allocation for slot={} skipped. Cause: PUCCH allocator grant list is full",
11121126
crnti,
11131127
pucch_slot_alloc.slot);
11141128
return;

lib/scheduler/pucch_scheduling/pucch_resource_manager.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,13 @@ bool pucch_resource_manager::release_csi_resource(slot_point s
253253
return true;
254254
}
255255

256-
void pucch_resource_manager::reset_last_ue_allocation()
256+
void pucch_resource_manager::reset_latest_reserved_res_tracker()
257257
{
258258
last_ue_allocations.rnti = rnti_t::INVALID_RNTI;
259259
last_ue_allocations.harq_set_0 = false;
260260
last_ue_allocations.harq_set_1 = false;
261261
last_ue_allocations.sr = false;
262-
last_ue_allocations.sr = false;
262+
last_ue_allocations.csi = false;
263263
}
264264

265265
void pucch_resource_manager::set_new_resource_allocation(rnti_t crnti, pucch_resource_usage res_type)
@@ -311,9 +311,9 @@ bool pucch_resource_manager::is_resource_allocated(rnti_t rnti, pucch_resource_u
311311
}
312312
}
313313

314-
void pucch_resource_manager::cancel_last_ue_allocations(slot_point slot_tx,
315-
rnti_t crnti,
316-
const ue_cell_configuration& ue_cell_cfg)
314+
void pucch_resource_manager::cancel_last_ue_res_reservations(slot_point slot_tx,
315+
rnti_t crnti,
316+
const ue_cell_configuration& ue_cell_cfg)
317317
{
318318
if (crnti != last_ue_allocations.rnti) {
319319
srsran_assertion_failure("Trying to cancel a UE allocation that was not the last one");

lib/scheduler/pucch_scheduling/pucch_resource_manager.h

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,19 @@ class pucch_resource_manager
126126
/// \return True if the resource for the UE was found in the allocation records for the given slot.
127127
bool release_csi_resource(slot_point slot_sr, rnti_t crnti, const ue_cell_configuration& ue_cell_cfg);
128128

129-
void reset_last_ue_allocation();
129+
/// \brief Reset the record of the PUCCH resources reserved to UE at the current slot.
130+
/// \remark This function doesn't release the resources, it only resets the record of which resources have been
131+
/// reserved.
132+
void reset_latest_reserved_res_tracker();
130133

134+
/// \brief Adds a records that a given resource has been reserved for the current slot for a given UE.
131135
void set_new_resource_allocation(rnti_t rnti, pucch_resource_usage res_type);
132136

137+
/// \brief Checks whether a given resource has been reserved for the current slot for a given UE.
133138
[[nodiscard]] bool is_resource_allocated(rnti_t rnti, pucch_resource_usage res_type) const;
134139

135-
void cancel_last_ue_allocations(slot_point slot_tx, rnti_t crnti, const ue_cell_configuration& ue_cell_cfg);
140+
/// \brief Releases the resources that have been recorded as reserved for the current slot for a given UE.
141+
void cancel_last_ue_res_reservations(slot_point slot_tx, rnti_t crnti, const ue_cell_configuration& ue_cell_cfg);
136142

137143
private:
138144
/// Size of the ring buffer of pucch_resource_manager. This size sets a limit on how far in advance a PUCCH can be
@@ -149,7 +155,7 @@ class pucch_resource_manager
149155
// As per Section 9.2.1, TS 38.213, this is given by the number of possible values of r_PUCCH, which is 16.
150156
static const size_t MAX_COMMON_PUCCH_RESOURCES{16};
151157

152-
// Tracks usage of PUCCH resources.
158+
// Tracks reservation of a PUCCH resource by a given UE and for a given usage (e.g., HARQ, SR, CSI).
153159
struct resource_tracker {
154160
rnti_t rnti;
155161
pucch_resource_usage resource_usage;
@@ -158,15 +164,19 @@ class pucch_resource_manager
158164
using pucch_res_record_array = std::array<resource_tracker, MAX_PUCCH_RESOURCES>;
159165
using common_res_record_array = std::array<bool, MAX_COMMON_PUCCH_RESOURCES>;
160166

161-
// Record for the RNTI and PUCCH resource indicator used for a given resource at a given slot.
167+
// Record for the RNTI and PUCCH resource indicator used for a given resource at a given slot; this information is
168+
// used to keep track of which resources are available and which UE is using them. This information is preserved over
169+
// the slots.
162170
struct rnti_pucch_res_id_slot_record {
163171
common_res_record_array used_common_resources;
164172
pucch_res_record_array ues_using_pucch_res;
165173
};
166174

167-
// Collects the information of what PUCCH cell resources have been allocated to a UE at given slot.
168-
// This info is used/updated by the PUCCH allocator and called for a new UE or new allocation for the same UE.
169-
struct ue_allocation_tracker {
175+
// Keeps track of which PUCCH cell resources have been allocated to a UE at the current slot.
176+
// This info is needed to release some resources after the PUCCH multiplexing (by the PUCCH allocator), during which
177+
// resources can be reserved and then released, depending on the multiplexing algorithm.
178+
// The lifespan of this information lasts for a single UE PUCCH allocation.
179+
struct current_slot_ue_allocations {
170180
rnti_t rnti = rnti_t::INVALID_RNTI;
171181
bool harq_set_0 = false;
172182
bool harq_set_1 = false;
@@ -194,7 +204,7 @@ class pucch_resource_manager
194204
// Ring buffer of rnti_pucch_res_id_slot_record for PUCCH resources.
195205
std::array<rnti_pucch_res_id_slot_record, RES_MANAGER_RING_BUFFER_SIZE> resource_slots;
196206

197-
ue_allocation_tracker last_ue_allocations;
207+
current_slot_ue_allocations last_ue_allocations;
198208

199209
// Keeps track of the last slot_point used by the resource manager.
200210
slot_point last_sl_ind;

0 commit comments

Comments
 (0)