From f88c47ba3ec561b16c8d7b9a211cb31516105e03 Mon Sep 17 00:00:00 2001 From: Roberto Rosca Date: Wed, 25 Sep 2024 09:28:04 +0300 Subject: [PATCH] Adding first layer timing advance - Added new structure to hold timing advance parameters - Made SIB19 related calculation to save to this struct - Modified in ra to get ta struct values --- executables/nr-ue.c | 2 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 13 ++++++++++--- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 9 +++++++++ openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 11 ++++------- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 49deb85456..993701fb11 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -156,7 +156,7 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, uint8_t UE_id) ue->if_inst = nr_ue_if_module_init(UE_id); ue->dci_thres = 0; ue->target_Nid_cell = -1; - ue->timing_advance = ue->frame_parms.samples_per_subframe * get_nrUE_params()->ntn_ta_common; + ue->timing_advance = ue->frame_parms.samples_per_subframe * 2 * get_nrUE_params()->ntn_ta_common; check_position(UE_id); // initialize all signal buffers diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index fb027c2083..7d9a1a40a1 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1775,16 +1775,23 @@ void nr_rrc_mac_config_req_sib19_r17(module_id_t module_id, NR_SIB19_r17_t *sib1 // ntn-Config-r17 deep copy into mac asn_copy(&asn_DEF_NR_NTN_Config_r17, (void **)&mac->sc_info.ntn_Config_r17, sib19_r17->ntn_Config_r17); + // populate ntn_ta structure from mac // if ephemerisInfo_r17 present in SIB19 if (mac->sc_info.ntn_Config_r17->ephemerisInfo_r17 && mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17 && (mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17->positionX_r17 != 0 || mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17->positionY_r17 != 0 || mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17->positionZ_r17 != 0)) { - get_nrUE_params()->ntn_ta_common = + mac->ntn_ta.N_UE_TA_adj = calculate_ue_sat_ta(get_position(module_id), mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17); } - - get_nrUE_params()->ntn_koffset = *mac->sc_info.ntn_Config_r17->cellSpecificKoffset_r17; + // if cellSpecificKoffset_r17 is present + if (sib19_r17->ntn_Config_r17->cellSpecificKoffset_r17) { + mac->ntn_ta.cell_specific_k_offset = *sib19_r17->ntn_Config_r17->cellSpecificKoffset_r17; + } + // Check if ta_Info_r17 is present and convert directly ta_Common_r17 (is in units of 4.072e-3 µs) + if (sib19_r17->ntn_Config_r17->ta_Info_r17) { + mac->ntn_ta.N_common_ta_adj = sib19_r17->ntn_Config_r17->ta_Info_r17->ta_Common_r17 * 4.072e-6; + } } static void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 51b9c29058..7c8f37175f 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -554,6 +554,13 @@ typedef struct { A_SEQUENCE_OF(si_schedinfo_config_t) si_SchedInfo_list; } si_schedInfo_t; +typedef struct ntn_timing_advance_components { +// N_common_ta_adj and N_UE_TA_adj are in ms +double N_common_ta_adj; +double N_UE_TA_adj; +long cell_specific_k_offset; +} ntn_timing_advance_componets_t; + /*!\brief Top level UE MAC structure */ typedef struct NR_UE_MAC_INST_s { module_id_t ue_id; @@ -623,6 +630,8 @@ typedef struct NR_UE_MAC_INST_s { int p_Max_alt; int n_ta_offset; // -1 not present, otherwise value to be applied + ntn_timing_advance_componets_t ntn_ta; + long pdsch_HARQ_ACK_Codebook; NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index dd98495fe0..98f1d7a9e8 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -40,16 +40,13 @@ #include #include "openair2/LAYER2/RLC/rlc.h" +#include "openair2/LAYER2/NR_MAC_UE/mac_defs.h" #include "nr-uesoftmodem.h" -static double get_ta_Common_ms(NR_NTN_Config_r17_t *ntn_Config_r17) +static double get_ta_Common_ms(const ntn_timing_advance_componets_t* ntn_ta) { - if (ntn_Config_r17 && ntn_Config_r17->ta_Info_r17) { - // ta_Common_r17 is in units of 4.072e-3 µs - return (ntn_Config_r17->ta_Info_r17->ta_Common_r17 * 4.072e-6 + get_nrUE_params()->ntn_ta_common) * 2; - } - return 0.0; + return (ntn_ta->N_common_ta_adj + ntn_ta->N_UE_TA_adj) * 2; } int16_t get_prach_tx_power(NR_UE_MAC_INST_t *mac) @@ -625,7 +622,7 @@ void nr_Msg3_transmitted(NR_UE_MAC_INST_t *mac, uint8_t CC_id, frame_t frameP, s { RA_config_t *ra = &mac->ra; NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon; - const double ta_Common_ms = get_ta_Common_ms(mac->sc_info.ntn_Config_r17); + const double ta_Common_ms = get_ta_Common_ms(&mac->ntn_ta); const int mu = mac->current_UL_BWP->scs; const int slots_per_ms = nr_slots_per_frame[mu] / 10;