diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index e297c16c62..acccdc549e 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -701,51 +701,33 @@ uint16_t get_NCS(uint8_t index, uint16_t format0, uint8_t restricted_set_config) } } -//from 38.211 Table 6.3.3.2-1 -static const int16_t N_RA_RB[16] = {6, 3, 2, 24, 12, 6, 12, 6, 3, 24, 12, 6, 12, 6, 24, 12}; - +//from 38.211 Table 6.3.3.2-1 // 15 30 60 120 240 480 +static const unsigned int N_RA_RB[6][6] = {{12, 6, 3, -1, -1, -1}, + {24, 12, 6, -1, -1, -1}, + {-1, -1, 12, 6, -1, -1}, + {-1, -1, 24, 12, 3, 2}, + // L839 + {6, 3, 2, -1, -1, -1}, + {24, 12, 6, -1, -1, -1}}; /* Function to get number of RBs required for prach occasion based on * 38.211 Table 6.3.3.2-1 */ -int16_t get_N_RA_RB (int delta_f_RA_PRACH, int delta_f_PUSCH) +unsigned int get_N_RA_RB(const unsigned int delta_f_RA_PRACH, const unsigned int delta_f_PUSCH) { - int8_t index = 0; - switch(delta_f_RA_PRACH) { - case 0 : - index = 6; - if (delta_f_PUSCH == 0) - index += 0; - else if(delta_f_PUSCH == 1) - index += 1; - else - index += 2; - break; - case 1 : - index = 9; - if (delta_f_PUSCH == 0) - index += 0; - else if(delta_f_PUSCH == 1) - index += 1; - else - index += 2; - break; - case 2 : - index = 11; - if (delta_f_PUSCH == 2) - index += 0; - else - index += 1; - break; - case 3: - index = 13; - if (delta_f_PUSCH == 2) - index += 0; - else - index += 1; - break; - default : index = 10;/*30khz prach scs and 30khz pusch scs*/ - } - return N_RA_RB[index]; -} + DevAssert(delta_f_PUSCH < 6); + DevAssert(delta_f_RA_PRACH < 6); + unsigned int n_rb; + n_rb = N_RA_RB[delta_f_RA_PRACH][delta_f_PUSCH]; + DevAssert(n_rb != -1); + return n_rb; +} + +// frome Table 6.3.3.1-1 +unsigned int get_delta_f_RA_long(const unsigned int format) +{ + DevAssert(format < 4); + return (format == 3) ? 5 : 4; +} + // Table 6.3.3.2-2: Random access configurations for FR1 and paired spectrum/supplementary uplink // the column 5, (SFN_nbr is a bitmap where we set bit to '1' in the position of the subframe where the RACH can be sent. // E.g. in row 4, and column 5 we have set value 512 ('1000000000') which means RACH can be sent at subframe 9. diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 923585205a..a8483dda3d 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -262,7 +262,8 @@ uint16_t compute_pucch_prb_size(uint8_t format, float get_max_code_rate(NR_PUCCH_MaxCodeRate_t *maxCodeRate); int get_f3_dmrs_symbols(NR_PUCCH_Resource_t *pucchres, NR_PUCCH_Config_t *pucch_Config); -int16_t get_N_RA_RB (int delta_f_RA_PRACH,int delta_f_PUSCH); +unsigned int get_delta_f_RA_long(const unsigned int format); +unsigned int get_N_RA_RB(const unsigned int delta_f_RA_PRACH, const unsigned int delta_f_PUSCH); void find_period_offset_SR(const NR_SchedulingRequestResourceConfig_t *SchedulingReqRec, int *period, int *offset); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 79f6aadf64..dd826efb79 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -190,7 +190,7 @@ static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, NR_ServingCellConfigCommo int config_index = rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; const int64_t *prach_config_info_p = get_prach_config_info(mac->frequency_range, config_index, frame_type); int format = prach_config_info_p[0]; - cfg->prach_config.prach_sub_c_spacing = format == 3 ? 5 : 4; + cfg->prach_config.prach_sub_c_spacing = get_delta_f_RA_long(format); } cfg->prach_config.restricted_set_config = rach_ConfigCommon->restrictedSetConfig; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index b3174e3bd3..f43e32039f 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -76,9 +76,18 @@ void init_RA(NR_UE_MAC_INST_t *mac, fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; prach_resources->RA_PREAMBLE_BACKOFF = 0; - AssertFatal(nr_rach_ConfigCommon && nr_rach_ConfigCommon->msg1_SubcarrierSpacing, - "Cannot handle yet the scenario without msg1_SubcarrierSpacing (L839)\n"); - NR_SubcarrierSpacing_t prach_scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing; + NR_SubcarrierSpacing_t prach_scs; + int scs_for_pcmax; // for long prach the UL BWP SCS is used for calculating RA_PCMAX + if (nr_rach_ConfigCommon && nr_rach_ConfigCommon->msg1_SubcarrierSpacing) { + prach_scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing; + scs_for_pcmax = prach_scs; + } else { + const unsigned int index = rach_ConfigGeneric->prach_ConfigurationIndex; + const unsigned int unpaired = mac->phy_config.config_req.cell_config.frame_duplex_type; + const unsigned int format = get_format0(index, unpaired, mac->frequency_range); + prach_scs = get_delta_f_RA_long(format); + scs_for_pcmax = mac->current_UL_BWP->scs; + } int n_prbs = get_N_RA_RB(prach_scs, mac->current_UL_BWP->scs); int start_prb = rach_ConfigGeneric->msg1_FrequencyStart + mac->current_UL_BWP->BWPStart; // PRACH shall be as specified for QPSK modulated DFT-s-OFDM of equivalent RB allocation (38.101-1) @@ -89,8 +98,8 @@ void init_RA(NR_UE_MAC_INST_t *mac, mac->current_UL_BWP->channel_bandwidth, 2, false, - prach_scs, - cfg->carrier_config.dl_grid_size[prach_scs], + scs_for_pcmax, + cfg->carrier_config.dl_grid_size[scs_for_pcmax], true, n_prbs, start_prb);