@@ -1305,7 +1305,24 @@ pucch_allocator_impl::get_pucch_res_pre_multiplexing(slot_point
13051305 // There is already a PUCCH resource for HARQ-ACK; if so, we use the info and configuration from this resource.
13061306 if (ue_current_grants.pucch_grants .harq_resource .has_value () and
13071307 ue_current_grants.pucch_grants .harq_resource .value ().harq_id .pucch_set_idx == pucch_set_idx) {
1308- harq_candidate_grant = ue_current_grants.pucch_grants .harq_resource .value ();
1308+ const pucch_resource* pucch_res =
1309+ pucch_set_idx == pucch_res_set_idx::set_0
1310+ ? resource_manager.reserve_f1_res_by_res_indicator (
1311+ sl_tx,
1312+ ue_current_grants.rnti ,
1313+ ue_current_grants.pucch_grants .harq_resource .value ().harq_id .pucch_res_ind ,
1314+ pucch_cfg)
1315+ : resource_manager.reserve_f2_res_by_res_indicator (
1316+ sl_tx,
1317+ ue_current_grants.rnti ,
1318+ ue_current_grants.pucch_grants .harq_resource .value ().harq_id .pucch_res_ind ,
1319+ pucch_cfg);
1320+ if (pucch_res == nullptr ) {
1321+ srsran_assertion_failure (" rnti={}: PUCCH HARQ-ACK resource previously reserved not available anymore" ,
1322+ ue_current_grants.rnti );
1323+ return std::nullopt ;
1324+ }
1325+ harq_candidate_grant.pucch_res_cfg = pucch_res;
13091326 }
13101327 // Get a new PUCCH resource for HARQ-ACK from the correct PUCCH resource set.
13111328 else {
@@ -1338,22 +1355,19 @@ pucch_allocator_impl::get_pucch_res_pre_multiplexing(slot_point
13381355 candidate_resources.sr_resource .emplace (pucch_grant{.type = pucch_grant_type::sr});
13391356 pucch_grant& sr_candidate_grant = candidate_resources.sr_resource .value ();
13401357
1341- // There is already a PUCCH resource for SR; if so, we use the info and configuration from this resource.
1342- if (ue_current_grants.pucch_grants .sr_resource .has_value ()) {
1343- sr_candidate_grant = ue_current_grants.pucch_grants .sr_resource .value ();
1344- }
1345- // Get the new resource from the resource manager; the UCI bits will be added later.
1346- else {
1347- // TODO: handle case in which the resource is already used by the same UE.
1348- const pucch_resource* sr_resource =
1349- resource_manager.reserve_sr_res_available (sl_tx, ue_current_grants.rnti , pucch_cfg);
1350- // Save the resources that have been generated; if at some point the allocation fails, we need to release them.
1351- resource_manager.set_new_resource_allocation (ue_current_grants.rnti , pucch_resource_usage::SR);
1352- if (sr_resource == nullptr ) {
1353- return std::nullopt ;
1354- }
1355- sr_candidate_grant.pucch_res_cfg = sr_resource;
1358+ // Get the resource from the resource manager; the UCI bits will be added later.
1359+ // NOTE: if the SR resource was already assigned to this UE, the resource manager will only return the PUCCH config
1360+ // that was reserved previously.
1361+ const pucch_resource* sr_resource =
1362+ resource_manager.reserve_sr_res_available (sl_tx, ue_current_grants.rnti , pucch_cfg);
1363+ // Save the resources that have been generated; if at some point the allocation fails, we need to release them.
1364+ resource_manager.set_new_resource_allocation (ue_current_grants.rnti , pucch_resource_usage::SR);
1365+ if (sr_resource == nullptr ) {
1366+ srsran_assertion_failure (" rnti={}: PUCCH SR resource previously reserved not available anymore" ,
1367+ ue_current_grants.rnti );
1368+ return std::nullopt ;
13561369 }
1370+ sr_candidate_grant.pucch_res_cfg = sr_resource;
13571371 // Only copy the SR bits, as at this stage we only need to consider the UCI bits assuming the resources still
13581372 // need to be multiplexed.
13591373 sr_candidate_grant.bits .harq_ack_nof_bits = 0U ;
@@ -1365,22 +1379,19 @@ pucch_allocator_impl::get_pucch_res_pre_multiplexing(slot_point
13651379 candidate_resources.csi_resource .emplace (pucch_grant{.type = pucch_grant_type::csi});
13661380 pucch_grant& csi_candidate_grant = candidate_resources.csi_resource .value ();
13671381
1368- // There is already a PUCCH resource for SR; if so, we use the info and configuration from this resource.
1369- if (ue_current_grants.pucch_grants .csi_resource .has_value ()) {
1370- csi_candidate_grant = ue_current_grants.pucch_grants .csi_resource .value ();
1371- }
1372- // Get the new resource from the resource manager; the UCI bits will be added later.
1373- else {
1374- // TODO: handle case in which the resource is already used by the same UE.
1375- const pucch_resource* csi_resource =
1376- resource_manager.reserve_csi_resource (sl_tx, ue_current_grants.rnti , ue_cell_cfg);
1377- // Save the resources that have been generated; if at some point the allocation fails, we need to release them.
1378- resource_manager.set_new_resource_allocation (ue_current_grants.rnti , pucch_resource_usage::CSI);
1379- if (csi_resource == nullptr ) {
1380- return std::nullopt ;
1381- }
1382- csi_candidate_grant.pucch_res_cfg = csi_resource;
1382+ // Get the resource from the resource manager; the UCI bits will be added later.
1383+ // NOTE: if the CSI resource was already assigned to this UE, the resource manager will only return the PUCCH config
1384+ // that was reserved previously.
1385+ const pucch_resource* csi_resource =
1386+ resource_manager.reserve_csi_resource (sl_tx, ue_current_grants.rnti , ue_cell_cfg);
1387+ // Save the resources that have been generated; if at some point the allocation fails, we need to release them.
1388+ resource_manager.set_new_resource_allocation (ue_current_grants.rnti , pucch_resource_usage::CSI);
1389+ if (csi_resource == nullptr ) {
1390+ srsran_assertion_failure (" rnti={}: PUCCH CSI resource previously reserved not available anymore" ,
1391+ ue_current_grants.rnti );
1392+ return std::nullopt ;
13831393 }
1394+ csi_candidate_grant.pucch_res_cfg = csi_resource;
13841395 // Only copy the HARQ-ACK bits, as at this stage we only need to consider the UCI bits assuming the resources still
13851396 // need to be multiplexed.
13861397 csi_candidate_grant.bits .harq_ack_nof_bits = 0U ;
0 commit comments