From a33735458873a77f03f833a89b3105065e863811 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 4 Mar 2025 16:41:58 +0100 Subject: [PATCH] Add function to compute slot for RA-RNTI --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 0b8bf3c03b..14b7951de3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -681,6 +681,27 @@ static uint8_t nr_get_msg3_tpc(uint32_t preamble_power) return 3; // it means 0dB } +static unsigned int get_slot_RA(const NR_ServingCellConfigCommon_t *scc, + const NR_RACH_ConfigCommon_t *rach_ConfigCommon, + const NR_MsgA_ConfigCommon_r16_t *msgacc, + frame_type_t frame_type, + int slot) +{ + uint8_t index = rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; + uint16_t prach_format = + get_nr_prach_format_from_index(index, scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA, frame_type); + unsigned int slot_RA; + if ((prach_format & 0xff) < 4) { + 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); + unsigned int slots_per_sf = (1 << mu); + slot_RA = slot / slots_per_sf; + } else { + slot_RA = slot; + } + return slot_RA; +} + void nr_initiate_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, @@ -723,35 +744,22 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->msg3_TPC = nr_get_msg3_tpc(preamble_power); NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - { - // 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; - } + // 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; + uint32_t slot_RA = get_slot_RA(scc, rach_ConfigCommon, msgacc, cc->frame_type, 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;