diff --git a/srsenb/hdr/stack/mac/scheduler_grid.h b/srsenb/hdr/stack/mac/scheduler_grid.h index 90ba9e8b1..4381b468d 100644 --- a/srsenb/hdr/stack/mac/scheduler_grid.h +++ b/srsenb/hdr/stack/mac/scheduler_grid.h @@ -221,6 +221,7 @@ public: }; struct pending_rar_t { uint16_t ra_rnti = 0; + uint32_t prach_tti = 0; uint32_t nof_grants = 0; sched_interface::dl_sched_rar_info_t msg3_grant[sched_interface::MAX_RAR_LIST]; }; diff --git a/srsenb/src/stack/mac/scheduler_carrier.cc b/srsenb/src/stack/mac/scheduler_carrier.cc index da2176886..e0b1a6926 100644 --- a/srsenb/src/stack/mac/scheduler_carrier.cc +++ b/srsenb/src/stack/mac/scheduler_carrier.cc @@ -151,7 +151,7 @@ void ra_sched::dl_sched(srsenb::sf_sched* tti_sched) while (not pending_rars.empty()) { sf_sched::pending_rar_t& rar = pending_rars.front(); - uint32_t prach_tti = rar.msg3_grant[0].prach_tti; + uint32_t prach_tti = rar.prach_tti; // Discard all RARs out of the window. The first one inside the window is scheduled, if we can't we exit if (not sched_utils::is_in_tti_interval(tti_tx_dl, prach_tti + 3, prach_tti + 3 + cfg->prach_rar_window)) { @@ -226,7 +226,6 @@ int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info) rar_info.temp_crnti, rar_info.ta_cmd, rar_info.msg3_size); - // RA-RNTI = 1 + t_id + f_id // t_id = index of first subframe specified by PRACH (0<=t_id<10) // f_id = index of the PRACH within subframe, in ascending order of freq domain (0<=f_id<6) (for FDD, f_id=0) @@ -234,7 +233,7 @@ int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info) // find pending rar with same RA-RNTI for (sf_sched::pending_rar_t& r : pending_rars) { - if (r.ra_rnti == ra_rnti) { + if (r.prach_tti == rar_info.prach_tti and ra_rnti == r.ra_rnti) { r.msg3_grant[r.nof_grants] = rar_info; r.nof_grants++; return SRSLTE_SUCCESS; @@ -244,6 +243,7 @@ int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info) // create new RAR sf_sched::pending_rar_t p; p.ra_rnti = ra_rnti; + p.prach_tti = rar_info.prach_tti; p.nof_grants = 1; p.msg3_grant[0] = rar_info; pending_rars.push_back(p); diff --git a/srsenb/src/stack/mac/scheduler_grid.cc b/srsenb/src/stack/mac/scheduler_grid.cc index fe567c3b3..fdd8e90f1 100644 --- a/srsenb/src/stack/mac/scheduler_grid.cc +++ b/srsenb/src/stack/mac/scheduler_grid.cc @@ -508,12 +508,11 @@ std::pair sf_sched::alloc_rar(uint32_t aggr_lvl, cons std::pair ret = {alloc_outcome_t::ERROR, 0}; for (uint32_t nof_grants = rar.nof_grants; nof_grants > 0; nof_grants--) { - uint32_t buf_rar = 7 * nof_grants + 1; // 1+6 bytes per RAR subheader+body and 1 byte for Backoff - uint32_t total_msg3_size = msg3_grant_size * nof_grants; - uint32_t msg3_prb_attempt = last_msg3_prb; + uint32_t buf_rar = 7 * nof_grants + 1; // 1+6 bytes per RAR subheader+body and 1 byte for Backoff + uint32_t total_msg3_size = msg3_grant_size * nof_grants; // check if there is enough space for Msg3, try again with a lower number of grants - if (msg3_prb_attempt + total_msg3_size > sched_params->cfg->cell.nof_prb - sched_params->cfg->nrb_pucch) { + if (last_msg3_prb + total_msg3_size > sched_params->cfg->cell.nof_prb - sched_params->cfg->nrb_pucch) { ret.first = alloc_outcome_t::RB_COLLISION; continue; } @@ -540,10 +539,10 @@ std::pair sf_sched::alloc_rar(uint32_t aggr_lvl, cons rar_grant.msg3_grant[i].data = rar.msg3_grant[i]; rar_grant.msg3_grant[i].grant.tpc_pusch = 3; rar_grant.msg3_grant[i].grant.trunc_mcs = 0; - uint32_t rba = srslte_ra_type2_to_riv(msg3_grant_size, msg3_prb_attempt, sched_params->cfg->cell.nof_prb); + uint32_t rba = srslte_ra_type2_to_riv(msg3_grant_size, last_msg3_prb, sched_params->cfg->cell.nof_prb); rar_grant.msg3_grant[i].grant.rba = rba; - msg3_prb_attempt += msg3_grant_size; + last_msg3_prb += msg3_grant_size; } rar_allocs.emplace_back(ret2.second, rar_grant);