@@ -136,7 +136,8 @@ const pucch_resource* pucch_resource_manager::reserve_csi_resource(slot_point
136136
137137 // Get resource list of wanted slot.
138138 auto & slot_record = get_slot_resource_counter (slot_csi);
139- if (slot_record.ues_using_pucch_res [csi_pucch_res_idx].rnti != rnti_t ::INVALID_RNTI) {
139+ if (slot_record.ues_using_pucch_res [csi_pucch_res_idx].rnti != rnti_t ::INVALID_RNTI and
140+ slot_record.ues_using_pucch_res [csi_pucch_res_idx].rnti != crnti) {
140141 return nullptr ;
141142 }
142143
@@ -148,14 +149,16 @@ const pucch_resource* pucch_resource_manager::reserve_csi_resource(slot_point
148149 return res.res_id .cell_res_id == csi_pucch_res_idx;
149150 });
150151
151- // If the PUCCH res with correct ID is found, then allocate it to the user.
152- if (res_cfg != pucch_res_list.end ()) {
152+ if (res_cfg == pucch_res_list.end ()) {
153+ return nullptr ;
154+ }
155+
156+ // If the PUCCH res with correct ID was not allocated to the UE's RNTI, allocate it to this RNTI.
157+ if (slot_record.ues_using_pucch_res [csi_pucch_res_idx].rnti != crnti) {
153158 slot_record.ues_using_pucch_res [csi_pucch_res_idx].rnti = crnti;
154159 slot_record.ues_using_pucch_res [csi_pucch_res_idx].resource_usage = pucch_resource_usage::CSI;
155- return &(*res_cfg);
156160 }
157-
158- return nullptr ;
161+ return &(*res_cfg);
159162};
160163
161164const pucch_resource*
@@ -169,7 +172,8 @@ pucch_resource_manager::reserve_sr_res_available(slot_point slot_sr, rnti_t crnt
169172
170173 // We assume each UE only has 1 SR Resource Config configured.
171174 const unsigned sr_pucch_res_id = pucch_cfg.sr_res_list [0 ].pucch_res_id .cell_res_id ;
172- if (slot_record.ues_using_pucch_res [sr_pucch_res_id].rnti != rnti_t ::INVALID_RNTI) {
175+ if (slot_record.ues_using_pucch_res [sr_pucch_res_id].rnti != rnti_t ::INVALID_RNTI and
176+ slot_record.ues_using_pucch_res [sr_pucch_res_id].rnti != crnti) {
173177 return nullptr ;
174178 }
175179
@@ -180,14 +184,16 @@ pucch_resource_manager::reserve_sr_res_available(slot_point slot_sr, rnti_t crnt
180184 return res.res_id .cell_res_id == sr_pucch_res_id;
181185 });
182186
183- // If the PUCCH res with correct ID is found, then allocate it to the user.
184- if (res_cfg != pucch_res_list.end ()) {
187+ if (res_cfg == pucch_res_list.end ()) {
188+ return nullptr ;
189+ }
190+
191+ // If the PUCCH res with correct ID was not allocated to the UE's RNTI, allocate it to this RNTI.
192+ if (slot_record.ues_using_pucch_res [sr_pucch_res_id].rnti != crnti and res_cfg != pucch_res_list.end ()) {
185193 slot_record.ues_using_pucch_res [sr_pucch_res_id].rnti = crnti;
186194 slot_record.ues_using_pucch_res [sr_pucch_res_id].resource_usage = pucch_resource_usage::SR;
187- return &(*res_cfg);
188195 }
189-
190- return nullptr ;
196+ return &(*res_cfg);
191197};
192198
193199bool pucch_resource_manager::release_harq_f1_resource (slot_point slot_harq, rnti_t crnti, const pucch_config& pucch_cfg)
@@ -243,100 +249,6 @@ bool pucch_resource_manager::release_csi_resource(slot_point s
243249 return true ;
244250}
245251
246- int pucch_resource_manager::fetch_f1_pucch_res_indic (slot_point slot_tx, rnti_t crnti, const pucch_config& pucch_cfg)
247- {
248- return fetch_pucch_res_indic (slot_tx, crnti, pucch_cfg, pucch_format::FORMAT_1);
249- }
250-
251- int pucch_resource_manager::fetch_f2_pucch_res_indic (slot_point slot_tx, rnti_t crnti, const pucch_config& pucch_cfg)
252- {
253- return fetch_pucch_res_indic (slot_tx, crnti, pucch_cfg, pucch_format::FORMAT_2);
254- }
255-
256- const pucch_harq_resource_alloc_record
257- pucch_resource_manager::fetch_allocated_f2_harq_resource (slot_point slot_harq,
258- rnti_t crnti,
259- const pucch_config& pucch_cfg)
260- {
261- srsran_sanity_check (slot_harq < last_sl_ind + RES_MANAGER_RING_BUFFER_SIZE,
262- " PUCCH being allocated too far into the future" );
263-
264- // Get resource list of wanted slot.
265- rnti_pucch_res_id_slot_record& res_counter = get_slot_resource_counter (slot_harq);
266-
267- auto & slot_res_array = res_counter.ues_using_pucch_res ;
268-
269- // Get the span over the array of resources for the specific UE.
270- const auto & ue_res_id_set_for_harq = pucch_cfg.pucch_res_set [PUCCH_HARQ_F2_RES_SET_ID].pucch_res_id_list ;
271- unsigned ue_first_res_id = ue_res_id_set_for_harq.front ().cell_res_id ;
272- srsran_assert (ue_first_res_id + ue_res_id_set_for_harq.size () <= slot_res_array.size (),
273- " Indexing of PUCCH resource set exceeds the size of the cell resource array" );
274- span<resource_tracker> slot_ue_res_array (&slot_res_array[ue_first_res_id], ue_res_id_set_for_harq.size ());
275-
276- // Check first if the target PUCCH resource (given the CRNTI and usage) exists within the resource tracker.
277- auto * target_ue_resource = std::find_if (
278- slot_ue_res_array.begin (), slot_ue_res_array.end (), [target_rnti = crnti](const resource_tracker& res) {
279- return res.rnti == target_rnti and res.resource_usage == pucch_resource_usage::HARQ_F2;
280- });
281-
282- const auto & pucch_res_list = pucch_cfg.pucch_res_list ;
283-
284- // If the resource is found, get the resource indicator and the configuration from the PUCCH resource list.
285- if (target_ue_resource != slot_ue_res_array.end () and
286- static_cast <unsigned >(target_ue_resource - slot_ue_res_array.begin ()) <
287- pucch_cfg.pucch_res_set [PUCCH_HARQ_F2_RES_SET_ID].pucch_res_id_list .size ()) {
288- // Get the PUCCH resource indicator from the available resource position within the span.
289- const unsigned pucch_res_indicator = static_cast <unsigned >(target_ue_resource - slot_ue_res_array.begin ());
290- // Get the PUCCH resource ID from the PUCCH resource indicator and the PUCCH resource set.
291- const unsigned pucch_res_idx_from_list = ue_res_id_set_for_harq[pucch_res_indicator].cell_res_id ;
292-
293- // Search for the PUCCH resource with the correct PUCCH resource ID from the PUCCH resource list.
294- const auto * res_cfg = std::find_if (
295- pucch_res_list.begin (), pucch_res_list.end (), [pucch_res_idx_from_list](const pucch_resource& res) {
296- return res.res_id .cell_res_id == pucch_res_idx_from_list;
297- });
298-
299- return pucch_harq_resource_alloc_record{.pucch_res = &(*res_cfg), .pucch_res_indicator = pucch_res_indicator};
300- }
301- return pucch_harq_resource_alloc_record{.pucch_res = nullptr };
302- }
303-
304- const pucch_resource* pucch_resource_manager::fetch_csi_pucch_res_config (slot_point slot_tx,
305- rnti_t crnti,
306- const ue_cell_configuration& ue_cell_cfg)
307- {
308- srsran_sanity_check (slot_tx < last_sl_ind + RES_MANAGER_RING_BUFFER_SIZE,
309- " PUCCH being allocated to far into the future" );
310-
311- rnti_pucch_res_id_slot_record& slot_record = get_slot_resource_counter (slot_tx);
312-
313- const int csi_pucch_res_idx_int = get_pucch_res_idx_for_csi (ue_cell_cfg);
314- if (csi_pucch_res_idx_int < 0 ) {
315- return nullptr ;
316- }
317-
318- const unsigned csi_pucch_res_idx = static_cast <unsigned >(csi_pucch_res_idx_int);
319- if (slot_record.ues_using_pucch_res [csi_pucch_res_idx].rnti != crnti) {
320- return nullptr ;
321- }
322-
323- const auto & pucch_res_list =
324- ue_cell_cfg.cfg_dedicated ().ul_config .value ().init_ul_bwp .pucch_cfg .value ().pucch_res_list ;
325-
326- // Search for the PUCCH resource with the correct PUCCH resource ID from the PUCCH resource list.
327- const auto * res_cfg =
328- std::find_if (pucch_res_list.begin (), pucch_res_list.end (), [csi_pucch_res_idx](const pucch_resource& res) {
329- return res.res_id .cell_res_id == csi_pucch_res_idx;
330- });
331-
332- // If the PUCCH res with correct ID is found, then return it to the user.
333- if (res_cfg != pucch_res_list.end ()) {
334- return &(*res_cfg);
335- }
336-
337- return nullptr ;
338- }
339-
340252pucch_harq_resource_alloc_record pucch_resource_manager::reserve_next_harq_res_available (slot_point slot_harq,
341253 rnti_t crnti,
342254 const pucch_config& pucch_cfg,
@@ -424,23 +336,27 @@ const pucch_resource* pucch_resource_manager::reserve_harq_res_by_res_indicator(
424336 const auto & pucch_res_list = pucch_cfg.pucch_res_list ;
425337
426338 // Check first if the wanted PUCCH resource is available.
427- if (pucch_res_tracker.rnti == rnti_t ::INVALID_RNTI) {
428- // Search for the PUCCH resource with the correct PUCCH resource ID from the PUCCH resource list.
429- const auto * res_cfg =
430- std::find_if (pucch_res_list.begin (), pucch_res_list.end (), [pucch_res_id](const pucch_resource& res) {
431- return res.res_id .cell_res_id == pucch_res_id;
432- });
339+ if (pucch_res_tracker.rnti != rnti_t ::INVALID_RNTI and pucch_res_tracker.rnti != crnti) {
340+ return nullptr ;
341+ }
433342
434- // If the PUCCH res with correct ID is found, then allocate it to the user.
435- if (res_cfg != pucch_res_list.end ()) {
436- pucch_res_tracker.rnti = crnti;
437- pucch_res_tracker.resource_usage =
438- format == pucch_format::FORMAT_1 ? pucch_resource_usage::HARQ_F1 : pucch_resource_usage::HARQ_F2;
439- return &(*res_cfg);
440- }
343+ // Search for the PUCCH resource with the correct PUCCH resource ID from the PUCCH resource list.
344+ const auto * res_cfg =
345+ std::find_if (pucch_res_list.begin (), pucch_res_list.end (), [pucch_res_id](const pucch_resource& res) {
346+ return res.res_id .cell_res_id == pucch_res_id;
347+ });
348+
349+ if (res_cfg == pucch_res_list.end ()) {
350+ return nullptr ;
441351 }
442352
443- return nullptr ;
353+ // If the PUCCH res with correct ID is found and previously not used by given UE's RNTI, then allocate it this RNTI.
354+ if (pucch_res_tracker.rnti == rnti_t ::INVALID_RNTI) {
355+ pucch_res_tracker.rnti = crnti;
356+ pucch_res_tracker.resource_usage =
357+ format == pucch_format::FORMAT_1 ? pucch_resource_usage::HARQ_F1 : pucch_resource_usage::HARQ_F2;
358+ }
359+ return &(*res_cfg);
444360}
445361
446362bool pucch_resource_manager::release_harq_resource (slot_point slot_harq,
@@ -485,49 +401,6 @@ bool pucch_resource_manager::release_harq_resource(slot_point slot_harq
485401 return false ;
486402}
487403
488- int pucch_resource_manager::fetch_pucch_res_indic (slot_point slot_tx,
489- rnti_t crnti,
490- const pucch_config& pucch_cfg,
491- pucch_format format)
492- {
493- srsran_sanity_check (slot_tx < last_sl_ind + RES_MANAGER_RING_BUFFER_SIZE,
494- " PUCCH being allocated to far into the future" );
495- srsran_assert (format == pucch_format::FORMAT_1 or format == pucch_format::FORMAT_2,
496- " Only PUCCH Format 1 and Format 2 are currently supported" );
497-
498- // Get resource list of wanted slot.
499- rnti_pucch_res_id_slot_record& res_counter = get_slot_resource_counter (slot_tx);
500-
501- auto & slot_res_array = res_counter.ues_using_pucch_res ;
502-
503- const unsigned res_set_idx = format == pucch_format::FORMAT_1 ? PUCCH_HARQ_F1_RES_SET_ID : PUCCH_HARQ_F2_RES_SET_ID;
504- const pucch_resource_usage res_usage =
505- format == pucch_format::FORMAT_1 ? pucch_resource_usage::HARQ_F1 : pucch_resource_usage::HARQ_F2;
506-
507- // Get the span over the array of resources for the specific UE.
508- const auto & ue_res_id_set_for_harq = pucch_cfg.pucch_res_set [res_set_idx].pucch_res_id_list ;
509- unsigned ue_first_res_id = ue_res_id_set_for_harq.front ().cell_res_id ;
510- srsran_assert (ue_first_res_id + ue_res_id_set_for_harq.size () <= slot_res_array.size (),
511- " Indexing of PUCCH resource set exceeds the size of the cell resource array" );
512- span<resource_tracker> slot_ue_res_array (&slot_res_array[ue_first_res_id], ue_res_id_set_for_harq.size ());
513-
514- // Check first if the target PUCCH resource (given the CRNTI and usage) exists within the resource tracker.
515- auto * ue_resource = std::find_if (slot_ue_res_array.begin (),
516- slot_ue_res_array.end (),
517- [target_rnti = crnti, res_usage](const resource_tracker& res) {
518- return res.rnti == target_rnti and res.resource_usage == res_usage;
519- });
520-
521- if (ue_resource != slot_ue_res_array.end () and static_cast <unsigned >(ue_resource - slot_ue_res_array.begin ()) <
522- pucch_cfg.pucch_res_set [res_set_idx].pucch_res_id_list .size ()) {
523- // Get the PUCCH resource indicator from the available resource position within the span.
524- return static_cast <unsigned >(ue_resource - slot_ue_res_array.begin ());
525- }
526-
527- // -1 indicates that the there is no UE record for given RNTI.
528- return -1 ;
529- }
530-
531404pucch_resource_manager::rnti_pucch_res_id_slot_record& pucch_resource_manager::get_slot_resource_counter (slot_point sl)
532405{
533406 srsran_sanity_check (sl < last_sl_ind + RES_MANAGER_RING_BUFFER_SIZE,
0 commit comments