@@ -45,14 +45,17 @@ int get_pucch_res_idx_for_csi(const ue_cell_configuration& ue_cell_cfg)
4545pucch_resource_manager::pucch_resource_manager ()
4646{
4747 auto reset_slot_record = [](rnti_pucch_res_id_slot_record& res_counter) {
48- res_counter.ue_using_sr_resource = INVALID_RNTI;
4948 res_counter.ue_using_csi_resource = INVALID_RNTI;
5049 for (auto & ue_rec : res_counter.ues_using_format1_res ) {
5150 ue_rec = INVALID_RNTI;
5251 }
5352 for (auto & ue_rec : res_counter.ues_using_format2_res ) {
5453 ue_rec = INVALID_RNTI;
5554 }
55+ for (auto & ue_rec : res_counter.ues_using_sr_resources ) {
56+ ue_rec.pucch_res_id = -1 ;
57+ ue_rec.allocated_ue = INVALID_RNTI;
58+ }
5659 };
5760
5861 std::for_each (resource_slots.begin (), resource_slots.end (), reset_slot_record);
@@ -65,14 +68,17 @@ void pucch_resource_manager::slot_indication(slot_point slot_tx)
6568
6669 rnti_pucch_res_id_slot_record& res_counter = get_slot_resource_counter (last_sl_ind - 1 );
6770
68- res_counter.ue_using_sr_resource = INVALID_RNTI;
6971 res_counter.ue_using_csi_resource = INVALID_RNTI;
7072 for (auto & ue_rec : res_counter.ues_using_format1_res ) {
7173 ue_rec = INVALID_RNTI;
7274 }
7375 for (auto & ue_rec : res_counter.ues_using_format2_res ) {
7476 ue_rec = INVALID_RNTI;
7577 }
78+ for (auto & ue_rec : res_counter.ues_using_sr_resources ) {
79+ ue_rec.pucch_res_id = -1 ;
80+ ue_rec.allocated_ue = INVALID_RNTI;
81+ }
7682}
7783
7884pucch_harq_resource_alloc_record pucch_resource_manager::reserve_next_harq_res_available (slot_point slot_harq,
@@ -214,28 +220,32 @@ pucch_resource_manager::reserve_sr_res_available(slot_point slot_sr, rnti_t crnt
214220
215221 auto & slot_record = get_slot_resource_counter (slot_sr);
216222
217- if (slot_record.ue_using_sr_resource == INVALID_RNTI) {
218- const auto & pucch_res_list = pucch_cfg.pucch_res_list ;
223+ // We assume each UE only has 1 SR Resource Config configured.
224+ const unsigned sr_pucch_res_id = pucch_cfg.sr_res_list [0 ].pucch_res_id ;
225+ auto * it = std::find_if (slot_record.ues_using_sr_resources .begin (),
226+ slot_record.ues_using_sr_resources .end (),
227+ [sr_res_idx = pucch_cfg.sr_res_list [0 ].pucch_res_id ](const sr_record& sr_rec) {
228+ return static_cast <int >(sr_res_idx) == sr_rec.pucch_res_id ;
229+ });
219230
220- // Check if the list of PUCCH resources (corresponding to \c resourceToAddModList, as part of \c PUCCH-Config, as
221- // per TS 38.331) contains the resource indexed to be used for SR.
222- const auto * sr_pucch_resource_cfg =
223- std::find_if (pucch_res_list.begin (),
224- pucch_res_list.end (),
225- [sr_res_idx = pucch_cfg.sr_res_list [0 ].pucch_res_id ](const pucch_resource& pucch_sr_res_cfg) {
226- return static_cast <unsigned >(sr_res_idx) == pucch_sr_res_cfg.res_id ;
227- });
231+ // If there is already a record for this pucch_res_id, it means it is used by another UE.
232+ if (it != slot_record.ues_using_sr_resources .end ()) {
233+ return nullptr ;
234+ }
228235
229- // If there is no such PUCCH resource, return \c nullptr.
230- if (sr_pucch_resource_cfg == pucch_res_list.end ()) {
231- // TODO: Add information about the LC which this SR is for.
232- return nullptr ;
233- }
236+ // Check the first available slot in the record list.
237+ it = std::find_if (slot_record.ues_using_sr_resources .begin (),
238+ slot_record.ues_using_sr_resources .end (),
239+ [](const sr_record& sr_rec) { return sr_rec.allocated_ue == INVALID_RNTI; });
234240
235- slot_record.ue_using_sr_resource = crnti;
236- return &(*sr_pucch_resource_cfg);
241+ // There are no available records for the SR.
242+ if (it == slot_record.ues_using_sr_resources .end ()) {
243+ return nullptr ;
237244 }
238- return nullptr ;
245+
246+ it->pucch_res_id = static_cast <int >(sr_pucch_res_id);
247+ it->allocated_ue = crnti;
248+ return &pucch_cfg.pucch_res_list [sr_pucch_res_id];
239249};
240250
241251bool pucch_resource_manager::release_harq_resource (slot_point slot_harq, rnti_t crnti, const pucch_config& pucch_cfg)
@@ -272,15 +282,20 @@ bool pucch_resource_manager::release_format2_resource(slot_point slot_harq, rnti
272282
273283bool pucch_resource_manager::release_sr_resource (slot_point slot_sr, rnti_t crnti)
274284{
275- auto & allocated_ue = get_slot_resource_counter (slot_sr).ue_using_sr_resource ;
285+ auto & slot_record = get_slot_resource_counter (slot_sr);
286+
287+ auto * it = std::find_if (slot_record.ues_using_sr_resources .begin (),
288+ slot_record.ues_using_sr_resources .end (),
289+ [crnti](const sr_record& sr_rec) { return crnti == sr_rec.allocated_ue ; });
276290
277291 // If the UE allocated to the SR PUCCH resource matches the given CRNTI, release the resource.
278- if (allocated_ue == crnti) {
279- allocated_ue = INVALID_RNTI;
280- return true ;
292+ if (it == slot_record.ues_using_sr_resources .end ()) {
293+ return false ;
281294 }
282295
283- return false ;
296+ it->allocated_ue = INVALID_RNTI;
297+ it->pucch_res_id = -1 ;
298+ return true ;
284299}
285300
286301bool pucch_resource_manager::release_csi_resource (slot_point slot_sr, rnti_t crnti)
0 commit comments