diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index fed8b9e6d2..2c9a2b02c0 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -1755,6 +1755,27 @@ int get_nr_prach_occasion_info_from_index(uint8_t index, } } +uint16_t get_nr_prach_format_from_index(uint8_t index, uint32_t pointa, uint8_t unpaired) +{ + uint8_t format2 = 0xff; + uint16_t format; + if (pointa > 2016666) { // FR2 + if (table_6_3_3_2_4_prachConfig_Index[index][1] != -1) + format2 = (uint8_t)table_6_3_3_2_4_prachConfig_Index[index][1]; + format = ((uint8_t)table_6_3_3_2_4_prachConfig_Index[index][0]) | (format2 << 8); + } else { + if (unpaired) { + if (table_6_3_3_2_3_prachConfig_Index[index][1] != -1) + format2 = (uint8_t)table_6_3_3_2_3_prachConfig_Index[index][1]; + format = ((uint8_t)table_6_3_3_2_3_prachConfig_Index[index][0]) | (format2 << 8); + } else { + if (table_6_3_3_2_2_prachConfig_Index[index][1] != -1) + format2 = (uint8_t)table_6_3_3_2_2_prachConfig_Index[index][1]; + format = ((uint8_t)table_6_3_3_2_2_prachConfig_Index[index][0]) | (format2 << 8); + } + } + return format; +} int get_nr_prach_info_from_index(uint8_t index, int frame, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index a8483dda3d..dced6f465a 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -141,6 +141,8 @@ void find_aggregation_candidates(uint8_t *aggregation_level, const NR_SearchSpace_t *ss, int maxL); +uint16_t get_nr_prach_format_from_index(uint8_t index, uint32_t pointa, uint8_t unpaired); + int get_nr_prach_info_from_index(uint8_t index, int frame, int slot, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 08add418d0..846d344584 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -2956,10 +2956,16 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_fra nr_get_prach_resources(mac, 0, 0, &ra->prach_resources, ra->rach_ConfigDedicated); pdu->prach_config_pdu.ra_PreambleIndex = ra->ra_PreambleIndex; pdu->prach_config_pdu.prach_tx_power = get_prach_tx_power(mac); - mac->ra.ra_rnti = nr_get_ra_rnti(pdu->prach_config_pdu.prach_start_symbol, - pdu->prach_config_pdu.prach_slot, - pdu->prach_config_pdu.num_ra, - 0); + unsigned int slot_RA; + // 3GPP TS 38.321 Section 5.1.3 says t_id for RA-RNTI depends on mu as specified in clause 5.3.2 in TS 38.211 + // so mu = 0 for prach format < 4. + if (pdu->prach_config_pdu.prach_format < 4) { + unsigned int slots_per_sf = (1 << mac->current_UL_BWP->scs); + slot_RA = pdu->prach_config_pdu.prach_slot / slots_per_sf; + } else { + slot_RA = pdu->prach_config_pdu.prach_slot; + } + mac->ra.ra_rnti = nr_get_ra_rnti(pdu->prach_config_pdu.prach_start_symbol, slot_RA, pdu->prach_config_pdu.num_ra, 0); release_ul_config(pdu, false); nr_scheduled_response_t scheduled_response = {.ul_config = mac->ul_config_request + slotP, .mac = mac, @@ -3007,7 +3013,7 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_fra // Compute MsgB RNTI ra->MsgB_rnti = - nr_get_MsgB_rnti(prach_occasion_info_p->start_symbol, prach_occasion_info_p->slot, prach_occasion_info_p->fdm, 0); + nr_get_MsgB_rnti(prach_occasion_info_p->start_symbol, slot_RA, prach_occasion_info_p->fdm, 0); LOG_D(NR_MAC, "ra->ra_state %s\n", nrra_ue_text[ra->ra_state]); ra->ra_state = nrRA_WAIT_MSGB; ra->t_crnti = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index c6f64e2109..067eee42a1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -761,17 +761,37 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->preamble_index = preamble_index; ra->timing_offset = timing_offset; ra->msg3_TPC = nr_get_msg3_tpc(preamble_power); - uint8_t ul_carrier_id = 0; // 0 for NUL 1 for SUL - ra->RA_rnti = nr_get_ra_rnti(symbol, slotP, freq_index, ul_carrier_id); NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - if (scc->uplinkConfigCommon->initialUplinkBWP->ext1 && scc->uplinkConfigCommon->initialUplinkBWP->ext1->msgA_ConfigCommon_r16) { - ra->ra_type = RA_2_STEP; - ra->ra_state = nrRA_WAIT_MsgA_PUSCH; - ra->MsgB_rnti = nr_get_MsgB_rnti(symbol, slotP, freq_index, ul_carrier_id); - } else { - ra->ra_type = RA_4_STEP; - ra->ra_state = nrRA_Msg2; + { + // 3GPP TS 38.321 Section 5.1.3(a) says t_id for RA-RNTI depends on mu as specified in clause 5.3.2 in TS 38.211 + // so mu = 0 for prach format < 4. + NR_RACH_ConfigCommon_t *rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; + NR_MsgA_ConfigCommon_r16_t *msgacc = NULL; + if (scc->uplinkConfigCommon->initialUplinkBWP->ext1 && scc->uplinkConfigCommon->initialUplinkBWP->ext1->msgA_ConfigCommon_r16) + msgacc = scc->uplinkConfigCommon->initialUplinkBWP->ext1->msgA_ConfigCommon_r16->choice.setup; + const int ul_mu = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + const int mu = nr_get_prach_or_ul_mu(msgacc, rach_ConfigCommon, ul_mu); + uint8_t index = rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; + uint16_t prach_format = + get_nr_prach_format_from_index(index, scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA, cc->frame_type); + unsigned int slot_RA; + if ((prach_format & 0xff) < 4) { + unsigned int slots_per_sf = (1 << mu); + slot_RA = slotP / slots_per_sf; + } else { + slot_RA = slotP; + } + uint8_t ul_carrier_id = 0; // 0 for NUL 1 for SUL + ra->RA_rnti = nr_get_ra_rnti(symbol, slot_RA, freq_index, ul_carrier_id); + if (scc->uplinkConfigCommon->initialUplinkBWP->ext1 && scc->uplinkConfigCommon->initialUplinkBWP->ext1->msgA_ConfigCommon_r16) { + ra->ra_type = RA_2_STEP; + ra->ra_state = nrRA_WAIT_MsgA_PUSCH; + ra->MsgB_rnti = nr_get_MsgB_rnti(symbol, slot_RA, freq_index, ul_carrier_id); + } else { + ra->ra_type = RA_4_STEP; + ra->ra_state = nrRA_Msg2; + } } int index = ra - cc->ra;