diff --git a/CMakeLists.txt b/CMakeLists.txt index 681c727dfc..b7b245ab76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1942,6 +1942,7 @@ target_link_libraries(lte-softmodem PRIVATE target_link_libraries(lte-softmodem PRIVATE pthread m CONFIG_LIB rt sctp) target_link_libraries(lte-softmodem PRIVATE ${T_LIB}) target_link_libraries(lte-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) +target_link_libraries(lte-softmodem PRIVATE ${blas_LIBRARIES} ${cblas_LIBRARIES} ${lapacke_LIBRARIES} ${lapack_LIBRARIES}) if(E2_AGENT) target_compile_definitions(lte-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT) @@ -1997,6 +1998,7 @@ target_link_libraries(lte-uesoftmodem PRIVATE target_link_libraries(lte-uesoftmodem PRIVATE pthread m CONFIG_LIB rt sctp) target_link_libraries(lte-uesoftmodem PRIVATE ${T_LIB}) target_link_libraries(lte-uesoftmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) +target_link_libraries(lte-uesoftmodem PRIVATE ${blas_LIBRARIES} ${cblas_LIBRARIES} ${lapacke_LIBRARIES} ${lapack_LIBRARIES}) # force the generation of ASN.1 so that we don't need to wait during the build target_link_libraries(lte-uesoftmodem PRIVATE @@ -2217,6 +2219,7 @@ target_link_libraries(nr_pucchsim PRIVATE target_link_libraries(nr_pucchsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) add_executable(nr_dlsim + ${OPENAIR_DIR}/executables/position_interface.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c ${OPENAIR_DIR}/executables/softmodem-common.c @@ -2252,6 +2255,7 @@ target_link_libraries(nr_ulschsim PRIVATE target_link_libraries(nr_ulschsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) add_executable(nr_ulsim + ${OPENAIR_DIR}/executables/position_interface.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c ${OPENAIR_DIR}/executables/softmodem-common.c diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 7704d59a7d..a70e9edd4e 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -43,8 +43,6 @@ #include "common/utils/threadPool/notified_fifo.h" #include "position_interface.h" -extern unsigned int NTN_UE_Koffset; - /* * NR SLOT PROCESSING SEQUENCE * @@ -828,12 +826,13 @@ void *UE_thread(void *arg) readFrame(UE, &tmp, true); } - double ntn_ta_common = (mac->ntn_ta.N_common_ta_adj + mac->ntn_ta.N_UE_TA_adj) * 2; - int ntn_koffset = mac->ntn_ta.cell_specific_k_offset; + double ntn_ta_common = GET_COMPLETE_TIME_ADVANCE_MS(mac); + int ntn_koffset = GET_NTN_UE_K_OFFSET(mac, 0); - int duration_rx_to_tx = DURATION_RX_TO_TX; + int duration_rx_to_tx = GET_DURATION_RX_TO_TX(mac); 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; @@ -907,7 +906,7 @@ void *UE_thread(void *arg) openair0_write_reorder_clear_context(&UE->rfdevice); if (get_nrUE_params()->time_sync_I) // ntn_ta_commondrift is in µs/s, max_pos_acc * time_sync_I is in samples/frame - UE->max_pos_acc = get_nrUE_params()->ntn_ta_commondrift * 1e-6 * fp->samples_per_frame / get_nrUE_params()->time_sync_I; + UE->max_pos_acc = mac->ntn_ta.ntn_ta_commondrift * 1e-6 * fp->samples_per_frame / get_nrUE_params()->time_sync_I; else UE->max_pos_acc = 0; shiftForNextFrame = -(UE->init_sync_frame + trashed_frames + 2) * UE->max_pos_acc * get_nrUE_params()->time_sync_I; // compensate for the time drift that happened during initial sync @@ -946,17 +945,15 @@ void *UE_thread(void *arg) if (update_ntn_system_information) { update_ntn_system_information = false; - int ta_offset = - UE->frame_parms.samples_per_subframe * 2 * (mac->ntn_ta.N_common_ta_adj + mac->ntn_ta.N_UE_TA_adj - ntn_ta_common); + int ta_offset = UE->frame_parms.samples_per_subframe * (GET_COMPLETE_TIME_ADVANCE_MS(mac) - ntn_ta_common); UE->timing_advance += ta_offset; - timing_advance = ntn_koffset * 7680; - ntn_ta_common = mac->ntn_ta.N_common_ta_adj + mac->ntn_ta.N_UE_TA_adj; + ntn_ta_common = GET_COMPLETE_TIME_ADVANCE_MS(mac); + ntn_koffset = GET_NTN_UE_K_OFFSET(mac, 0); + timing_advance = ntn_koffset * (UE->frame_parms.samples_per_subframe >> mac->current_UL_BWP->scs); } - if (ntn_koffset != mac->ntn_ta.cell_specific_k_offset && ntn_ta_common != mac->ntn_ta.N_common_ta_adj) { - ntn_koffset = mac->ntn_ta.cell_specific_k_offset; - NTN_UE_Koffset = ntn_koffset; + if (ntn_koffset != (GET_NTN_UE_K_OFFSET(mac, 0)) && ntn_ta_common != GET_COMPLETE_TIME_ADVANCE_MS(mac)) { update_ntn_system_information = true; nr_slot_tx_offset = mac->ntn_ta.cell_specific_k_offset % nb_slot_frame; } @@ -1061,8 +1058,14 @@ void *UE_thread(void *arg) curMsgTx); stream_status = STREAM_STATUS_SYNCED; tx_wait_for_dlsch[slot] = 0; - if (duration_rx_to_tx != DURATION_RX_TO_TX) { - duration_rx_to_tx = DURATION_RX_TO_TX; + // 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; } } diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index ff8a7f7fa8..3d6a4ae0a8 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -129,9 +129,6 @@ int otg_enabled; double cpuf; uint32_t N_RB_DL = 106; -// NTN cellSpecificKoffset-r17, but in slots for DL SCS -unsigned int NTN_UE_Koffset = 0; - int create_tasks_nrue(uint32_t ue_nb) { LOG_D(NR_RRC, "%s(ue_nb:%d)\n", __FUNCTION__, ue_nb); itti_wait_ready(1); @@ -518,9 +515,6 @@ int main(int argc, char **argv) } } - // NTN cellSpecificKoffset-r17, but in slots for DL SCS - NTN_UE_Koffset = nrUE_params.ntn_koffset << PHY_vars_UE_g[0][0]->frame_parms.numerology_index; - init_openair0(); lock_memory_to_ram(); diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 40ff2075a5..74aa64affe 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -12,9 +12,6 @@ #define CONFIG_HLP_MAX_LDPC_ITERATIONS "Maximum LDPC decoder iterations\n" #define CONFIG_HLP_TIME_SYNC_P "coefficient for Proportional part of time sync PI controller\n" #define CONFIG_HLP_TIME_SYNC_I "coefficient for Integrating part of time sync PI controller\n" -#define CONFIG_HLP_NTN_KOFFSET "NTN cellSpecificKoffset-r17 (number of slots for a given subcarrier spacing of 15 kHz)\n" -#define CONFIG_HLP_NTN_TA_COMMON "NTN ta-Common, but given in ms\n" -#define CONFIG_HLP_NTN_TA_COMMONDRIFT "NTN ta-CommonDrift, but given in µs/s\n" #define CONFIG_HLP_AUTONOMOUS_TA "Autonomously update TA based on DL drift (useful if main contribution to DL drift is movement, e.g. LEO satellite)\n" #define CONFIG_HLP_AGC "Rx Gain control used for UE\n" @@ -67,9 +64,6 @@ {"num-ues", NULL, 0, .iptr=&(NB_UE_INST), .defuintval=1, TYPE_INT, 0}, \ {"time-sync-P", CONFIG_HLP_TIME_SYNC_P, 0, .dblptr=&(nrUE_params.time_sync_P), .defdblval=0.5, TYPE_DOUBLE, 0}, \ {"time-sync-I", CONFIG_HLP_TIME_SYNC_I, 0, .dblptr=&(nrUE_params.time_sync_I), .defdblval=0.0, TYPE_DOUBLE, 0}, \ - {"ntn-koffset", CONFIG_HLP_NTN_KOFFSET, 0, .uptr=&(nrUE_params.ntn_koffset), .defuintval=0, TYPE_UINT, 0}, \ - {"ntn-ta-common", CONFIG_HLP_NTN_TA_COMMON, 0, .dblptr=&(nrUE_params.ntn_ta_common), .defdblval=0.0, TYPE_DOUBLE, 0}, \ - {"ntn-ta-commondrift", CONFIG_HLP_NTN_TA_COMMONDRIFT, 0, .dblptr=&(nrUE_params.ntn_ta_commondrift), .defdblval=0.0, TYPE_DOUBLE, 0}, \ {"autonomous-ta", CONFIG_HLP_AUTONOMOUS_TA, PARAMFLAG_BOOL, .iptr=&(nrUE_params.autonomous_ta), .defintval=0, TYPE_INT, 0}, \ {"agc", CONFIG_HLP_AGC, PARAMFLAG_BOOL, .iptr=&(nrUE_params.agc), .defintval=0, TYPE_INT, 0}, \ } @@ -94,9 +88,6 @@ typedef struct { int ldpc_offload_flag; double time_sync_P; double time_sync_I; - unsigned int ntn_koffset; - double ntn_ta_common; - double ntn_ta_commondrift; int autonomous_ta; int agc; char *usrp_args; diff --git a/executables/position_interface.c b/executables/position_interface.c index c2cd0b09ca..885859014d 100644 --- a/executables/position_interface.c +++ b/executables/position_interface.c @@ -26,7 +26,7 @@ position_t *init_position_coordinates(char *sectionName) return position; } -position_t *get_position(int Mod_id) +position_t *get_position_coordinates(int Mod_id) { return positionArray[Mod_id]; } \ No newline at end of file diff --git a/executables/position_interface.h b/executables/position_interface.h index 7edda34970..dce6656689 100644 --- a/executables/position_interface.h +++ b/executables/position_interface.h @@ -34,5 +34,5 @@ typedef struct { void config_position_coordinates(int Mod_id); position_t *init_position_coordinates(char *sectionName); -position_t *get_position(int Mod_id); +position_t *get_position_coordinates(int Mod_id); #endif \ No newline at end of file diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index 24f1599873..27384532c5 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -276,20 +276,6 @@ /* - between reception of un uplink grant and its related transmission (k2) */ #define NR_UE_CAPABILITY_SLOT_RX_TO_TX (3) -/* When the OAI UE receives RX slot N, it starts sending TX slot N+DURATION_RX_TO_TX. - * Therefore DURATION_RX_TO_TX must not be larger than the minimum k1 and k2 values (NR_UE_CAPABILITY_SLOT_RX_TO_TX). - * In case of NTN, the propagation delay is so large, that the TX slot needs to be transmitted far in advance. - * Therefore, the NTN_UE_Koffset is added to DURATION_RX_TO_TX. - * - * Note: currently, the UE requires this to be a constant. - * But in case of NTN, Koffset is only known after receiving SIB19. - * Therefore, support should be added to allow changing DURATION_RX_TO_TX on reception of SIB19 (via FAPI-like interface). - * E.g. no transmission before successful reception of SIB19, and re-sync with disabled transmission if Koffset changes. - * When this has been implemented, the global variable NTN_UE_Koffset should be removed, too. - */ -extern unsigned int NTN_UE_Koffset; -#define DURATION_RX_TO_TX (NR_UE_CAPABILITY_SLOT_RX_TO_TX + NTN_UE_Koffset) - #define NR_MAX_ULSCH_HARQ_PROCESSES (NR_MAX_HARQ_PROCESSES) /* cf 38.214 6.1 UE procedure for receiving the physical uplink shared channel */ #define NR_MAX_DLSCH_HARQ_PROCESSES (NR_MAX_HARQ_PROCESSES) /* cf 38.214 5.1 UE procedure for receiving the physical downlink shared channel */ #endif @@ -317,6 +303,6 @@ typedef struct { #include "common/openairinterface5g_limits.h" #include "assertions.h" -#endif //__PHY_IMPLEMENTATION_DEFS_H__ -/**@} +#endif //__PHY_IMPLEMENTATION_DEFS_H__ +/**@} */ diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 1400548665..6edbb55914 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -33,7 +33,7 @@ #define _GNU_SOURCE #define SPEED_OF_LIGHT 299792458 -//#include "mac_defs.h" +#include "mac_defs.h" #include #include "NR_MAC_UE/mac_proto.h" #include "NR_MAC-CellGroupConfig.h" @@ -254,7 +254,7 @@ static void config_common_ue(NR_UE_MAC_INST_t *mac, mac->phy_config.Mod_id = mac->ue_id; mac->phy_config.CC_id = cc_idP; - + // carrier config LOG_D(MAC, "[UE %d] Entering UE Config Common\n", mac->ue_id); @@ -1771,28 +1771,32 @@ 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; - // 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); + // update ntn_Config_r17 with received values + 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 = mac->sc_info.ntn_Config_r17->ephemerisInfo_r17; - struct NR_PositionVelocity_r17 *position_velocity = mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17; - - if (ephemeris_info && position_velocity - && (position_velocity->positionX_r17 != 0 || position_velocity->positionY_r17 != 0 - || position_velocity->positionZ_r17 != 0)) { - 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); + 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; + if (position_velocity + && (position_velocity->positionX_r17 != 0 || position_velocity->positionY_r17 != 0 + || position_velocity->positionZ_r17 != 0)) { + mac->ntn_ta.N_UE_TA_adj = calculate_ue_sat_ta(get_position_coordinates(module_id), position_velocity); + } } // 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; + if (ntn_Config_r17->cellSpecificKoffset_r17) { + mac->ntn_ta.cell_specific_k_offset = *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; + if (ntn_Config_r17->ta_Info_r17) { + mac->ntn_ta.N_common_ta_adj = ntn_Config_r17->ta_Info_r17->ta_Common_r17 * 4.072e-6; + // ta_CommonDrift_r17 (is in units of 0.2e-3 µs/s) + 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; } } @@ -2638,4 +2642,4 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, ue_init_config_request(mac, mac->current_DL_BWP->scs); ret = pthread_mutex_unlock(&mac->if_mutex); AssertFatal(!ret, "mutex failed %d\n", ret); -} +} \ No newline at end of file diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 7c8f37175f..8f211e2215 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -485,7 +485,6 @@ typedef struct nr_lcordered_info_s { bool lc_SRMask; } nr_lcordered_info_t; - typedef struct { uint8_t payload[NR_CCCH_PAYLOAD_SIZE_MAX]; } __attribute__ ((__packed__)) NR_CCCH_PDU; @@ -555,9 +554,13 @@ typedef struct { } si_schedInfo_t; typedef struct ntn_timing_advance_components { -// N_common_ta_adj and N_UE_TA_adj are in ms +// 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; } ntn_timing_advance_componets_t; @@ -670,5 +673,9 @@ 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) + /*@}*/ #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index e30b69f6be..45b1cf6320 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -42,12 +42,6 @@ #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(const ntn_timing_advance_componets_t* ntn_ta) -{ - 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) { @@ -622,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_ta_Common_ms(&mac->ntn_ta); + const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(mac); const int mu = mac->current_UL_BWP->scs; const int slots_per_ms = nr_slots_per_frame[mu] / 10; @@ -923,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_ta_Common_ms(&mac->ntn_ta); + const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(mac); 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 5808cf3dcb..3f1077bb9a 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -147,13 +147,6 @@ static nr_dci_format_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, const uint8_t *dci_pdu, const int slot); -static int get_NTN_UE_Koffset(NR_NTN_Config_r17_t *ntn_Config_r17, int scs) -{ - if (ntn_Config_r17 && ntn_Config_r17->cellSpecificKoffset_r17) - return *ntn_Config_r17->cellSpecificKoffset_r17 << scs; - return 0; -} - int get_rnti_type(const NR_UE_MAC_INST_t *mac, const uint16_t rnti) { const RA_config_t *ra = &mac->ra; @@ -506,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_Koffset(mac->sc_info.ntn_Config_r17, mac->current_UL_BWP->scs); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, 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; @@ -604,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_Koffset(mac->sc_info.ntn_Config_r17, mac->current_UL_BWP->scs); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, 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; @@ -921,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_Koffset(mac->sc_info.ntn_Config_r17, dlsch_pdu->SubcarrierSpacing); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, 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 > DURATION_RX_TO_TX, - "PDSCH to HARQ feedback time (%d) needs to be higher than DURATION_RX_TO_TX (%d).\n", + AssertFatal(feedback_ti > GET_DURATION_RX_TO_TX(mac), + "PDSCH to HARQ feedback time (%d) needs to be higher than DURATION_RX_TO_TX (%ld).\n", feedback_ti, - DURATION_RX_TO_TX); + GET_DURATION_RX_TO_TX(mac)); // set the harq status at MAC for feedback const int tpc[] = {-1, 0, 1, 3}; set_harq_status(mac, @@ -1266,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_Koffset(mac->sc_info.ntn_Config_r17, dlsch_pdu->SubcarrierSpacing); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, 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 > DURATION_RX_TO_TX, - "PDSCH to HARQ feedback time (%d) needs to be higher than DURATION_RX_TO_TX (%d). Min feedback time set in config " + AssertFatal(feedback_ti > GET_DURATION_RX_TO_TX(mac), + "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, - DURATION_RX_TO_TX); + GET_DURATION_RX_TO_TX(mac)); // set the harq status at MAC for feedback const int tpc[] = {-1, 0, 1, 3}; @@ -3453,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_Koffset(mac->sc_info.ntn_Config_r17, mac->current_UL_BWP->scs); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, 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; @@ -4108,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_Koffset(mac->sc_info.ntn_Config_r17, mac->current_UL_BWP->scs); + const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, 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 0e9b26c773..44bcedc435 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1266,9 +1266,9 @@ void nr_ue_aperiodic_srs_scheduling(NR_UE_MAC_INST_t *mac, long resource_trigger return; } - AssertFatal(slot_offset > DURATION_RX_TO_TX, - "Slot offset between DCI and aperiodic SRS (%d) needs to be higher than DURATION_RX_TO_TX (%d)\n", - slot_offset, DURATION_RX_TO_TX); + AssertFatal(slot_offset > GET_DURATION_RX_TO_TX(mac), + "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)); 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; @@ -1732,7 +1732,7 @@ static uint8_t nr_locate_BsrIndexByBufferSize(const uint32_t *table, int size, i // PUSCH scheduler: // - Calculate the slot in which ULSCH should be scheduled. This is current slot + K2, // - where K2 is the offset between the slot in which UL DCI is received and the slot -// - in which ULSCH should be scheduled. K2 is configured in RRC configuration. +// - in which ULSCH should be scheduled. K2 is configured in RRC configuration. // PUSCH Msg3 scheduler: // - scheduled by RAR UL grant according to 8.3 of TS 38.213 // Note: Msg3 tx in the uplink symbols of mixed slot @@ -1772,24 +1772,24 @@ int nr_ue_pusch_scheduler(const NR_UE_MAC_INST_t *mac, AssertFatal(1 == 0, "Invalid numerology %i\n", mu); } - AssertFatal((k2 + delta) > DURATION_RX_TO_TX, - "Slot offset (%ld) for Msg3 needs to be higher than DURATION_RX_TO_TX (%d). Please set min_rxtxtime at least to %d in gNB config file or gNBs.[0].min_rxtxtime=%d via command line.\n", + AssertFatal((k2 + delta) > GET_DURATION_RX_TO_TX(mac), + "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, - DURATION_RX_TO_TX, - DURATION_RX_TO_TX, - DURATION_RX_TO_TX); + GET_DURATION_RX_TO_TX(mac), + GET_DURATION_RX_TO_TX(mac), + GET_DURATION_RX_TO_TX(mac)); *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 > DURATION_RX_TO_TX, - "Slot offset K2 (%ld) needs to be higher than DURATION_RX_TO_TX (%d). Please set min_rxtxtime at least to %d in gNB config file or gNBs.[0].min_rxtxtime=%d via command line.\n", + AssertFatal(k2 > GET_DURATION_RX_TO_TX(mac), + "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, - DURATION_RX_TO_TX, - DURATION_RX_TO_TX, - DURATION_RX_TO_TX); + GET_DURATION_RX_TO_TX(mac), + GET_DURATION_RX_TO_TX(mac), + GET_DURATION_RX_TO_TX(mac)); 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); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf index 955b7b1253..115104e8f1 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf @@ -10,5 +10,5 @@ nssai_sd=1; position0 = { x = 0.0; y = 0.0; - z = 6371400.0; + z = 6377900.0; } \ No newline at end of file