1919#include " srsran/ran/resource_allocation/ofdm_symbol_range.h"
2020#include " srsran/scheduler/result/sched_result.h"
2121#include " srsran/srslog/srslog.h"
22+ #include " srsran/support/srsran_assert.h"
2223#include < algorithm>
2324#include < array>
2425#include < variant>
@@ -1285,6 +1286,28 @@ pucch_allocator_impl::multiplex_and_allocate_pucch(cell_slot_resource_allocator&
12851286 return std::nullopt ;
12861287 }
12871288
1289+ // Reserve the resources needed for the multiplexed grants.
1290+ if (grants_to_tx.sr_resource .has_value ()) {
1291+ const auto * sr_res = guard.reserve_sr_resource ();
1292+ if (sr_res == nullptr ) {
1293+ logger.error (" rnti={}: the multiplexing of PUCCH resources for slot={} could not be completed. Cause: SR "
1294+ " resource not available" ,
1295+ current_grants.rnti ,
1296+ pucch_slot_alloc.slot );
1297+ return std::nullopt ;
1298+ }
1299+ }
1300+ if (grants_to_tx.csi_resource .has_value ()) {
1301+ const auto * csi_res = guard.reserve_csi_resource ();
1302+ if (csi_res == nullptr ) {
1303+ logger.error (" rnti={}: the multiplexing of PUCCH resources for slot={} could not be completed. Cause: CSI "
1304+ " resource not available" ,
1305+ current_grants.rnti ,
1306+ pucch_slot_alloc.slot );
1307+ return std::nullopt ;
1308+ }
1309+ }
1310+
12881311 // If the grants for the common PUCCH resource are provided, this PUCCH is allocated by the fallback scheduler.
12891312 if (common_grants.has_value ()) {
12901313 // At most 3 PUCCH resources with 2 grants each.
@@ -1374,12 +1397,9 @@ pucch_allocator_impl::get_pucch_res_pre_multiplexing(pucch_resource_manager::ue_
13741397 // Get the resource from the resource manager; the UCI bits will be added later.
13751398 // NOTE: if the SR resource was already assigned to this UE, the resource manager will only return the PUCCH
13761399 // config that was reserved previously.
1377- const pucch_resource* sr_resource = guard.reserve_sr_resource ();
1378- if (sr_resource == nullptr ) {
1379- srsran_assertion_failure (" rnti={}: PUCCH SR resource previously reserved not available anymore" ,
1380- ue_current_grants.rnti );
1381- return std::nullopt ;
1382- }
1400+ const pucch_resource* sr_resource = guard.peek_sr_resource ();
1401+ srsran_assert (
1402+ sr_resource != nullptr , " rnti={}: Peeking a PUCCH SR resource returned nullptr" , ue_current_grants.rnti );
13831403 sr_candidate_grant.set_res_config (*sr_resource);
13841404 // Only copy the SR bits, as at this stage we only need to consider the UCI bits assuming the resources still
13851405 // need to be multiplexed.
@@ -1395,12 +1415,9 @@ pucch_allocator_impl::get_pucch_res_pre_multiplexing(pucch_resource_manager::ue_
13951415 // Get the resource from the resource manager; the UCI bits will be added later.
13961416 // NOTE: if the CSI resource was already assigned to this UE, the resource manager will only return the PUCCH
13971417 // config that was reserved previously.
1398- const pucch_resource* csi_resource = guard.reserve_csi_resource ();
1399- if (csi_resource == nullptr ) {
1400- srsran_assertion_failure (" rnti={}: PUCCH CSI resource previously reserved not available anymore" ,
1401- ue_current_grants.rnti );
1402- return std::nullopt ;
1403- }
1418+ const pucch_resource* csi_resource = guard.peek_csi_resource ();
1419+ srsran_assert (
1420+ csi_resource != nullptr , " rnti={}: Peeking a PUCCH CSI resource returned nullptr" , ue_current_grants.rnti );
14041421 csi_candidate_grant.set_res_config (*csi_resource);
14051422 // Only copy the HARQ-ACK bits, as at this stage we only need to consider the UCI bits assuming the resources
14061423 // still need to be multiplexed.
0 commit comments