Skip to content

Commit 1dc6fc4

Browse files
carlo-galcodebot
authored andcommitted
sched: fix pucch res indexing in pucch_allocator
Signed-off-by: Carlo Galiotto <[email protected]>
1 parent de4230b commit 1dc6fc4

File tree

4 files changed

+72
-26
lines changed

4 files changed

+72
-26
lines changed

lib/scheduler/pucch_scheduling/pucch_allocator_impl.cpp

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,9 +1068,6 @@ pucch_harq_ack_grant pucch_allocator_impl::update_format2_grant(pucch_info&
10681068
sr_nof_bits sr_bits_increment,
10691069
unsigned csi_part1_bits_increment)
10701070
{
1071-
// TODO replace this with value from config.
1072-
const unsigned PUCCH_FORMAT2_RES_SET_IDX = 1;
1073-
10741071
// Retrieving the PUCCH resource configuration depends on whether existing grant is for CSI.
10751072
// If so: (i) the resource indicator is meaningless; (ii) the PUCCH resource configuration is the CSI specific one.
10761073
// If not: (i) the resource indicator is needed; (ii) the PUCCH resource configuration is retrieved from the resource
@@ -1082,29 +1079,23 @@ pucch_harq_ack_grant pucch_allocator_impl::update_format2_grant(pucch_info&
10821079
srsran_sanity_check(not(current_csi_part1_bits > 0 and current_harq_ack_bits == 0 and harq_ack_bits_increment > 0),
10831080
"PUCCH resource CSI cannot be converted into HARQ-ACK through this function.");
10841081

1085-
const int res_indicator = current_csi_part1_bits > 0 and current_harq_ack_bits == 0
1086-
? 0
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());
1091-
srsran_sanity_check(res_indicator >= 0,
1092-
"The resource indicator for the allocated PUCCH Format 2 grant is expected to be non-negative");
1082+
const bool use_pucch_f2_csi_res = current_csi_part1_bits > 0 and current_harq_ack_bits == 0;
1083+
1084+
const pucch_harq_resource_alloc_record pucch_f2_harq_info =
1085+
use_pucch_f2_csi_res ? pucch_harq_resource_alloc_record{.pucch_res = nullptr}
1086+
: resource_manager.fetch_specific_f2_harq_resource(
1087+
sl_tx,
1088+
existing_f2_grant.crnti,
1089+
ue_cell_cfg.cfg_dedicated().ul_config.value().init_ul_bwp.pucch_cfg.value());
10931090

10941091
const pucch_resource* res_cfg =
1095-
current_csi_part1_bits > 0 and current_harq_ack_bits == 0
1096-
? resource_manager.fetch_csi_pucch_res_config(sl_tx, existing_f2_grant.crnti, ue_cell_cfg)
1097-
: &ue_cell_cfg.cfg_dedicated()
1098-
.ul_config.value()
1099-
.init_ul_bwp.pucch_cfg.value()
1100-
.pucch_res_list[ue_cell_cfg.cfg_dedicated()
1101-
.ul_config.value()
1102-
.init_ul_bwp.pucch_cfg.value()
1103-
.pucch_res_set[PUCCH_FORMAT2_RES_SET_IDX]
1104-
.pucch_res_id_list[static_cast<unsigned>(res_indicator)]];
1105-
1106-
srsran_sanity_check(res_cfg != nullptr,
1107-
"PUCCH resource previously allocated for UCI not found in the PUCCH resource manager.");
1092+
use_pucch_f2_csi_res ? resource_manager.fetch_csi_pucch_res_config(sl_tx, existing_f2_grant.crnti, ue_cell_cfg)
1093+
: pucch_f2_harq_info.pucch_res;
1094+
1095+
if (res_cfg == nullptr) {
1096+
srsran_assertion_failure("PUCCH resource previously allocated for UCI not found in the PUCCH resource manager.");
1097+
return pucch_harq_ack_grant{.pucch_res_indicator = 0, .pucch_pdu = nullptr};
1098+
}
11081099

11091100
// Check if the number of PRBs is sufficient for the number of bits to be acked.
11101101
const float max_pucch_code_rate = to_max_code_rate_float(ue_cell_cfg.cfg_dedicated()
@@ -1142,6 +1133,7 @@ pucch_harq_ack_grant pucch_allocator_impl::update_format2_grant(pucch_info&
11421133
}
11431134

11441135
logger.debug("ue={:#x}'s UCI mltplxd on existing PUCCH F2 for slot={}", existing_f2_grant.crnti, sl_tx);
1136+
const unsigned res_indicator = use_pucch_f2_csi_res ? 0U : pucch_f2_harq_info.pucch_res_indicator;
11451137
return pucch_harq_ack_grant{.pucch_res_indicator = static_cast<unsigned>(res_indicator),
11461138
.pucch_pdu = &existing_f2_grant};
11471139
}

lib/scheduler/pucch_scheduling/pucch_resource_manager.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,54 @@ int pucch_resource_manager::fetch_f2_pucch_res_indic(slot_point slot_tx, rnti_t
280280
return fetch_pucch_res_indic(slot_tx, crnti, pucch_cfg, pucch_format::FORMAT_2);
281281
}
282282

283+
const pucch_harq_resource_alloc_record
284+
pucch_resource_manager::fetch_specific_f2_harq_resource(slot_point slot_harq,
285+
rnti_t crnti,
286+
const pucch_config& pucch_cfg)
287+
{
288+
srsran_sanity_check(slot_harq < last_sl_ind + RES_MANAGER_RING_BUFFER_SIZE,
289+
"PUCCH being allocated to far into the future");
290+
291+
// Get resource list of wanted slot.
292+
rnti_pucch_res_id_slot_record& res_counter = get_slot_resource_counter(slot_harq);
293+
294+
auto& slot_res_array = res_counter.ues_using_pucch_res;
295+
296+
// Get the span over the array of resources for the specific UE.
297+
const auto& ue_res_id_set_for_harq = pucch_cfg.pucch_res_set[PUCCH_HARQ_F2_RES_SET_ID].pucch_res_id_list;
298+
unsigned ue_first_res_id = ue_res_id_set_for_harq.front();
299+
srsran_assert(ue_first_res_id + ue_res_id_set_for_harq.size() <= slot_res_array.size(),
300+
"Indexing of PUCCH resource set exceeds the size of the cell resource array");
301+
span<resource_tracker> slot_ue_res_array(&slot_res_array[ue_first_res_id], ue_res_id_set_for_harq.size());
302+
303+
// Check first if the target PUCCH resource (given the CRNTI and usage) exists within the resource tracker.
304+
auto* target_ue_resource = std::find_if(
305+
slot_ue_res_array.begin(), slot_ue_res_array.end(), [target_rnti = crnti](const resource_tracker res) {
306+
return res.rnti == target_rnti and res.resource_usage == pucch_resource_usage::HARQ_F2;
307+
});
308+
309+
const auto& pucch_res_list = pucch_cfg.pucch_res_list;
310+
311+
// If there is an available resource, try to allocate it.
312+
if (target_ue_resource != slot_ue_res_array.end() and
313+
static_cast<unsigned>(target_ue_resource - slot_ue_res_array.begin()) <
314+
pucch_cfg.pucch_res_set[PUCCH_HARQ_F2_RES_SET_ID].pucch_res_id_list.size()) {
315+
// Get the PUCCH resource indicator from the available resource position within the span.
316+
const unsigned pucch_res_indicator = static_cast<unsigned>(target_ue_resource - slot_ue_res_array.begin());
317+
// Get the PUCCH resource ID from the PUCCH resource indicator and the PUCCH resource set.
318+
const unsigned pucch_res_idx_from_list = ue_res_id_set_for_harq[pucch_res_indicator];
319+
320+
// Search for the PUCCH resource with the correct PUCCH resource ID from the PUCCH resource list.
321+
const auto* res_cfg = std::find_if(
322+
pucch_res_list.begin(), pucch_res_list.end(), [pucch_res_idx_from_list](const pucch_resource& res) {
323+
return res.res_id == pucch_res_idx_from_list;
324+
});
325+
326+
return pucch_harq_resource_alloc_record{.pucch_res = &(*res_cfg), .pucch_res_indicator = pucch_res_indicator};
327+
}
328+
return pucch_harq_resource_alloc_record{.pucch_res = nullptr};
329+
}
330+
283331
const pucch_resource* pucch_resource_manager::fetch_csi_pucch_res_config(slot_point slot_tx,
284332
rnti_t crnti,
285333
const ue_cell_configuration& ue_cell_cfg)

lib/scheduler/pucch_scheduling/pucch_resource_manager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ class pucch_resource_manager
124124
/// \return PUCCH resource indicator of the resource used allocated to the UE; if UE is not found, returns -1.
125125
int fetch_f2_pucch_res_indic(slot_point slot_tx, rnti_t crnti, const pucch_config& pucch_cfg);
126126

127+
/// \brief Returns the configuration of the PUCCH Format 2 resource used for HARQ already allocated to a given RNTI at
128+
/// a given slot.
129+
/// \return Pointer to the resource configuration allocated to the UE; if UE is not found, returns \c nullptr.
130+
const pucch_harq_resource_alloc_record
131+
fetch_specific_f2_harq_resource(slot_point slot_harq, rnti_t crnti, const pucch_config& pucch_cfg);
132+
127133
/// \brief Returns the configuration of the PUCCH resource used for CSI (format 2) for a given RNTI at a given slot.
128134
/// \return Pointer to the resource configuration used allocated to the UE; if UE is not found, returns \c nullptr.
129135
const pucch_resource*

lib/scheduler/uci_scheduling/uci_allocator_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ void uci_allocator_impl::multiplex_uci_on_pusch(ul_sched_info& pu
208208
const ue_cell_configuration& ue_cell_cfg,
209209
rnti_t crnti)
210210
{
211-
// Note: the UCI bits is capped to the PUCCH Format 2 capacity. When multiplexing UCI to PUSCH, we only "tranfer" the
212-
// bits that would have been fit within the PUCCH, not the all the bits that should have been reported.
211+
// Note: the UCI bits is capped to the PUCCH Format 2 capacity. When multiplexing UCI to PUSCH, we only "tranfer"
212+
// the bits that would have been fit within the PUCCH, not the all the bits that should have been reported.
213213
// TODO: Check if this approach is correct.
214214
const pucch_uci_bits pucch_uci = pucch_alloc.remove_ue_uci_from_pucch(slot_alloc, crnti, ue_cell_cfg);
215215

0 commit comments

Comments
 (0)