Commit 8ed99c28 authored by cig's avatar cig Committed by Thomas Schlichter

Fixes UE RA procedures:

- using NR RACH config common from scc
- fixed return type RA preamble target power functions
- retrieving PRACH format from PRACH resources
parent b5bb01d4
...@@ -224,12 +224,14 @@ typedef struct { ...@@ -224,12 +224,14 @@ typedef struct {
} NR_PRACH_CONFIG_COMMON; } NR_PRACH_CONFIG_COMMON;
typedef struct { typedef struct {
/// PRACH format retrieved from prach_ConfigIndex
uint16_t prach_format;
/// Preamble index for PRACH (0-63) /// Preamble index for PRACH (0-63)
uint8_t ra_PreambleIndex; uint8_t ra_PreambleIndex;
/// RACH MaskIndex /// RACH MaskIndex
uint8_t ra_RACH_MaskIndex; uint8_t ra_RACH_MaskIndex;
/// Target received power at eNB (-120 ... -82 dBm) /// Target received power at gNB. Baseline is range -202..-60 dBm. Depends on delta preamble, power ramping counter and step.
uint32_t ra_PREAMBLE_RECEIVED_TARGET_POWER; int ra_PREAMBLE_RECEIVED_TARGET_POWER;
/// PRACH index for TDD (0 ... 6) depending on TDD configuration and prachConfigIndex /// PRACH index for TDD (0 ... 6) depending on TDD configuration and prachConfigIndex
uint8_t ra_TDD_map_index; uint8_t ra_TDD_map_index;
/// RA Preamble Power Ramping Step in dB /// RA Preamble Power Ramping Step in dB
......
...@@ -117,8 +117,6 @@ typedef struct { ...@@ -117,8 +117,6 @@ typedef struct {
/* Random Access parameters */ /* Random Access parameters */
/// state of RA procedure /// state of RA procedure
RA_state_t ra_state; RA_state_t ra_state;
/// RACH ConfigCommon
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon;
/// RA-rnti /// RA-rnti
uint16_t ra_rnti; uint16_t ra_rnti;
/// Temporary CRNTI /// Temporary CRNTI
......
...@@ -185,17 +185,26 @@ int set_tdd_config_nr_ue(fapi_nr_config_request_t *cfg, int mu, ...@@ -185,17 +185,26 @@ int set_tdd_config_nr_ue(fapi_nr_config_request_t *cfg, int mu,
@param Mod_id Module id of UE @param Mod_id Module id of UE
@returns Po_NOMINAL_PUSCH (PREAMBLE_RECEIVED_TARGET_POWER+DELTA_PREAMBLE @returns Po_NOMINAL_PUSCH (PREAMBLE_RECEIVED_TARGET_POWER+DELTA_PREAMBLE
*/ */
int8_t nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t module_idP, uint8_t CC_id); int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t module_idP, uint8_t CC_id);
/** \brief Function to compute DELTA_PREAMBLE from 38.321 subclause 7.3 /** \brief Function to compute DELTA_PREAMBLE from 38.321 subclause 7.3
(for RA power ramping procedure and Msg3 PUSCH power control policy) (for RA power ramping procedure and Msg3 PUSCH power control policy)
@param Mod_id Module id of UE @param Mod_id Module id of UE
@returns DELTA_PREAMBLE @returns DELTA_PREAMBLE
*/ */
int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id); int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format);
/* Random Access */ /* Random Access */
/* \brief This function schedules the PRACH according to prach_ConfigurationIndex and TS 38.211 tables 6.3.3.2.x
and fills the PRACH PDU per each FD occasion.
@param module_idP Index of UE instance
@param frameP Frame index
@param slotP Slot index
@returns void
*/
void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP);
/* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It provides the timing advance and t-CRNTI. /* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It provides the timing advance and t-CRNTI.
@param Mod_id Index of UE instance @param Mod_id Index of UE instance
@param CC_id Index to a component carrier @param CC_id Index to a component carrier
......
...@@ -35,21 +35,16 @@ ...@@ -35,21 +35,16 @@
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
#include "LAYER2/NR_MAC_UE/mac_proto.h" #include "LAYER2/NR_MAC_UE/mac_proto.h"
// WIP todo:
//- frame_type and fr are hardcoded. Retireve from fp
/* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */ /* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */
int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format){
NR_UE_MAC_INST_t *nrUE_mac_inst = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = nrUE_mac_inst->nr_rach_ConfigCommon; NR_ServingCellConfigCommon_t *scc = mac->scc;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
AssertFatal(CC_id == 0, "Transmission on secondary CCs is not supported yet\n"); AssertFatal(CC_id == 0, "Transmission on secondary CCs is not supported yet\n");
uint8_t preambleFormat, prachConfigIndex; uint8_t prachConfigIndex, mu;
lte_frame_type_t frame_type = TDD;
nr_frequency_range_e fr = nr_FR1;
int mu;
// SCS configuration from msg1_SubcarrierSpacing and table 4.2-1 in TS 38.211 // SCS configuration from msg1_SubcarrierSpacing and table 4.2-1 in TS 38.211
...@@ -95,9 +90,8 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){ ...@@ -95,9 +90,8 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){
// Preamble formats given by prach_ConfigurationIndex and tables 6.3.3.2-2 and 6.3.3.2-2 in TS 38.211 // Preamble formats given by prach_ConfigurationIndex and tables 6.3.3.2-2 and 6.3.3.2-2 in TS 38.211
prachConfigIndex = nr_rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; prachConfigIndex = nr_rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex;
preambleFormat = get_nr_prach_fmt(prachConfigIndex,frame_type,fr);
switch (preambleFormat) { switch (prach_format) {
// long preamble formats // long preamble formats
case 0: case 0:
case 3: case 3:
...@@ -130,19 +124,25 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){ ...@@ -130,19 +124,25 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){
return 5 + 3*mu; return 5 + 3*mu;
default: default:
AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n", mod_id, preambleFormat, prachConfigIndex); AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n", mod_id, prach_format, prachConfigIndex);
} }
} }
/* TS 38.321 subclause 5.1.3 - RA preamble transmission - ra_PREAMBLE_RECEIVED_TARGET_POWER configuration */ /* TS 38.321 subclause 5.1.3 - RA preamble transmission - ra_PREAMBLE_RECEIVED_TARGET_POWER configuration */
int8_t nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id){ int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id){
NR_UE_MAC_INST_t *nr_UE_mac_inst = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = nr_UE_mac_inst->nr_rach_ConfigCommon; NR_ServingCellConfigCommon_t *scc = mac->scc;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
int8_t receivedTargerPower, delta_preamble;
long preambleReceivedTargetPower;
AssertFatal(nr_rach_ConfigCommon != NULL, "[UE %d] CCid %d FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id, CC_id); AssertFatal(nr_rach_ConfigCommon != NULL, "[UE %d] CCid %d FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id, CC_id);
int8_t receivedTargerPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower + nr_get_DELTA_PREAMBLE(mod_id, CC_id) + (nr_UE_mac_inst->RA_PREAMBLE_POWER_RAMPING_COUNTER - 1) * prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP; preambleReceivedTargetPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower;
delta_preamble = nr_get_DELTA_PREAMBLE(mod_id, CC_id, prach_resources->prach_format);
receivedTargerPower = preambleReceivedTargetPower + delta_preamble + (mac->RA_PREAMBLE_POWER_RAMPING_COUNTER - 1) * prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP;
return receivedTargerPower; return receivedTargerPower;
} }
\ No newline at end of file
...@@ -79,11 +79,14 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -79,11 +79,14 @@ void nr_get_prach_resources(module_id_t mod_id,
NR_RACH_ConfigDedicated_t * rach_ConfigDedicated){ NR_RACH_ConfigDedicated_t * rach_ConfigDedicated){
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
NR_ServingCellConfigCommon_t *scc = mac->scc;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon; NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon;
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric;
// NR_BeamFailureRecoveryConfig_t *beam_failure_recovery_config = &mac->RA_BeamFailureRecoveryConfig; // todo // NR_BeamFailureRecoveryConfig_t *beam_failure_recovery_config = &mac->RA_BeamFailureRecoveryConfig; // todo
int messagePowerOffsetGroupB, messageSizeGroupA, PLThreshold, sizeOfRA_PreamblesGroupA, numberOfRA_Preambles, i, deltaPreamble_Msg3; int messagePowerOffsetGroupB, messageSizeGroupA, PLThreshold, sizeOfRA_PreamblesGroupA, numberOfRA_Preambles, i, deltaPreamble_Msg3;
uint8_t noGroupB = 0, s_id, f_id, ul_carrier_id, msg1_FDM, prach_ConfigIndex, SFN_nbr, Msg3_size; uint8_t noGroupB = 0, s_id, f_id, ul_carrier_id, prach_ConfigIndex, SFN_nbr, Msg3_size;
// NR_RSRP_Range_t rsrp_ThresholdSSB; // todo // NR_RSRP_Range_t rsrp_ThresholdSSB; // todo
...@@ -116,9 +119,10 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -116,9 +119,10 @@ void nr_get_prach_resources(module_id_t mod_id,
// rsrp_ThresholdSSB = *nr_rach_ConfigCommon->rsrp_ThresholdSSB; // rsrp_ThresholdSSB = *nr_rach_ConfigCommon->rsrp_ThresholdSSB;
AssertFatal(mac->nr_rach_ConfigCommon != NULL, "[UE %d] FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id); AssertFatal(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup != NULL, "[UE %d] FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id);
nr_rach_ConfigCommon = mac->nr_rach_ConfigCommon; nr_rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
rach_ConfigGeneric = &nr_rach_ConfigCommon->rach_ConfigGeneric;
Msg3_size = mac->RA_Msg3_size; Msg3_size = mac->RA_Msg3_size;
numberOfRA_Preambles = *nr_rach_ConfigCommon->totalNumberOfRA_Preambles; numberOfRA_Preambles = *nr_rach_ConfigCommon->totalNumberOfRA_Preambles;
...@@ -202,7 +206,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -202,7 +206,7 @@ void nr_get_prach_resources(module_id_t mod_id,
deltaPreamble_Msg3 = mac->deltaPreamble_Msg3; deltaPreamble_Msg3 = mac->deltaPreamble_Msg3;
} }
PLThreshold = prach_resources->RA_PCMAX - nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower - deltaPreamble_Msg3 - messagePowerOffsetGroupB; PLThreshold = prach_resources->RA_PCMAX - rach_ConfigGeneric->preambleReceivedTargetPower - deltaPreamble_Msg3 - messagePowerOffsetGroupB;
/* Msg3 has not been transmitted yet */ /* Msg3 has not been transmitted yet */
if (first_Msg3 == 1) { if (first_Msg3 == 1) {
...@@ -254,24 +258,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -254,24 +258,7 @@ void nr_get_prach_resources(module_id_t mod_id,
// 1) this does not apply to contention-free RA Preamble for beam failure recovery request // 1) this does not apply to contention-free RA Preamble for beam failure recovery request
// 2) getting star_symb, SFN_nbr from table 6.3.3.2-3 (TDD and FR1 scenario) // 2) getting star_symb, SFN_nbr from table 6.3.3.2-3 (TDD and FR1 scenario)
switch (nr_rach_ConfigCommon->rach_ConfigGeneric.msg1_FDM){ // todo this is not used prach_ConfigIndex = rach_ConfigGeneric->prach_ConfigurationIndex;
case 0:
msg1_FDM = 1;
break;
case 1:
msg1_FDM = 2;
break;
case 2:
msg1_FDM = 4;
break;
case 3:
msg1_FDM = 8;
break;
default:
AssertFatal(1 == 0,"Unknown msg1_FDM %lu\n", nr_rach_ConfigCommon->rach_ConfigGeneric.msg1_FDM);
}
prach_ConfigIndex = nr_rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex;
// ra_RNTI computation // ra_RNTI computation
// - todo: this is for TDD FR1 only // - todo: this is for TDD FR1 only
...@@ -281,7 +268,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -281,7 +268,7 @@ void nr_get_prach_resources(module_id_t mod_id,
// - t_id is the first slot of the PRACH occasion in a system frame [0...80] // - t_id is the first slot of the PRACH occasion in a system frame [0...80]
ul_carrier_id = 0; // NUL ul_carrier_id = 0; // NUL
f_id = nr_rach_ConfigCommon->rach_ConfigGeneric.msg1_FrequencyStart; f_id = rach_ConfigGeneric->msg1_FrequencyStart;
SFN_nbr = table_6_3_3_2_3_prachConfig_Index[prach_ConfigIndex][4]; SFN_nbr = table_6_3_3_2_3_prachConfig_Index[prach_ConfigIndex][4];
s_id = table_6_3_3_2_3_prachConfig_Index[prach_ConfigIndex][5]; s_id = table_6_3_3_2_3_prachConfig_Index[prach_ConfigIndex][5];
...@@ -348,7 +335,9 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -348,7 +335,9 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
uint8_t lcid = UL_SCH_LCID_CCCH_MSG3, *mac_sdus, *payload, ra_ResponseWindow; uint8_t lcid = UL_SCH_LCID_CCCH_MSG3, *mac_sdus, *payload, ra_ResponseWindow;
uint16_t size_sdu = 0; uint16_t size_sdu = 0;
unsigned short post_padding; unsigned short post_padding;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (NR_RACH_ConfigCommon_t *) NULL; NR_ServingCellConfigCommon_t *scc = mac->scc;
NR_RACH_ConfigCommon_t *setup = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric;
// int32_t frame_diff = 0; // int32_t frame_diff = 0;
uint8_t sdu_lcids[NB_RB_MAX] = {0}; uint8_t sdu_lcids[NB_RB_MAX] = {0};
...@@ -361,11 +350,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -361,11 +350,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
LOG_D(MAC, "nr_ue_get_rach, RA_active value: %d", mac->RA_active); LOG_D(MAC, "nr_ue_get_rach, RA_active value: %d", mac->RA_active);
AssertFatal(mac->nr_rach_ConfigCommon != NULL, "[UE %d] FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id); AssertFatal(setup != NULL, "[UE %d] FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id);
if (mac->nr_rach_ConfigCommon != NULL) {
nr_rach_ConfigCommon = mac->nr_rach_ConfigCommon;
} else prach_resources = NULL;
if (mac->RA_active == 0) { if (mac->RA_active == 0) {
/* RA not active - checking if RRC is ready to initiate the RA procedure */ /* RA not active - checking if RRC is ready to initiate the RA procedure */
...@@ -375,7 +360,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -375,7 +360,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
mac->RA_RAPID_found = 0; mac->RA_RAPID_found = 0;
/* Set RA_PREAMBLE_POWER_RAMPING_STEP */ /* Set RA_PREAMBLE_POWER_RAMPING_STEP */
switch (nr_rach_ConfigCommon->rach_ConfigGeneric.powerRampingStep){ // in dB switch (rach_ConfigGeneric->powerRampingStep){ // in dB
case 0: case 0:
prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP = 0; prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP = 0;
break; break;
...@@ -444,7 +429,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -444,7 +429,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
mac->RA_active = 1; mac->RA_active = 1;
prach_resources->Msg3 = payload; prach_resources->Msg3 = payload;
ra_ResponseWindow = nr_rach_ConfigCommon->rach_ConfigGeneric.ra_ResponseWindow; ra_ResponseWindow = rach_ConfigGeneric->ra_ResponseWindow;
switch (ra_ResponseWindow) { switch (ra_ResponseWindow) {
case 0: case 0:
mac->RA_window_cnt = 1; mac->RA_window_cnt = 1;
...@@ -528,38 +513,38 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -528,38 +513,38 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
mac->RA_PREAMBLE_TRANSMISSION_COUNTER++; mac->RA_PREAMBLE_TRANSMISSION_COUNTER++;
preambleTransMax = -1; preambleTransMax = -1;
switch (nr_rach_ConfigCommon->rach_ConfigGeneric.preambleTransMax) { switch (rach_ConfigGeneric->preambleTransMax) {
case NR_RACH_ConfigGeneric__preambleTransMax_n3: case 0:
preambleTransMax = 3; preambleTransMax = 3;
break; break;
case NR_RACH_ConfigGeneric__preambleTransMax_n4: case 1:
preambleTransMax = 4; preambleTransMax = 4;
break; break;
case NR_RACH_ConfigGeneric__preambleTransMax_n5: case 2:
preambleTransMax = 5; preambleTransMax = 5;
break; break;
case NR_RACH_ConfigGeneric__preambleTransMax_n6: case 3:
preambleTransMax = 6; preambleTransMax = 6;
break; break;
case NR_RACH_ConfigGeneric__preambleTransMax_n7: case 4:
preambleTransMax = 7; preambleTransMax = 7;
break; break;
case NR_RACH_ConfigGeneric__preambleTransMax_n8: case 5:
preambleTransMax = 8; preambleTransMax = 8;
break; break;
case NR_RACH_ConfigGeneric__preambleTransMax_n10: case 6:
preambleTransMax = 10; preambleTransMax = 10;
break; break;
case NR_RACH_ConfigGeneric__preambleTransMax_n20: case 7:
preambleTransMax = 20; preambleTransMax = 20;
break; break;
case NR_RACH_ConfigGeneric__preambleTransMax_n50: case 8:
preambleTransMax = 50; preambleTransMax = 50;
break; break;
case NR_RACH_ConfigGeneric__preambleTransMax_n100: case 9:
preambleTransMax = 100; preambleTransMax = 100;
break; break;
case NR_RACH_ConfigGeneric__preambleTransMax_n200: case 10:
preambleTransMax = 200; preambleTransMax = 200;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment