From 654fadb1168015197ba7d674bc5dc66acb39c47a Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 10 Sep 2025 14:23:50 +0200 Subject: [PATCH] NR UE: calculate the epoch_hfn whenever an ntn_Config_r17 is received --- .../open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h | 1 + openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 1 + openair2/LAYER2/NR_MAC_UE/config_ue.c | 10 ++++++++-- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 1 + openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index faebaffc6f..c6efc62876 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -562,6 +562,7 @@ typedef struct { } fapi_nr_ta_command_pdu; typedef struct { + int epoch_hfn; int epoch_sfn; int epoch_subframe; diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index a3e86ce433..793b5c1f42 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -95,6 +95,7 @@ static void configure_ntn_params(PHY_VARS_NR_UE *ue, fapi_nr_dl_ntn_config_comma ue->ntn_config_message = CALLOC(1, sizeof(*ue->ntn_config_message)); } + ue->ntn_config_message->ntn_config_params.epoch_hfn = ntn_params_message->epoch_hfn; ue->ntn_config_message->ntn_config_params.epoch_sfn = ntn_params_message->epoch_sfn; ue->ntn_config_message->ntn_config_params.epoch_subframe = ntn_params_message->epoch_subframe; ue->ntn_config_message->ntn_config_params.cell_specific_k_offset = ntn_params_message->cell_specific_k_offset; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index de488fe459..ee6a010cfa 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -318,6 +318,10 @@ static void configure_ntn_ta(module_id_t module_id, // epochTime_r17 must be present (this is assured by function `eval_epoch_time()`) const NR_EpochTime_r17_t *epoch_time_r17 = ntn_Config_r17->epochTime_r17; AssertFatal(epoch_time_r17, "epoch_time_r17 should not be NULL here\n"); + if (epoch_time_r17->sfn_r17 >= frame) + ntn_ta->epoch_hfn = hfn; + else + ntn_ta->epoch_hfn = hfn + 1; ntn_ta->epoch_sfn = epoch_time_r17->sfn_r17; ntn_ta->epoch_subframe = epoch_time_r17->subFrameNR_r17; @@ -368,9 +372,11 @@ static void configure_ntn_ta(module_id_t module_id, ntn_ta->ntn_params_changed = true; - LOG_D(NR_MAC, - "SIB19 Rxd. Epoch SFN: %d, Epoch Subframe: %d, k_offset: %ldms, N_Common_Ta: %fms, drift: %fµs/s, variant %fµs/s², " + LOG_I(NR_MAC, + "SIB19 Rxd. Epoch HFN: %d, Epoch SFN: %d, Epoch Subframe: %d, k_offset: %ldms, " + "N_Common_Ta: %fms, drift: %fµs/s, variant %fµs/s², " "N_UE_TA: %fms, drift: %fµs/s, variant %fµs/s²\n", + ntn_ta->epoch_hfn, ntn_ta->epoch_sfn, ntn_ta->epoch_subframe, ntn_ta->cell_specific_k_offset, diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index b43937d362..07721e0369 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -543,6 +543,7 @@ typedef struct { } si_schedInfo_t; typedef struct ntn_timing_advance_components { + int epoch_hfn; int epoch_sfn; int epoch_subframe; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index bd9ea09041..7397bdb89f 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -2849,6 +2849,7 @@ static void schedule_ntn_config_command(fapi_nr_dl_config_request_t *dl_config, { fapi_nr_dl_ntn_config_command_pdu *ntn_config_command_pdu = &dl_config->dl_config_list[dl_config->number_pdus].ntn_config_command_pdu; + ntn_config_command_pdu->epoch_hfn = mac->ntn_ta.epoch_hfn; ntn_config_command_pdu->epoch_sfn = mac->ntn_ta.epoch_sfn; ntn_config_command_pdu->epoch_subframe = mac->ntn_ta.epoch_subframe; ntn_config_command_pdu->cell_specific_k_offset = mac->ntn_ta.cell_specific_k_offset;