From e0cdf278b5b5ce298c402433e771d8ffb2825232 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 17 Oct 2022 17:14:38 +0200 Subject: [PATCH] remove init_msg1 and sync_frame from prach structure --- .../PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c | 2 -- openair1/PHY/NR_UE_TRANSPORT/nr_prach.c | 4 ++-- openair1/PHY/defs_nr_common.h | 4 ---- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 17 ++--------------- openair1/SIMULATION/NR_PHY/prachsim.c | 1 - openair2/LAYER2/NR_MAC_UE/config_ue.c | 1 - openair2/LAYER2/NR_MAC_UE/mac_defs.h | 2 +- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 15 +++++++-------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 4 +++- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 5 +++-- 11 files changed, 19 insertions(+), 38 deletions(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c index 045197adc1..bbfd33b1fe 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c @@ -110,8 +110,6 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, //mac_resynch(); //dl_phy_sync_success(ue->Mod_id,frame,0,1);//ue->common_vars.eNb_id); ue->UE_mode[0] = PRACH; - ue->prach_resources[gNB_id]->sync_frame = frame; - ue->prach_resources[gNB_id]->init_msg1 = 0; } else { ue->UE_mode[0] = PUSCH; } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c index f56f01f764..95c410aa0b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c @@ -73,7 +73,6 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int frame, uint8_t int16_t Ncp = 0, amp, *prach, *prach2, *prachF, *Xu; int32_t Xu_re, Xu_im; int prach_start, prach_sequence_length, i, prach_len, dftlen, mu, kbar, K, n_ra_prb, k, prachStartSymbol, sample_offset_slot; - //int restricted_Type; fd_occasion = 0; prach_len = 0; @@ -96,7 +95,8 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int frame, uint8_t K = 24; k = 12*n_ra_prb - 6*fp->N_RB_UL; prachStartSymbol = prach_pdu->prach_start_symbol; - //restricted_Type = 0; + + LOG_D(PHY,"Generate NR PRACH %d.%d\n", frame, slot); compute_nr_prach_seq(nrUE_config->prach_config.prach_sequence_length, nrUE_config->prach_config.num_prach_fd_occasions_list[fd_occasion].num_root_sequences, diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 10c4c9df6d..a5ab87676e 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -230,10 +230,6 @@ typedef struct { int RA_PCMAX; /// Corresponding RA-RNTI for UL-grant uint16_t ra_RNTI; - /// Frame of last completed synch - uint16_t sync_frame; - /// Flag to indicate that prach is ready to start: it is enabled with an initial delay after the sync - uint8_t init_msg1; } NR_PRACH_RESOURCES_t; typedef struct { diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 697638f6cf..ca94fce44c 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -395,8 +395,6 @@ static void nr_ue_pbch_procedures(uint8_t gNB_id, if (ue->UE_mode[gNB_id] == NOT_SYNCHED && ue->no_timing_correction == 1){ if (get_softmodem_params()->do_ra) { ue->UE_mode[gNB_id] = PRACH; - ue->prach_resources[gNB_id]->sync_frame = frame_rx; - ue->prach_resources[gNB_id]->init_msg1 = 0; } else { ue->UE_mode[gNB_id] = PUSCH; } @@ -1458,19 +1456,8 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_IN); - if (ue->mac_enabled == 0){ - - prach_resources->ra_TDD_map_index = 0; - prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER = 10; - prach_resources->ra_RNTI = 0x1234; - nr_prach = 1; - prach_resources->init_msg1 = 1; - - } else { - - nr_prach = nr_ue_get_rach(prach_resources, &ue->prach_vars[0]->prach_pdu, mod_id, ue->CC_id, frame_tx, gNB_id, nr_slot_tx); - LOG_D(PHY, "In %s:[%d.%d] getting PRACH resources : %d\n", __FUNCTION__, frame_tx, nr_slot_tx,nr_prach); - } + nr_prach = nr_ue_get_rach(prach_resources, &ue->prach_vars[0]->prach_pdu, mod_id, ue->CC_id, frame_tx, gNB_id, nr_slot_tx); + LOG_D(PHY, "In %s:[%d.%d] getting PRACH resources : %d\n", __FUNCTION__, frame_tx, nr_slot_tx,nr_prach); if (nr_prach == GENERATE_PREAMBLE) { diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 7adb0d4b93..d0f3af4e60 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -718,7 +718,6 @@ int main(int argc, char **argv){ printf("raPreamble %d\n",preamble_tx); UE->prach_resources[0]->ra_PreambleIndex = preamble_tx; - UE->prach_resources[0]->init_msg1 = 1; // Configure channel bw = N_RB_UL*(180e3)*(1 << frame_parms->numerology_index); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 2804a9ec1e..909a0428d4 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -632,7 +632,6 @@ int nr_rrc_mac_config_req_ue( build_ssb_to_ro_map(mac);//->scc, mac->phy_config.config_req.cell_config.frame_duplex_type); if (!get_softmodem_params()->emulate_l1) mac->if_module->phy_config_request(&mac->phy_config); - mac->common_configuration_complete = 1; } if(scell_group_config != NULL ){ mac->cg = scell_group_config; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 51711e70f0..fb06cf749a 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -355,7 +355,7 @@ typedef struct { NR_CSI_ReportConfig_t *csirc; long physCellId; //// MAC config - int common_configuration_complete; + int first_sync_frame; NR_DRX_Config_t *drx_Config; NR_SchedulingRequestConfig_t *schedulingRequestConfig; NR_BSR_Config_t *bsr_Config; diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 524c3b3fcd..1e59782d21 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -52,12 +52,12 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { //init mac here nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t),NB_NR_UE_MAC_INST); + nr_ue_mac_inst->first_sync_frame = -1; for (int j=0;jscell_group_config) { nr_rrc_mac_config_req_ue(0,0,0,NULL,NULL,NULL,rrc_inst->scell_group_config); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 00117ec4ad..9833ccbe35 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -677,26 +677,25 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigDedicated_t *rach_ConfigDedicated = ra->rach_ConfigDedicated; // Delay init RA procedure to allow the convergence of the IIR filter on PRACH noise measurements at gNB side - if (!prach_resources->init_msg1) { - if ((mac->common_configuration_complete > 0 || get_softmodem_params()->do_ra || get_softmodem_params()->nsa) && - ((MAX_FRAME_NUMBER + frame - prach_resources->sync_frame) % MAX_FRAME_NUMBER) > 150) { - prach_resources->init_msg1 = 1; + if (ra->ra_state == RA_UE_IDLE) { + if ((mac->first_sync_frame > -1 || get_softmodem_params()->do_ra || get_softmodem_params()->nsa) && + ((MAX_FRAME_NUMBER + frame - mac->first_sync_frame) % MAX_FRAME_NUMBER) > 150) { + ra->ra_state = GENERATE_PREAMBLE; } else { - LOG_D(NR_MAC,"PRACH Condition not met: frame %d, prach_resources->sync_frame %d\n",frame,prach_resources->sync_frame); + LOG_D(NR_MAC,"PRACH Condition not met: ra state %d, frame %d, prach_resources->sync_frame %d\n", ra->ra_state, frame, mac->first_sync_frame); return 0; } } - LOG_D(NR_MAC, "In %s: [UE %d][%d.%d]: init_msg1 %d, ra_state %d, RA_active %d\n", + LOG_D(NR_MAC, "In %s: [UE %d][%d.%d]: ra_state %d, RA_active %d\n", __FUNCTION__, mod_id, frame, nr_slot_tx, - prach_resources->init_msg1, ra->ra_state, ra->RA_active); - if (prach_resources->init_msg1 && ra->ra_state != RA_SUCCEEDED) { + if (ra->ra_state > RA_UE_IDLE && ra->ra_state < RA_SUCCEEDED) { if (ra->RA_active == 0) { /* RA not active - checking if RRC is ready to initiate the RA procedure */ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index be4bc4b362..6b04441cb3 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -374,7 +374,7 @@ int8_t nr_ue_decode_mib(module_id_t module_id, else ssb_sc_offset_norm = ssb_subcarrier_offset; - if (mac->common_configuration_complete == 0) + if (mac->first_sync_frame == -1) nr_ue_sib1_scheduler(module_id, cc_id, ssb_start_symbol, @@ -394,6 +394,8 @@ int8_t nr_ue_decode_mib(module_id_t module_id, mac->dl_config_request.sfn = frame; mac->dl_config_request.slot = ssb_start_symbol/14; + if (mac->first_sync_frame == -1) + mac->first_sync_frame = frame; return 0; } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 7f6da1b915..21fa6176d4 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -2699,7 +2699,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s (int)slotP, &prach_occasion_info_p); - if (is_nr_prach_slot && ra->ra_state == RA_UE_IDLE) { + if (is_nr_prach_slot && ra->ra_state == GENERATE_PREAMBLE) { AssertFatal(NULL != prach_occasion_info_p,"PRACH Occasion Info not returned in a valid NR Prach Slot\n"); ra->generate_nr_prach = GENERATE_PREAMBLE; @@ -2733,7 +2733,8 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s prach_config_pdu->restricted_set = prach_config->restricted_set_config; prach_config_pdu->freq_msg1 = prach_config->num_prach_fd_occasions_list[prach_occasion_info_p->fdm].k1; - LOG_D(NR_MAC,"Selected RO Frame %u, Slot %u, Symbol %u, Fdm %u\n", frameP, prach_config_pdu->prach_slot, prach_config_pdu->prach_start_symbol, prach_config_pdu->num_ra); + LOG_D(NR_MAC,"PRACH scheduler: Selected RO Frame %u, Slot %u, Symbol %u, Fdm %u\n", + frameP, prach_config_pdu->prach_slot, prach_config_pdu->prach_start_symbol, prach_config_pdu->num_ra); // Search which SSB is mapped in the RO (among all the SSBs mapped to this RO) for (prach_config_pdu->ssb_nb_in_ro=0; prach_config_pdu->ssb_nb_in_ronb_mapped_ssb; prach_config_pdu->ssb_nb_in_ro++) {