Skip to content

Commit 7308b57

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

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

lib/scheduler/pucch_scheduling/pucch_allocator_impl.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ std::optional<unsigned> pucch_allocator_impl::alloc_common_and_ded_harq_res(cell
223223
return std::nullopt;
224224
}
225225

226-
const bool new_ue_grants_added = ue_grants_it == pucch_grants.end();
226+
const bool new_ue_grant_added = ue_grants_it == pucch_grants.end();
227227

228-
if (new_ue_grants_added) {
228+
// Keep track of whether a new ue_grant has been added; in case the function fails, remove it before exiting.
229+
if (new_ue_grant_added) {
229230
pucch_grants.emplace_back(ue_grants{.rnti = rnti});
230231
}
231232

@@ -239,7 +240,7 @@ std::optional<unsigned> pucch_allocator_impl::alloc_common_and_ded_harq_res(cell
239240
return pucch_common_info.value().pucch_res_indicator;
240241
}
241242

242-
if (new_ue_grants_added) {
243+
if (new_ue_grant_added) {
243244
pucch_grants.pop_back();
244245
}
245246

@@ -1654,11 +1655,14 @@ pucch_allocator_impl::multiplex_resources(slot_point sl_tx,
16541655
const ue_cell_configuration& ue_cell_cfg,
16551656
bool preserve_res_indicator)
16561657
{
1658+
// This function implements the multiplexing pseudo-code for PUCCH resources defined in Section 9.2.5, TS 38.213.
1659+
// Refer to paragraph starting as "Set Q to the set of resources for transmission of corresponding PUCCHs in a single
1660+
// slot without repetitions where".
16571661
pucch_grant_list mplexed_grants;
16581662

16591663
std::vector<pucch_grant> resource_set_q;
16601664

1661-
// Build the resource set Q.
1665+
// Build the resource set Q. Refer to Section 9.2.5, TS 38.213.
16621666
if (candidate_grants.harq_resource.has_value()) {
16631667
resource_set_q.emplace_back(candidate_grants.harq_resource.value());
16641668
}
@@ -1680,7 +1684,7 @@ pucch_allocator_impl::multiplex_resources(slot_point sl_tx,
16801684

16811685
sort_res_set_q();
16821686

1683-
// This is the implementation of the sudo code for multiplexing the resources provided in Section 9.2.5, TS 38.213.
1687+
// This is the implementation of the pseudo-code for multiplexing the resources provided in Section 9.2.5, TS 38.213.
16841688
unsigned o_cnt = 0;
16851689
unsigned j_cnt = 0;
16861690
while (j_cnt < resource_set_q.size()) {
@@ -1701,6 +1705,7 @@ pucch_allocator_impl::multiplex_resources(slot_point sl_tx,
17011705
return {};
17021706
}
17031707
// Remove the old resources that got merged from the set.
1708+
// TODO: check if, by using a different data structure, we can achive the deletion more efficiently.
17041709
resource_set_q.erase(resource_set_q.begin() + j_cnt - o_cnt, resource_set_q.begin() + j_cnt + 1);
17051710

17061711
// Add the new resource (resulting from the previous merge) to the set.
@@ -1718,8 +1723,8 @@ pucch_allocator_impl::multiplex_resources(slot_point sl_tx,
17181723
}
17191724
}
17201725

1721-
// The PUCCH resource multiplexing algorithm above is specified for the UE. In the GNB, we need to add an extra
1722-
// resource Format 1 if slot there is a SR opportunity and HARQ bits to be reported with PUCCH Format 1.
1726+
// The PUCCH resource multiplexing algorithm above is specified from the UE's perspective. In the GNB, we need to add
1727+
// an extra resource Format 1 if slot there is a SR opportunity and HARQ bits to be reported with PUCCH Format 1.
17231728
if (resource_set_q.size() == 1 and resource_set_q.front().get_format() == pucch_format::FORMAT_1 and
17241729
resource_set_q.front().bits.harq_ack_nof_bits != 0 and
17251730
resource_set_q.front().bits.sr_bits != sr_nof_bits::no_sr) {
@@ -1760,13 +1765,16 @@ pucch_allocator_impl::multiplex_and_allocate_pucch(cell_slot_resource_allocator&
17601765
{
17611766
slot_point sl_ack = pucch_slot_alloc.slot;
17621767

1763-
// Find resource needed for the bits to be reported, assuming the resource is not multiplexed.
1768+
// Find the resources needed for the UCI bits to be reported, assuming the resources are not multiplexed.
17641769
std::optional<pucch_grant_list> candidate_resources =
17651770
get_pucch_res_pre_multiplexing(sl_ack, new_bits, current_grants, ue_cell_cfg);
17661771
if (not candidate_resources.has_value()) {
17671772
return std::nullopt;
17681773
}
17691774

1775+
// TODO: Implement optimization step to avoid the multiplexing process if the UCI bits results in the same PUCCH
1776+
// grants as the previous allocation.
1777+
17701778
// Multiplex the resources.
17711779
pucch_grant_list multiplexed_grants = multiplex_resources(
17721780
sl_ack, current_grants.rnti, candidate_resources.value(), ue_cell_cfg, preserve_res_indicator);

lib/scheduler/pucch_scheduling/pucch_allocator_impl.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,57 +173,63 @@ class pucch_allocator_impl final : public pucch_allocator
173173
const ue_cell_configuration& ue_cell_cfg,
174174
const dci_context_information& dci_info);
175175

176-
// Helper that allocates a NEW PUCCH HARQ grant (Format 1).
176+
// Helper that allocates a NEW PUCCH HARQ grant (Format 0 or 1).
177177
std::optional<unsigned> allocate_harq_grant(cell_slot_resource_allocator& pucch_slot_alloc,
178178
rnti_t crnti,
179179
const ue_cell_configuration& ue_cell_cfg);
180180

181-
// Helper that allocates a new PUCCH HARQ grant (Format 2) for CSI.
181+
// Helper that allocates a new PUCCH HARQ grant (Format 2/3/4) for CSI.
182182
void allocate_csi_grant(cell_slot_resource_allocator& pucch_slot_alloc,
183183
rnti_t crnti,
184184
const ue_cell_configuration& ue_cell_cfg,
185185
unsigned csi_part1_bits);
186186

187+
// Implements the main steps of the multiplexing procedure as defined in TS 38.213, Section 9.2.5.
187188
std::optional<unsigned> multiplex_and_allocate_pucch(cell_slot_resource_allocator& pucch_slot_alloc,
188189
pucch_uci_bits new_bits,
189190
ue_grants& current_grants,
190191
const ue_cell_configuration& ue_cell_cfg,
191192
bool preserve_res_indicator = false);
192193

194+
// Computes which resources are expected to be sent, depending on the UCI bits to be sent, before any multiplexing.
193195
std::optional<pucch_grant_list> get_pucch_res_pre_multiplexing(slot_point sl_tx,
194196
pucch_uci_bits new_bits,
195197
ue_grants ue_current_grants,
196198
const ue_cell_configuration& ue_cell_cfg);
197199

200+
// Execute the multiplexing algorithm as defined in TS 38.213, Section 9.2.5.
198201
pucch_grant_list multiplex_resources(slot_point sl_tx,
199202
rnti_t crnti,
200203
pucch_grant_list candidate_grants,
201204
const ue_cell_configuration& ue_cell_cfg,
202205
bool preserve_res_indicator = false);
203206

207+
// Applies the multiplexing rules depending on the PUCCH resource format, as per TS 38.213, Section 9.2.5.1/2.
204208
std::optional<pucch_grant> merge_pucch_resources(span<const pucch_grant> resources_to_merge,
205209
slot_point slot_harq,
206210
rnti_t crnti,
207211
const pucch_config& pucch_cfg,
208212
bool preserve_res_indicator = false);
209213

214+
// Allocate the PUCCH PDUs in the scheduler output, depending on the new PUCCH grants to be transmitted, and depending
215+
// on the PUCCH PDUs currently allocated.
210216
std::optional<unsigned> allocate_grants(cell_slot_resource_allocator& pucch_slot_alloc,
211217
ue_grants& existing_pucchs,
212218
rnti_t crnti,
213219
pucch_grant_list grants_to_tx,
214220
const ue_cell_configuration& ue_cell_cfg);
215221

216-
// Fills the PUCCH HARQ grant for common resources.
222+
// Fills the PUCCH HARQ PDU for common resources.
217223
void fill_pucch_harq_common_grant(pucch_info& pucch_info, rnti_t rnti, const pucch_res_alloc_cfg& pucch_res);
218224

219-
// Fills the PUCCH Format 1 grant.
225+
// Fills the PUCCH Format 1 PDU.
220226
void fill_pucch_ded_format1_grant(pucch_info& pucch_grant,
221227
rnti_t crnti,
222228
const pucch_resource& pucch_ded_res_cfg,
223229
unsigned harq_ack_bits,
224230
sr_nof_bits sr_bits);
225231

226-
// Fills the PUCCH Format 2 grant.
232+
// Fills the PUCCH Format 2 PDU.
227233
void fill_pucch_format2_grant(pucch_info& pucch_grant,
228234
rnti_t crnti,
229235
const pucch_resource& pucch_ded_res_cfg,

0 commit comments

Comments
 (0)