From be618b069ed09fe7ccc19aebc9738dc4dd68bf74 Mon Sep 17 00:00:00 2001 From: Roberto Rosca Date: Mon, 18 Nov 2024 16:23:28 +0200 Subject: [PATCH] Added message-based communication between L2 and L1 regarding NTN configuration parameters --- executables/nr-ue.c | 30 +++++++-------- executables/position_interface.c | 21 ++++++++++ executables/position_interface.h | 21 ++++++++++ .../nfapi/public_inc/fapi_nr_ue_constants.h | 4 +- .../nfapi/public_inc/fapi_nr_ue_interface.h | 14 +++++++ openair1/PHY/INIT/nr_init_ue.c | 2 + openair1/PHY/defs_nr_UE.h | 8 ++++ openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 16 ++++++++ openair2/LAYER2/NR_MAC_UE/config_ue.c | 11 ++++-- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 35 +++++++++++------ openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 1 + openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 4 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 20 +++++----- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 38 ++++++++++++++----- .../gnb.sa.band66.fr1.25PRB.usrpx300.conf | 2 +- 15 files changed, 173 insertions(+), 54 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index a70e9edd4e..2536e90060 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -157,6 +157,9 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, uint8_t UE_id) ue->dci_thres = 0; ue->target_Nid_cell = -1; + ue->ntn_config_message = CALLOC(1, sizeof(*ue->ntn_config_message)); + ue->ntn_config_message->update = false; + config_position_coordinates(UE_id); // initialize all signal buffers init_nr_ue_signal(ue, nb_connected_gNB); @@ -826,13 +829,12 @@ void *UE_thread(void *arg) readFrame(UE, &tmp, true); } - double ntn_ta_common = GET_COMPLETE_TIME_ADVANCE_MS(mac); - int ntn_koffset = GET_NTN_UE_K_OFFSET(mac, 0); + double ntn_ta_common = 0; + int ntn_koffset = 0; - int duration_rx_to_tx = GET_DURATION_RX_TO_TX(mac); + int duration_rx_to_tx = NR_UE_CAPABILITY_SLOT_RX_TO_TX; int nr_slot_tx_offset = 0; bool update_ntn_system_information = false; - bool apply_duration_next_run = false; while (!oai_exit) { nr_slot_tx_offset = 0; @@ -945,17 +947,18 @@ void *UE_thread(void *arg) if (update_ntn_system_information) { update_ntn_system_information = false; - int ta_offset = UE->frame_parms.samples_per_subframe * (GET_COMPLETE_TIME_ADVANCE_MS(mac) - ntn_ta_common); + int ta_offset = UE->frame_parms.samples_per_subframe * (UE->ntn_config_message->ntn_config_params.ntn_total_time_advance_ms - ntn_ta_common); UE->timing_advance += ta_offset; - ntn_ta_common = GET_COMPLETE_TIME_ADVANCE_MS(mac); - ntn_koffset = GET_NTN_UE_K_OFFSET(mac, 0); + ntn_ta_common = UE->ntn_config_message->ntn_config_params.ntn_total_time_advance_ms; + ntn_koffset = UE->ntn_config_message->ntn_config_params.cell_specific_k_offset; timing_advance = ntn_koffset * (UE->frame_parms.samples_per_subframe >> mac->current_UL_BWP->scs); } - if (ntn_koffset != (GET_NTN_UE_K_OFFSET(mac, 0)) && ntn_ta_common != GET_COMPLETE_TIME_ADVANCE_MS(mac)) { + if (UE->ntn_config_message->update) { + UE->ntn_config_message->update = false; update_ntn_system_information = true; - nr_slot_tx_offset = mac->ntn_ta.cell_specific_k_offset % nb_slot_frame; + nr_slot_tx_offset = UE->ntn_config_message->ntn_config_params.cell_specific_k_offset % nb_slot_frame; } int slot_nr = absolute_slot % nb_slot_frame; @@ -1059,13 +1062,8 @@ void *UE_thread(void *arg) stream_status = STREAM_STATUS_SYNCED; tx_wait_for_dlsch[slot] = 0; // apply new duration next run to avoid thread dead lock - if (apply_duration_next_run) { - duration_rx_to_tx = GET_DURATION_RX_TO_TX(mac); - apply_duration_next_run = false; - } - - if (duration_rx_to_tx != GET_DURATION_RX_TO_TX(mac)) { - apply_duration_next_run = true; + if (update_ntn_system_information) { + duration_rx_to_tx = NR_UE_CAPABILITY_SLOT_RX_TO_TX + UE->ntn_config_message->ntn_config_params.cell_specific_k_offset; } } diff --git a/executables/position_interface.c b/executables/position_interface.c index 885859014d..4aecf16604 100644 --- a/executables/position_interface.c +++ b/executables/position_interface.c @@ -1,3 +1,24 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + #include "position_interface.h" extern uint16_t NB_UE_INST; diff --git a/executables/position_interface.h b/executables/position_interface.h index dce6656689..6fd80819e4 100644 --- a/executables/position_interface.h +++ b/executables/position_interface.h @@ -1,3 +1,24 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + #ifndef __POSITION_INTERFACE__H__ #define __POSITION_INTERFACE__H__ diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h index 1094e82fa7..37b661afb9 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h @@ -51,7 +51,9 @@ #define FAPI_NR_DL_CONFIG_TYPE_CSI_RS 0x06 #define FAPI_NR_DL_CONFIG_TYPE_CSI_IM 0x07 #define FAPI_NR_CONFIG_TA_COMMAND 0x08 -#define FAPI_NR_DL_CONFIG_TYPES 0x08 +#define FAPI_NR_DL_NTN_CONFIG_PARAMS 0x09 +#define FAPI_NR_DL_CONFIG_TYPES 0x09 + #define FAPI_NR_CCE_REG_MAPPING_TYPE_INTERLEAVED 0x01 #define FAPI_NR_CCE_REG_MAPPING_TYPE_NON_INTERLEAVED 0x02 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 d0d9fc9093..b8228778b6 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 @@ -555,6 +555,19 @@ typedef struct { bool is_rar; } fapi_nr_ta_command_pdu; +typedef struct { + // N_common_ta_adj represents common propagation delay received in SIB19 (ms) + double N_common_ta_adj; + // N_UE_TA_adj calculated propagation delay from UE and SAT (ms) + double N_UE_TA_adj; + // drift rate of common ta in µs/s + double ntn_ta_commondrift; + // cell scheduling offset expressed in terms of 15kHz SCS + long cell_specific_k_offset; + + double ntn_total_time_advance_ms; +} fapi_nr_dl_ntn_config_command_pdu; + typedef struct { uint8_t pdu_type; union { @@ -563,6 +576,7 @@ typedef struct { fapi_nr_dl_config_csirs_pdu csirs_config_pdu; fapi_nr_dl_config_csiim_pdu csiim_config_pdu; fapi_nr_ta_command_pdu ta_command_pdu; + fapi_nr_dl_ntn_config_command_pdu ntn_config_command_pdu; }; } fapi_nr_dl_config_request_pdu_t; diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 677401ae47..1c5be50f3f 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -338,6 +338,8 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) free_and_zero(ue->prs_vars[idx]); } + free_and_zero(ue->ntn_config_message); + sl_ue_free(ue); } diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index b5ef2b4c85..2db8530a99 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -322,6 +322,11 @@ typedef struct UE_NR_SCAN_INFO_s { int32_t freq_offset_Hz[3][10]; } UE_NR_SCAN_INFO_t; +typedef struct { + bool update; + fapi_nr_dl_ntn_config_command_pdu ntn_config_params; +} ntn_config_message_t; + /// Top-level PHY Data Structure for UE typedef struct PHY_VARS_NR_UE_s { /// \brief Module ID indicator for this instance @@ -532,6 +537,9 @@ typedef struct PHY_VARS_NR_UE_s { sl_nr_ue_phy_params_t SL_UE_PHY_PARAMS; Actor_t sync_actor; Actor_t dl_actors[NUM_DL_ACTORS]; + + ntn_config_message_t* ntn_config_message; + } PHY_VARS_NR_UE; typedef struct { diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index dc2db2d2ea..4ab9167c0a 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -326,6 +326,19 @@ static void configure_dlsch(NR_UE_DLSCH_t *dlsch0, } } +static void configure_ntn_params(PHY_VARS_NR_UE *ue, fapi_nr_dl_ntn_config_command_pdu* ntn_params_message) +{ + if (!ue->ntn_config_message) { + ue->ntn_config_message = CALLOC(1, sizeof(*ue->ntn_config_message)); + } + + ue->ntn_config_message->ntn_config_params.cell_specific_k_offset = ntn_params_message->cell_specific_k_offset; + ue->ntn_config_message->ntn_config_params.N_common_ta_adj = ntn_params_message->N_common_ta_adj; + ue->ntn_config_message->ntn_config_params.ntn_ta_commondrift = ntn_params_message->ntn_ta_commondrift; + ue->ntn_config_message->ntn_config_params.ntn_total_time_advance_ms = ntn_params_message->ntn_total_time_advance_ms; + ue->ntn_config_message->update = true; +} + static void configure_ta_command(PHY_VARS_NR_UE *ue, fapi_nr_ta_command_pdu *ta_command_pdu) { /* Time Alignment procedure @@ -451,6 +464,9 @@ static void nr_ue_scheduled_response_dl(NR_UE_MAC_INST_t *mac, case FAPI_NR_CONFIG_TA_COMMAND: configure_ta_command(phy, &pdu->ta_command_pdu); break; + case FAPI_NR_DL_NTN_CONFIG_PARAMS: + configure_ntn_params(phy, &pdu->ntn_config_command_pdu); + break; default: LOG_W(PHY, "unhandled dl pdu type %d \n", pdu->pdu_type); } diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 6edbb55914..95a08b113c 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1771,16 +1771,18 @@ static double calculate_ue_sat_ta(position_t *position_params, struct NR_Positio void nr_rrc_mac_config_req_sib19_r17(module_id_t module_id, NR_SIB19_r17_t *sib19_r17) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - struct NR_NTN_Config_r17 *ntn_Config_r17 = mac->sc_info.ntn_Config_r17; - + int ret = pthread_mutex_lock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); + // update ntn_Config_r17 with received values + struct NR_NTN_Config_r17 *ntn_Config_r17 = mac->sc_info.ntn_Config_r17; UPDATE_IE(ntn_Config_r17, sib19_r17->ntn_Config_r17, NR_NTN_Config_r17_t); // populate ntn_ta structure from mac // if ephemerisInfo_r17 present in SIB19 struct NR_EphemerisInfo_r17 *ephemeris_info = ntn_Config_r17->ephemerisInfo_r17; if (ephemeris_info) { - struct NR_PositionVelocity_r17 *position_velocity = ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17; + struct NR_PositionVelocity_r17 *position_velocity = ephemeris_info->choice.positionVelocity_r17; if (position_velocity && (position_velocity->positionX_r17 != 0 || position_velocity->positionY_r17 != 0 || position_velocity->positionZ_r17 != 0)) { @@ -1798,6 +1800,9 @@ void nr_rrc_mac_config_req_sib19_r17(module_id_t module_id, NR_SIB19_r17_t *sib1 if (ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17) mac->ntn_ta.ntn_ta_commondrift = *ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17 * 0.2e-3; } + mac->ntn_ta.ntn_params_changed = true; + ret = pthread_mutex_unlock(&mac->if_mutex); + AssertFatal(!ret, "mutex failed %d\n", ret); } 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 8f211e2215..55120dca96 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -554,14 +554,16 @@ typedef struct { } si_schedInfo_t; typedef struct ntn_timing_advance_components { -// N_common_ta_adj represents common propagation delay received in SIB19 (ms) -double N_common_ta_adj; -// N_UE_TA_adj calculated propagation delay from UE and SAT (ms) -double N_UE_TA_adj; -// drift rate of common ta in µs/s -double ntn_ta_commondrift; -// cell scheduling offset expressed in terms of 15kHz SCS -long cell_specific_k_offset; + // N_common_ta_adj represents common propagation delay received in SIB19 (ms) + double N_common_ta_adj; + // N_UE_TA_adj calculated propagation delay from UE and SAT (ms) + double N_UE_TA_adj; + // drift rate of common ta in µs/s + double ntn_ta_commondrift; + // cell scheduling offset expressed in terms of 15kHz SCS + long cell_specific_k_offset; + + bool ntn_params_changed; } ntn_timing_advance_componets_t; /*!\brief Top level UE MAC structure */ @@ -673,9 +675,20 @@ typedef struct NR_UE_MAC_INST_s { ue_mac_stats_t stats; } NR_UE_MAC_INST_t; -#define GET_NTN_UE_K_OFFSET(mac, scs) (mac->ntn_ta.cell_specific_k_offset << scs) -#define GET_COMPLETE_TIME_ADVANCE_MS(mac) ((mac)->ntn_ta.N_common_ta_adj + (mac)->ntn_ta.N_UE_TA_adj * 2) -#define GET_DURATION_RX_TO_TX(mac) (NR_UE_CAPABILITY_SLOT_RX_TO_TX + (mac)->ntn_ta.cell_specific_k_offset) +static inline int GET_NTN_UE_K_OFFSET(const ntn_timing_advance_componets_t *ntn_ta, int scs) +{ + return (int)ntn_ta->cell_specific_k_offset << scs; +} + +static inline double GET_COMPLETE_TIME_ADVANCE_MS(const ntn_timing_advance_componets_t *ntn_ta) +{ + return (ntn_ta->N_common_ta_adj + ntn_ta->N_UE_TA_adj) * 2; +} + +static inline long GET_DURATION_RX_TO_TX(const ntn_timing_advance_componets_t *ntn_ta) +{ + return NR_UE_CAPABILITY_SLOT_RX_TO_TX + ntn_ta->cell_specific_k_offset; +} /*@}*/ #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 064fcc4e78..10d982442f 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -70,6 +70,7 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac) mac->p_Max = INT_MIN; mac->p_Max_alt = INT_MIN; mac->n_ta_offset = -1; + mac->ntn_ta.ntn_params_changed = false; pthread_mutex_init(&mac->if_mutex, NULL); reset_mac_inst(mac); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 45b1cf6320..70e3019701 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -616,7 +616,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_COMPLETE_TIME_ADVANCE_MS(mac); + const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(&mac->ntn_ta); const int mu = mac->current_UL_BWP->scs; const int slots_per_ms = nr_slots_per_frame[mu] / 10; @@ -917,7 +917,7 @@ void nr_get_RA_window(NR_UE_MAC_INST_t *mac) NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP->rach_ConfigCommon; AssertFatal(&setup->rach_ConfigGeneric != NULL, "In %s: FATAL! rach_ConfigGeneric is NULL...\n", __FUNCTION__); - const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(mac); + const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(&mac->ntn_ta); const int mu = mac->current_DL_BWP->scs; const int slots_per_ms = nr_slots_per_frame[mu] / 10; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 3f1077bb9a..8a46ad9a25 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -499,7 +499,7 @@ static int nr_ue_process_dci_ul_00(NR_UE_MAC_INST_t *mac, frame_t frame_tx; int slot_tx; - const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, mac->current_UL_BWP->scs); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, mac->current_UL_BWP->scs); if (-1 == nr_ue_pusch_scheduler(mac, 0, frame, slot, &frame_tx, &slot_tx, tda_info.k2 + ntn_ue_koffset)) { LOG_E(MAC, "Cannot schedule PUSCH\n"); return -1; @@ -597,7 +597,7 @@ static int nr_ue_process_dci_ul_01(NR_UE_MAC_INST_t *mac, tda_info.k2 = csi_K2; } - const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, mac->current_UL_BWP->scs); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, mac->current_UL_BWP->scs); if (-1 == nr_ue_pusch_scheduler(mac, 0, frame, slot, &frame_tx, &slot_tx, tda_info.k2 + ntn_ue_koffset)) { LOG_E(MAC, "Cannot schedule PUSCH\n"); return -1; @@ -914,14 +914,14 @@ static int nr_ue_process_dci_dl_10(NR_UE_MAC_INST_t *mac, /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */ // according to TS 38.213 9.2.3 - const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, dlsch_pdu->SubcarrierSpacing); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, dlsch_pdu->SubcarrierSpacing); const uint16_t feedback_ti = 1 + dci->pdsch_to_harq_feedback_timing_indicator.val + ntn_ue_koffset; if (rnti_type != TYPE_RA_RNTI_ && rnti_type != TYPE_SI_RNTI_) { - AssertFatal(feedback_ti > GET_DURATION_RX_TO_TX(mac), + AssertFatal(feedback_ti > GET_DURATION_RX_TO_TX(&mac->ntn_ta), "PDSCH to HARQ feedback time (%d) needs to be higher than DURATION_RX_TO_TX (%ld).\n", feedback_ti, - GET_DURATION_RX_TO_TX(mac)); + GET_DURATION_RX_TO_TX(&mac->ntn_ta)); // set the harq status at MAC for feedback const int tpc[] = {-1, 0, 1, 3}; set_harq_status(mac, @@ -1259,14 +1259,14 @@ static int nr_ue_process_dci_dl_11(NR_UE_MAC_INST_t *mac, /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */ // according to TS 38.213 Table 9.2.3-1 - const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, dlsch_pdu->SubcarrierSpacing); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, dlsch_pdu->SubcarrierSpacing); const uint16_t feedback_ti = pucch_Config->dl_DataToUL_ACK->list.array[dci->pdsch_to_harq_feedback_timing_indicator.val][0] + ntn_ue_koffset; - AssertFatal(feedback_ti > GET_DURATION_RX_TO_TX(mac), + AssertFatal(feedback_ti > GET_DURATION_RX_TO_TX(&mac->ntn_ta), "PDSCH to HARQ feedback time (%d) needs to be higher than DURATION_RX_TO_TX (%ld). Min feedback time set in config " "file (min_rxtxtime).\n", feedback_ti, - GET_DURATION_RX_TO_TX(mac)); + GET_DURATION_RX_TO_TX(&mac->ntn_ta)); // set the harq status at MAC for feedback const int tpc[] = {-1, 0, 1, 3}; @@ -3446,7 +3446,7 @@ static void set_time_alignment(NR_UE_MAC_INST_t *mac, int ta, ta_type_t type, in ul_time_alignment->ta_command = ta; ul_time_alignment->ta_apply = type; - const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, mac->current_UL_BWP->scs); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, mac->current_UL_BWP->scs); const int n_slots_frame = nr_slots_per_frame[mac->current_UL_BWP->scs]; ul_time_alignment->frame = (frame + (slot + ntn_ue_koffset) / n_slots_frame) % MAX_FRAME_NUMBER; ul_time_alignment->slot = (slot + ntn_ue_koffset) % n_slots_frame; @@ -4101,7 +4101,7 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d LOG_E(MAC, "Cannot schedule Msg3. Something wrong in TDA information\n"); return; } - const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, mac->current_UL_BWP->scs); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, mac->current_UL_BWP->scs); ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2 + ntn_ue_koffset); // TA command diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 44bcedc435..8e4fbf7154 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -62,6 +62,8 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_frame_t slotP); static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UE_MAC_INST_t *mac); +static void schedule_ntn_config_command(fapi_nr_dl_config_request_t *dl_config, NR_UE_MAC_INST_t *mac); + static void nr_ue_fill_phr(NR_UE_MAC_INST_t *mac, NR_SINGLE_ENTRY_PHR_MAC_CE *phr, float P_CMAX, @@ -1266,9 +1268,9 @@ void nr_ue_aperiodic_srs_scheduling(NR_UE_MAC_INST_t *mac, long resource_trigger return; } - AssertFatal(slot_offset > GET_DURATION_RX_TO_TX(mac), + AssertFatal(slot_offset > GET_DURATION_RX_TO_TX(&mac->ntn_ta), "Slot offset between DCI and aperiodic SRS (%d) needs to be higher than DURATION_RX_TO_TX (%ld)\n", - slot_offset, GET_DURATION_RX_TO_TX(mac)); + slot_offset, GET_DURATION_RX_TO_TX(&mac->ntn_ta)); int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; int sched_slot = (slot + slot_offset) % n_slots_frame; NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->tdd_UL_DL_ConfigurationCommon; @@ -1368,6 +1370,11 @@ void nr_ue_dl_scheduler(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info if (mac->ul_time_alignment.ta_apply != no_ta) schedule_ta_command(dl_config, mac); + + if (mac->ntn_ta.ntn_params_changed) { + mac->ntn_ta.ntn_params_changed = false; + schedule_ntn_config_command(dl_config, mac); + } nr_scheduled_response_t scheduled_response = {.dl_config = dl_config, .module_id = mac->ue_id, @@ -1772,24 +1779,24 @@ int nr_ue_pusch_scheduler(const NR_UE_MAC_INST_t *mac, AssertFatal(1 == 0, "Invalid numerology %i\n", mu); } - AssertFatal((k2 + delta) > GET_DURATION_RX_TO_TX(mac), + AssertFatal((k2 + delta) > GET_DURATION_RX_TO_TX(&mac->ntn_ta), "Slot offset (%ld) for Msg3 needs to be higher than DURATION_RX_TO_TX (%ld). Please set min_rxtxtime at least to %ld in gNB config file or gNBs.[0].min_rxtxtime=%ld via command line.\n", k2, - GET_DURATION_RX_TO_TX(mac), - GET_DURATION_RX_TO_TX(mac), - GET_DURATION_RX_TO_TX(mac)); + GET_DURATION_RX_TO_TX(&mac->ntn_ta), + GET_DURATION_RX_TO_TX(&mac->ntn_ta), + GET_DURATION_RX_TO_TX(&mac->ntn_ta)); *slot_tx = (current_slot + k2 + delta) % nr_slots_per_frame[mu]; *frame_tx = (current_frame + (current_slot + k2 + delta) / nr_slots_per_frame[mu]) % MAX_FRAME_NUMBER; } else { - AssertFatal(k2 > GET_DURATION_RX_TO_TX(mac), + AssertFatal(k2 > GET_DURATION_RX_TO_TX(&mac->ntn_ta), "Slot offset K2 (%ld) needs to be higher than DURATION_RX_TO_TX (%ld). Please set min_rxtxtime at least to %ld in gNB config file or gNBs.[0].min_rxtxtime=%ld via command line.\n", k2, - GET_DURATION_RX_TO_TX(mac), - GET_DURATION_RX_TO_TX(mac), - GET_DURATION_RX_TO_TX(mac)); + GET_DURATION_RX_TO_TX(&mac->ntn_ta), + GET_DURATION_RX_TO_TX(&mac->ntn_ta), + GET_DURATION_RX_TO_TX(&mac->ntn_ta)); if (k2 < 0) { // This can happen when a false DCI is received LOG_W(PHY, "%d.%d. Received k2 %ld\n", current_frame, current_slot, k2); @@ -3591,6 +3598,17 @@ static uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac, return mac_ce_info.num_sdus > 0; // success if we got at least one sdu } +static void schedule_ntn_config_command(fapi_nr_dl_config_request_t *dl_config, NR_UE_MAC_INST_t *mac) +{ + 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->cell_specific_k_offset = mac->ntn_ta.cell_specific_k_offset; + ntn_config_command_pdu->N_common_ta_adj = mac->ntn_ta.N_common_ta_adj; + ntn_config_command_pdu->N_UE_TA_adj = mac->ntn_ta.N_UE_TA_adj; + ntn_config_command_pdu->ntn_total_time_advance_ms = (mac->ntn_ta.N_common_ta_adj + mac->ntn_ta.N_UE_TA_adj) * 2; + dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_NTN_CONFIG_PARAMS; + dl_config->number_pdus += 1; +} + static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UE_MAC_INST_t *mac) { NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &mac->ul_time_alignment; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf index ebf9279bbd..c8f0c31489 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf @@ -165,7 +165,7 @@ gNBs = #ntn_Config_r17 # cellSpecificKoffset_r17 = 478; # GEO satellite # cellSpecificKoffset_r17 = 40; # LEO satellite -# ta-Common-r17 = 29319745; +# ta-Common-r17 = 29314900; # positionX-r17 = 0; # positionY-r17 = 0; # positionZ-r17 = 32433846;