diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 262f0b1631..047ef6c557 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -159,6 +159,9 @@ int oaisim_flag = 0; int emulate_rf = 0; uint32_t N_RB_DL = 106; +// NTN cellSpecificKoffset-r17, but in slots for DL SCS +unsigned int NTN_UE_Koffset = 0; + /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution */ @@ -591,6 +594,9 @@ 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/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 4fc91037b8..6a2c300b72 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -262,15 +262,15 @@ uint32_t get_slot_from_timestamp(openair0_timestamp timestamp_rx, const NR_DL_FR return slot_idx; } -uint32_t get_samples_slot_timestamp(int slot, const NR_DL_FRAME_PARMS *fp, uint8_t sl_ahead) +uint32_t get_samples_slot_timestamp(int slot, const NR_DL_FRAME_PARMS *fp, unsigned int sl_ahead) { uint32_t samp_count = 0; if(!sl_ahead) { - for(uint8_t idx_slot = 0; idx_slot < slot; idx_slot++) + for(unsigned int idx_slot = 0; idx_slot < slot; idx_slot++) samp_count += fp->get_samples_per_slot(idx_slot, fp); } else { - for(uint8_t idx_slot = slot; idx_slot < slot+sl_ahead; idx_slot++) + for(unsigned int idx_slot = slot; idx_slot < slot+sl_ahead; idx_slot++) samp_count += fp->get_samples_per_slot(idx_slot, fp); } return samp_count; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 3d0f2efa88..9c2dff22b8 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -135,7 +135,7 @@ typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; typedef uint32_t (*get_samples_per_slot_t)(int slot, const NR_DL_FRAME_PARMS *fp); typedef uint32_t (*get_slot_from_timestamp_t)(openair0_timestamp timestamp_rx, const NR_DL_FRAME_PARMS *fp); -typedef uint32_t (*get_samples_slot_timestamp_t)(int slot, const NR_DL_FRAME_PARMS *fp, uint8_t sl_ahead); +typedef uint32_t (*get_samples_slot_timestamp_t)(int slot, const NR_DL_FRAME_PARMS *fp, unsigned int sl_ahead); struct NR_DL_FRAME_PARMS { /// frequency range diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index c06cd13ff7..618a7e6c58 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -268,13 +268,24 @@ #define TDD_CONFIG_NB_FRAMES (2) #define NR_MAX_SLOTS_PER_FRAME (160) /* number of slots per frame */ -/* FFS_NR_TODO it defines ue capability which is the number of slots */ -/* - between reception of pdsch and tarnsmission of its acknowlegment */ -/* - between reception of un uplink grant and its related transmission */ -// should be 2 as per NR standard, but current UE is not able to perform this value +/* FFS_NR_TODO it defines ue capability which is the number of slots */ +/* - between reception of pdsch and transmission of its acknowlegment (k1) */ +/* - between reception of un uplink grant and its related transmission (k2) */ #define NR_UE_CAPABILITY_SLOT_RX_TO_TX (3) -#define DURATION_RX_TO_TX (NR_UE_CAPABILITY_SLOT_RX_TO_TX) +/* 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 */ diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 728163e049..d6be222a9b 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -95,6 +95,9 @@ nfapi_ue_release_request_body_t release_rntis; instance_t DUuniqInstance=0; instance_t CUuniqInstance=0; +// NTN cellSpecificKoffset-r17, but in slots for DL SCS +unsigned int NTN_UE_Koffset = 0; + void nr_derive_key_ng_ran_star(uint16_t pci, uint64_t nr_arfcn_dl, const uint8_t key[32], uint8_t *key_ng_ran_star) { } diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 822153fd14..e0cf501e96 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -93,6 +93,9 @@ nfapi_ue_release_request_body_t release_rntis; instance_t DUuniqInstance=0; instance_t CUuniqInstance=0; +// NTN cellSpecificKoffset-r17, but in slots for DL SCS +unsigned int NTN_UE_Koffset = 0; + void nr_derive_key_ng_ran_star(uint16_t pci, uint64_t nr_arfcn_dl, const uint8_t key[32], uint8_t *key_ng_ran_star) { }