From 3e70405b582609c9d595c703eb0e5b0c1bda972d Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 9 Apr 2020 16:39:44 +0200 Subject: [PATCH 01/42] Cleanup transport_proto header --- executables/nr-gnb.c | 2 +- executables/nr-ru.c | 2 +- openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/INIT/nr_init_ru.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 1 + openair1/PHY/NR_TRANSPORT/nr_prach.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_pss.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_sss.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_transport.h | 116 ---------------- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 128 ++++++++++++++++-- openair1/SCHED_NR/nr_prach_procedures.c | 2 +- openair1/SIMULATION/NR_PHY/dlschsim.c | 2 +- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 2 +- openair1/SIMULATION/NR_PHY/prachsim.c | 2 +- openair1/SIMULATION/NR_PHY/pucchsim.c | 2 +- openair1/SIMULATION/NR_PHY/ulschsim.c | 2 +- 18 files changed, 129 insertions(+), 146 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 8121332ac7..f457db5c02 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -47,7 +47,7 @@ #include "SCHED/sched_eNB.h" #include "SCHED_NR/sched_nr.h" #include "SCHED_NR/fapi_nr_l1.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 105b6b849a..3dd367d505 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -68,7 +68,7 @@ #include "PHY/defs_nr_common.h" #include "PHY/phy_extern.h" #include "PHY/LTE_TRANSPORT/transport_proto.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/INIT/phy_init.h" #include "SCHED/sched_eNB.h" #include "SCHED_NR/sched_nr.h" diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 62fb89aebb..74f3aa2d04 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -25,7 +25,7 @@ #include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/INIT/phy_init.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_transport_proto_common.h" /*#include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c index 60921da1cb..ead2538e75 100644 --- a/openair1/PHY/INIT/nr_init_ru.c +++ b/openair1/PHY/INIT/nr_init_ru.c @@ -22,7 +22,7 @@ #include "phy_init.h" #include "SCHED/sched_common.h" #include "PHY/phy_extern.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "SIMULATION/TOOLS/sim.h" /*#include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 065e62a2cb..94ac937bba 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -36,7 +36,7 @@ #include "PHY/CODING/coding_defs.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "PHY/CODING/nrLDPC_extern.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index b6a4787193..923e920321 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -32,6 +32,7 @@ */ #include "PHY/defs_gNB.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_transport.h" #include "PHY/LTE_REFSIG/lte_refsig.h" #include "PHY/sse_intrin.h" diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c index 2a29d16e0c..c856d29f3c 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c @@ -31,7 +31,7 @@ */ #include "PHY/defs_gNB.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_transport_proto_common.h" extern uint16_t prach_root_sequence_map_0_3[838]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_pss.c b/openair1/PHY/NR_TRANSPORT/nr_pss.c index be9e011e60..535ce99143 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pss.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pss.c @@ -20,7 +20,7 @@ */ -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" //#define NR_PSS_DEBUG diff --git a/openair1/PHY/NR_TRANSPORT/nr_sss.c b/openair1/PHY/NR_TRANSPORT/nr_sss.c index 7d8b551d7c..de92237f6c 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_sss.c +++ b/openair1/PHY/NR_TRANSPORT/nr_sss.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" //#define NR_SSS_DEBUG diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport.h b/openair1/PHY/NR_TRANSPORT/nr_transport.h index 157e309228..9597de10a7 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport.h @@ -22,122 +22,6 @@ #ifndef __NR_TRANSPORT__H__ #define __NR_TRANSPORT__H__ -#include "PHY/defs_gNB.h" -#include "LAYER2/NR_MAC_gNB/mac_proto.h" - #define NR_PBCH_PDU_BITS 24 -/*! -\fn int nr_generate_pss -\brief Generation of the NR PSS -@param -@returns 0 on success - */ -int nr_generate_pss( int16_t *d_pss, - int32_t *txdataF, - int16_t amp, - uint8_t ssb_start_symbol, - nfapi_nr_config_request_scf_t *config, - NR_DL_FRAME_PARMS *frame_parms); - -/*! -\fn int nr_generate_sss -\brief Generation of the NR SSS -@param -@returns 0 on success - */ -int nr_generate_sss( int16_t *d_sss, - int32_t *txdataF, - int16_t amp, - uint8_t ssb_start_symbol, - nfapi_nr_config_request_scf_t *config, - NR_DL_FRAME_PARMS *frame_parms); - -/*! -\fn int nr_generate_pbch_dmrs -\brief Generation of the DMRS for the PBCH -@param -@returns 0 on success - */ -int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, - int32_t *txdataF, - int16_t amp, - uint8_t ssb_start_symbol, - nfapi_nr_config_request_scf_t *config, - NR_DL_FRAME_PARMS *frame_parms); - -/*! -\fn int nr_pbch_scrambling -\brief PBCH scrambling function -@param - */ -void nr_pbch_scrambling(NR_gNB_PBCH *pbch, - uint32_t Nid, - uint8_t nushift, - uint16_t M, - uint16_t length, - uint8_t encoded, - uint32_t unscrambling_mask); - -/*! -\fn int nr_generate_pbch -\brief Generation of the PBCH -@param -@returns 0 on success - */ -int nr_generate_pbch(NR_gNB_PBCH *pbch, - nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, - uint8_t *interleaver, - int32_t *txdataF, - int16_t amp, - uint8_t ssb_start_symbol, - uint8_t n_hf, - int sfn, - nfapi_nr_config_request_scf_t *config, - NR_DL_FRAME_PARMS *frame_parms); - -/*! -\fn int nr_generate_pbch -\brief PBCH interleaving function -@param bit index i of the input payload -@returns the bit index of the output - */ -void nr_init_pbch_interleaver(uint8_t *interleaver); - -NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, - unsigned char Kmimo, - unsigned char Mdlharq, - uint32_t Nsoft, - uint8_t abstraction_flag, - uint16_t N_RB); - -void rx_nr_prach(PHY_VARS_gNB *gNB, - nfapi_nr_prach_pdu_t *prach_pdu, - int frame, - int subframe, - uint16_t *max_preamble, - uint16_t *max_preamble_energy, - uint16_t *max_preamble_delay - ); - -void rx_nr_prach_ru(RU_t *ru, - int prach_fmt, - int numRA, - int prachStartSymbol, - int frame, - int subframe); - -void nr_fill_prach_ru(RU_t *ru, - int SFN, - int Slot, - nfapi_nr_prach_pdu_t *prach_pdu); - -int16_t find_nr_prach(PHY_VARS_gNB *gNB,int frame,int slot, int numRA, find_type_t type); -int16_t find_nr_prach_ru(RU_t *ru,int frame,int slot, find_type_t type); - -void init_prach_list(PHY_VARS_gNB *gNB); -void init_prach_ru_list(RU_t *ru); -void free_nr_ru_prach_entry(RU_t *ru, - int prach_id); - #endif /*__NR_TRANSPORT__H__*/ diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index c279a5ba44..26fc190662 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -31,6 +31,92 @@ */ #include "PHY/defs_nr_common.h" +#include "PHY/defs_gNB.h" +#include "LAYER2/NR_MAC_gNB/mac_proto.h" + +/*! +\fn int nr_generate_pss +\brief Generation of the NR PSS +@param +@returns 0 on success + */ +int nr_generate_pss(int16_t *d_pss, + int32_t *txdataF, + int16_t amp, + uint8_t ssb_start_symbol, + nfapi_nr_config_request_scf_t *config, + NR_DL_FRAME_PARMS *frame_parms); + +/*! +\fn int nr_generate_sss +\brief Generation of the NR SSS +@param +@returns 0 on success + */ +int nr_generate_sss(int16_t *d_sss, + int32_t *txdataF, + int16_t amp, + uint8_t ssb_start_symbol, + nfapi_nr_config_request_scf_t *config, + NR_DL_FRAME_PARMS *frame_parms); + +/*! +\fn int nr_generate_pbch_dmrs +\brief Generation of the DMRS for the PBCH +@param +@returns 0 on success + */ +int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, + int32_t *txdataF, + int16_t amp, + uint8_t ssb_start_symbol, + nfapi_nr_config_request_scf_t *config, + NR_DL_FRAME_PARMS *frame_parms); + +/*! +\fn int nr_pbch_scrambling +\brief PBCH scrambling function +@param + */ +void nr_pbch_scrambling(NR_gNB_PBCH *pbch, + uint32_t Nid, + uint8_t nushift, + uint16_t M, + uint16_t length, + uint8_t encoded, + uint32_t unscrambling_mask); + +/*! +\fn int nr_generate_pbch +\brief Generation of the PBCH +@param +@returns 0 on success + */ +int nr_generate_pbch(NR_gNB_PBCH *pbch, + nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, + uint8_t *interleaver, + int32_t *txdataF, + int16_t amp, + uint8_t ssb_start_symbol, + uint8_t n_hf, + int sfn, + nfapi_nr_config_request_scf_t *config, + NR_DL_FRAME_PARMS *frame_parms); + +/*! +\fn int nr_generate_pbch +\brief PBCH interleaving function +@param bit index i of the input payload +@returns the bit index of the output + */ +void nr_init_pbch_interleaver(uint8_t *interleaver); + +NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, + unsigned char Kmimo, + unsigned char Mdlharq, + uint32_t Nsoft, + uint8_t abstraction_flag, + uint16_t N_RB); /** \brief This function is the top-level entry point to PUSCH demodulation, after frequency-domain transformation and channel estimation. It performs - RB extraction (signal and channel estimates) @@ -53,7 +139,6 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, unsigned char symbol, unsigned char harq_pid); - /** \brief This function performs RB extraction (signal and channel estimates) (currently signal only until channel estimation and compensation are implemented) @param rxdataF pointer to the received frequency domain signal @param rxdataF_ext pointer to the extracted frequency domain signal @@ -62,9 +147,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, @param start_rb The starting RB in the RB allocation (used for Resource Allocation Type 1 in NR) @param nb_rb_pusch The number of RBs allocated (used for Resource Allocation Type 1 in NR) @param frame_parms, Pointer to frame descriptor structure - */ - void nr_ulsch_extract_rbs_single(int32_t **rxdataF, NR_gNB_PUSCH *pusch_vars, unsigned char symbol, @@ -80,7 +163,6 @@ void nr_ulsch_scale_channel(int32_t **ul_ch_estimates_ext, uint16_t nb_rb, pusch_dmrs_type_t pusch_dmrs_type); - /** \brief This function computes the average channel level over all allocated RBs and antennas (TX/RX) in order to compute output shift for compensated signal @param ul_ch_estimates_ext Channel estimates in allocated RBs @param frame_parms Pointer to frame descriptor @@ -95,7 +177,6 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext, uint32_t len, unsigned short nb_rb); - /** \brief This function performs channel compensation (matched filtering) on the received RBs for this allocation. In addition, it computes the squared-magnitude of the channel with weightings for 16QAM/64QAM detection as well as dual-stream detection (cross-correlation) @param rxdataF_ext Frequency-domain received signal in RBs to be demodulated @param ul_ch_estimates_ext Frequency-domain channel estimates in RBs to be demodulated @@ -206,16 +287,33 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); void nr_fill_prach(PHY_VARS_gNB *gNB, - int SFN, - int Slot, - nfapi_nr_prach_pdu_t *prach_pdu); + int SFN, + int Slot, + nfapi_nr_prach_pdu_t *prach_pdu); void rx_nr_prach(PHY_VARS_gNB *gNB, - nfapi_nr_prach_pdu_t *prach_pdu, - int frame, - int subframe, - uint16_t *max_preamble, - uint16_t *max_preamble_energy, - uint16_t *max_preamble_delay - ); + nfapi_nr_prach_pdu_t *prach_pdu, + int frame, + int subframe, + uint16_t *max_preamble, + uint16_t *max_preamble_energy, + uint16_t *max_preamble_delay); +void rx_nr_prach_ru(RU_t *ru, + int prach_fmt, + int numRA, + int prachStartSymbol, + int frame, + int subframe); + +void nr_fill_prach_ru(RU_t *ru, + int SFN, + int Slot, + nfapi_nr_prach_pdu_t *prach_pdu); + +int16_t find_nr_prach(PHY_VARS_gNB *gNB,int frame,int slot, int numRA, find_type_t type); +int16_t find_nr_prach_ru(RU_t *ru,int frame,int slot, find_type_t type); + +void init_prach_list(PHY_VARS_gNB *gNB); +void init_prach_ru_list(RU_t *ru); +void free_nr_ru_prach_entry(RU_t *ru, int prach_id); diff --git a/openair1/SCHED_NR/nr_prach_procedures.c b/openair1/SCHED_NR/nr_prach_procedures.c index b86701f4e3..4649598f27 100644 --- a/openair1/SCHED_NR/nr_prach_procedures.c +++ b/openair1/SCHED_NR/nr_prach_procedures.c @@ -32,7 +32,7 @@ #include "PHY/defs_gNB.h" #include "PHY/phy_extern.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "nfapi_nr_interface_scf.h" #include "fapi_nr_l1.h" #include "nfapi_pnf.h" diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index fedf9394da..25813191be 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -40,7 +40,7 @@ #include "PHY/NR_REFSIG/nr_mod_table.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "SCHED_NR/sched_nr.h" #include "openair1/SIMULATION/TOOLS/sim.h" diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 60268a6ad1..195ca19fbd 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -41,7 +41,7 @@ #include "PHY/MODULATION/modulation_UE.h" #include "PHY/NR_REFSIG/nr_mod_table.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "SCHED_NR/fapi_nr_l1.h" #include "SCHED_NR/sched_nr.h" diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 99ca466fee..1eb058d15b 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -37,7 +37,7 @@ #include "PHY/MODULATION/modulation_eNB.h" #include "PHY/MODULATION/modulation_UE.h" #include "PHY/INIT/phy_init.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_UE_ESTIMATION/nr_estimation.h" #include "PHY/phy_vars.h" diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index aed7eb4505..a6904ed25b 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -41,7 +41,7 @@ #include "PHY/MODULATION/modulation_eNB.h" #include "PHY/MODULATION/modulation_UE.h" #include "PHY/INIT/phy_init.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_transport_proto_common.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "nr_unitary_defs.h" diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 445c45693e..0f6c432ebc 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -37,7 +37,7 @@ #include "PHY/MODULATION/modulation_eNB.h" #include "PHY/MODULATION/modulation_UE.h" #include "PHY/INIT/phy_init.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_UE_TRANSPORT/pucch_nr.h" #include "SCHED_NR/sched_nr.h" diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index d0710f6734..fd36d9cda3 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -37,7 +37,7 @@ #include "PHY/NR_REFSIG/nr_mod_table.h" #include "PHY/MODULATION/modulation_eNB.h" #include "PHY/MODULATION/modulation_UE.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_TRANSPORT/nr_ulsch.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" From c0029473dc9c10aa911847bcf7ebeeed1a54b20e Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 9 Apr 2020 17:15:43 +0200 Subject: [PATCH 02/42] Fixed some warnings --- openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 1 + openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 6aa9ab9d4b..163b719d9d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -42,6 +42,7 @@ #include "SIMULATION/TOOLS/sim.h" #include "executables/nr-uesoftmodem.h" #include "PHY/CODING/nrLDPC_extern.h" +#include "LAYER2/NR_MAC_gNB/mac_proto.h" //#define DEBUG_DLSCH_DECODING //#define ENABLE_PHY_PAYLOAD_DEBUG 1 diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 43545bada2..5c4df8ce40 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -30,6 +30,8 @@ */ #include "PHY/defs_nr_UE.h" #include "PHY/phy_extern_nr_ue.h" +#include "PHY/NR_TRANSPORT/nr_transport.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "nr_transport_proto_ue.h" //#include "SCHED/defs.h" //#include "PHY/defs.h" From 8dd88bcb0efe78d5544fab1af375f89a5e51475b Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 9 Apr 2020 18:34:39 +0200 Subject: [PATCH 03/42] Deleted duplicated transport common proto header file --- openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_prach.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_prach_common.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c | 2 +- .../NR_TRANSPORT/nr_transport_common_proto.h | 31 +- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 10 - .../NR_TRANSPORT/nr_transport_proto_common.h | 1763 ----------------- openair1/PHY/NR_UE_TRANSPORT/nr_prach.c | 2 +- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 21 +- openair1/SIMULATION/NR_PHY/prachsim.c | 2 +- 10 files changed, 31 insertions(+), 1806 deletions(-) delete mode 100644 openair1/PHY/NR_TRANSPORT/nr_transport_proto_common.h diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 74f3aa2d04..2d9fdbea81 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -26,7 +26,7 @@ #include "PHY/INIT/phy_init.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" -#include "PHY/NR_TRANSPORT/nr_transport_proto_common.h" +#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" /*#include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" #include "TDD-Config.h" diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c index c856d29f3c..0aa1db57ec 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c @@ -32,7 +32,7 @@ #include "PHY/defs_gNB.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" -#include "PHY/NR_TRANSPORT/nr_transport_proto_common.h" +#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" extern uint16_t prach_root_sequence_map_0_3[838]; extern uint16_t prach_root_sequence_map_abc[138]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach_common.c b/openair1/PHY/NR_TRANSPORT/nr_prach_common.c index 8373e775bd..251d1cbfd8 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach_common.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach_common.c @@ -34,7 +34,7 @@ #include "PHY/impl_defs_nr.h" #include "PHY/defs_nr_UE.h" #include "PHY/NR_TRANSPORT/nr_prach.h" -#include "PHY/NR_TRANSPORT/nr_transport_proto_common.h" +#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h" diff --git a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c index ea8e39488e..e535286084 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c @@ -32,7 +32,7 @@ #include "nr_transport_common_proto.h" #include "PHY/CODING/coding_defs.h" - +#include "PHY/defs_nr_common.h" uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm, uint8_t Nl) { uint32_t G; diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h index 762346048f..82a0cd5d03 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h @@ -31,22 +31,35 @@ * \warning */ +/** @addtogroup _PHY_TRANSPORT_ + * @{ + */ + #ifndef __NR_TRANSPORT_COMMON_PROTO__H__ #define __NR_TRANSPORT_COMMON_PROTO__H__ -#include "PHY/defs_nr_common.h" - - -#define NR_PUSCH_x 2 // UCI placeholder bit TS 38.212 V15.4.0 subclause 5.3.3.1 -#define NR_PUSCH_y 3 // UCI placeholder bit - - - - +#include /** \brief Computes available bits G. */ uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch, uint8_t nb_re_dmrs, uint16_t length_dmrs, uint8_t Qm, uint8_t Nl); uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r); +uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx); + +uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx); + +uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); + +uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); + +void compute_nr_prach_seq(uint8_t short_sequence, + uint8_t num_sequences, + uint8_t rootSequenceIndex, + uint32_t X_u[64][839]); + +void init_nr_prach_tables(int N_ZC); + +/**@}*/ + #endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 26fc190662..24b6303b9c 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -276,16 +276,6 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB, int slot, nfapi_nr_pusch_pdu_t *ulsch_pdu); -uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); - -uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx); - -uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx); - -uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); - -uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); - void nr_fill_prach(PHY_VARS_gNB *gNB, int SFN, int Slot, diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto_common.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto_common.h deleted file mode 100644 index 78dd266eea..0000000000 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto_common.h +++ /dev/null @@ -1,1763 +0,0 @@ -/* - * 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 - */ - -/*! \file PHY/NR_UE_TRANSPORT/transport_proto_ue.h - * \brief Function prototypes for PHY physical/transport channel processing and generation V8.6 2009-03 - * \author R. Knopp, F. Kaltenberger - * \date 2011 - * \version 0.1 - * \company Eurecom - * \email: knopp@eurecom.fr - * \note - * \warning - */ -#ifndef __NR_TRANSPORT_PROTO_UE__H__ -#define __NR_TRANSPORT_PROTO_UE__H__ -#include "PHY/defs_nr_UE.h" -#include "SCHED_NR_UE/defs.h" -//#include "PHY/LTE_TRANSPORT/transport_common_proto.h" -#include -#include "nfapi_interface.h" - -// Functions below implement 36-211 and 36-212 - -/** @addtogroup _PHY_TRANSPORT_ - * @{ - */ - -/** \fn free_ue_dlsch(NR_UE_DLSCH_t *dlsch) - \brief This function frees memory allocated for a particular DLSCH at UE - @param dlsch Pointer to DLSCH to be removed -*/ -void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch); - -/** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag) - \brief This function allocates structures for a particular DLSCH at UE - @returns Pointer to DLSCH to be removed - @param Kmimo Kmimo factor from 36-212/36-213 - @param Mdlharq Maximum number of HARQ rounds (36-212/36-213) - @param Nsoft Soft-LLR buffer size from UE-Category - @params N_RB_DL total number of resource blocks (determine the operating BW) - @param abstraction_flag Flag to indicate abstracted interface -*/ -NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag); - - -void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch); - - -NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag); - -void fill_UE_dlsch_MCH(PHY_VARS_NR_UE *ue,int mcs,int ndi,int rvidx,int eNB_id); - -int rx_pmch(PHY_VARS_NR_UE *phy_vars_ue, - unsigned char eNB_id, - uint8_t subframe, - unsigned char symbol); - -/** \brief Dump OCTAVE/MATLAB files for PMCH debugging - @param phy_vars_ue Pointer to UE variables - @param eNB_id index of eNB in ue variables - @param coded_bits_per_codeword G from 36.211 - @param subframe Index of subframe - @returns 0 on success -*/ -void dump_mch(PHY_VARS_NR_UE *phy_vars_ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,int subframe); - - - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/QPSK reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qpsk_qpsk(int16_t *stream0_in, - int16_t *stream1_in, - int16_t *stream0_out, - int16_t *rho01, - int32_t length); - -/** \brief This function perform LLR computation for dual-stream (QPSK/QPSK) transmission. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param rho_i Correlation between channel of signal and inteference - @param dlsch_llr llr output - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag flag to indicate this is the first symbol of the dlsch - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS - @param llr128p pointer to pointer to symbol in dlsch_llr*/ -int32_t nr_dlsch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - int32_t **rho_i, - int16_t *dlsch_llr, - uint8_t symbol, - uint32_t len, - uint8_t first_symbol_flag, - uint16_t nb_rb, - uint16_t pbch_pss_sss_adj, - int16_t **llr128p); - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/16QAM reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qpsk_qam16(int16_t *stream0_in, - int16_t *stream1_in, - short *ch_mag_i, - int16_t *stream0_out, - int16_t *rho01, - int32_t length); - -/** \brief This function perform LLR computation for dual-stream (QPSK/16QAM) transmission. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param rho_i Correlation between channel of signal and inteference - @param dlsch_llr llr output - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag flag to indicate this is the first symbol of the dlsch - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS - @param llr128p pointer to pointer to symbol in dlsch_llr*/ -int32_t nr_dlsch_qpsk_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10}) - int32_t **rho_i, - int16_t *dlsch_llr, - uint8_t symbol, - uint8_t first_symbol_flag, - uint16_t nb_rb, - uint16_t pbch_pss_sss_adj, - int16_t **llr128p); - - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/64QAM reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qpsk_qam64(int16_t *stream0_in, - int16_t *stream1_in, - short *ch_mag_i, - int16_t *stream0_out, - int16_t *rho01, - int32_t length); - -/** \brief This function perform LLR computation for dual-stream (QPSK/64QAM) transmission. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param rho_i Correlation between channel of signal and inteference - @param dlsch_llr llr output - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag flag to indicate this is the first symbol of the dlsch - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS - @param llr128p pointer to pointer to symbol in dlsch_llr*/ -int32_t nr_dlsch_qpsk_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10}) - int32_t **rho_i, - int16_t *dlsch_llr, - uint8_t symbol, - uint8_t first_symbol_flag, - uint16_t nb_rb, - uint16_t pbch_pss_sss_adj, - int16_t **llr128p); - - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 16QAM/QPSK reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qam16_qpsk(short *stream0_in, - short *stream1_in, - short *ch_mag, - short *stream0_out, - short *rho01, - int length); -/** \brief This function perform LLR computation for dual-stream (16QAM/QPSK) transmission. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param rho_i Correlation between channel of signal and inteference - @param dlsch_llr llr output - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag flag to indicate this is the first symbol of the dlsch - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS - @param llr16p pointer to pointer to symbol in dlsch_llr*/ -int nr_dlsch_16qam_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - int **rxdataF_comp_i, - int **dl_ch_mag, //|h_0|^2*(2/sqrt{10}) - int **rho_i, - short *dlsch_llr, - unsigned char symbol, - unsigned char first_symbol_flag, - unsigned short nb_rb, - uint16_t pbch_pss_sss_adjust, - short **llr16p); - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 16QAM/16QAM reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qam16_qam16(short *stream0_in, - short *stream1_in, - short *ch_mag, - short *ch_mag_i, - short *stream0_out, - short *rho01, - int length); - -/** \brief This function perform LLR computation for dual-stream (16QAM/16QAM) transmission. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param rho_i Correlation between channel of signal and inteference - @param dlsch_llr llr output - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag flag to indicate this is the first symbol of the dlsch - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS - @param llr16p pointer to pointer to symbol in dlsch_llr*/ -int nr_dlsch_16qam_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - int **rxdataF_comp_i, - int **dl_ch_mag, //|h_0|^2*(2/sqrt{10}) - int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10}) - int **rho_i, - short *dlsch_llr, - unsigned char symbol, - uint32_t len, - unsigned char first_symbol_flag, - unsigned short nb_rb, - uint16_t pbch_pss_sss_adjust, - short **llr16p); - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 16QAM/64QAM reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qam16_qam64(short *stream0_in, - short *stream1_in, - short *ch_mag, - short *ch_mag_i, - short *stream0_out, - short *rho01, - int length); - -/** \brief This function perform LLR computation for dual-stream (16QAM/64QAM) transmission. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param rho_i Correlation between channel of signal and inteference - @param dlsch_llr llr output - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag flag to indicate this is the first symbol of the dlsch - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS - @param llr16p pointer to pointer to symbol in dlsch_llr*/ -int nr_dlsch_16qam_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - int **rxdataF_comp_i, - int **dl_ch_mag, //|h_0|^2*(2/sqrt{10}) - int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10}) - int **rho_i, - short *dlsch_llr, - unsigned char symbol, - unsigned char first_symbol_flag, - unsigned short nb_rb, - uint16_t pbch_pss_sss_adjust, - short **llr16p); - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/64QAM reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qam64_qpsk(short *stream0_in, - short *stream1_in, - short *ch_mag, - short *stream0_out, - short *rho01, - int length); - -/** \brief This function perform LLR computation for dual-stream (64QAM/64QAM) transmission. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param rho_i Correlation between channel of signal and inteference - @param dlsch_llr llr output - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag flag to indicate this is the first symbol of the dlsch - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS - @param llr16p pointer to pointer to symbol in dlsch_llr*/ -int nr_dlsch_64qam_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - int **rxdataF_comp_i, - int **dl_ch_mag, - int **rho_i, - short *dlsch_llr, - unsigned char symbol, - unsigned char first_symbol_flag, - unsigned short nb_rb, - uint16_t pbch_pss_sss_adjust, - short **llr16p); - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/16QAM reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qam64_qam16(short *stream0_in, - short *stream1_in, - short *ch_mag, - short *ch_mag_i, - short *stream0_out, - short *rho01, - int length); - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/16QAM reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qam64_qam16_avx2(short *stream0_in, - short *stream1_in, - short *ch_mag, - short *ch_mag_i, - short *stream0_out, - short *rho01, - int length); - -/** \brief This function perform LLR computation for dual-stream (64QAM/16QAM) transmission. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param rho_i Correlation between channel of signal and inteference - @param dlsch_llr llr output - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag flag to indicate this is the first symbol of the dlsch - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS - @param llr16p pointer to pointer to symbol in dlsch_llr*/ -int nr_dlsch_64qam_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - int **rxdataF_comp_i, - int **dl_ch_mag, - int **dl_ch_mag_i, - int **rho_i, - short *dlsch_llr, - unsigned char symbol, - unsigned char first_symbol_flag, - unsigned short nb_rb, - uint16_t pbch_pss_sss_adjust, - short **llr16p); - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/64QAM reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qam64_qam64(short *stream0_in, - short *stream1_in, - short *ch_mag, - short *ch_mag_i, - short *stream0_out, - short *rho01, - int length); - -/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/64QAM reception. - @param stream0_in Input from channel compensated (MR combined) stream 0 - @param stream1_in Input from channel compensated (MR combined) stream 1 - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param stream0_out Output from LLR unit for stream0 - @param rho01 Cross-correlation between channels (MR combined) - @param length in complex channel outputs*/ -void qam64_qam64_avx2(int32_t *stream0_in, - int32_t *stream1_in, - int32_t *ch_mag, - int32_t *ch_mag_i, - int16_t *stream0_out, - int32_t *rho01, - int length); - -/** \brief This function perform LLR computation for dual-stream (64QAM/64QAM) transmission. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param ch_mag Input from scaled channel magnitude square of h0'*g0 - @param ch_mag_i Input from scaled channel magnitude square of h0'*g1 - @param rho_i Correlation between channel of signal and inteference - @param dlsch_llr llr output - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag flag to indicate this is the first symbol of the dlsch - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS - @param llr16p pointer to pointer to symbol in dlsch_llr*/ -int nr_dlsch_64qam_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - int **rxdataF_comp_i, - int **dl_ch_mag, - int **dl_ch_mag_i, - int **rho_i, - short *dlsch_llr, - unsigned char symbol, - uint32_t len, - unsigned char first_symbol_flag, - unsigned short nb_rb, - uint16_t pbch_pss_sss_adjust, - //short **llr16p, - uint32_t llr_offset); - - -/** \brief This function generates log-likelihood ratios (decoder input) for single-stream QPSK received waveforms. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param dlsch_llr llr output - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS - @param llr128p pointer to pointer to symbol in dlsch_llr - @param beamforming_mode beamforming mode -*/ -int32_t nr_dlsch_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int16_t *dlsch_llr, - uint8_t symbol, - uint32_t len, - uint8_t first_symbol_flag, - uint16_t nb_rb, - uint8_t beamforming_mode); - -/** - \brief This function generates log-likelihood ratios (decoder input) for single-stream 16QAM received waveforms - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param dlsch_llr llr output - @param dl_ch_mag Squared-magnitude of channel in each resource element position corresponding to allocation and weighted for mid-point in 16QAM constellation - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adjust Adjustment factor in RE for PBCH/PSS/SSS allocations - @param llr128p pointer to pointer to symbol in dlsch_llr - @param beamforming_mode beamforming mode -*/ - -int32_t nr_dlsch_qpsk_llr_SIC(NR_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - int32_t **sic_buffer, - int **rho_i, - short *dlsch_llr, - uint8_t num_pdcch_symbols, - uint16_t nb_rb, - uint8_t subframe, - uint16_t mod_order_0, - uint32_t rb_alloc); - -void nr_dlsch_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int16_t *dlsch_llr, - int32_t **dl_ch_mag, - uint8_t symbol, - uint32_t len, - uint8_t first_symbol_flag, - uint16_t nb_rb, - int16_t **llr32p, - uint8_t beamforming_mode); -/** - \brief This function generates log-likelihood ratios (decoder input) for single-stream 16QAM received waveforms - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param dlsch_llr llr output - @param dl_ch_mag Squared-magnitude of channel in each resource element position corresponding to allocation, weighted by first mid-point of 64-QAM constellation - @param dl_ch_magb Squared-magnitude of channel in each resource element position corresponding to allocation, weighted by second mid-point of 64-QAM constellation - @param symbol OFDM symbol index in sub-frame - @param first_symbol_flag - @param nb_rb number of RBs for this allocation - @param pbch_pss_sss_adjust PBCH/PSS/SSS RE adjustment (in REs) - @param beamforming_mode beamforming mode -*/ -void nr_dlsch_16qam_llr_SIC (NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **sic_buffer, //Q15 - int32_t **rho_i, - int16_t *dlsch_llr, - uint8_t num_pdcch_symbols, - int32_t **dl_ch_mag, - uint16_t nb_rb, - uint8_t subframe, - uint16_t mod_order_0, - uint32_t rb_alloc); - -void dlsch_64qam_llr_SIC(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **sic_buffer, //Q15 - int32_t **rho_i, - int16_t *dlsch_llr, - uint8_t num_pdcch_symbols, - int32_t **dl_ch_mag, - int32_t **dl_ch_magb, - uint16_t nb_rb, - uint8_t subframe, - uint16_t mod_order_0, - uint32_t rb_alloc); - -void nr_dlsch_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int16_t *dlsch_llr, - int32_t **dl_ch_mag, - int32_t **dl_ch_magb, - uint8_t symbol, - uint32_t len, - uint8_t first_symbol_flag, - uint16_t nb_rb, - uint32_t llr_offset, - uint8_t beamforming_mode); - - -/** \fn dlsch_siso(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - uint8_t l, - uint16_t nb_rb) - \brief This function does the first stage of llr computation for SISO, by just extracting the pilots, PBCH and primary/secondary synchronization sequences. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param l symbol in sub-frame - @param nb_rb Number of RBs in this allocation -*/ - -void dlsch_siso(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - uint8_t l, - uint16_t nb_rb); - -/** \fn dlsch_alamouti(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **dl_ch_mag, - int32_t **dl_ch_magb, - uint8_t symbol, - uint16_t nb_rb) - \brief This function does Alamouti combining on RX and prepares LLR inputs by skipping pilots, PBCH and primary/secondary synchronization signals. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param dl_ch_mag First squared-magnitude of channel (16QAM and 64QAM) for LLR computation. Alamouti combining should be performed on this as well. Result is stored in first antenna position - @param dl_ch_magb Second squared-magnitude of channel (64QAM only) for LLR computation. Alamouti combining should be performed on this as well. Result is stored in first antenna position - @param symbol Symbol in sub-frame - @param nb_rb Number of RBs in this allocation -*/ -void dlsch_alamouti(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **dl_ch_mag, - int32_t **dl_ch_magb, - uint8_t symbol, - uint16_t nb_rb); - -/** \fn dlsch_antcyc(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **dl_ch_mag, - int32_t **dl_ch_magb, - uint8_t symbol, - uint16_t nb_rb) - \brief This function does antenna selection (based on antenna cycling pattern) on RX and prepares LLR inputs by skipping pilots, PBCH and primary/secondary synchronization signals. Note that this is not LTE, it is just included for comparison purposes. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param dl_ch_mag First squared-magnitude of channel (16QAM and 64QAM) for LLR computation. Alamouti combining should be performed on this as well. Result is stored in first antenna position - @param dl_ch_magb Second squared-magnitude of channel (64QAM only) for LLR computation. Alamouti combining should be performed on this as well. Result is stored in first antenna position - @param symbol Symbol in sub-frame - @param nb_rb Number of RBs in this allocation -*/ -void dlsch_antcyc(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **dl_ch_mag, - int32_t **dl_ch_magb, - uint8_t symbol, - uint16_t nb_rb); - -/** \fn dlsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - int32_t **rho, - int32_t **rho_i, - int32_t **dl_ch_mag, - int32_t **dl_ch_magb, - uint8_t symbol, - uint16_t nb_rb, - uint8_t dual_stream_UE) - - \brief This function does maximal-ratio combining for dual-antenna receivers. - @param frame_parms Frame descriptor structure - @param rxdataF_comp Compensated channel output - @param rxdataF_comp_i Compensated channel output for interference - @param rho Cross correlation between spatial channels - @param rho_i Cross correlation between signal and inteference channels - @param dl_ch_mag First squared-magnitude of channel (16QAM and 64QAM) for LLR computation. Alamouti combining should be performed on this as well. Result is stored in first antenna position - @param dl_ch_magb Second squared-magnitude of channel (64QAM only) for LLR computation. Alamouti combining should be performed on this as well. Result is stored in first antenna position - @param symbol Symbol in sub-frame - @param nb_rb Number of RBs in this allocation - @param dual_stream_UE Flag to indicate dual-stream detection -*/ -void dlsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - int32_t **rho, - int32_t **rho_i, - int32_t **dl_ch_mag, - int32_t **dl_ch_magb, - int32_t **dl_ch_mag_i, - int32_t **dl_ch_magb_i, - uint8_t symbol, - uint16_t nb_rb, - uint8_t dual_stream_UE); - -void dlsch_detection_mrc_TM34(NR_DL_FRAME_PARMS *frame_parms, - NR_UE_PDSCH *lte_ue_pdsch_vars, - int harq_pid, - int round, - unsigned char symbol, - unsigned short nb_rb, - unsigned char dual_stream_UE); - -/** \fn dlsch_extract_rbs_single(int32_t **rxdataF, - int32_t **dl_ch_estimates, - int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - uint16_t pmi, - uint8_t *pmi_ext, - uint32_t *rb_alloc, - uint8_t symbol, - uint8_t subframe, - NR_DL_FRAME_PARMS *frame_parms) - \brief This function extracts the received resource blocks, both channel estimates and data symbols, - for the current allocation and for single antenna eNB transmission. - @param rxdataF Raw FFT output of received signal - @param dl_ch_estimates Channel estimates of current slot - @param rxdataF_ext FFT output for RBs in this allocation - @param dl_ch_estimates_ext Channel estimates for RBs in this allocation - @param pmi subband Precoding matrix indicator - @param pmi_ext Extracted PMI for chosen RBs - @param rb_alloc RB allocation vector - @param symbol Symbol to extract - @param subframe Subframe number - @param vrb_type Flag to indicate distributed VRB type - @param high_speed_flag - @param frame_parms Pointer to frame descriptor -*/ -/*uint16_t nr_dlsch_extract_rbs_single(int32_t **rxdataF, - int32_t **dl_ch_estimates, - int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - uint16_t pmi, - uint8_t *pmi_ext, - uint32_t *rb_alloc, - uint8_t symbol, - uint8_t subframe, - uint32_t high_speed_flag, - NR_DL_FRAME_PARMS *frame_parms);*/ - -unsigned short nr_dlsch_extract_rbs_single(int **rxdataF, - int **dl_ch_estimates, - int **rxdataF_ext, - int **dl_ch_estimates_ext, - unsigned short pmi, - unsigned char *pmi_ext, - unsigned char symbol, - uint8_t pilots, - unsigned short start_rb, - unsigned short nb_pdsch_rb, - unsigned char nr_tti_rx, - uint32_t high_speed_flag, - NR_DL_FRAME_PARMS *frame_parms); - -/** \fn dlsch_extract_rbs_dual(int32_t **rxdataF, - int32_t **dl_ch_estimates, - int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - uint16_t pmi, - uint8_t *pmi_ext, - uint32_t *rb_alloc, - uint8_t symbol, - NR_DL_FRAME_PARMS *frame_parms) - \brief This function extracts the received resource blocks, both channel estimates and data symbols, - for the current allocation and for dual antenna eNB transmission. - @param rxdataF Raw FFT output of received signal - @param dl_ch_estimates Channel estimates of current slot - @param rxdataF_ext FFT output for RBs in this allocation - @param dl_ch_estimates_ext Channel estimates for RBs in this allocation - @param pmi subband Precoding matrix indicator - @param pmi_ext Extracted PMI for chosen RBs - @param rb_alloc RB allocation vector - @param symbol Symbol to extract - @param subframe Subframe index - @param high_speed_flag - @param frame_parms Pointer to frame descriptor -*/ -unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF, - int **dl_ch_estimates, - int **rxdataF_ext, - int **dl_ch_estimates_ext, - unsigned short pmi, - unsigned char *pmi_ext, - unsigned char symbol, - uint8_t pilots, - unsigned short start_rb, - unsigned short nb_rb_pdsch, - unsigned char nr_tti_rx, - uint32_t high_speed_flag, - NR_DL_FRAME_PARMS *frame_parms, - MIMO_mode_t mimo_mode); - -/** \fn dlsch_extract_rbs_TM7(int32_t **rxdataF, - int32_t **dl_bf_ch_estimates, - int32_t **rxdataF_ext, - int32_t **dl_bf_ch_estimates_ext, - uint32_t *rb_alloc, - uint8_t symbol, - uint8_t subframe, - uint32_t high_speed_flag, - NR_DL_FRAME_PARMS *frame_parms) - \brief This function extracts the received resource blocks, both channel estimates and data symbols, - for the current allocation and for single antenna eNB transmission. - @param rxdataF Raw FFT output of received signal - @param dl_bf_ch_estimates Beamforming channel estimates of current slot - @param rxdataF_ext FFT output for RBs in this allocation - @param dl_bf_ch_estimates_ext Beamforming channel estimates for RBs in this allocation - @param rb_alloc RB allocation vector - @param symbol Symbol to extract - @param subframe Subframe number - @param high_speed_flag - @param frame_parms Pointer to frame descriptor -*/ -uint16_t dlsch_extract_rbs_TM7(int32_t **rxdataF, - int32_t **dl_bf_ch_estimates, - int32_t **rxdataF_ext, - int32_t **dl_bf_ch_estimates_ext, - uint32_t *rb_alloc, - uint8_t symbol, - uint8_t subframe, - uint32_t high_speed_flag, - NR_DL_FRAME_PARMS *frame_parms); - -/** \brief This function performs channel compensation (matched filtering) on the received RBs for this allocation. In addition, it computes the squared-magnitude of the channel with weightings for 16QAM/64QAM detection as well as dual-stream detection (cross-correlation) - @param rxdataF_ext Frequency-domain received signal in RBs to be demodulated - @param dl_ch_estimates_ext Frequency-domain channel estimates in RBs to be demodulated - @param dl_ch_mag First Channel magnitudes (16QAM/64QAM) - @param dl_ch_magb Second weighted Channel magnitudes (64QAM) - @param rxdataF_comp Compensated received waveform - @param rho Cross-correlation between two spatial channels on each RX antenna - @param frame_parms Pointer to frame descriptor - @param symbol Symbol on which to operate - @param first_symbol_flag set to 1 on first DLSCH symbol - @param mod_order Modulation order of allocation - @param nb_rb Number of RBs in allocation - @param output_shift Rescaling for compensated output (should be energy-normalizing) - @param phy_measurements Pointer to UE PHY measurements -*/ -void nr_dlsch_channel_compensation(int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - int32_t **dl_ch_mag, - int32_t **dl_ch_magb, - int32_t **rxdataF_comp, - int32_t **rho, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t symbol, - uint8_t start_symbol, - uint8_t first_symbol_flag, - uint8_t mod_order, - uint16_t nb_rb, - uint8_t output_shift, - PHY_NR_MEASUREMENTS *phy_measurements); - -void nr_dlsch_channel_compensation_core(int **rxdataF_ext, - int **dl_ch_estimates_ext, - int **dl_ch_mag, - int **dl_ch_magb, - int **rxdataF_comp, - int **rho, - unsigned char n_tx, - unsigned char n_rx, - unsigned char mod_order, - unsigned char output_shift, - int length, - int start_point); - -void nr_dlsch_deinterleaving(uint8_t symbol, - uint8_t start_symbol, - uint16_t L, - uint16_t *llr, - uint16_t *llr_deint, - uint16_t nb_rb_pdsch); - -void dlsch_dual_stream_correlation(NR_DL_FRAME_PARMS *frame_parms, - unsigned char symbol, - unsigned short nb_rb, - int **dl_ch_estimates_ext, - int **dl_ch_estimates_ext_i, - int **dl_ch_rho_ext, - unsigned char output_shift); - -void dlsch_dual_stream_correlationTM34(NR_DL_FRAME_PARMS *frame_parms, - unsigned char symbol, - unsigned short nb_rb, - int **dl_ch_estimates_ext, - int **dl_ch_estimates_ext_i, - int **dl_ch_rho_ext, - unsigned char output_shift0, - unsigned char output_shift1); -//This function is used to compute multiplications in Hhermitian * H matrix -void conjch0_mult_ch1(int *ch0, - int *ch1, - int32_t *ch0conj_ch1, - unsigned short nb_rb, - unsigned char output_shift0); - -void construct_HhH_elements(int *ch0conj_ch0, - int *ch1conj_ch1, - int *ch2conj_ch2, - int *ch3conj_ch3, - int *ch0conj_ch1, - int *ch1conj_ch0, - int *ch2conj_ch3, - int *ch3conj_ch2, - int32_t *after_mf_00, - int32_t *after_mf_01, - int32_t *after_mf_10, - int32_t *after_mf_11, - unsigned short nb_rb); - -void squared_matrix_element(int32_t *Hh_h_00, - int32_t *Hh_h_00_sq, - unsigned short nb_rb); - -void dlsch_channel_level_TM34_meas(int *ch00, - int *ch01, - int *ch10, - int *ch11, - int *avg_0, - int *avg_1, - unsigned short nb_rb); - -void nr_dlsch_channel_level_median(int **dl_ch_estimates_ext, - int32_t *median, - int n_tx, - int n_rx, - int length, - int start_point); - -void nr_dlsch_detection_mrc_core(int **rxdataF_comp, - int **rxdataF_comp_i, - int **rho, - int **rho_i, - int **dl_ch_mag, - int **dl_ch_magb, - int **dl_ch_mag_i, - int **dl_ch_magb_i, - unsigned char n_tx, - unsigned char n_rx, - int length, - int start_point); - -void det_HhH(int32_t *after_mf_00, - int32_t *after_mf_01, - int32_t *after_mf_10, - int32_t *after_mf_11, - int32_t *det_fin_128, - unsigned short nb_rb); - -void numer(int32_t *Hh_h_00_sq, - int32_t *Hh_h_01_sq, - int32_t *Hh_h_10_sq, - int32_t *Hh_h_11_sq, - int32_t *num_fin, - unsigned short nb_rb); - -uint8_t rank_estimation_tm3_tm4(int *dl_ch_estimates_00, - int *dl_ch_estimates_01, - int *dl_ch_estimates_10, - int *dl_ch_estimates_11, - unsigned short nb_rb); - -void dlsch_channel_compensation_TM56(int **rxdataF_ext, - int **dl_ch_estimates_ext, - int **dl_ch_mag, - int **dl_ch_magb, - int **rxdataF_comp, - unsigned char *pmi_ext, - NR_DL_FRAME_PARMS *frame_parms, - PHY_NR_MEASUREMENTS *phy_measurements, - int eNB_id, - unsigned char symbol, - unsigned char mod_order, - unsigned short nb_rb, - unsigned char output_shift, - unsigned char dl_power_off); - - -void dlsch_channel_compensation_TM34(NR_DL_FRAME_PARMS *frame_parms, - NR_UE_PDSCH *lte_ue_pdsch_vars, - PHY_NR_MEASUREMENTS *phy_measurements, - int eNB_id, - unsigned char symbol, - unsigned char mod_order0, - unsigned char mod_order1, - int harq_pid, - int round, - MIMO_mode_t mimo_mode, - unsigned short nb_rb, - unsigned char output_shift0, - unsigned char output_shift1); - - -/** \brief This function computes the average channel level over all allocated RBs and antennas (TX/RX) in order to compute output shift for compensated signal - @param dl_ch_estimates_ext Channel estimates in allocated RBs - @param frame_parms Pointer to frame descriptor - @param avg Pointer to average signal strength - @param pilots_flag Flag to indicate pilots in symbol - @param nb_rb Number of allocated RBs -*/ -void nr_dlsch_channel_level(int **dl_ch_estimates_ext, - NR_DL_FRAME_PARMS *frame_parms, - int32_t *avg, - uint8_t symbol, - uint32_t len, - unsigned short nb_rb); - - -void dlsch_channel_level_TM34(int **dl_ch_estimates_ext, - NR_DL_FRAME_PARMS *frame_parms, - unsigned char *pmi_ext, - int *avg_0, - int *avg_1, - uint8_t symbol, - unsigned short nb_rb, - MIMO_mode_t mimo_mode); - - -void dlsch_channel_level_TM56(int32_t **dl_ch_estimates_ext, - NR_DL_FRAME_PARMS *frame_parms, - unsigned char *pmi_ext, - int32_t *avg, - uint8_t symbol_mod, - uint16_t nb_rb); - -void dlsch_channel_level_TM7(int32_t **dl_bf_ch_estimates_ext, - NR_DL_FRAME_PARMS *frame_parms, - int32_t *avg, - uint8_t pilots_flag, - uint16_t nb_rb); - -void nr_dlsch_scale_channel(int32_t **dl_ch_estimates_ext, - NR_DL_FRAME_PARMS *frame_parms, - NR_UE_DLSCH_t **dlsch_ue, - uint8_t symbol, - uint8_t start_symbol, - uint16_t nb_rb); - -/** \brief This is the top-level entry point for DLSCH decoding in UE. It should be replicated on several - threads (on multi-core machines) corresponding to different HARQ processes. The routine first - computes the segmentation information, followed by rate dematching and sub-block deinterleaving the of the - received LLRs computed by dlsch_demodulation for each transport block segment. It then calls the - turbo-decoding algorithm for each segment and stops after either after unsuccesful decoding of at least - one segment or correct decoding of all segments. Only the segment CRCs are check for the moment, the - overall CRC is ignored. Finally transport block reassembly is performed. - @param phy_vars_ue Pointer to ue variables - @param dlsch_llr Pointer to LLR values computed by dlsch_demodulation - @param lte_frame_parms Pointer to frame descriptor - @param dlsch Pointer to DLSCH descriptor - @param frame Frame number - @param subframe Subframe number - @param num_pdcch_symbols Number of PDCCH symbols - @param is_crnti indicates if PDSCH belongs to a CRNTI (necessary for parallelizing decoding threads) - @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used - @returns 0 on success, 1 on unsuccessful decoding -*/ - -uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, - short *dlsch_llr, - NR_DL_FRAME_PARMS *frame_parms, - NR_UE_DLSCH_t *dlsch, - NR_DL_UE_HARQ_t *harq_process, - uint32_t frame, - uint16_t nb_symb_sch, - uint8_t nr_tti_rx, - uint8_t harq_pid, - uint8_t is_crnti, - uint8_t llr8_flag); - -int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, - NR_DL_FRAME_PARMS* frame_parms, - uint8_t harq_pid); - -/*! \brief Perform PUSCH scrambling. TS 38.211 V15.4.0 subclause 6.3.1.1 - @param[in] in Pointer to input bits - @param[in] size of input bits - @param[in] Nid cell id - @param[in] n_RNTI CRNTI - @param[out] out the scrambled bits -*/ - -void nr_pusch_codeword_scrambling(uint8_t *in, - uint16_t size, - uint32_t Nid, - uint32_t n_RNTI, - uint32_t* out); - - -uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, - UE_nr_rxtx_proc_t *proc, - int eNB_id, - short *dlsch_llr, - NR_DL_FRAME_PARMS *frame_parms, - NR_UE_DLSCH_t *dlsch, - NR_DL_UE_HARQ_t *harq_process, - uint32_t frame, - uint16_t nb_symb_sch, - uint8_t nr_tti_rx, - uint8_t harq_pid, - uint8_t is_crnti, - uint8_t llr8_flag); - -void *nr_dlsch_decoding_2thread0(void *arg); - -void *nr_dlsch_decoding_2thread1(void *arg); - -void nr_dlsch_unscrambling(int16_t* llr, - uint32_t size, - uint8_t q, - uint32_t Nid, - uint32_t n_RNTI); - -uint32_t dlsch_decoding_emul(PHY_VARS_NR_UE *phy_vars_ue, - uint8_t subframe, - PDSCH_t dlsch_id, - uint8_t eNB_id); - -/** \brief This function is the top-level entry point to PDSCH demodulation, after frequency-domain transformation and channel estimation. It performs - - RB extraction (signal and channel estimates) - - channel compensation (matched filtering) - - RE extraction (pilot, PBCH, synch. signals) - - antenna combining (MRC, Alamouti, cycling) - - LLR computation - This function supports TM1, 2, 3, 5, and 6. - @param PHY_VARS_NR_UE Pointer to PHY variables - @param type Type of PDSCH (SI_PDSCH,RA_PDSCH,PDSCH,PMCH) - @param eNB_id eNb index (Nid1) 0,1,2 - @param eNB_id_i Interfering eNB index (Nid1) 0,1,2, or 3 in case of MU-MIMO IC receiver - @param subframe Subframe number - @param symbol Symbol on which to act (within sub-frame) - @param first_symbol_flag set to 1 on first DLSCH symbol - @param rx_type. rx_type=RX_IC_single_stream will enable interference cancellation of a second stream when decoding the first stream. In case of TM1, 2, 5, and this can cancel interference from a neighbouring cell given by eNB_id_i. In case of TM5, eNB_id_i should be set to n_connected_eNB to perform multi-user interference cancellation. In case of TM3, eNB_id_i should be set to eNB_id to perform co-channel interference cancellation; this option should be used together with an interference cancellation step [...]. In case of TM3, if rx_type=RX_IC_dual_stream, both streams will be decoded by applying the IC single stream receiver twice. - @param i_mod Modulation order of the interfering stream -*/ -int32_t nr_rx_pdsch(PHY_VARS_NR_UE *phy_vars_ue, - PDSCH_t type, - uint8_t eNB_id, - uint8_t eNB_id_i, - uint32_t frame, - uint8_t subframe, - uint8_t symbol, - uint8_t first_symbol_flag, - RX_type_t rx_type, - uint8_t i_mod, - uint8_t harq_pid); - -int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, - uint32_t frame, - uint8_t nr_tti_rx, - uint8_t eNB_id, - MIMO_mode_t mimo_mode, - uint32_t high_speed_flag, - uint8_t is_secondary_ue, - int nb_coreset_active, - uint16_t symbol_mon, - NR_SEARCHSPACE_TYPE_t searchSpaceType); - -/*! \brief Extract PSS and SSS resource elements - @param phy_vars_ue Pointer to UE variables - @param[out] pss_ext contain the PSS signals after the extraction - @param[out] sss_ext contain the SSS signals after the extraction - @returns 0 on success -*/ -int pss_sss_extract(PHY_VARS_NR_UE *phy_vars_ue, - int32_t pss_ext[4][72], - int32_t sss_ext[4][72], - uint8_t subframe); - -/*! \brief Extract only PSS resource elements - @param phy_vars_ue Pointer to UE variables - @param[out] pss_ext contain the PSS signals after the extraction - @returns 0 on success -*/ -int pss_only_extract(PHY_VARS_NR_UE *phy_vars_ue, - int32_t pss_ext[4][72], - uint8_t subframe); - -/*! \brief Extract only SSS resource elements - @param phy_vars_ue Pointer to UE variables - @param[out] sss_ext contain the SSS signals after the extraction - @returns 0 on success -*/ -int sss_only_extract(PHY_VARS_NR_UE *phy_vars_ue, - int32_t sss_ext[4][72], - uint8_t subframe); - -/*! \brief Performs detection of SSS to find cell ID and other framing parameters (FDD/TDD, normal/extended prefix) - @param phy_vars_ue Pointer to UE variables - @param tot_metric Pointer to variable containing maximum metric under framing hypothesis (to be compared to other hypotheses - @param flip_max Pointer to variable indicating if start of frame is in second have of RX buffer (i.e. PSS/SSS is flipped) - @param phase_max Pointer to variable (0 ... 6) containing rought phase offset between PSS and SSS (can be used for carrier - frequency adjustment. 0 means -pi/3, 6 means pi/3. - @returns 0 on success -*/ -int rx_sss(PHY_VARS_NR_UE *phy_vars_ue,int32_t *tot_metric,uint8_t *flip_max,uint8_t *phase_max); - -/*! \brief receiver for the PBCH - \returns number of tx antennas or -1 if error -*/ -int nr_rx_pbch( PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - NR_UE_PBCH *nr_ue_pbch_vars, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t eNB_id, - uint8_t i_ssb, - MIMO_mode_t mimo_mode, - uint32_t high_speed_flag); - -int nr_pbch_detection(UE_nr_rxtx_proc_t *proc, - PHY_VARS_NR_UE *ue, - int pbch_initial_symbol, - runmode_t mode); - -uint16_t rx_pbch_emul(PHY_VARS_NR_UE *phy_vars_ue, - uint8_t eNB_id, - uint8_t pbch_phase); - - -/*! \brief PBCH unscrambling - This is similar to pbch_scrabling with the difference that inputs are signed s16s (llr values) and instead of flipping bits we change signs. - \param frame_parms Pointer to frame descriptor - \param llr Output of the demodulator - \param length Length of the sequence - \param frame_mod4 Frame number modulo 4*/ -void pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, - int8_t* llr, - uint32_t length, - uint8_t frame_mod4); - - -void generate_64qam_table(void); -void generate_16qam_table(void); -void generate_qpsk_table(void); - -uint16_t extract_crc(uint8_t *dci,uint8_t DCI_LENGTH); - -/*! \brief LLR from two streams. This function takes two streams (qpsk modulated) and calculates the LLR, considering one stream as interference. - \param stream0_in pointer to first stream0 - \param stream1_in pointer to first stream1 - \param stream0_out pointer to output stream - \param rho01 pointer to correlation matrix - \param length*/ -void qpsk_qpsk_TM3456(short *stream0_in, - short *stream1_in, - short *stream0_out, - short *rho01, - int length - ); - -/** \brief Attempt decoding of a particular DCI with given length and format. - @param DCI_LENGTH length of DCI in bits - @param DCI_FMT Format of DCI - @param e e-sequence (soft bits) - @param decoded_output Output of Viterbi decoder -*/ -void dci_decoding(uint8_t DCI_LENGTH, - uint8_t DCI_FMT, - int8_t *e, - uint8_t *decoded_output); - -/** \brief Do 36.213 DCI decoding procedure by searching different RNTI options and aggregation levels. Currently does - not employ the complexity reducing procedure based on RNTI. - @param phy_vars_ue UE variables - @param dci_alloc Pointer to DCI_ALLOC_t array to store results for DLSCH/ULSCH programming - @param do_common If 1 perform search in common search-space else ue-specific search-space - @param eNB_id eNB Index on which to act - @param subframe Index of subframe - @returns bitmap of occupied CCE positions (i.e. those detected) -*/ -uint16_t dci_decoding_procedure(PHY_VARS_NR_UE *phy_vars_ue, - DCI_ALLOC_t *dci_alloc, - int do_common, - int16_t eNB_id, - uint8_t subframe); - -uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_NR_UE *ue, - DCI_ALLOC_t *dci_alloc, - uint8_t DCIFormat, - uint8_t agregationLevel, - int16_t eNB_id, - uint8_t subframe); - -uint16_t dci_decoding_procedure_emul(NR_UE_PDCCH **lte_ue_pdcch_vars, - uint8_t num_ue_spec_dci, - uint8_t num_common_dci, - DCI_ALLOC_t *dci_alloc_tx, - DCI_ALLOC_t *dci_alloc_rx, - int16_t eNB_id); - -/** \brief Compute Q (modulation order) based on I_MCS PDSCH. Implements table 7.1.7.1-1 from 36.213. - @param I_MCS */ -uint8_t get_Qm(uint8_t I_MCS); - -/** \brief Compute Q (modulation order) based on I_MCS for PUSCH. Implements table 8.6.1-1 from 36.213. - @param I_MCS */ -uint8_t get_Qm_ul(uint8_t I_MCS); - -/** \brief Compute I_TBS (transport-block size) based on I_MCS for PDSCH. Implements table 7.1.7.1-1 from 36.213. - @param I_MCS */ -uint8_t get_I_TBS(uint8_t I_MCS); - -/** \brief Compute I_TBS (transport-block size) based on I_MCS for PUSCH. Implements table 8.6.1-1 from 36.213. - @param I_MCS */ -unsigned char get_I_TBS_UL(unsigned char I_MCS); - -/** \brief Compute Q (modulation order) based on downlink I_MCS. Implements table 7.1.7.1-1 from 36.213. - @param I_MCS - @param nb_rb - @return Transport block size */ -uint32_t get_TBS_DL(uint8_t mcs, uint16_t nb_rb); - -/** \brief Compute Q (modulation order) based on uplink I_MCS. Implements table 7.1.7.1-1 from 36.213. - @param I_MCS - @param nb_rb - @return Transport block size */ -uint32_t get_TBS_UL(uint8_t mcs, uint16_t nb_rb); - -/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type - @param N_RB_DL number of PRB on DL - @param indicator for even/odd slot - @param vrb vrb index - @param Ngap Gap indicator -*/ -uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap); - -/* \brief Return prb for a given vrb index - @param vrb_type VRB type (0=localized,1=distributed) - @param rb_alloc_dci rballoc field from DCI -*/ -uint32_t get_rballoc(vrb_t vrb_type,uint16_t rb_alloc_dci); - - -/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type - @returns Transmission mode (1-7) -*/ -uint8_t get_transmission_mode(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); - - -/* \brief - @param ra_header Header of resource allocation (0,1) (See sections 7.1.6.1/7.1.6.2 of 36.213 Rel8.6) - @param rb_alloc Bitmap allocation from DCI (format 1,2) - @returns number of physical resource blocks -*/ -uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL); - -int get_G(NR_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint8_t mod_order,uint8_t Nl,uint8_t num_pdcch_symbols,int frame,uint8_t subframe, uint8_t beamforming_mode); - -int adjust_G(NR_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe); -int adjust_G2(NR_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol); - - -#ifndef modOrder -#define modOrder(I_MCS,I_TBS) ((I_MCS-I_TBS)*2+2) // Find modulation order from I_TBS and I_MCS -#endif - -/** \fn uint8_t I_TBS2I_MCS(uint8_t I_TBS); - \brief This function maps I_tbs to I_mcs according to Table 7.1.7.1-1 in 3GPP TS 36.213 V8.6.0. Where there is two supported modulation orders for the same I_TBS then either high or low modulation is chosen by changing the equality of the two first comparisons in the if-else statement. - \param I_TBS Index of Transport Block Size - \return I_MCS given I_TBS -*/ -uint8_t I_TBS2I_MCS(uint8_t I_TBS); - -/** \fn uint8_t SE2I_TBS(float SE, - uint8_t N_PRB, - uint8_t symbPerRB); - \brief This function maps a requested throughput in number of bits to I_tbs. The throughput is calculated as a function of modulation order, RB allocation and number of symbols per RB. The mapping orginates in the "Transport block size table" (Table 7.1.7.2.1-1 in 3GPP TS 36.213 V8.6.0) - \param SE Spectral Efficiency (before casting to integer, multiply by 1024, remember to divide result by 1024!) - \param N_PRB Number of PhysicalResourceBlocks allocated \sa lte_frame_parms->N_RB_DL - \param symbPerRB Number of symbols per resource block allocated to this channel - \return I_TBS given an SE and an N_PRB -*/ -uint8_t SE2I_TBS(float SE, - uint8_t N_PRB, - uint8_t symbPerRB); -/** \brief This function generates the sounding reference symbol (SRS) for the uplink according to 36.211 v8.6.0. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence. - @param frame_parms LTE DL Frame Parameters - @param soundingrs_ul_config_dedicated Dynamic configuration from RRC during Connection Establishment - @param txdataF pointer to the frequency domain TX signal - @returns 0 on success*/ -int generate_srs(NR_DL_FRAME_PARMS *frame_parms, - SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated, - int *txdataF, - int16_t amp, - uint32_t subframe); - - -/*! - \brief This function is similar to generate_srs_tx but generates a conjugate sequence for channel estimation. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence. - @param phy_vars_ue Pointer to PHY_VARS structure - @param eNB_id Index of destination eNB for this SRS - @param amp Linear amplitude of SRS - @param subframe Index of subframe on which to act - @returns 0 on success, -1 on error with message -*/ - -int32_t generate_srs_tx(PHY_VARS_NR_UE *phy_vars_ue, - uint8_t eNB_id, - int16_t amp, - uint32_t subframe); - -/*! - \brief This function generates the downlink reference signal for the PUSCH according to 36.211 v8.6.0. The DRS occuies the RS defined by rb_alloc and the symbols 2 and 8 for extended CP and 3 and 10 for normal CP. -*/ - -int32_t generate_drs_pusch(PHY_VARS_NR_UE *phy_vars_ue, - UE_nr_rxtx_proc_t *proc, - uint8_t eNB_id, - int16_t amp, - uint32_t subframe, - uint32_t first_rb, - uint32_t nb_rb, - uint8_t ant); - -/*! - \brief This function initializes the Group Hopping, Sequence Hopping and nPRS sequences for PUCCH/PUSCH according to 36.211 v8.6.0. It should be called after configuration of UE (reception of SIB2/3) and initial configuration of eNB (or after reconfiguration of cell-specific parameters). - @param frame_parms Pointer to a NR_DL_FRAME_PARMS structure (eNB or UE)*/ -void init_ul_hopping(NR_DL_FRAME_PARMS *frame_parms); - - -/*! - \brief This function implements the initialization of paging parameters for UE (See Section 7, 36.304).It must be called after setting IMSImod1024 during UE startup and after receiving SIB2 - @param ue Pointer to UE context - @param defaultPagingCycle T from 36.304 (0=32,1=64,2=128,3=256) - @param nB nB from 36.304 (0=4T,1=2T,2=T,3=T/2,4=T/4,5=T/8,6=T/16,7=T/32*/ -int init_ue_paging_info(PHY_VARS_NR_UE *ue, long defaultPagingCycle, long nB); - -int32_t compareints (const void * a, const void * b); - - -void ulsch_modulation(int32_t **txdataF, - int16_t amp, - frame_t frame, - uint32_t subframe, - NR_DL_FRAME_PARMS *frame_parms, - NR_UE_ULSCH_t *ulsch); - - - - - - -int generate_ue_dlsch_params_from_dci(int frame, - uint8_t subframe, - void *dci_pdu, - rnti_t rnti, - DCI_format_t dci_format, - NR_UE_PDCCH *pdcch_vars, - NR_UE_PDSCH *pdsch_vars, - NR_UE_DLSCH_t **dlsch, - NR_DL_FRAME_PARMS *frame_parms, - PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint8_t beamforming_mode, - uint16_t tc_rnti); - - -int generate_ue_ulsch_params_from_dci(void *dci_pdu, - rnti_t rnti, - uint8_t subframe, - DCI_format_t dci_format, - PHY_VARS_NR_UE *phy_vars_ue, - UE_nr_rxtx_proc_t *proc, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t cba_rnti, - uint8_t eNB_id, - uint8_t use_srs); - -int32_t generate_ue_ulsch_params_from_rar(PHY_VARS_NR_UE *phy_vars_ue, - UE_nr_rxtx_proc_t *proc, - uint8_t eNB_id); -double sinr_eff_cqi_calc(PHY_VARS_NR_UE *phy_vars_ue, - uint8_t eNB_id, - uint8_t subframe); - -uint8_t sinr2cqi(double sinr,uint8_t trans_mode); - - -int dump_dci(NR_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci); - -int dump_ue_stats(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, char* buffer, int length, runmode_t mode, int input_level_dBm); - -void init_transport_channels(uint8_t); - -void generate_RIV_tables(void); - -/*! - \brief This function performs the initial cell search procedure - PSS detection, SSS detection and PBCH detection. At the - end, the basic frame parameters are known (Frame configuration - TDD/FDD and cyclic prefix length, - N_RB_DL, PHICH_CONFIG and Nid_cell) and the UE can begin decoding PDCCH and DLSCH SI to retrieve the rest. Once these - parameters are know, the routine calls some basic initialization routines (cell-specific reference signals, etc.) - @param phy_vars_ue Pointer to UE variables - @param mode current running mode -*/ -int nr_initial_sync(UE_nr_rxtx_proc_t *proc, - PHY_VARS_NR_UE *phy_vars_ue, runmode_t mode); - - -/*! - \brief Encoding of PUSCH/ACK/RI/ACK from 36-212. - @param a Pointer to ulsch SDU - @param frame_parms Pointer to Frame parameters - @param ulsch Pointer to ulsch descriptor - @param harq_pid HARQ process ID - @param tmode Transmission mode (1-7) - @param control_only_flag Generate PUSCH with control information only - @param Nbundled Parameter for ACK/NAK bundling (36.213 Section 7.3) -*/ -uint32_t ulsch_encoding(uint8_t *a, - PHY_VARS_NR_UE *phy_vars_ue, - uint8_t harq_pid, - uint8_t eNB_id, - uint8_t subframe_rx, - uint8_t tmode, - uint8_t control_only_flag, - uint8_t Nbundled); - -void print_CQI(void *o,UCI_format_t uci_format,uint8_t eNB_id,int N_RB_DL); - -void fill_CQI(NR_UE_ULSCH_t *ulsch,PHY_NR_MEASUREMENTS *meas,uint8_t eNB_id, uint8_t harq_pid,int N_RB_DL, rnti_t rnti, uint8_t trans_mode,double sinr_eff); - -void reset_cba_uci(void *o); - -/** \brief This routine computes the subband PMI bitmap based on measurements (0,1,2,3 for rank 0 and 0,1 for rank 1) in the format needed for UCI - @param meas pointer to measurements - @param eNB_id eNB_id - @param nb_subbands number of subbands - @returns subband PMI bitmap -*/ -uint16_t quantize_subband_pmi(PHY_NR_MEASUREMENTS *meas,uint8_t eNB_id,int nb_subbands); - -int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb); - -uint16_t quantize_subband_pmi2(PHY_NR_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t a_id,int nb_subbands); - - - -uint64_t cqi2hex(uint32_t cqi); - -uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); - - -/** \brief This routine extracts a single subband PMI from a bitmap coming from UCI or the pmi_extend function - @param N_RB_DL number of resource blocks - @param mimo_mode - @param pmi_alloc subband PMI bitmap - @param rb resource block for which to extract PMI - @returns subband PMI -*/ -uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb); - -int get_nCCE_offset_l1(int *CCE_table, - const unsigned char L, - const int nCCE, - const int common_dci, - const unsigned short rnti, - const unsigned char subframe); - -uint16_t get_nCCE(uint8_t num_pdcch_symbols,NR_DL_FRAME_PARMS *frame_parms,uint8_t mi); - -uint16_t get_nquad(uint8_t num_pdcch_symbols,NR_DL_FRAME_PARMS *frame_parms,uint8_t mi); - -uint8_t get_mi(NR_DL_FRAME_PARMS *frame,uint8_t subframe); - -uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe); - -uint8_t get_num_pdcch_symbols(uint8_t num_dci,DCI_ALLOC_t *dci_alloc,NR_DL_FRAME_PARMS *frame_parms,uint8_t subframe); - -void pdcch_interleaving(NR_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wbar,uint8_t n_symbols_pdcch,uint8_t mi); - -void pdcch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - int8_t* llr, - uint32_t length); - - - -void dlsch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, - int mbsfn_flag, - NR_UE_DLSCH_t *dlsch, - int G, - int16_t* llr, - uint8_t q, - uint8_t Ns); - -void init_ncs_cell(NR_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]); - -void generate_pucch1x(int32_t **txdataF, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t ncs_cell[20][7], - PUCCH_FMT_t fmt, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint16_t n1_pucch, - uint8_t shortened_format, - uint8_t *payload, - int16_t amp, - uint8_t subframe); - -void generate_pucch2x(int32_t **txdataF, - NR_DL_FRAME_PARMS *fp, - uint8_t ncs_cell[20][7], - PUCCH_FMT_t fmt, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint16_t n2_pucch, - uint8_t *payload, - int A, - int B2, - int16_t amp, - uint8_t subframe, - uint16_t rnti); - -void generate_pucch3x(int32_t **txdataF, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t ncs_cell[20][7], - PUCCH_FMT_t fmt, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint16_t n3_pucch, - uint8_t shortened_format, - uint8_t *payload, - int16_t amp, - uint8_t subframe, - uint16_t rnti); - - -void init_ulsch_power_LUT(void); - -/*! - \brief Check for PRACH TXop in subframe - @param frame_parms Pointer to NR_DL_FRAME_PARMS - @param frame frame index to check - @param subframe subframe index to check - @returns 0 on success -*/ -int is_prach_subframe(NR_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t subframe); - -/*! - \brief Generate PRACH waveform - @param phy_vars_ue Pointer to ue top-level descriptor - @param eNB_id Index of destination eNB - @param subframe subframe index to operate on - @param index of preamble (0-63) - @param Nf System frame number - @returns 0 on success - -*/ -int32_t generate_prach(PHY_VARS_NR_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe,uint16_t Nf); - - -/*! - \brief Helper for MAC, returns number of available PRACH in TDD for a particular configuration index - @param frame_parms Pointer to NR_DL_FRAME_PARMS structure - @returns 0-5 depending on number of available prach -*/ -uint8_t get_num_prach_tdd(module_id_t Mod_id); - -/*! - \brief Return the PRACH format as a function of the Configuration Index and Frame type. - @param prach_ConfigIndex PRACH Configuration Index - @param frame_type 0-FDD, 1-TDD - @returns 0-1 accordingly -*/ -uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type); - -/*! - \brief Helper for MAC, returns frequency index of PRACH resource in TDD for a particular configuration index - @param frame_parms Pointer to NR_DL_FRAME_PARMS structure - @returns 0-5 depending on number of available prach -*/ -uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index); - -/*! - \brief Comp ute DFT of PRACH ZC sequences. Used for generation of prach in UE and reception of PRACH in eNB. - @param rootSequenceIndex PRACH root sequence - #param prach_ConfigIndex PRACH Configuration Index - @param zeroCorrelationZoneConfig PRACH ncs_config - @param highSpeedFlat PRACH High-Speed Flag - @param frame_type TDD/FDD flag - @param Xu DFT output -*/ -void compute_prach_seq(uint16_t rootSequenceIndex, - uint8_t prach_ConfigIndex, - uint8_t zeroCorrelationZoneConfig, - uint8_t highSpeedFlag, - lte_frame_type_t frame_type, - uint32_t X_u[64][839]); - -void compute_nr_prach_seq(uint8_t short_sequence, - uint8_t num_sequences, - uint8_t rootSequenceIndex, - uint32_t X_u[64][839]); - -void init_prach_tables(int N_ZC); -void init_nr_prach_tables(int N_ZC); - -void init_unscrambling_lut(void); -void init_scrambling_lut(void); - -/*! - \brief Return the status of MBSFN in this frame/subframe - @param frame Frame index - @param subframe Subframe index - @param frame_parms Pointer to frame parameters - @returns 1 if subframe is for MBSFN -*/ -int is_pmch_subframe(frame_t frame, int subframe, NR_DL_FRAME_PARMS *frame_parms); - -uint8_t is_not_pilot(uint8_t pilots, uint8_t re, uint8_t nushift, uint8_t use2ndpilots); - -uint8_t is_not_UEspecRS(int8_t lprime, uint8_t re, uint8_t nushift, uint8_t Ncp, uint8_t beamforming_mode); - -uint32_t dlsch_decoding_abstraction(double *dlsch_MIPB, - NR_DL_FRAME_PARMS *lte_frame_parms, - NR_UE_DLSCH_t *dlsch, - uint8_t subframe, - uint8_t num_pdcch_symbols); - -// DL power control functions -double get_pa_dB(uint8_t pa); - - -double computeRhoA_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - NR_UE_DLSCH_t *dlsch_ue, - uint8_t dl_power_off, - uint8_t n_antenna_port); - -double computeRhoB_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - PDSCH_CONFIG_COMMON *pdsch_config_common, - uint8_t n_antenna_port, - NR_UE_DLSCH_t *dlsch_ue, - uint8_t dl_power_off); - -/*void compute_sqrt_RhoAoRhoB(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - PDSCH_CONFIG_COMMON *pdsch_config_common, - uint8_t n_antenna_port, - NR_UE_DLSCH_t *dlsch_ue); -*/ - -uint8_t get_prach_prb_offset(NR_DL_FRAME_PARMS *frame_parms, - uint8_t prach_ConfigIndex, - uint8_t n_ra_prboffset, - uint8_t tdd_mapindex, uint16_t Nf); - -void nr_pdcch_unscrambling(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx, - int16_t *z, uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common); - - -uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset); - -int nr_rx_pdsch(PHY_VARS_NR_UE *ue, - PDSCH_t type, - unsigned char eNB_id, - unsigned char eNB_id_i, //if this == ue->n_connected_eNB, we assume MU interference - uint32_t frame, - uint8_t nr_tti_rx, - unsigned char symbol, - unsigned char first_symbol_flag, - RX_type_t rx_type, - unsigned char i_mod, - unsigned char harq_pid); - -uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm, uint8_t Nl) ; - -uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, - short *dlsch_llr, - NR_DL_FRAME_PARMS *frame_parms, - NR_UE_DLSCH_t *dlsch, - NR_DL_UE_HARQ_t *harq_process, - uint32_t frame, - uint16_t nb_symb_sch, - uint8_t nr_tti_rx, - uint8_t harq_pid, - uint8_t is_crnti, - uint8_t llr8_flag); - -/**@}*/ -#endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c index cdb7229998..c8dcfdd3f9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c @@ -35,7 +35,7 @@ #include "PHY/impl_defs_nr.h" #include "PHY/defs_nr_UE.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" -#include "PHY/NR_TRANSPORT/nr_transport_proto_common.h" +#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index d20457de06..8dbe588cb8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -37,6 +37,9 @@ #include #include "nfapi_interface.h" +#define NR_PUSCH_x 2 // UCI placeholder bit TS 38.212 V15.4.0 subclause 5.3.3.1 +#define NR_PUSCH_y 3 // UCI placeholder bit + // Functions below implement 36-211 and 36-212 /** @addtogroup _PHY_TRANSPORT_ @@ -66,24 +69,6 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulsch,unsigned char N_RB_UL); NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag); -void fill_UE_dlsch_MCH(PHY_VARS_NR_UE *ue,int mcs,int ndi,int rvidx,int eNB_id); - -int rx_pmch(PHY_VARS_NR_UE *phy_vars_ue, - unsigned char eNB_id, - uint8_t subframe, - unsigned char symbol); - -/** \brief Dump OCTAVE/MATLAB files for PMCH debugging - @param phy_vars_ue Pointer to UE variables - @param eNB_id index of eNB in ue variables - @param coded_bits_per_codeword G from 36.211 - @param subframe Index of subframe - @returns 0 on success -*/ -void dump_mch(PHY_VARS_NR_UE *phy_vars_ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,int subframe); - - - /** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/QPSK reception. @param stream0_in Input from channel compensated (MR combined) stream 0 @param stream1_in Input from channel compensated (MR combined) stream 1 diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index a6904ed25b..4c37e49fb2 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -42,7 +42,7 @@ #include "PHY/MODULATION/modulation_UE.h" #include "PHY/INIT/phy_init.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" -#include "PHY/NR_TRANSPORT/nr_transport_proto_common.h" +#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "nr_unitary_defs.h" #include "OCG_vars.h" From 19530c5ab9f03f6f620e67a29adedd4a537f0d23 Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 9 Apr 2020 18:55:57 +0200 Subject: [PATCH 04/42] Cleanup nr transport header file --- openair1/PHY/CODING/TESTBENCH/polartest.c | 1 - openair1/PHY/NR_TRANSPORT/nr_pbch.c | 1 - openair1/PHY/NR_TRANSPORT/nr_transport.h | 27 ------------------- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 7 +++++ .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 1 - openair1/SCHED_NR/fapi_nr_l1.c | 1 - openair1/SCHED_NR/phy_procedures_nr_gNB.c | 1 - openair1/SIMULATION/NR_PHY/ulsim.c | 1 - 8 files changed, 7 insertions(+), 33 deletions(-) delete mode 100644 openair1/PHY/NR_TRANSPORT/nr_transport.h diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 806d8de28c..776409121b 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -12,7 +12,6 @@ #include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" -//#include "PHY/NR_TRANSPORT/nr_transport.h" //#include "common/utils/LOG/log.h" //#define DEBUG_DCI_POLAR_PARAMS diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 923e920321..f5a26aec80 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -33,7 +33,6 @@ #include "PHY/defs_gNB.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" #include "PHY/LTE_REFSIG/lte_refsig.h" #include "PHY/sse_intrin.h" diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport.h b/openair1/PHY/NR_TRANSPORT/nr_transport.h deleted file mode 100644 index 9597de10a7..0000000000 --- a/openair1/PHY/NR_TRANSPORT/nr_transport.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 __NR_TRANSPORT__H__ -#define __NR_TRANSPORT__H__ - -#define NR_PBCH_PDU_BITS 24 - -#endif /*__NR_TRANSPORT__H__*/ diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 24b6303b9c..11d38cc113 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -30,10 +30,15 @@ * \warning */ +#ifndef __NR_TRANSPORT__H__ +#define __NR_TRANSPORT__H__ + #include "PHY/defs_nr_common.h" #include "PHY/defs_gNB.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" +#define NR_PBCH_PDU_BITS 24 + /*! \fn int nr_generate_pss \brief Generation of the NR PSS @@ -307,3 +312,5 @@ int16_t find_nr_prach_ru(RU_t *ru,int frame,int slot, find_type_t type); void init_prach_list(PHY_VARS_gNB *gNB); void init_prach_ru_list(RU_t *ru); void free_nr_ru_prach_entry(RU_t *ru, int prach_id); + +#endif /*__NR_TRANSPORT__H__*/ diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 5c4df8ce40..c38deaff2d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -30,7 +30,6 @@ */ #include "PHY/defs_nr_UE.h" #include "PHY/phy_extern_nr_ue.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "nr_transport_proto_ue.h" //#include "SCHED/defs.h" diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index a2d26765f1..40e4a56667 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -31,7 +31,6 @@ */ #include "fapi_nr_l1.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_TRANSPORT/nr_dci.h" diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 37d4e94972..e8b685a885 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -23,7 +23,6 @@ #include "PHY/defs_gNB.h" #include "sched_nr.h" #include "PHY/NR_REFSIG/dmrs_nr.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_TRANSPORT/nr_ulsch.h" diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 18a1ea6c92..eaff133adb 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -41,7 +41,6 @@ #include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h" -#include "PHY/NR_TRANSPORT/nr_transport.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_ulsch.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" From ec422f705056f2a4ca5c9366cd313a84da4eb649 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 13 Apr 2020 20:26:01 +0200 Subject: [PATCH 05/42] Introduced a delay after a completed sync before starting msg1 generation: - this was necessary because as soon as the gNB starts, it tries detecting the prach preambles and it mesaures the background noise. However, there is a delay of several dozens of frames before it considers the preables as detected. - the solution at the UE consists in avoiding sending preamble as soon as the UE syncs by introducing an offset, this keeps the power measurements low at gNB side as long as the preamble detection counter is under threshold --- openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c | 3 +++ openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 1 + openair1/PHY/defs_nr_common.h | 6 +++++- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 11 +++++++++-- openair1/SIMULATION/NR_PHY/prachsim.c | 1 + openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 2 +- 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c index d140442523..b49443c03c 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c @@ -35,6 +35,7 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, PHY_VARS_NR_UE *ue, module_id_t gNB_id, + uint8_t frame, uint8_t subframe, unsigned char clear, short coef) @@ -104,6 +105,8 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, //mac_resynch(); //dl_phy_sync_success(ue->Mod_id,ue->proc.proc_rxtx[0].frame_rx,0,1);//ue->common_vars.eNb_id); ue->UE_mode[0] = PRACH; + ue->prach_resources[gNB_id]->sync_frame = frame; + ue->prach_resources[gNB_id]->init_msg1 = 0; } else { ue->UE_mode[0] = PUSCH; diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index 6326ed9446..1837664391 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -75,6 +75,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, PHY_VARS_NR_UE *ue, module_id_t eNB_id, + uint8_t frame, uint8_t subframe, unsigned char clear, short coef); diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 9caf3bc682..6531f582ac 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -221,8 +221,12 @@ typedef struct { uint16_t ra_RNTI; /// Pointer to Msg3 payload for UL-grant uint8_t *Msg3; - /// Flag for the Msg1 generation + /// Flag for the Msg1 generation: it is enabled every time it is nr prach slot uint8_t generate_nr_prach; + /// Frame of last completed synch + uint8_t sync_frame; + /// Flag to indicate that prach is ready to start: it is enabled with an initial delay after the sync + uint8_t init_msg1; } NR_PRACH_RESOURCES_t; typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index b7922993cf..ced577b16e 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2482,8 +2482,11 @@ void nr_ue_pbch_procedures(uint8_t gNB_id, ue->pbch_vars[gNB_id]->pdu_errors_conseq = 0; // Switch to PRACH state if it is first PBCH after initial synch and no timing correction is performed - if (ue->UE_mode[gNB_id] == NOT_SYNCHED && ue->no_timing_correction == 1) + if (ue->UE_mode[gNB_id] == NOT_SYNCHED && ue->no_timing_correction == 1){ ue->UE_mode[gNB_id] = PRACH; + ue->prach_resources[gNB_id]->sync_frame = frame_rx; + ue->prach_resources[gNB_id]->init_msg1 = 0; + } #ifdef DEBUG_PHY_PROC uint16_t frame_tx; @@ -4079,6 +4082,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_adjust_synch_ue(fp, ue, eNB_id, + frame_rx, nr_tti_rx, 0, 16384); @@ -4523,7 +4527,10 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t } } - if (ue->prach_resources[gNB_id] != NULL && prach_resources->generate_nr_prach == 1) { + if (!prach_resources->init_msg1 && (frame_tx > ue->prach_resources[gNB_id]->sync_frame + 150)) + prach_resources->init_msg1 = 1; + + if (ue->prach_resources[gNB_id] != NULL && prach_resources->generate_nr_prach == 1 && prach_resources->init_msg1) { ue->prach_cnt = 0; pathloss = get_nr_PL(mod_id, ue->CC_id, gNB_id); diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 4c37e49fb2..014813aae5 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -501,6 +501,7 @@ int main(int argc, char **argv){ printf("raPreamble %d\n",preamble_tx); UE->prach_resources[0]->ra_PreambleIndex = preamble_tx; + UE->prach_resources[0]->init_msg1 = 1; // Configure channel bw = N_RB_UL*(180e3)*(1 << frame_parms->numerology_index); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 75091d49e2..00eaa56855 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -353,7 +353,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, AssertFatal(CC_id == 0,"Transmission on secondary CCs is not supported yet\n"); - if (UE_mode == PRACH) { + if (UE_mode == PRACH && prach_resources->init_msg1) { LOG_D(MAC, "nr_ue_get_rach, RA_active value: %d", mac->RA_active); From 6f87d474b7433acd4cf02c5e2d4df3ea0d32ce7c Mon Sep 17 00:00:00 2001 From: cig Date: Tue, 14 Apr 2020 16:08:42 +0200 Subject: [PATCH 06/42] Fixed wrong printing in nr_process_timing_advance --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index ced577b16e..cc1a2fe838 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1302,7 +1302,7 @@ void nr_process_timing_advance(module_id_t Mod_id, uint8_t CC_id, uint8_t ta_com PHY_vars_UE_g[Mod_id][CC_id]->timing_advance += (ta_command - 31) * bw_scaling / factor_mu; - LOG_D(PHY, "[UE %d] Got timing advance command %u from MAC, new value is %u\n", Mod_id, ta_command, PHY_vars_UE_g[Mod_id][CC_id]->timing_advance); + LOG_D(PHY, "[UE %d] Got timing advance command %u from MAC, new value is %d\n", Mod_id, ta_command, PHY_vars_UE_g[Mod_id][CC_id]->timing_advance); } // WIP From 0546bcea9409d33dac9935715e8202c33b567da4 Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 22 Apr 2020 17:57:24 +0200 Subject: [PATCH 07/42] Doing phy procedures RX in slot 7 for RAR DCI --- executables/nr-ue.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 514d5f0239..759d139169 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -434,7 +434,8 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { //program DCI for slot 1 //TODO: all of this has to be moved to the MAC!!! - if (proc->nr_tti_rx == NR_DOWNLINK_SLOT || UE->frame_parms.frame_type == FDD){ + // Note: temp hardcoded slot 7 for RAR + if (proc->nr_tti_rx == NR_DOWNLINK_SLOT || proc->nr_tti_rx == 7 || UE->frame_parms.frame_type == FDD){ dcireq.module_id = UE->Mod_id; dcireq.gNB_index = 0; dcireq.cc_id = 0; @@ -462,7 +463,7 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { } // Process Rx data for one sub-frame - if ( proc->nr_tti_rx >=0 && proc->nr_tti_rx <= 1 ) { + if ( proc->nr_tti_rx >=0 && proc->nr_tti_rx <= 1 || proc->nr_tti_rx == 7) { #ifdef UE_SLOT_PARALLELISATION phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); #else From 220685e320ff0f2fbc362cc9659ab10d060e60b4 Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 22 Apr 2020 18:04:39 +0200 Subject: [PATCH 08/42] UE RAR DCI reception - NR UE scheduled response for RA PDSCH case - UE processing of RAR DCI - some cleanup and formatting --- .../nfapi/public_inc/fapi_nr_ue_constants.h | 1 + openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 15 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 219 +++++++++--------- .../NR_MAC_UE/nr_ue_dci_configuration.c | 34 ++- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 6 +- 5 files changed, 146 insertions(+), 129 deletions(-) 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 4b0720078a..e1d06335f5 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 @@ -43,6 +43,7 @@ #define FAPI_NR_DL_CONFIG_TYPE_DCI 0x01 #define FAPI_NR_DL_CONFIG_TYPE_DLSCH 0x02 +#define FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH 0x03 #define FAPI_NR_CCE_REG_MAPPING_TYPE_INTERLEAVED 0x01 diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 7edbfcbd6c..f48635d3f7 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -51,8 +51,8 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ // Note: we have to handle the thread IDs for this. To be revisited completely. thread_id = PHY_vars_UE_g[module_id][cc_id]->current_thread_id[slot]; + NR_UE_DLSCH_t *dlsch0; NR_UE_PDCCH *pdcch_vars = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][0]; - NR_UE_DLSCH_t *dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch[thread_id][0][0]; NR_UE_ULSCH_t *ulsch0 = PHY_vars_UE_g[module_id][cc_id]->ulsch[thread_id][0][0]; if(scheduled_response->dl_config != NULL){ @@ -69,7 +69,14 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ pdcch_vars->nb_search_space = pdcch_vars->nb_search_space + 1; LOG_D(PHY,"Number of DCI SearchSpaces %d\n",pdcch_vars->nb_search_space); - } else { //FAPI_NR_DL_CONFIG_TYPE_DLSCH + } else { + + if (dl_config->dl_config_list[i].pdu_type == FAPI_NR_DL_CONFIG_TYPE_DLSCH){ + dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch[thread_id][0][0]; + } + else if (dl_config->dl_config_list[i].pdu_type == FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH){ + dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch_ra[0]; + } fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu = &dl_config->dl_config_list[i].dlsch_config_pdu.dlsch_config_rel15; uint8_t current_harq_pid = dlsch_config_pdu->harq_process_nbr; @@ -80,7 +87,9 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ dlsch0->rnti = dl_config->dl_config_list[i].dlsch_config_pdu.rnti; //dlsch0->harq_processes[0]->mcs = &dlsch_config_pdu->mcs; dlsch0_harq = dlsch0->harq_processes[current_harq_pid]; - if (dlsch0_harq != NULL){ + + if (dlsch0_harq){ + dlsch0_harq->BWPStart = dlsch_config_pdu->BWPStart; dlsch0_harq->BWPSize = dlsch_config_pdu->BWPSize; dlsch0_harq->nb_rb = dlsch_config_pdu->number_rbs; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index cc1a2fe838..adeb186517 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2774,19 +2774,20 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, nr_tti_rx, &dci_ind); -#ifdef NR_PDCCH_SCHED_DEBUG +//#ifdef NR_PDCCH_SCHED_DEBUG LOG_I(PHY,"<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%u\n",dci_cnt); -#endif +//#endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_OUT); //LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_tti_rx %d PHICH RX\n",ue->Mod_id,frame_rx,nr_tti_rx); for (int i=0; i rnti %x : format %d\n", - ue->Mod_id,frame_rx%1024,nr_tti_rx,nr_mode_string[ue->UE_mode[gNB_id]], - i, - dci_ind.dci_list[i].rnti, - dci_ind.dci_list[i].dci_format); + LOG_D(PHY,"[UE %d] AbsSubFrame %d.%d, Mode %s: DCI %i of %d total DCIs found --> rnti %x : format %d\n", + ue->Mod_id,frame_rx%1024,nr_tti_rx,nr_mode_string[ue->UE_mode[gNB_id]], + i + 1, + dci_cnt, + dci_ind.dci_list[i].rnti, + dci_ind.dci_list[i].dci_format); } ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->dci_received += dci_cnt; @@ -3035,7 +3036,7 @@ void nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB int first_symbol_flag=0; if (!dlsch0) - return; + return; if (dlsch0->active == 0) return; @@ -3044,9 +3045,9 @@ void nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB uint16_t BWPStart = dlsch0->harq_processes[harq_pid]->BWPStart; // uint16_t BWPSize = dlsch0->harq_processes[harq_pid]->BWPSize; uint16_t pdsch_start_rb = dlsch0->harq_processes[harq_pid]->start_rb; - uint16_t pdsch_nb_rb = dlsch0->harq_processes[harq_pid]->nb_rb; - uint16_t s0 = dlsch0->harq_processes[harq_pid]->start_symbol; - uint16_t s1 = dlsch0->harq_processes[harq_pid]->nb_symbols; + uint16_t pdsch_nb_rb = dlsch0->harq_processes[harq_pid]->nb_rb; + uint16_t s0 = dlsch0->harq_processes[harq_pid]->start_symbol; + uint16_t s1 = dlsch0->harq_processes[harq_pid]->nb_symbols; LOG_D(PHY,"[UE %d] PDSCH type %d active in nr_tti_rx %d, harq_pid %d, rb_start %d, nb_rb %d, symbol_start %d, nb_symbols %d, DMRS mask %x\n",ue->Mod_id,pdsch,nr_tti_rx,harq_pid,pdsch_start_rb,pdsch_nb_rb,s0,s1,dlsch0->harq_processes[harq_pid]->dlDmrsSymbPos); @@ -3305,14 +3306,11 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, if (dlsch0==NULL) AssertFatal(0,"dlsch0 should be defined at this level \n"); - harq_pid = dlsch0->current_harq_pid; is_cw0_active = dlsch0->harq_processes[harq_pid]->status; nb_symb_sch = dlsch0->harq_processes[harq_pid]->nb_symbols; start_symbol = dlsch0->harq_processes[harq_pid]->start_symbol; - - if(dlsch1) is_cw1_active = dlsch1->harq_processes[harq_pid]->status; @@ -3379,10 +3377,10 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, start_meas(&ue->dlsch_unscrambling_stats); #endif nr_dlsch_unscrambling(pdsch_vars->llr[0], - dlsch0->harq_processes[harq_pid]->G, - 0, - ue->frame_parms.Nid_cell, - dlsch0->rnti); + dlsch0->harq_processes[harq_pid]->G, + 0, + ue->frame_parms.Nid_cell, + dlsch0->rnti); #if UE_TIMING_TRACE @@ -3463,10 +3461,10 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, start_meas(&ue->dlsch_unscrambling_stats); #endif nr_dlsch_unscrambling(pdsch_vars->llr[1], - dlsch1->harq_processes[harq_pid]->G, - 0, - ue->frame_parms.Nid_cell, - dlsch1->rnti); + dlsch1->harq_processes[harq_pid]->G, + 0, + ue->frame_parms.Nid_cell, + dlsch1->rnti); #if UE_TIMING_TRACE stop_meas(&ue->dlsch_unscrambling_stats); #endif @@ -3487,31 +3485,31 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, #ifdef UE_DLSCH_PARALLELISATION ret1 = nr_dlsch_decoding_mthread(ue, - proc, - eNB_id, - pdsch_vars->llr[1], - &ue->frame_parms, - dlsch1, - dlsch1->harq_processes[harq_pid], - frame_rx, - nb_symb_sch, - nr_tti_rx, - harq_pid, - pdsch==PDSCH?1:0, - dlsch1->harq_processes[harq_pid]->TBS>256?1:0); + proc, + eNB_id, + pdsch_vars->llr[1], + &ue->frame_parms, + dlsch1, + dlsch1->harq_processes[harq_pid], + frame_rx, + nb_symb_sch, + nr_tti_rx, + harq_pid, + pdsch==PDSCH?1:0, + dlsch1->harq_processes[harq_pid]->TBS>256?1:0); LOG_T(PHY,"UE_DLSCH_PARALLELISATION is defined, ret1 = %d\n", ret1); #else ret1 = nr_dlsch_decoding(ue, - pdsch_vars->llr[1], - &ue->frame_parms, - dlsch1, - dlsch1->harq_processes[harq_pid], - frame_rx, - nb_symb_sch, - nr_tti_rx, - harq_pid, - pdsch==PDSCH?1:0,//proc->decoder_switch, - dlsch1->harq_processes[harq_pid]->TBS>256?1:0); + pdsch_vars->llr[1], + &ue->frame_parms, + dlsch1, + dlsch1->harq_processes[harq_pid], + frame_rx, + nb_symb_sch, + nr_tti_rx, + harq_pid, + pdsch==PDSCH?1:0,//proc->decoder_switch, + dlsch1->harq_processes[harq_pid]->TBS>256?1:0); LOG_T(PHY,"UE_DLSCH_PARALLELISATION is NOT defined, ret1 = %d\n", ret1); printf("start cw1 dlsch decoding\n"); #endif @@ -3533,45 +3531,46 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, #endif LOG_I(PHY,"AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", frame_rx%1024, nr_tti_rx,(ue->dlsch_decoding_stats[ue->current_thread_id[nr_tti_rx]].p_time)/(cpuf*1000.0)); + + LOG_D(PHY, "harq_pid: %d, TBS expected dlsch1: %d \n", harq_pid, dlsch1->harq_processes[harq_pid]->TBS); } LOG_D(PHY," ------ end ldpc decoder for AbsSubframe %d.%d ------ \n", frame_rx, nr_tti_rx); - - LOG_D(PHY, "harq_pid: %d, TBS expected dlsch0: %d, TBS expected dlsch1: %d \n",harq_pid, dlsch0->harq_processes[harq_pid]->TBS, dlsch1->harq_processes[harq_pid]->TBS); + LOG_D(PHY, "harq_pid: %d, TBS expected dlsch0: %d \n",harq_pid, dlsch0->harq_processes[harq_pid]->TBS); if(retmax_ldpc_iterations+1){ - // fill dl_indication message - dl_indication.module_id = ue->Mod_id; - dl_indication.cc_id = ue->CC_id; - dl_indication.gNB_index = eNB_id; - dl_indication.frame = frame_rx; - dl_indication.slot = nr_tti_rx; - dl_indication.rx_ind = &rx_ind; // hang on rx_ind instance - dl_indication.proc=proc; + // fill dl_indication message + dl_indication.module_id = ue->Mod_id; + dl_indication.cc_id = ue->CC_id; + dl_indication.gNB_index = eNB_id; + dl_indication.frame = frame_rx; + dl_indication.slot = nr_tti_rx; + dl_indication.rx_ind = &rx_ind; // hang on rx_ind instance + dl_indication.proc=proc; - //dl_indication.rx_ind->number_pdus - switch (pdsch) { - case RA_PDSCH: - rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_RAR; - break; - case PDSCH: - rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_DLSCH; - break; - default: - break; - } + //dl_indication.rx_ind->number_pdus + switch (pdsch) { + case RA_PDSCH: + rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_RAR; + break; + case PDSCH: + rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_DLSCH; + break; + default: + break; + } - rx_ind.rx_indication_body[0].pdsch_pdu.pdu = dlsch0->harq_processes[harq_pid]->b; - rx_ind.rx_indication_body[0].pdsch_pdu.pdu_length = dlsch0->harq_processes[harq_pid]->TBS>>3; - LOG_D(PHY, "PDU length in bits: %d, in bytes: %d \n", dlsch0->harq_processes[harq_pid]->TBS, rx_ind.rx_indication_body[0].pdsch_pdu.pdu_length); - rx_ind.number_pdus = 1; + rx_ind.rx_indication_body[0].pdsch_pdu.pdu = dlsch0->harq_processes[harq_pid]->b; + rx_ind.rx_indication_body[0].pdsch_pdu.pdu_length = dlsch0->harq_processes[harq_pid]->TBS>>3; + LOG_D(PHY, "PDU length in bits: %d, in bytes: %d \n", dlsch0->harq_processes[harq_pid]->TBS, rx_ind.rx_indication_body[0].pdsch_pdu.pdu_length); + rx_ind.number_pdus = 1; - //ue->dl_indication.rx_ind = &dlsch1->harq_processes[harq_pid]->b; //no data, only dci for now - dl_indication.dci_ind = NULL; //&ue->dci_ind; - // send to mac - if (ue->if_inst && ue->if_inst->dl_indication) - ue->if_inst->dl_indication(&dl_indication, ul_time_alignment); + //ue->dl_indication.rx_ind = &dlsch1->harq_processes[harq_pid]->b; //no data, only dci for now + dl_indication.dci_ind = NULL; //&ue->dci_ind; + // send to mac + if (ue->if_inst && ue->if_inst->dl_indication) + ue->if_inst->dl_indication(&dl_indication, ul_time_alignment); } // TODO CRC check for CW0 @@ -4026,18 +4025,13 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, int nr_tti_rx = proc->nr_tti_rx; int slot_pbch; NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; - NR_UE_DLSCH_t **dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id]; fapi_nr_config_request_t *cfg = &ue->nrUE_config; - uint8_t harq_pid = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid; - NR_DL_UE_HARQ_t *dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - uint16_t nb_symb_sch = dlsch0_harq->nb_symbols; - uint16_t start_symb_sch = dlsch0_harq->start_symbol; uint8_t nb_symb_pdcch = pdcch_vars->nb_search_space > 0 ? pdcch_vars->pdcch_config[0].coreset.duration : 0; uint8_t dci_cnt = 0; NR_DL_FRAME_PARMS *fp = &ue->frame_parms; - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); - + LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx%1024, nr_tti_rx); /* @@ -4045,7 +4039,6 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); */ - int coreset_nb_rb=0; int coreset_start_rb=0; if (pdcch_vars->nb_search_space > 0) @@ -4080,12 +4073,12 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if (ue->no_timing_correction==0) { LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction); nr_adjust_synch_ue(fp, - ue, - eNB_id, + ue, + eNB_id, frame_rx, - nr_tti_rx, - 0, - 16384); + nr_tti_rx, + 0, + 16384); } } @@ -4100,10 +4093,10 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, #endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); nr_slot_fep(ue, - l, - nr_tti_rx, - 0, - 0); + l, + nr_tti_rx, + 0, + 0); // note: this only works if RBs for PDCCH are contigous! LOG_D(PHY,"pdcch_channel_estimation: first_carrier_offset %d, BWPStart %d, coreset_start_rb %d\n", @@ -4130,40 +4123,40 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if (dci_cnt > 0) { - LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: found %d DCIs\n",ue->Mod_id,frame_rx,nr_tti_rx,dci_cnt); + LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: found %d DCIs\n", ue->Mod_id, frame_rx, nr_tti_rx, dci_cnt); - } else { - LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: No DCIs found\n",ue->Mod_id,frame_rx,nr_tti_rx); - } -#endif //NR_PDCCH_SCHED + NR_UE_DLSCH_t *dlsch; + if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1){ + dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]; + } else if (ue->dlsch_ra[0]->active == 1){ + dlsch = ue->dlsch_ra[0]; + } + uint8_t harq_pid = dlsch->current_harq_pid; + NR_DL_UE_HARQ_t *dlsch0_harq = dlsch->harq_processes[harq_pid]; + uint16_t nb_symb_sch = dlsch0_harq->nb_symbols; + uint16_t start_symb_sch = dlsch0_harq->start_symbol; + int symb_dmrs = -1; - - if (dci_cnt > 0){ LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR Frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); //to update from pdsch config - start_symb_sch = dlsch0_harq->start_symbol; - int symb_dmrs=-1; + for (int i=0;i<4;i++) if (((1<dlDmrsSymbPos) > 0) {symb_dmrs=i;break;} AssertFatal(symb_dmrs>=0,"no dmrs in 0..3\n"); LOG_D(PHY,"Initializing dmrs for symb %d DMRS mask %x\n",symb_dmrs,dlsch0_harq->dlDmrsSymbPos); nr_gold_pdsch(ue,symb_dmrs,0, 1); - - nb_symb_sch = dlsch0_harq->nb_symbols; for (uint16_t m=start_symb_sch;m<(nb_symb_sch+start_symb_sch) ; m++){ nr_slot_fep(ue, - m, //to be updated from higher layer - nr_tti_rx, - 0, - 0); - - + m, //to be updated from higher layer + nr_tti_rx, + 0, + 0); } - //set active for testing, to be removed - ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active = 1; + } else { + LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: No DCIs found\n",ue->Mod_id,frame_rx,nr_tti_rx); } - else - ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active = 0; + +#endif //NR_PDCCH_SCHED #if UE_TIMING_TRACE start_meas(&ue->generic_stat); @@ -4540,7 +4533,7 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ue->tx_power_dBm[nr_tti_tx] = prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER + pathloss; } - LOG_I(PHY,"[UE %d][RAPROC] Frame %d, nr_tti_tx %d : Generating PRACH, preamble %d, PL %d, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, RA-RNTI %d\n", + LOG_I(PHY,"[UE %d][RAPROC] Frame %d, nr_tti_tx %d : Generating PRACH, preamble %d, PL %d, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, RA-RNTI %x\n", ue->Mod_id, frame_tx, nr_tti_tx, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 2155374512..61cf7332b2 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -36,6 +36,7 @@ #include "LAYER2/NR_MAC_UE/mac_extern.h" #include "mac_defs.h" #include "common/utils/nr/nr_common.h" +#include "executables/softmodem-common.h" #include #ifdef NR_PDCCH_DCI_TOOLS_DEBUG @@ -104,7 +105,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac,fapi_nr_dl_config_request_t *dl_ AssertFatal(mac->ULbwp[0]->bwp_Dedicated!=NULL,"bwp_Dedicated is null\n"); } // check search spaces - + int ss_id=0; fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15; int sps =mac->DLbwp[0]->bwp_Common->genericParameters.cyclicPrefix == NULL ? 14 : 12; @@ -120,18 +121,31 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac,fapi_nr_dl_config_request_t *dl_ if (mac->ra_state == WAIT_RAR) { // check for RAR rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - rel15->rnti = 2;//get_RA_RNTI(mac,frame,slot); // WIP - dl_config->number_pdus = dl_config->number_pdus + 1; + // rel15->rnti = 2;//get_RA_RNTI(mac,frame,slot); // WIP } else if (mac->ra_state == WAIT_CONTENTION_RESOLUTION) { rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; rel15->rnti = mac->t_crnti; - dl_config->number_pdus = dl_config->number_pdus + 1; + //dl_config->number_pdus = dl_config->number_pdus + 1; } if (mac->crnti>0) { rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - rel15->rnti = mac->crnti; - rel15->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275); + + if (get_softmodem_params()->do_ra == 1) + rel15->rnti = 0x00; + else // phy_test + rel15->rnti = mac->crnti; + + rel15->dci_format = NR_DL_DCI_FORMAT_1_0; + + if (slot == 0 || slot == 1){ + rel15->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275); + rel15->dci_length = nr_dci_size(rel15->dci_format, NR_RNTI_C, rel15->BWPSize); + } else if (slot == 7){ + rel15->BWPSize = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, 275); + rel15->dci_length = nr_dci_size(rel15->dci_format, NR_RNTI_RA, rel15->BWPSize); + } + rel15->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275); rel15->SubcarrierSpacing = mac->DLbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; // get UE-specific search space @@ -166,19 +180,15 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac,fapi_nr_dl_config_request_t *dl_ } rel15->coreset.CoreSetType = 1; rel15->coreset.precoder_granularity = mac->coreset[0][0]->precoderGranularity; + if (mac->coreset[0][0]->pdcch_DMRS_ScramblingID) rel15->coreset.pdcch_dmrs_scrambling_id = *mac->coreset[0][0]->pdcch_DMRS_ScramblingID; else rel15->coreset.pdcch_dmrs_scrambling_id = *mac->scc->physCellId; + fill_dci_search_candidates(mac->SSpace[0][0][ss_id],rel15); - rel15->dci_format = NR_DL_DCI_FORMAT_1_0; - rel15->dci_length = nr_dci_size(rel15->dci_format,NR_RNTI_C,rel15->BWPSize); dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI; dl_config->number_pdus = dl_config->number_pdus + 1; } } } - - - - diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 39b75669b4..6cf0d68a62 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2622,7 +2622,11 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr dlsch_config_pdu_1_0->pucch_resource_id, dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind); - dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; + if (mac->ra_rnti == rnti) + dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH; + else + dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; + // dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = n_RB_DLBWP; LOG_D(MAC,"(nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type); From acfad36f1a2698aaba527eeceddb9da673497b00 Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 22 Apr 2020 18:28:35 +0200 Subject: [PATCH 09/42] Code cleanup: - restructured nr_pdcch_unscrambling function - minor cleanups - formatting --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 6 +-- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 41 ++++++++++--------- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 10 ++--- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 812c49d6f6..8508621ae5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -131,13 +131,13 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, void nr_pdcch_scrambling(uint32_t *in, uint32_t size, uint32_t Nid, - uint32_t n_RNTI, + uint32_t scrambling_RNTI, uint32_t *out) { uint8_t reset; uint32_t x1, x2, s=0; reset = 1; - x2 = (n_RNTI<<16) + Nid; - LOG_D(PHY,"PDCCH Scrambling x2 %x : n_RNTI %x\n",x2,n_RNTI); + x2 = (scrambling_RNTI<<16) + Nid; + LOG_D(PHY,"PDCCH Scrambling x2 %x : scrambling_RNTI %x \n", x2, scrambling_RNTI); for (int i=0; inumber_of_candidates;j++) { - LOG_D(PHY,"Trying DCI candidate %d, CCE %d (%d), L %d\n",j,rel15->CCE[j],rel15->CCE[j]*9*6*2,rel15->L[j]); int CCEind = rel15->CCE[j]; int L = rel15->L[j]; uint64_t dci_estimation[2]= {0}; - const t_nrPolar_params *currentPtrDCI=nr_polar_params(1, dci_length, L,1,&ue->polarList); + const t_nrPolar_params *currentPtrDCI = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L, 1, &ue->polarList); - nr_pdcch_unscrambling(rel15->rnti, - &ue->frame_parms, - slot, - &pdcch_vars->e_rx[CCEind*108], - tmp_e, - L*108, - // get_nCCE(n_pdcch_symbols, frame_parms, mi) * 72, - rel15->coreset.pdcch_dmrs_scrambling_id); + LOG_D(PHY, "Trying DCI candidate %d, CCE %d (%d), L %d\n", j, CCEind, CCEind*9*6*2, L); + + nr_pdcch_unscrambling(&pdcch_vars->e_rx[CCEind*108], rel15->rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); + + #ifdef DEBUG_DCI_DECODING + uint32_t * z = (uint32_t *) &pdcch_vars->e_rx[CCEind*108]; + for (int index_z = 0; index_z < 96; index_z++){ + for (int i=0; i<9; i++) { + LOG_D(PHY,"z[%d]=(%d,%d) \n", (9*index_z + i), *(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i])); + } + } + #endif uint16_t crc = polar_decoder_int16(tmp_e, dci_estimation, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 8dbe588cb8..38781d7b7e 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1524,11 +1524,11 @@ uint8_t get_num_pdcch_symbols(uint8_t num_dci,DCI_ALLOC_t *dci_alloc,NR_DL_FRAME void pdcch_interleaving(NR_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wbar,uint8_t n_symbols_pdcch,uint8_t mi); -void nr_pdcch_unscrambling(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t slot, - int16_t *z, int16_t *z2,uint32_t length, uint16_t pdcch_DMRS_scrambling_id); - - - +void nr_pdcch_unscrambling(int16_t *z, + uint16_t scrambling_RNTI, + uint32_t length, + uint16_t pdcch_DMRS_scrambling_id, + int16_t *z2); void dlsch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, int mbsfn_flag, From c56854afe4f393a9e79f8bd38d96717115ae912f Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 22 Apr 2020 18:31:48 +0200 Subject: [PATCH 10/42] Set proper polar rnti and scrambling rnti for the phy-test and do-ra running modes: - in phy-test both rnti are set to same rnti - in do-ra the scrambling rnti is set to 0 while the polar rnti is the RA_rnti (computed as per TS 38.321) --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index f3faec2ea2..adc619825a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -29,11 +29,15 @@ * \note * \warning */ + #ifdef USER_MODE #include #include #include #endif + +#include "executables/softmodem-common.h" + #include "nr_transport_proto_ue.h" #include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" #include "PHY/phy_extern_nr_ue.h" @@ -842,7 +846,9 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, rel15 = &pdcch_vars->pdcch_config[i]; int dci_length = rel15->dci_length; + int gNB_id = 0; int16_t tmp_e[16*108]; + rnti_t n_rnti; for (int j=0;jnumber_of_candidates;j++) { int CCEind = rel15->CCE[j]; @@ -850,7 +856,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, uint64_t dci_estimation[2]= {0}; const t_nrPolar_params *currentPtrDCI = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L, 1, &ue->polarList); - LOG_D(PHY, "Trying DCI candidate %d, CCE %d (%d), L %d\n", j, CCEind, CCEind*9*6*2, L); + LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d\n", j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L); nr_pdcch_unscrambling(&pdcch_vars->e_rx[CCEind*108], rel15->rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); @@ -867,16 +873,24 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, dci_estimation, 1, currentPtrDCI); - LOG_D(PHY,"Decoded crc %x\n",crc); - if (crc == rel15->rnti) { + + if (get_softmodem_params()->do_ra == 1) + n_rnti = ue->prach_resources[gNB_id]->ra_RNTI; + else + n_rnti = rel15->rnti; + + if (crc == n_rnti) { + LOG_D(PHY,"Decoded crc %x matches rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format); dci_ind->SFN = frame; dci_ind->slot = slot; - dci_ind->dci_list[dci_ind->number_of_dcis].rnti = rel15->rnti; + dci_ind->dci_list[dci_ind->number_of_dcis].rnti = n_rnti; dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE = CCEind; dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format; dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length; memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8); dci_ind->number_of_dcis++; + } else { + LOG_D(PHY,"Decoded crc %x does not match rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format); } } } From f27649431721d5c673d20f65b458e57a90c4b399 Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 22 Apr 2020 18:49:38 +0200 Subject: [PATCH 11/42] Completed dlsch demodulation for RA PDSCH --- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 108 +++++++++--------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index c38deaff2d..b532dea3c7 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -132,7 +132,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, unsigned short nb_rb = 0, round; int avgs = 0;// rb; - NR_DL_UE_HARQ_t *dlsch0_harq,*dlsch1_harq = 0; + NR_DL_UE_HARQ_t *dlsch0_harq, *dlsch1_harq = NULL; uint8_t beamforming_mode; @@ -157,82 +157,87 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, int32_t median[16]; uint32_t len; - switch (type) { case SI_PDSCH: pdsch_vars = ue->pdsch_vars_SI; dlsch = &ue->dlsch_SI[eNB_id]; dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - beamforming_mode = 0; + beamforming_mode = 0; break; case RA_PDSCH: pdsch_vars = ue->pdsch_vars_ra; dlsch = &ue->dlsch_ra[eNB_id]; dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - beamforming_mode = 0; + beamforming_mode = 0; + break; case PDSCH: pdsch_vars = ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]]; dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id]; - dlsch[0]->harq_processes[harq_pid]->Qm = nr_get_Qm_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); - dlsch[0]->harq_processes[harq_pid]->R = nr_get_code_rate_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); - + beamforming_mode = ue->transmission_mode[eNB_id] < 7 ? 0 :ue->transmission_mode[eNB_id]; + + dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; + dlsch1_harq = dlsch[1]->harq_processes[harq_pid]; + //printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status); - LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n", - frame,nr_tti_rx,symbol,harq_pid, - dlsch[0]->harq_processes[harq_pid]->status, - dlsch[1]->harq_processes[harq_pid]->status); - - if ((dlsch[0]->harq_processes[harq_pid]->status == ACTIVE) && - (dlsch[1]->harq_processes[harq_pid]->status == ACTIVE)){ - codeword_TB0 = dlsch[0]->harq_processes[harq_pid]->codeword; - codeword_TB1 = dlsch[1]->harq_processes[harq_pid]->codeword; + LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n", frame, nr_tti_rx, symbol, harq_pid, dlsch0_harq->status, dlsch1_harq->status); + + if ((dlsch0_harq->status == ACTIVE) && (dlsch1_harq->status == ACTIVE)){ + codeword_TB0 = dlsch0_harq->codeword; + codeword_TB1 = dlsch1_harq->codeword; dlsch0_harq = dlsch[codeword_TB0]->harq_processes[harq_pid]; dlsch1_harq = dlsch[codeword_TB1]->harq_processes[harq_pid]; -#ifdef DEBUG_HARQ - printf("[DEMOD] I am assuming both TBs are active\n"); -#endif - } - else if ((dlsch[0]->harq_processes[harq_pid]->status == ACTIVE) && - (dlsch[1]->harq_processes[harq_pid]->status != ACTIVE) ) { - codeword_TB0 = dlsch[0]->harq_processes[harq_pid]->codeword; + + #ifdef DEBUG_HARQ + printf("[DEMOD] I am assuming both TBs are active\n"); + #endif + + } else if ((dlsch0_harq->status == ACTIVE) && (dlsch1_harq->status != ACTIVE) ) { + codeword_TB0 = dlsch0_harq->codeword; + codeword_TB1 = -1; dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; dlsch1_harq = NULL; - codeword_TB1 = -1; -#ifdef DEBUG_HARQ - printf("[DEMOD] I am assuming only TB0 is active\n"); -#endif - } - else if ((dlsch[0]->harq_processes[harq_pid]->status != ACTIVE) && - (dlsch[1]->harq_processes[harq_pid]->status == ACTIVE) ){ - codeword_TB1 = dlsch[1]->harq_processes[harq_pid]->codeword; - dlsch0_harq = dlsch[1]->harq_processes[harq_pid]; - dlsch1_harq = NULL; + + #ifdef DEBUG_HARQ + printf("[DEMOD] I am assuming only TB0 is active\n"); + #endif + + } else if ((dlsch0_harq->status != ACTIVE) && (dlsch1_harq->status == ACTIVE)){ codeword_TB0 = -1; -#ifdef DEBUG_HARQ - printf("[DEMOD] I am assuming only TB1 is active, it is in cw %d\n", dlsch0_harq->codeword); -#endif - } - else { - LOG_E(PHY,"[UE][FATAL] nr_tti_rx %d: no active DLSCH\n",nr_tti_rx); + codeword_TB1 = dlsch1_harq->codeword; + dlsch0_harq = NULL; + dlsch1_harq = dlsch[1]->harq_processes[codeword_TB1]; + + #ifdef DEBUG_HARQ + printf("[DEMOD] I am assuming only TB1 is active, it is in cw %d\n", dlsch0_harq->codeword); + #endif + + AssertFatal(1 == 0, "[UE][FATAL] DLSCH: TB0 not active and TB1 active case is not supported %d\n"); + + } else { + LOG_E(PHY,"[UE][FATAL] nr_tti_rx %d: no active DLSCH\n", nr_tti_rx); return(-1); } - beamforming_mode = ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id]; - break; - - default: - AssertFatal(1==0,"[UE][FATAL] nr_tti_rx %d: Unknown PDSCH format %d\n",nr_tti_rx,type); - return(-1); - break; + + break; + + default: + AssertFatal(1 == 0, "[UE][FATAL] nr_tti_rx %d: Unknown PDSCH format %d\n", nr_tti_rx, type); + return(-1); + break; + } -#ifdef DEBUG_HARQ - printf("[DEMOD] MIMO mode = %d\n", dlsch0_harq->mimo_mode); - printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1); -#endif - + dlsch0_harq->Qm = nr_get_Qm_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); + dlsch0_harq->R = nr_get_code_rate_dl(dlsch[0]->harq_processes[harq_pid]->mcs, dlsch[0]->harq_processes[harq_pid]->mcs_table); + + #ifdef DEBUG_HARQ + printf("[DEMOD] MIMO mode = %d\n", dlsch0_harq->mimo_mode); + printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1); + #endif + start_rb = dlsch0_harq->start_rb; nb_rb_pdsch = dlsch0_harq->nb_rb; @@ -270,7 +275,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, return(-1); } - if (dlsch0_harq->mimo_mode==NR_DUALSTREAM) { DevAssert(dlsch1_harq); } From 32af60bcf5ffc296b288db376a6539ad80b15352 Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 22 Apr 2020 19:49:08 +0200 Subject: [PATCH 12/42] UE RA procedures changes to preamble selection: - get preamble from rach_ConfigDedicated in contention free mode - do preamble selection only in prach slot --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 1 + openair2/LAYER2/NR_MAC_UE/mac_defs.h | 1 + openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 268 ++++++++++--------- 3 files changed, 142 insertions(+), 128 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 758de4f4af..f50c15df50 100755 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -350,6 +350,7 @@ int nr_rrc_mac_config_req_ue( if(spCell_ConfigP != NULL ){ mac->servCellIndex = *spCell_ConfigP->servCellIndex; if (spCell_ConfigP->reconfigurationWithSync) { + mac->rach_ConfigDedicated = spCell_ConfigP->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; mac->scc = spCell_ConfigP->reconfigurationWithSync->spCellConfigCommon; config_common_ue(mac,module_id,cc_idP); mac->crnti = spCell_ConfigP->reconfigurationWithSync->newUE_Identity; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index c64c518cee..64dd241499 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -156,6 +156,7 @@ typedef struct { NR_ServingCellConfigCommon_t *scc; NR_ServingCellConfig_t *scd; + NR_RACH_ConfigDedicated_t *rach_ConfigDedicated; int servCellIndex; //// MAC config NR_DRX_Config_t *drx_Config; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 00eaa56855..a5e1c72c93 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -88,6 +88,10 @@ void nr_get_prach_resources(module_id_t mod_id, int messagePowerOffsetGroupB, messageSizeGroupA, PLThreshold, sizeOfRA_PreamblesGroupA, numberOfRA_Preambles, i, deltaPreamble_Msg3; uint8_t noGroupB = 0, s_id, f_id, ul_carrier_id, prach_ConfigIndex, SFN_nbr, Msg3_size; + AssertFatal(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup != NULL, "[UE %d] FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id); + nr_rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; + rach_ConfigGeneric = &nr_rach_ConfigCommon->rach_ConfigGeneric; + // NR_RSRP_Range_t rsrp_ThresholdSSB; // todo /////////////////////////////////////////////////////////// @@ -104,138 +108,140 @@ void nr_get_prach_resources(module_id_t mod_id, // -- RA initiated for SI request: // --- SSB selection, set prach_resources->ra_PreambleIndex - // if (rach_ConfigDedicated) { // This is for network controlled Mobility - // // operation for contention-free RA resources when: - // // - available SSB with SS-RSRP above rsrp-ThresholdSSB: SSB selection - // // - availalbe CSI-RS with CSI-RSRP above rsrp-ThresholdCSI-RS: CSI-RS selection - // prach_resources->ra_PreambleIndex = rach_ConfigDedicated->ra_PreambleIndex; - // } - - //////////* Contention-based RA preamble selection *////////// - // todo: - // - selection of SSB with SS-RSRP above rsrp-ThresholdSSB else select any SSB - // - todo determine next available PRACH occasion - - // rsrp_ThresholdSSB = *nr_rach_ConfigCommon->rsrp_ThresholdSSB; - - AssertFatal(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup != NULL, "[UE %d] FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id); - - nr_rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; - rach_ConfigGeneric = &nr_rach_ConfigCommon->rach_ConfigGeneric; - - Msg3_size = mac->RA_Msg3_size; - - numberOfRA_Preambles = 64; - if(nr_rach_ConfigCommon->totalNumberOfRA_Preambles != NULL) - numberOfRA_Preambles = *(nr_rach_ConfigCommon->totalNumberOfRA_Preambles); - - if (!nr_rach_ConfigCommon->groupBconfigured) { - noGroupB = 1; + if (rach_ConfigDedicated) { + //////////* Contention free RA *////////// + // - the PRACH preamble for the UE to transmit is set through RRC configuration + // - this is the default mode in current implementation! + // Operation for contention-free RA resources when: + // - available SSB with SS-RSRP above rsrp-ThresholdSSB: SSB selection + // - available CSI-RS with CSI-RSRP above rsrp-ThresholdCSI-RS: CSI-RS selection + // - network controlled Mobility + uint8_t cfra_ssb_resource_idx = 0; + prach_resources->ra_PreambleIndex = rach_ConfigDedicated->cfra->resources.choice.ssb->ssb_ResourceList.list.array[cfra_ssb_resource_idx]->ra_PreambleIndex; + LOG_D(MAC, "[RAPROC] - Selected RA preamble index %d for contention-free random access procedure... \n", prach_resources->ra_PreambleIndex); } else { - // RA preambles group B is configured - // - Defining the number of RA preambles in RA Preamble Group A for each SSB */ - sizeOfRA_PreamblesGroupA = nr_rach_ConfigCommon->groupBconfigured->numberOfRA_PreamblesGroupA; - switch (nr_rach_ConfigCommon->groupBconfigured->ra_Msg3SizeGroupA){ - /* - Threshold to determine the groups of RA preambles */ - case 0: - messageSizeGroupA = 56; - break; - case 1: - messageSizeGroupA = 144; - break; - case 2: - messageSizeGroupA = 208; - break; - case 3: - messageSizeGroupA = 256; - break; - case 4: - messageSizeGroupA = 282; - break; - case 5: - messageSizeGroupA = 480; - break; - case 6: - messageSizeGroupA = 640; - break; - case 7: - messageSizeGroupA = 800; - break; - case 8: - messageSizeGroupA = 1000; - break; - case 9: - messageSizeGroupA = 72; - break; - default: - AssertFatal(1 == 0,"Unknown ra_Msg3SizeGroupA %lu\n", nr_rach_ConfigCommon->groupBconfigured->ra_Msg3SizeGroupA); - /* todo cases 10 -15*/ - } + //////////* Contention-based RA preamble selection *////////// + // todo: + // - selection of SSB with SS-RSRP above rsrp-ThresholdSSB else select any SSB + // - todo determine next available PRACH occasion - /* Power offset for preamble selection in dB */ - messagePowerOffsetGroupB = -9999; - switch (nr_rach_ConfigCommon->groupBconfigured->messagePowerOffsetGroupB){ - case 0: - messagePowerOffsetGroupB = -9999; - break; - case 1: - messagePowerOffsetGroupB = 0; - break; - case 2: - messagePowerOffsetGroupB = 5; - break; - case 3: - messagePowerOffsetGroupB = 8; - break; - case 4: - messagePowerOffsetGroupB = 10; - break; - case 5: - messagePowerOffsetGroupB = 12; - break; - case 6: - messagePowerOffsetGroupB = 15; - break; - case 7: - messagePowerOffsetGroupB = 18; - break; - default: - AssertFatal(1 == 0,"Unknown messagePowerOffsetGroupB %lu\n", nr_rach_ConfigCommon->groupBconfigured->messagePowerOffsetGroupB); - } + // rsrp_ThresholdSSB = *nr_rach_ConfigCommon->rsrp_ThresholdSSB; - // todo Msg3-DeltaPreamble should be provided from higher layers, otherwise is 0 - mac->deltaPreamble_Msg3 = 0; - deltaPreamble_Msg3 = mac->deltaPreamble_Msg3; - } + Msg3_size = mac->RA_Msg3_size; - PLThreshold = prach_resources->RA_PCMAX - rach_ConfigGeneric->preambleReceivedTargetPower - deltaPreamble_Msg3 - messagePowerOffsetGroupB; + numberOfRA_Preambles = 64; + if(nr_rach_ConfigCommon->totalNumberOfRA_Preambles != NULL) + numberOfRA_Preambles = *(nr_rach_ConfigCommon->totalNumberOfRA_Preambles); - /* Msg3 has not been transmitted yet */ - if (first_Msg3 == 1) { - if (noGroupB == 1) { - // use Group A preamble - prach_resources->ra_PreambleIndex = (taus()) % numberOfRA_Preambles; - mac->RA_usedGroupA = 1; - } else if ((Msg3_size < messageSizeGroupA) && (get_nr_PL(mod_id, CC_id, gNB_id) > PLThreshold)) { - // Group B is configured and RA preamble Group A is used - // - todo add condition on CCCH_sdu_size for initiation by CCCH - prach_resources->ra_PreambleIndex = (taus()) % sizeOfRA_PreamblesGroupA; - mac->RA_usedGroupA = 1; + if (!nr_rach_ConfigCommon->groupBconfigured) { + noGroupB = 1; } else { - // Group B preamble is configured and used - // the first sizeOfRA_PreamblesGroupA RA preambles belong to RA Preambles Group A - // the remaining belong to RA Preambles Group B - prach_resources->ra_PreambleIndex = sizeOfRA_PreamblesGroupA + (taus()) % (numberOfRA_Preambles - sizeOfRA_PreamblesGroupA); - mac->RA_usedGroupA = 0; + // RA preambles group B is configured + // - Defining the number of RA preambles in RA Preamble Group A for each SSB */ + sizeOfRA_PreamblesGroupA = nr_rach_ConfigCommon->groupBconfigured->numberOfRA_PreamblesGroupA; + switch (nr_rach_ConfigCommon->groupBconfigured->ra_Msg3SizeGroupA){ + /* - Threshold to determine the groups of RA preambles */ + case 0: + messageSizeGroupA = 56; + break; + case 1: + messageSizeGroupA = 144; + break; + case 2: + messageSizeGroupA = 208; + break; + case 3: + messageSizeGroupA = 256; + break; + case 4: + messageSizeGroupA = 282; + break; + case 5: + messageSizeGroupA = 480; + break; + case 6: + messageSizeGroupA = 640; + break; + case 7: + messageSizeGroupA = 800; + break; + case 8: + messageSizeGroupA = 1000; + break; + case 9: + messageSizeGroupA = 72; + break; + default: + AssertFatal(1 == 0,"Unknown ra_Msg3SizeGroupA %lu\n", nr_rach_ConfigCommon->groupBconfigured->ra_Msg3SizeGroupA); + /* todo cases 10 -15*/ + } + + /* Power offset for preamble selection in dB */ + messagePowerOffsetGroupB = -9999; + switch (nr_rach_ConfigCommon->groupBconfigured->messagePowerOffsetGroupB){ + case 0: + messagePowerOffsetGroupB = -9999; + break; + case 1: + messagePowerOffsetGroupB = 0; + break; + case 2: + messagePowerOffsetGroupB = 5; + break; + case 3: + messagePowerOffsetGroupB = 8; + break; + case 4: + messagePowerOffsetGroupB = 10; + break; + case 5: + messagePowerOffsetGroupB = 12; + break; + case 6: + messagePowerOffsetGroupB = 15; + break; + case 7: + messagePowerOffsetGroupB = 18; + break; + default: + AssertFatal(1 == 0,"Unknown messagePowerOffsetGroupB %lu\n", nr_rach_ConfigCommon->groupBconfigured->messagePowerOffsetGroupB); + } + + // todo Msg3-DeltaPreamble should be provided from higher layers, otherwise is 0 + mac->deltaPreamble_Msg3 = 0; + deltaPreamble_Msg3 = mac->deltaPreamble_Msg3; } - } else { // Msg3 is being retransmitted - if (mac->RA_usedGroupA == 1 && noGroupB == 1) { - prach_resources->ra_PreambleIndex = (taus()) % numberOfRA_Preambles; - } else if (mac->RA_usedGroupA == 1 && noGroupB == 0){ - prach_resources->ra_PreambleIndex = (taus()) % sizeOfRA_PreamblesGroupA; - } else { - prach_resources->ra_PreambleIndex = sizeOfRA_PreamblesGroupA + (taus()) % (numberOfRA_Preambles - sizeOfRA_PreamblesGroupA); + + PLThreshold = prach_resources->RA_PCMAX - rach_ConfigGeneric->preambleReceivedTargetPower - deltaPreamble_Msg3 - messagePowerOffsetGroupB; + + /* Msg3 has not been transmitted yet */ + if (first_Msg3 == 1) { + if (noGroupB == 1) { + // use Group A preamble + prach_resources->ra_PreambleIndex = (taus()) % numberOfRA_Preambles; + mac->RA_usedGroupA = 1; + } else if ((Msg3_size < messageSizeGroupA) && (get_nr_PL(mod_id, CC_id, gNB_id) > PLThreshold)) { + // Group B is configured and RA preamble Group A is used + // - todo add condition on CCCH_sdu_size for initiation by CCCH + prach_resources->ra_PreambleIndex = (taus()) % sizeOfRA_PreamblesGroupA; + mac->RA_usedGroupA = 1; + } else { + // Group B preamble is configured and used + // the first sizeOfRA_PreamblesGroupA RA preambles belong to RA Preambles Group A + // the remaining belong to RA Preambles Group B + prach_resources->ra_PreambleIndex = sizeOfRA_PreamblesGroupA + (taus()) % (numberOfRA_Preambles - sizeOfRA_PreamblesGroupA); + mac->RA_usedGroupA = 0; + } + } else { // Msg3 is being retransmitted + if (mac->RA_usedGroupA == 1 && noGroupB == 1) { + prach_resources->ra_PreambleIndex = (taus()) % numberOfRA_Preambles; + } else if (mac->RA_usedGroupA == 1 && noGroupB == 0){ + prach_resources->ra_PreambleIndex = (taus()) % sizeOfRA_PreamblesGroupA; + } else { + prach_resources->ra_PreambleIndex = sizeOfRA_PreamblesGroupA + (taus()) % (numberOfRA_Preambles - sizeOfRA_PreamblesGroupA); + } } + LOG_D(MAC, "[RAPROC] - Selected RA preamble index %d for contention-based random access procedure... \n", prach_resources->ra_PreambleIndex); } // todo determine next available PRACH occasion @@ -284,7 +290,7 @@ void nr_get_prach_resources(module_id_t mod_id, prach_resources->ra_RNTI = 1 + s_id + 14 * t_id + 1120 * f_id + 8960 * ul_carrier_id; mac->ra_rnti = prach_resources->ra_RNTI; - LOG_D(MAC, "Computed ra_RNTI is %d", prach_resources->ra_RNTI); + LOG_D(MAC, "Computed ra_RNTI is %x \n", prach_resources->ra_RNTI); } // TbD: RA_attempt_number not used @@ -311,6 +317,7 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint /// Handling inizialization by PDCCH order, MAC entity or RRC (TS 38.300) /// Only one RA procedure is ongoing at any point in time in a MAC entity /// the RA procedure on a SCell shall only be initiated by PDCCH order +/// in the current implementation, RA is contention free only // WIP // todo TS 38.321: @@ -324,7 +331,6 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint // - retrieve TBS // - add mac_rrc_nr_data_req_ue, etc ... // - add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) - void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, int CC_id, @@ -345,6 +351,8 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *setup = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; NR_FrequencyInfoDL_t *frequencyInfoDL = scc->downlinkConfigCommon->frequencyInfoDL; + NR_RACH_ConfigDedicated_t *rach_ConfigDedicated = mac->rach_ConfigDedicated; + // int32_t frame_diff = 0; uint8_t sdu_lcids[NB_RB_MAX] = {0}; @@ -485,7 +493,8 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, } // Fill in preamble and PRACH resources - nr_get_prach_resources(mod_id, CC_id, gNB_id, nr_tti_tx, 1, prach_resources, NULL); + if (is_nr_prach_slot) + nr_get_prach_resources(mod_id, CC_id, gNB_id, nr_tti_tx, 1, prach_resources, rach_ConfigDedicated); offset = nr_generate_ulsch_pdu((uint8_t *) mac_sdus, // sdus buffer (uint8_t *) payload, // UL MAC pdu pointer @@ -601,8 +610,11 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, mac->RA_tx_frame = frame; mac->RA_tx_subframe = nr_tti_tx; + // Fill in preamble and PRACH resources - nr_get_prach_resources(mod_id, CC_id, gNB_id, nr_tti_tx, 0, prach_resources, NULL); + if (is_nr_prach_slot) + nr_get_prach_resources(mod_id, CC_id, gNB_id, nr_tti_tx, 0, prach_resources, rach_ConfigDedicated); + } } } else if (UE_mode == PUSCH) { From 5eacaddd0e4f8ca630b54f5f4ae3d8b127f5079b Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 22 Apr 2020 20:32:02 +0200 Subject: [PATCH 13/42] Code cleanup --- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 77 ++++++++++--------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 3 - 3 files changed, 40 insertions(+), 42 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index b532dea3c7..693284a052 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -182,7 +182,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, dlsch1_harq = dlsch[1]->harq_processes[harq_pid]; //printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status); - LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n", frame, nr_tti_rx, symbol, harq_pid, dlsch0_harq->status, dlsch1_harq->status); + LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n", frame, nr_tti_rx, symbol, harq_pid, dlsch0_harq->status, dlsch1_harq->status); if ((dlsch0_harq->status == ACTIVE) && (dlsch1_harq->status == ACTIVE)){ codeword_TB0 = dlsch0_harq->codeword; @@ -969,45 +969,46 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, return(-1); break; } + if (dlsch1_harq) { - switch (nr_get_Qm_dl(dlsch1_harq->mcs,dlsch1_harq->mcs_table)) { - case 2 : - if (rx_type==rx_standard) { - nr_dlsch_qpsk_llr(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pllr_symbol_cw0, - symbol,len,first_symbol_flag,nb_rb, - beamforming_mode); + switch (nr_get_Qm_dl(dlsch1_harq->mcs,dlsch1_harq->mcs_table)) { + case 2 : + if (rx_type==rx_standard) { + nr_dlsch_qpsk_llr(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pllr_symbol_cw0, + symbol,len,first_symbol_flag,nb_rb, + beamforming_mode); + } + break; + case 4: + if (rx_type==rx_standard) { + nr_dlsch_16qam_llr(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pdsch_vars[eNB_id]->llr[0], + pdsch_vars[eNB_id]->dl_ch_mag0, + symbol,len,first_symbol_flag,nb_rb, + pdsch_vars[eNB_id]->llr128, + beamforming_mode); + } + break; + case 6 : + if (rx_type==rx_standard) { + nr_dlsch_64qam_llr(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pllr_symbol_cw0, + pdsch_vars[eNB_id]->dl_ch_mag0, + pdsch_vars[eNB_id]->dl_ch_magb0, + symbol,len,first_symbol_flag,nb_rb, + pdsch_vars[eNB_id]->llr_offset[symbol], + beamforming_mode); + } + break; + default: + LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n"); + return(-1); + break; } - break; - case 4: - if (rx_type==rx_standard) { - nr_dlsch_16qam_llr(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], - pdsch_vars[eNB_id]->dl_ch_mag0, - symbol,len,first_symbol_flag,nb_rb, - pdsch_vars[eNB_id]->llr128, - beamforming_mode); - } - break; - case 6 : - if (rx_type==rx_standard) { - nr_dlsch_64qam_llr(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pllr_symbol_cw0, - pdsch_vars[eNB_id]->dl_ch_mag0, - pdsch_vars[eNB_id]->dl_ch_magb0, - symbol,len,first_symbol_flag,nb_rb, - pdsch_vars[eNB_id]->llr_offset[symbol], - beamforming_mode); - } - break; - default: - LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n"); - return(-1); - break; - } } //nr_dlsch_deinterleaving(symbol,bundle_L,(int16_t*)pllr_symbol_cw0,(int16_t*)pllr_symbol_cw0_deint, nb_rb_pdsch); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 6cf0d68a62..c7fadbdafe 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2599,7 +2599,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/ dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind = dci->pdsch_to_harq_feedback_time_ind; - LOG_D(MAC,"(nr_ue_procedures.c) rnti=%d dl_config->number_pdus=%d\n", + LOG_D(MAC,"(nr_ue_procedures.c) rnti = %x dl_config->number_pdus = %d\n", dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti, dl_config->number_pdus); LOG_D(MAC,"(nr_ue_procedures.c) frequency_domain_resource_assignment=%d \t number_rbs=%d \t start_rb=%d\n", diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 042e53e2dc..56c3d27210 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -247,8 +247,6 @@ void nr_initiate_ra_proc(module_id_t module_idP, // ra_rnti from 5.1.3 in 38.321 uint16_t ra_rnti=1+symbol+(slotP*14)+(freq_index*14*80)+(ul_carrier_id*14*80*8); - - uint16_t msg2_frame, msg2_slot,monitoring_slot_period,monitoring_offset; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_UE_list_t *UE_list = &nr_mac->UE_list; @@ -672,7 +670,6 @@ void nr_generate_Msg2(module_id_t module_idP, dci_pdu->ScramblingId[numDlDci] = *scc->physCellId; dci_pdu->ScramblingRNTI[numDlDci] = 0; dci_pdu->AggregationLevel[numDlDci] = aggregation; - dci_pdu->powerControlOffsetSS[numDlDci] = 0; dci_pdu->CceIndex[numDlDci] = CCEIndex; dci_pdu->beta_PDCCH_1_0[numDlDci] = 0; dci_pdu->powerControlOffsetSS[numDlDci] = 1; From eeef6da2aa3bd922603ec31215ae7416670ae2bc Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Tue, 28 Apr 2020 17:47:21 +0200 Subject: [PATCH 14/42] Fixed bug regarding TBS calculation and G calculation - The number of nb_dmrs_re at gNB side was set to 6, but here it is assumed that there will be no data allocation in OFDM symbols that carry DMRS - nb_dmrs_re that is being given as an input to the TBS calculation, should be multiplied by the number of DMRS symbols in order to get the total number of DMRS REs per RB - In the calculation of G, only the number of DMRS per RB in 1 OFDM symbol should be given as an input, because inside the function of the G calculation, this number is being multiplied by the number of OFDM symbols that carry DMRS --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 3 +-- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 9 ++++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index e8b685a885..247f5cb79d 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -226,7 +226,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH number_dmrs_symbols += ((pusch_pdu->ul_dmrs_symb_pos)>>l)&0x01; if (nodata_dmrs) - nb_re_dmrs = 12*number_dmrs_symbols; + nb_re_dmrs = 12; else nb_re_dmrs = ((pusch_pdu->dmrs_config_type == pusch_dmrs_type1)?6:4); @@ -241,7 +241,6 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH //---------------------------------------------------------- //------------------- ULSCH unscrambling ------------------- //---------------------------------------------------------- - start_meas(&gNB->ulsch_unscrambling_stats); nr_ulsch_unscrambling(gNB->pusch_vars[ULSCH_id]->llr, G, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 5a93d2abbf..baab2f5809 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -1452,7 +1452,7 @@ void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, R, pdsch_rel15->rbSize, N_sh_symb, - N_PRB_DMRS, + N_PRB_DMRS, // FIXME // This should be multiplied by the number of dmrs symbols N_PRB_oh, tb_scaling, pdsch_rel15->nrOfLayers)>>3; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 8f1a043221..3a8db970e8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -792,11 +792,18 @@ void nr_schedule_uss_ulsch_phytest(int Mod_idP, pusch_pdu->pusch_data.rv_index = 0; pusch_pdu->pusch_data.harq_process_id = 0; pusch_pdu->pusch_data.new_data_indicator = 0; + + uint8_t no_data_in_dmrs = 1; // temp implementation + uint8_t num_dmrs_symb = 0; + + for(int dmrs_counter = pusch_pdu->start_symbol_index; dmrs_counter < pusch_pdu->start_symbol_index + pusch_pdu->nr_of_symbols; dmrs_counter++) + num_dmrs_symb += ((pusch_pdu->ul_dmrs_symb_pos >> dmrs_counter) & 1); + pusch_pdu->pusch_data.tb_size = nr_compute_tbs(pusch_pdu->qam_mod_order, pusch_pdu->target_code_rate, pusch_pdu->rb_size, pusch_pdu->nr_of_symbols, - 6, //nb_re_dmrs - not sure where this is coming from - its not in the FAPI + ( no_data_in_dmrs ? 12 : ((pusch_pdu->dmrs_config_type == pusch_dmrs_type1) ? 6 : 4) ) * num_dmrs_symb, 0, //nb_rb_oh 0, pusch_pdu->nrOfLayers)>>3; From fcf64390409d1265175ddab72c402e7d6dc3924e Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Tue, 28 Apr 2020 17:54:38 +0200 Subject: [PATCH 15/42] Fixed bug related to N_TA_offset not being applied at UE - By default this value is equal to 0 at gNB in case of ulsim, but has a value in case of RF simulator - The N_TA_offset was calculated but not used at UE side --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 52 +++++++++++++++++----- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 14c70e6582..769cea37a1 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -537,21 +537,51 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, txdata = UE->common_vars.txdata; txdataF = UE->common_vars.txdataF; - for (ap = 0; ap < Nl; ap++) { + if(UE->N_TA_offset > tx_offset) { + int32_t *tmp_idft_out = (int32_t*)malloc16(frame_parms->get_samples_per_slot(slot, frame_parms) * sizeof(int32_t)); + + for(ap = 0; ap < Nl; ap++) { if (frame_parms->Ncp == 1) { // extended cyclic prefix - PHY_ofdm_mod(txdataF[ap], - &txdata[ap][tx_offset], - frame_parms->ofdm_symbol_size, - 12, - frame_parms->nb_prefix_samples, - CYCLIC_PREFIX); + PHY_ofdm_mod(txdataF[ap], + tmp_idft_out, + frame_parms->ofdm_symbol_size, + 12, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); } else { // normal cyclic prefix - nr_normal_prefix_mod(txdataF[ap], - &txdata[ap][tx_offset], - 14, - frame_parms); + nr_normal_prefix_mod(txdataF[ap], + tmp_idft_out, + 14, + frame_parms); + } + + memcpy((void *) &txdata[ap][frame_parms->samples_per_frame - UE->N_TA_offset + tx_offset], + (void *) tmp_idft_out, + (UE->N_TA_offset - tx_offset) * sizeof(int32_t)); + + memcpy((void *) &txdata[ap][0], + (void *) &tmp_idft_out[UE->N_TA_offset - tx_offset], + (frame_parms->get_samples_per_slot(slot, frame_parms) - UE->N_TA_offset + tx_offset) * sizeof(int32_t)); + } + + free(tmp_idft_out); + } else { // UE->N_TA_offset <= tx_offset + for (ap = 0; ap < Nl; ap++) { + if (frame_parms->Ncp == 1) { // extended cyclic prefix + PHY_ofdm_mod(txdataF[ap], + &txdata[ap][tx_offset-UE->N_TA_offset], + frame_parms->ofdm_symbol_size, + 12, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); + } else { // normal cyclic prefix + nr_normal_prefix_mod(txdataF[ap], + &txdata[ap][tx_offset-UE->N_TA_offset], + 14, + frame_parms); } } + } /////////// //////////////////////////////////////////////////// From d4929cc21e917bf13eba929f7d9a1e3b9d2d8fa6 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Thu, 7 May 2020 09:52:48 +0200 Subject: [PATCH 16/42] bugfix in dmrs offset for pusch --- openair1/PHY/NR_REFSIG/nr_dmrs_rx.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index b1b038e918..4580ccce8c 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -63,32 +63,34 @@ int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB, int8_t w, nb_dmrs; short *mod_table; unsigned char idx=0; - + int k; typedef int array_of_w[2]; array_of_w *wf; array_of_w *wt; wf = (dmrs_type==pusch_dmrs_type1) ? wf1 : wf2; wt = (dmrs_type==pusch_dmrs_type1) ? wt1 : wt2; + int dmrs_offset = re_offset/((dmrs_type==pusch_dmrs_type1)?2:3); + if (dmrs_type > 2) LOG_E(PHY,"PUSCH DMRS config type %d not valid\n", dmrs_type+1); if ((p>=1000) && (p<((dmrs_type==pusch_dmrs_type1) ? 1008 : 1012))) { if (gNB->frame_parms.Ncp == NORMAL) { nb_dmrs = ((dmrs_type==pusch_dmrs_type1) ? 6:4); - for (int i=re_offset; i>5])>>((i<<1)&0x1f))&1)<<1) ^ (((nr_gold_pusch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); - ((int16_t*)output)[i<<1] = mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; - ((int16_t*)output)[(i<<1)+1] = mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; + ((int16_t*)output)[k<<1] = mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; + ((int16_t*)output)[(k<<1)+1] = mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; #ifdef DEBUG_PUSCH printf("nr_pusch_dmrs_rx dmrs config type %d port %d nb_pusch_rb %d\n", dmrs_type, p, nb_pusch_rb); printf("wf[%d] = %d wt[%d]= %d\n", i&1, wf[p-1000][i&1], lp, wt[p-1000][lp]); printf("i %d idx %d pusch gold %u b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, nr_gold_pusch[(i<<1)>>5], (((nr_gold_pusch[(i<<1)>>5])>>((i<<1)&0x1f))&1), - (((nr_gold_pusch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), ((int16_t*)output)[i<<1], ((int16_t*)output)[(i<<1)+1]); + (((nr_gold_pusch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), ((int16_t*)output)[k<<1], ((int16_t*)output)[(k<<1)+1]); #endif } @@ -103,7 +105,6 @@ int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB, } - int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, unsigned int Ns, unsigned int *nr_gold_pdsch, From fa18a88fdb79892a27c035f15f7ea5e0d1a07690 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 29 Apr 2020 14:17:09 +0200 Subject: [PATCH 17/42] fix updating UE->frame_gap and calculation if proc->frame_rx > dcireq.dl_config_req.sfn --- executables/nr-ue.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index f5b0c157ef..71d98ce387 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -443,19 +443,18 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { dcireq.slot = proc->nr_tti_rx; nr_ue_dcireq(&dcireq); //to be replaced with function pointer later + if ((proc->frame_rx % (1 << (ssb_period-1)) == 0) && (proc->nr_tti_rx == 1)) { + UE->frame_gap = (MAX_FRAME_NUMBER + dcireq.dl_config_req.sfn - proc->frame_rx) % MAX_FRAME_NUMBER; + proc->frame_rx = (proc->frame_rx + UE->frame_gap) % MAX_FRAME_NUMBER; + proc->frame_tx = (proc->frame_tx + UE->frame_gap) % MAX_FRAME_NUMBER; + } + // we should have received a DL DCI here, so configure DL accordingly scheduled_response.dl_config = &dcireq.dl_config_req; scheduled_response.ul_config = NULL; scheduled_response.tx_request = NULL; scheduled_response.module_id = UE->Mod_id; scheduled_response.CC_id = 0; - if (!((proc->frame_rx)%(1<<(ssb_period-1)))) { - if(proc->frame_rx > dcireq.dl_config_req.sfn) - UE->frame_gap = proc->frame_rx - dcireq.dl_config_req.sfn; - if(proc->frame_rx < dcireq.dl_config_req.sfn) - UE->frame_gap = dcireq.dl_config_req.sfn - proc->frame_rx; - proc->frame_rx = dcireq.dl_config_req.sfn; - } scheduled_response.frame = proc->frame_rx; scheduled_response.slot = proc->nr_tti_rx; @@ -737,6 +736,12 @@ void *UE_thread(void *arg) { absolute_slot++; + + if(UE->frame_gap) { + absolute_slot += UE->frame_gap * nb_slot_frame; + UE->frame_gap = 0; + } + // whatever means thread_idx // Fix me: will be wrong when slot 1 is slow, as slot 2 finishes // Slot 3 will overlap if RX_NB_TH is 2 @@ -754,8 +759,8 @@ void *UE_thread(void *arg) { curMsg->proc.subframe_rx=slot_nr/(nb_slot_frame/10); curMsg->proc.nr_tti_tx = (absolute_slot + DURATION_RX_TO_TX) % nb_slot_frame; curMsg->proc.subframe_tx=curMsg->proc.nr_tti_rx; - curMsg->proc.frame_rx = ((absolute_slot/nb_slot_frame)+UE->frame_gap) % MAX_FRAME_NUMBER; - curMsg->proc.frame_tx = (((absolute_slot+DURATION_RX_TO_TX)/nb_slot_frame)+UE->frame_gap) % MAX_FRAME_NUMBER; + curMsg->proc.frame_rx = (absolute_slot/nb_slot_frame) % MAX_FRAME_NUMBER; + curMsg->proc.frame_tx = ((absolute_slot+DURATION_RX_TO_TX)/nb_slot_frame) % MAX_FRAME_NUMBER; curMsg->proc.decoded_frame_rx=-1; //LOG_I(PHY,"Process slot %d thread Idx %d total gain %d\n", slot_nr, thread_idx, UE->rx_total_gain_dB); From aa7e10c4052b8b6bff9685df5f4c7efaa5360cd5 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 29 Apr 2020 17:39:33 +0200 Subject: [PATCH 18/42] also use the high 6 bits from MIB when calculating decoded_frame_rx after the initial synchronization --- executables/nr-ue.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 71d98ce387..cf7a77a1d4 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -690,8 +690,11 @@ void *UE_thread(void *arg) { if (res) { syncRunning=false; syncData_t *tmp=(syncData_t *)NotifiedFifoData(res); - // shift the frame index with all the frames we trashed meanwhile we perform the synch search - decoded_frame_rx=(tmp->proc.decoded_frame_rx + (!UE->init_sync_frame) + trashed_frames) % MAX_FRAME_NUMBER; + if (UE->is_synchronized) { + decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx); + // shift the frame index with all the frames we trashed meanwhile we perform the synch search + decoded_frame_rx=(decoded_frame_rx + (!UE->init_sync_frame) + trashed_frames) % MAX_FRAME_NUMBER; + } delNotifiedFIFO_elt(res); } else { readFrame(UE, ×tamp, true); From 25c4cea36f66a9730a83439d9446855cf3c0fb20 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 29 Apr 2020 18:12:47 +0200 Subject: [PATCH 19/42] remove now unnecessary frame_gap completely --- executables/nr-ue.c | 11 ----------- openair1/PHY/defs_nr_UE.h | 2 -- 2 files changed, 13 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index cf7a77a1d4..8e59bd98b4 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -443,12 +443,6 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { dcireq.slot = proc->nr_tti_rx; nr_ue_dcireq(&dcireq); //to be replaced with function pointer later - if ((proc->frame_rx % (1 << (ssb_period-1)) == 0) && (proc->nr_tti_rx == 1)) { - UE->frame_gap = (MAX_FRAME_NUMBER + dcireq.dl_config_req.sfn - proc->frame_rx) % MAX_FRAME_NUMBER; - proc->frame_rx = (proc->frame_rx + UE->frame_gap) % MAX_FRAME_NUMBER; - proc->frame_tx = (proc->frame_tx + UE->frame_gap) % MAX_FRAME_NUMBER; - } - // we should have received a DL DCI here, so configure DL accordingly scheduled_response.dl_config = &dcireq.dl_config_req; scheduled_response.ul_config = NULL; @@ -740,11 +734,6 @@ void *UE_thread(void *arg) { absolute_slot++; - if(UE->frame_gap) { - absolute_slot += UE->frame_gap * nb_slot_frame; - UE->frame_gap = 0; - } - // whatever means thread_idx // Fix me: will be wrong when slot 1 is slow, as slot 2 finishes // Slot 3 will overlap if RX_NB_TH is 2 diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index ac71f708ec..b3bb21881f 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -884,8 +884,6 @@ typedef struct { fapi_nr_config_request_t nrUE_config; - uint16_t frame_gap; - // the following structures are not part of PHY_vars_UE anymore as it is not thread safe. They are now on the stack of the functions that actually need them //nr_downlink_indication_t dl_indication; From cdead06962a6d8ccfa7934842015998f2774bedc Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 24 Apr 2020 11:42:50 +0200 Subject: [PATCH 20/42] fix for scrambling rnti and dci format --- .../open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h | 2 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c | 10 ++++++---- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 6 +++++- 4 files changed, 13 insertions(+), 7 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 610a798292..4318db7a68 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 @@ -60,7 +60,7 @@ typedef struct { uint8_t CoreSetType; uint8_t precoder_granularity; uint16_t pdcch_dmrs_scrambling_id; - + uint16_t scrambling_rnti; uint8_t tci_state_pdcch; uint8_t tci_present_in_dci; } fapi_nr_coreset_t; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index adc619825a..1c722665bc 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -858,7 +858,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d\n", j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L); - nr_pdcch_unscrambling(&pdcch_vars->e_rx[CCEind*108], rel15->rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); + nr_pdcch_unscrambling(&pdcch_vars->e_rx[CCEind*108], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); #ifdef DEBUG_DCI_DECODING uint32_t * z = (uint32_t *) &pdcch_vars->e_rx[CCEind*108]; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 61cf7332b2..362b1d3466 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -180,12 +180,14 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac,fapi_nr_dl_config_request_t *dl_ } rel15->coreset.CoreSetType = 1; rel15->coreset.precoder_granularity = mac->coreset[0][0]->precoderGranularity; - - if (mac->coreset[0][0]->pdcch_DMRS_ScramblingID) + if (mac->coreset[0][0]->pdcch_DMRS_ScramblingID) { rel15->coreset.pdcch_dmrs_scrambling_id = *mac->coreset[0][0]->pdcch_DMRS_ScramblingID; - else + rel15->coreset.scrambling_rnti = mac->t_crnti; + } + else { rel15->coreset.pdcch_dmrs_scrambling_id = *mac->scc->physCellId; - + rel15->coreset.scrambling_rnti = 0; + } fill_dci_search_candidates(mac->SSpace[0][0][ss_id],rel15); dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI; dl_config->number_pdus = dl_config->number_pdus + 1; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 3a8db970e8..08d55779bd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -392,7 +392,11 @@ int configure_fapi_dl_pdu(int Mod_idP, int dci_formats[2]; int rnti_types[2]; - dci_formats[0] = NR_DL_DCI_FORMAT_1_0; + if (ss->searchSpaceType->choice.ue_Specific->dci_Formats) + dci_formats[0] = NR_DL_DCI_FORMAT_1_1; + else + dci_formats[0] = NR_DL_DCI_FORMAT_1_0; + rnti_types[0] = NR_RNTI_C; pdcch_pdu_rel15->dci_pdu.PayloadSizeBits[0]=nr_dci_size(dci_formats[0],rnti_types[0],pdcch_pdu_rel15->BWPSize); From e3ba90b055aaf122783917241018996e4dc19455 Mon Sep 17 00:00:00 2001 From: cig Date: Tue, 28 Apr 2020 14:00:58 +0200 Subject: [PATCH 21/42] Fixes for polar and scrambling RNTI at UE - including temporary hotfix for the polar rnti --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 5 +---- .../LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 1c722665bc..04dd321db2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -874,10 +874,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, 1, currentPtrDCI); - if (get_softmodem_params()->do_ra == 1) - n_rnti = ue->prach_resources[gNB_id]->ra_RNTI; - else - n_rnti = rel15->rnti; + n_rnti = rel15->rnti; if (crc == n_rnti) { LOG_D(PHY,"Decoded crc %x matches rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 362b1d3466..e745bfb693 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -130,12 +130,6 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac,fapi_nr_dl_config_request_t *dl_ } if (mac->crnti>0) { rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - - if (get_softmodem_params()->do_ra == 1) - rel15->rnti = 0x00; - else // phy_test - rel15->rnti = mac->crnti; - rel15->dci_format = NR_DL_DCI_FORMAT_1_0; if (slot == 0 || slot == 1){ @@ -180,14 +174,20 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac,fapi_nr_dl_config_request_t *dl_ } rel15->coreset.CoreSetType = 1; rel15->coreset.precoder_granularity = mac->coreset[0][0]->precoderGranularity; + if (mac->coreset[0][0]->pdcch_DMRS_ScramblingID) { rel15->coreset.pdcch_dmrs_scrambling_id = *mac->coreset[0][0]->pdcch_DMRS_ScramblingID; rel15->coreset.scrambling_rnti = mac->t_crnti; - } - else { + } else { rel15->coreset.pdcch_dmrs_scrambling_id = *mac->scc->physCellId; rel15->coreset.scrambling_rnti = 0; } + + if (get_softmodem_params()->do_ra && slot == 7) + rel15->rnti = mac->ra_rnti; + else + rel15->rnti = mac->crnti; + fill_dci_search_candidates(mac->SSpace[0][0][ss_id],rel15); dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI; dl_config->number_pdus = dl_config->number_pdus + 1; From 4dc0e7f2355717c22b5f0d3df9dc7176905d3aaf Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 29 Apr 2020 12:15:49 +0200 Subject: [PATCH 22/42] Enabled UE to process RX and TX in every DL or UL (or mixed) slot respectivey - the commit fixes also the selection of the thread_id in TX procedures - DCI configuration is currently limited to slot 1 and 7 --- executables/nr-ue.c | 18 ++--- openair1/SCHED_NR/phy_frame_config_nr.c | 67 +++++++++++++++++++ .../NR_MAC_UE/nr_ue_dci_configuration.c | 8 ++- 3 files changed, 82 insertions(+), 11 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 8e59bd98b4..fb9d260541 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -373,8 +373,11 @@ void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; + fapi_nr_config_request_t *cfg = &UE->nrUE_config; + int tx_slot_type = nr_ue_slot_select(cfg, proc->frame_tx, proc->nr_tti_tx); + // program PUSCH. this should actually be done by the MAC upon reception of an UL DCI - if (proc->nr_tti_tx == 8 || proc->nr_tti_tx == 19 || UE->frame_parms.frame_type == FDD){ + if (tx_slot_type == NR_UPLINK_SLOT || tx_slot_type == NR_MIXED_SLOT){ mod_id = UE->Mod_id; @@ -403,7 +406,7 @@ void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { rvidx = 0; //------------------------------------------------------------------------------// - scheduled_response.ul_config->slot = 8; + scheduled_response.ul_config->slot = proc->nr_tti_tx; scheduled_response.ul_config->number_pdus = 1; scheduled_response.ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.rnti = n_rnti; @@ -420,7 +423,7 @@ void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { nr_ue_scheduled_response(&scheduled_response); if (UE->mode != loop_through_memory) { - uint8_t thread_id = PHY_vars_UE_g[mod_id][0]->current_thread_id[proc->nr_tti_tx]; + uint8_t thread_id = PHY_vars_UE_g[mod_id][0]->current_thread_id[proc->nr_tti_rx]; phy_procedures_nrUE_TX(UE,proc,0,thread_id); } } @@ -430,12 +433,13 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; - uint8_t ssb_period = UE->nrUE_config.ssb_table.ssb_period; + fapi_nr_config_request_t *cfg = &UE->nrUE_config; + int rx_slot_type = nr_ue_slot_select(cfg, proc->frame_rx, proc->nr_tti_rx); + uint8_t ssb_period = UE->nrUE_config.ssb_table.ssb_period; //program DCI for slot 1 //TODO: all of this has to be moved to the MAC!!! - // Note: temp hardcoded slot 7 for RAR - if (proc->nr_tti_rx == NR_DOWNLINK_SLOT || proc->nr_tti_rx == 7 || UE->frame_parms.frame_type == FDD){ + if (rx_slot_type == NR_DOWNLINK_SLOT || rx_slot_type == NR_MIXED_SLOT){ dcireq.module_id = UE->Mod_id; dcireq.gNB_index = 0; dcireq.cc_id = 0; @@ -453,10 +457,8 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { scheduled_response.slot = proc->nr_tti_rx; nr_ue_scheduled_response(&scheduled_response); - } // Process Rx data for one sub-frame - if ( proc->nr_tti_rx >=0 && proc->nr_tti_rx <= 1 || proc->nr_tti_rx == 7) { #ifdef UE_SLOT_PARALLELISATION phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); #else diff --git a/openair1/SCHED_NR/phy_frame_config_nr.c b/openair1/SCHED_NR/phy_frame_config_nr.c index a36cebd6ae..0ccb13fc7c 100644 --- a/openair1/SCHED_NR/phy_frame_config_nr.c +++ b/openair1/SCHED_NR/phy_frame_config_nr.c @@ -369,6 +369,73 @@ int nr_slot_select(nfapi_nr_config_request_scf_t *cfg, int nr_frame, int nr_tti) } } +/******************************************************************* +* +* NAME : nr_ue_slot_select +* +* DESCRIPTION : function for the UE equivalent to nr_slot_select +* +*********************************************************************/ + +int nr_ue_slot_select(fapi_nr_config_request_t *cfg, int nr_frame, int nr_tti) { + /* for FFD all slot can be considered as an uplink */ + int mu = cfg->ssb_config.scs_common, check_slot = 0; + + if (cfg->cell_config.frame_duplex_type == FDD) { + return (NR_UPLINK_SLOT | NR_DOWNLINK_SLOT); + } + + if (nr_frame%2 == 0) { + for(int symbol_count=0; symbol_counttdd_table.max_tdd_periodicity_list[nr_tti].max_num_of_symbol_per_slot_list[symbol_count].slot_config == 1) { + check_slot++; + } + } + + if(check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) { + return (NR_UPLINK_SLOT); + } + + check_slot = 0; + + for(int symbol_count=0; symbol_counttdd_table.max_tdd_periodicity_list[nr_tti].max_num_of_symbol_per_slot_list[symbol_count].slot_config == 0) { + check_slot++; + } + } + + if(check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) { + return (NR_DOWNLINK_SLOT); + } else { + return (NR_MIXED_SLOT); + } + } else { + for(int symbol_count=0; symbol_counttdd_table.max_tdd_periodicity_list[((1<tdd_table.max_tdd_periodicity_list[((1<scc,slot)==1) { - - // get BWP 1, Coreset 0, SearchSpace 0 + if (slot == 1 || slot == 7) { + + LOG_D(PHY,"Entering UE DCI configuration frame %d slot %d \n", frame, slot); + + // get BWP 1, Coreset 0, SearchSpace 0 if (mac->DLbwp[0]==NULL) { AssertFatal(mac->scd->downlinkBWP_ToAddModList!=NULL,"downlinkBWP_ToAddModList is null\n"); AssertFatal(mac->scd->downlinkBWP_ToAddModList->list.count==1,"downlinkBWP_ToAddModList->list->count is %d\n", From 785ffa4def2cee1ffc2d934e1c94f1eccbf15832 Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 29 Apr 2020 12:25:30 +0200 Subject: [PATCH 23/42] Minor fixes --- openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 8e4b45f744..b142022e37 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -296,7 +296,7 @@ static inline void polar_rate_matching(t_nrPolar_params *polarParams,void *in,vo void build_polar_tables(t_nrPolar_params *polarParams) { // build table b -> c' AssertFatal(polarParams->K > 32, "K = %d < 33, is not supported yet\n",polarParams->K); - AssertFatal(polarParams->K < 129, "K = %d > 64, is not supported yet\n",polarParams->K); + AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n", polarParams->K); int bit_i,ip; int numbytes = polarParams->K>>3; int residue = polarParams->K&7; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index adeb186517..d76718d388 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -4153,7 +4153,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, 0); } } else { - LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: No DCIs found\n",ue->Mod_id,frame_rx,nr_tti_rx); + LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: No DCIs found\n", ue->Mod_id, frame_rx, nr_tti_rx); } #endif //NR_PDCCH_SCHED From 96b57557533366db1a4aad1d202a606c20091467 Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 29 Apr 2020 18:13:31 +0200 Subject: [PATCH 24/42] Cleanup NR UE DCI configuration --- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c | 4 +--- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 6 ++++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index b4827e4d60..1516b2a08c 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -168,7 +168,7 @@ unsigned char nr_generate_ulsch_pdu(uint8_t *sdus_payload, int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_indication_t *dci_ind, void *pduP, uint32_t pdu_len); -void ue_dci_configuration(NR_UE_MAC_INST_t *mac,fapi_nr_dl_config_request_t *dl_config,int frame,int slot); +void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, int slot); void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, int dci_format, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index e5db0c28f8..bb2972c46c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -61,13 +61,11 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd } -void ue_dci_configuration(NR_UE_MAC_INST_t *mac,fapi_nr_dl_config_request_t *dl_config,int frame,int slot) { +void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, int slot) { // check if DL slot if (slot == 1 || slot == 7) { - LOG_D(PHY,"Entering UE DCI configuration frame %d slot %d \n", frame, slot); - // get BWP 1, Coreset 0, SearchSpace 0 if (mac->DLbwp[0]==NULL) { AssertFatal(mac->scd->downlinkBWP_ToAddModList!=NULL,"downlinkBWP_ToAddModList is null\n"); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 87ddd97366..3688d095f1 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -312,7 +312,9 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq) { dl_config->sfn=UE_mac->dl_config_request.sfn; dl_config->slot=UE_mac->dl_config_request.slot; dl_config->number_pdus=0; - - ue_dci_configuration(UE_mac,dl_config,dcireq->frame,dcireq->slot); + + LOG_D(PHY, "Entering UE DCI configuration frame %d slot %d \n", dcireq->frame, dcireq->slot); + ue_dci_configuration(UE_mac, dl_config, dcireq->slot); + return 0; } From 58dbf7d4b9b0901d0b5a36499021076a80c9e96f Mon Sep 17 00:00:00 2001 From: cig Date: Sun, 3 May 2020 14:38:30 +0200 Subject: [PATCH 25/42] New design UE scheduler --- executables/nr-ue.c | 32 ++-- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 20 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 191 ++++++++++--------- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 11 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h | 5 +- 5 files changed, 126 insertions(+), 133 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index fb9d260541..25fe092401 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -431,32 +431,24 @@ void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { - nr_dcireq_t dcireq; - nr_scheduled_response_t scheduled_response; fapi_nr_config_request_t *cfg = &UE->nrUE_config; int rx_slot_type = nr_ue_slot_select(cfg, proc->frame_rx, proc->nr_tti_rx); - uint8_t ssb_period = UE->nrUE_config.ssb_table.ssb_period; + uint8_t gNB_id = 0; + + nr_downlink_indication_t dl_indication; + memset((void*)&dl_indication, 0, sizeof(dl_indication)); - //program DCI for slot 1 - //TODO: all of this has to be moved to the MAC!!! if (rx_slot_type == NR_DOWNLINK_SLOT || rx_slot_type == NR_MIXED_SLOT){ - dcireq.module_id = UE->Mod_id; - dcireq.gNB_index = 0; - dcireq.cc_id = 0; - dcireq.frame = proc->frame_rx; - dcireq.slot = proc->nr_tti_rx; - nr_ue_dcireq(&dcireq); //to be replaced with function pointer later - // we should have received a DL DCI here, so configure DL accordingly - scheduled_response.dl_config = &dcireq.dl_config_req; - scheduled_response.ul_config = NULL; - scheduled_response.tx_request = NULL; - scheduled_response.module_id = UE->Mod_id; - scheduled_response.CC_id = 0; - scheduled_response.frame = proc->frame_rx; - scheduled_response.slot = proc->nr_tti_rx; + if(UE->if_inst != NULL && UE->if_inst->dl_indication != NULL) { + dl_indication.module_id = UE->Mod_id; + dl_indication.gNB_index = gNB_id; + dl_indication.cc_id = UE->CC_id; + dl_indication.frame = proc->frame_rx; + dl_indication.slot = proc->nr_tti_rx; + } - nr_ue_scheduled_response(&scheduled_response); + nr_ue_scheduler(&dl_indication, NULL); // Process Rx data for one sub-frame #ifdef UE_SLOT_PARALLELISATION diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 1516b2a08c..7b71c0c00f 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -84,23 +84,9 @@ NR_UE_MAC_INST_t *get_mac_inst( /**\brief called at each slot, slot length based on numerology. now use u=0, scs=15kHz, slot=1ms performs BSR/SR/PHR procedures, random access procedure handler and DLSCH/ULSCH procedures. - \param module_id module id - \param gNB_index corresponding gNB index - \param cc_id component carrier id - \param rx_frame receive frame number - \param rx_slot receive slot number - \param tx_frame transmit frame number - \param tx_slot transmit slot number*/ -NR_UE_L2_STATE_t nr_ue_scheduler( - const module_id_t module_id, - const uint8_t gNB_index, - const int cc_id, - const frame_t rx_frame, - const slot_t rx_slot, - const int32_t ssb_index, - const frame_t tx_frame, - const slot_t tx_slot); - + \param dl_info DL indication + \param ul_info UL indication*/ +NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_indication_t *ul_info); /* \brief Get SR payload (0,1) from UE MAC @param Mod_id Instance id of UE in machine diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c7fadbdafe..1b87c37b55 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -651,99 +651,120 @@ uint32_t get_ssb_frame(uint32_t test){ // 1. TODO: Call RRC for link status return to PHY // 2. TODO: Perform SR/BSR procedures for scheduling feedback // 3. TODO: Perform PHR procedures -NR_UE_L2_STATE_t nr_ue_scheduler(const module_id_t module_id, - const uint8_t gNB_index, - const int cc_id, - const frame_t rx_frame, - const slot_t rx_slot, - const int32_t ssb_index, - const frame_t tx_frame, - const slot_t tx_slot ){ +NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_indication_t *ul_info){ uint32_t search_space_mask = 0; - NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; + if (dl_info){ + + module_id_t mod_id = dl_info->module_id; + NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + int cc_id = dl_info->cc_id; + fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; + nr_scheduled_response_t scheduled_response; + nr_dcireq_t dcireq; + frame_t rx_frame = dl_info->frame; + slot_t rx_slot = dl_info->slot; - // check type0 from 38.213 13 if we have no CellGroupConfig - if ( mac->scd == NULL) { - if( ssb_index != -1){ - - if(mac->type0_pdcch_ss_mux_pattern == 1){ - // 38.213 chapter 13 - if((mac->type0_pdcch_ss_sfn_c == SFN_C_MOD_2_EQ_0) && !(rx_frame & 0x1) && (rx_slot == mac->type0_pdcch_ss_n_c)){ - search_space_mask = search_space_mask | type0_pdcch; - mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration; - } - if((mac->type0_pdcch_ss_sfn_c == SFN_C_MOD_2_EQ_1) && (rx_frame & 0x1) && (rx_slot == mac->type0_pdcch_ss_n_c)){ - search_space_mask = search_space_mask | type0_pdcch; - mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration; - } + // check type0 from 38.213 13 if we have no CellGroupConfig + // TODO: implementation to be completed + if (mac->scd == NULL) { + if(dl_info->ssb_index != -1){ + + if(mac->type0_pdcch_ss_mux_pattern == 1){ + // 38.213 chapter 13 + if((mac->type0_pdcch_ss_sfn_c == SFN_C_MOD_2_EQ_0) && !(rx_frame & 0x1) && (rx_slot == mac->type0_pdcch_ss_n_c)){ + search_space_mask = search_space_mask | type0_pdcch; + mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration; + } + if((mac->type0_pdcch_ss_sfn_c == SFN_C_MOD_2_EQ_1) && (rx_frame & 0x1) && (rx_slot == mac->type0_pdcch_ss_n_c)){ + search_space_mask = search_space_mask | type0_pdcch; + mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration; + } + } + if(mac->type0_pdcch_ss_mux_pattern == 2){ + // 38.213 Table 13-13, 13-14 + if((rx_frame == get_ssb_frame(rx_frame)) && (rx_slot == mac->type0_pdcch_ss_n_c)){ + search_space_mask = search_space_mask | type0_pdcch; + mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration; + } + } + if(mac->type0_pdcch_ss_mux_pattern == 3){ + // 38.213 Table 13-15 + if((rx_frame == get_ssb_frame(rx_frame)) && (rx_slot == mac->type0_pdcch_ss_n_c)){ + search_space_mask = search_space_mask | type0_pdcch; + mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration; + } + } + } // ssb_index != -1 + + // Type0 PDCCH search space + if((search_space_mask & type0_pdcch) || ( mac->type0_pdcch_consecutive_slots != 0 )){ + mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_consecutive_slots - 1; + + dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15 = mac->type0_pdcch_dci_config; + dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI; + + /* + dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.rnti = 0xaaaa; // to be set + dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = 106; // to be set + + LOG_I(MAC,"nr_ue_scheduler Type0 PDCCH with rnti %x, BWP %d\n", + dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.rnti, + dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP); + */ + dl_config->number_pdus = dl_config->number_pdus + 1; + mac->scheduled_response.dl_config = dl_config; } - if(mac->type0_pdcch_ss_mux_pattern == 2){ - // 38.213 Table 13-13, 13-14 - if((rx_frame == get_ssb_frame(rx_frame)) && (rx_slot == mac->type0_pdcch_ss_n_c)){ - search_space_mask = search_space_mask | type0_pdcch; - mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration; - } - } - if(mac->type0_pdcch_ss_mux_pattern == 3){ - // 38.213 Table 13-15 - if((rx_frame == get_ssb_frame(rx_frame)) && (rx_slot == mac->type0_pdcch_ss_n_c)){ - search_space_mask = search_space_mask | type0_pdcch; - mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration; - } - } - } // ssb_index != -1 - - // Type0 PDCCH search space - if((search_space_mask & type0_pdcch) || ( mac->type0_pdcch_consecutive_slots != 0 )){ - mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_consecutive_slots - 1; - - dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15 = mac->type0_pdcch_dci_config; - dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI; - + } else { // get PDCCH configuration(s) from SCGConfig + // get Coreset and SearchSpace Information from spCellConfigDedicated + // DCI configuration done for BWP 1, Coreset 0, SearchSpace 0 + + // TBR first thing to do : schedule msg2 + + // TBR program DCI for slot 1 if PDSCH + // TBR program DCI for slot 7 if RAR DCI PDSCH + + dcireq.module_id = mod_id; + dcireq.gNB_index = 0; + dcireq.cc_id = 0; + dcireq.frame = rx_frame; // TBR not needed + dcireq.slot = rx_slot; + nr_ue_dcireq(&dcireq); //to be replaced with function pointer later + + // we should have received a DL DCI here, so configure DL accordingly + scheduled_response.dl_config = &dcireq.dl_config_req; + scheduled_response.ul_config = NULL; + scheduled_response.tx_request = NULL; + scheduled_response.module_id = mod_id; + scheduled_response.CC_id = cc_id; + scheduled_response.frame = rx_frame; + scheduled_response.slot = rx_slot; + + nr_ue_scheduled_response(&scheduled_response); + /* - dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.rnti = 0xaaaa; // to be set - dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = 106; // to be set - - LOG_I(MAC,"nr_ue_scheduler Type0 PDCCH with rnti %x, BWP %d\n", - dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.rnti, - dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP); - */ - dl_config->number_pdus = dl_config->number_pdus + 1; + if(search_space_mask & type0a_pdcch){ + } + + if(search_space_mask & type1_pdcch){ + } + + if(search_space_mask & type2_pdcch){ + } + + if(search_space_mask & type3_pdcch){ + } + */ } + } else if (ul_info) { + module_id_t mod_id = ul_info->module_id; + NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + // TODO: expand + // Note: Contention resolution is currently not active + if (mac->RA_contention_resolution_timer_active == 1) + ue_contention_resolution(mod_id, ul_info->gNB_index, ul_info->cc_id, ul_info->frame_tx); } - else { // get PDCCH configuration(s) from SCGConfig - - - - - // get Coreset and SearchSpace Information from spCellConfigDedicated - - - - /* - if(search_space_mask & type0a_pdcch){ - } - - if(search_space_mask & type1_pdcch){ - } - - if(search_space_mask & type2_pdcch){ - } - - if(search_space_mask & type3_pdcch){ - } - */ - } - - if (mac->RA_contention_resolution_timer_active == 1) { - ue_contention_resolution(module_id, gNB_index, cc_id, tx_frame); - } - - mac->scheduled_response.dl_config = dl_config; - return UE_CONNECTION_OK; } diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 3688d095f1..b250f84c7b 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -113,14 +113,7 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ mac->dl_config_request.number_pdus = 0; // clean previous FAPI messages - ret = nr_ue_scheduler(ul_info->module_id, - ul_info->gNB_index, - ul_info->cc_id, - ul_info->frame_rx, - ul_info->slot_rx, - ul_info->ssb_index, - ul_info->frame_tx, - ul_info->slot_tx); + ret = nr_ue_scheduler(NULL, ul_info); if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && get_softmodem_params()->do_ra) nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx); @@ -313,6 +306,8 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq) { dl_config->slot=UE_mac->dl_config_request.slot; dl_config->number_pdus=0; + printf(" UE_mac->dl_config_request.slot %d VS dcireq->slot %d \n", UE_mac->dl_config_request.slot, dcireq->slot); + LOG_D(PHY, "Entering UE DCI configuration frame %d slot %d \n", dcireq->frame, dcireq->slot); ue_dci_configuration(UE_mac, dl_config, dcireq->slot); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index b7ddfc0c57..df2d78f0cb 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -72,7 +72,8 @@ typedef struct { /// NR UE FAPI-like P7 message, direction: L1 to L2 /// data reception indication structure fapi_nr_rx_indication_t *rx_ind; - + /// ssb_index, if ssb is not present in current TTI, value set to -1 + int ssb_index; /// dci reception indication structure fapi_nr_dci_indication_t *dci_ind; @@ -94,8 +95,6 @@ typedef struct { frame_t frame_tx; /// slot tx uint32_t slot_tx; - /// ssb_index, if ssb is not present in current TTI, thie value set to -1 - int ssb_index; /// dci reception indication structure fapi_nr_dci_indication_t *dci_ind; } nr_uplink_indication_t; From 12b585a190f1b89e04f4fef2d24a2bb1fc308aa3 Mon Sep 17 00:00:00 2001 From: cig Date: Sun, 3 May 2020 17:26:49 +0200 Subject: [PATCH 26/42] Fixes to RA procedure --- openair1/PHY/defs_nr_common.h | 2 - openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 33 +++++----- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 2 + openair2/LAYER2/NR_MAC_UE/mac_proto.h | 16 ++--- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 64 +++++++------------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 4 ++ openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 +- 7 files changed, 53 insertions(+), 70 deletions(-) diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 6531f582ac..584962c55c 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -221,8 +221,6 @@ typedef struct { uint16_t ra_RNTI; /// Pointer to Msg3 payload for UL-grant uint8_t *Msg3; - /// Flag for the Msg1 generation: it is enabled every time it is nr prach slot - uint8_t generate_nr_prach; /// Frame of last completed synch uint8_t sync_frame; /// Flag to indicate that prach is ready to start: it is enabled with an initial delay after the sync diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index d76718d388..2d09fc7135 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2269,9 +2269,6 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, if ((ue->UE_mode[gNB_id] == PRACH) && (ue->prach_vars[gNB_id]->prach_Config_enabled == 1)) { nr_ue_prach_procedures(ue, proc, gNB_id, mode); } - else { - ue->prach_resources[gNB_id]->generate_nr_prach = 0; - } } LOG_I(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); @@ -4497,6 +4494,7 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t uint8_t mod_id = ue->Mod_id; UE_MODE_t UE_mode = get_nrUE_mode(mod_id, ue->CC_id, gNB_id); NR_PRACH_RESOURCES_t * prach_resources = ue->prach_resources[gNB_id]; + uint8_t nr_prach; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_IN); @@ -4505,7 +4503,7 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t prach_resources->ra_TDD_map_index = 0; prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER = 10; prach_resources->ra_RNTI = 0x1234; - prach_resources->generate_nr_prach = 1; + nr_prach = 1; } else { // ask L2 for RACH transport if ((runmode != rx_calib_ue) && (runmode != rx_calib_ue_med) && (runmode != rx_calib_ue_byp) && (runmode != no_L2_connect) ) { @@ -4516,16 +4514,17 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ue->ulsch_Msg3_active[i] = 0; } } - nr_ue_get_rach(ue->prach_resources[gNB_id], mod_id, ue->CC_id, UE_mode, frame_tx, gNB_id, nr_tti_tx); + nr_prach = nr_ue_get_rach(ue->prach_resources[gNB_id], mod_id, ue->CC_id, UE_mode, frame_tx, gNB_id, nr_tti_tx); } } - if (!prach_resources->init_msg1 && (frame_tx > ue->prach_resources[gNB_id]->sync_frame + 150)) - prach_resources->init_msg1 = 1; - - if (ue->prach_resources[gNB_id] != NULL && prach_resources->generate_nr_prach == 1 && prach_resources->init_msg1) { - + if (!prach_resources->init_msg1 && (frame_tx > ue->prach_resources[gNB_id]->sync_frame + 150)){ ue->prach_cnt = 0; + prach_resources->init_msg1 = 1; + } + + if (ue->prach_resources[gNB_id] != NULL && nr_prach == 1 && prach_resources->init_msg1) { + pathloss = get_nr_PL(mod_id, ue->CC_id, gNB_id); LOG_D(PHY,"runmode %d\n",runmode); @@ -4585,18 +4584,18 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t prach_resources->ra_PreambleIndex, ue->tx_power_dBm[nr_tti_tx], pathloss); + + LOG_D(PHY,"[UE %d] frame %d nr_tti_tx %d : prach_cnt %d\n", ue->Mod_id, frame_tx, nr_tti_tx, ue->prach_cnt); + + ue->prach_cnt++; + + if (ue->prach_cnt == 3) + ue->prach_cnt = 0; } // if we're calibrating the PRACH kill the pointer to its resources so that the RA protocol doesn't continue if (runmode == calib_prach_tx) ue->prach_resources[gNB_id] = NULL; - LOG_D(PHY,"[UE %d] frame %d nr_tti_tx %d : generate_nr_prach %d, prach_cnt %d\n", ue->Mod_id, frame_tx, nr_tti_tx, ue->prach_resources[gNB_id]->generate_nr_prach, ue->prach_cnt); - - ue->prach_cnt++; - - if (ue->prach_cnt == 3) - prach_resources->generate_nr_prach = 0; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 64dd241499..8da2d29d75 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -239,6 +239,8 @@ typedef struct { uint8_t RA_RAPID_found; /// Flag to monitor if BI was received in RAR uint8_t RA_BI_found; + /// Flag for the Msg1 generation: enabled at every occurrence of nr prach slot + uint8_t generate_nr_prach; //// FAPI-like interface message fapi_nr_tx_request_t tx_request; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 7b71c0c00f..1ba5600dae 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -235,14 +235,14 @@ andom-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 @param frame @param gNB_id gNB index @param nr_tti_tx slot for PRACH transmission -@returns void */ -void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, - module_id_t mod_id, - int CC_id, - UE_MODE_t UE_mode, - frame_t frame, - uint8_t gNB_id, - int nr_tti_tx); +@returns indication to generate PRACH to phy */ +uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, + module_id_t mod_id, + int CC_id, + UE_MODE_t UE_mode, + frame_t frame, + uint8_t gNB_id, + int nr_tti_tx); /* \brief Function implementing the routine for the selection of Random Access resources (5.1.2 TS 38.321). @param module_idP Index of UE instance diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index a5e1c72c93..b41b966a82 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -331,19 +331,17 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint // - retrieve TBS // - add mac_rrc_nr_data_req_ue, etc ... // - add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) -void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, - module_id_t mod_id, - int CC_id, - UE_MODE_t UE_mode, - frame_t frame, - uint8_t gNB_id, - int nr_tti_tx){ +uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, + module_id_t mod_id, + int CC_id, + UE_MODE_t UE_mode, + frame_t frame, + uint8_t gNB_id, + int nr_tti_tx){ NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); uint8_t mac_sdus[MAX_NR_ULSCH_PAYLOAD_BYTES]; uint8_t lcid = UL_SCH_LCID_CCCH_MSG3, *payload, ra_ResponseWindow; - uint8_t config_index, mu; - int is_nr_prach_slot; uint16_t size_sdu = 0; unsigned short post_padding; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; @@ -365,27 +363,6 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, LOG_D(MAC, "nr_ue_get_rach, RA_active value: %d", mac->RA_active); - config_index = rach_ConfigGeneric->prach_ConfigurationIndex; - if (setup->msg1_SubcarrierSpacing) - mu = *setup->msg1_SubcarrierSpacing; - else - mu = frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; - - is_nr_prach_slot = get_nr_prach_info_from_index(config_index, - (int)frame, - (int)nr_tti_tx, - frequencyInfoDL->absoluteFrequencyPointA, - mu, - cfg->cell_config.frame_duplex_type, - NULL, - NULL, - NULL, - NULL); - if (is_nr_prach_slot) - prach_resources->generate_nr_prach = 1; - else - prach_resources->generate_nr_prach = 0; - AssertFatal(setup != NULL, "[UE %d] FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id); if (mac->RA_active == 0) { @@ -393,6 +370,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, LOG_I(MAC, "RA not active. Starting RA preamble initialization.\n"); + mac->ra_state = RA_UE_IDLE; mac->RA_RAPID_found = 0; /* Set RA_PREAMBLE_POWER_RAMPING_STEP */ @@ -446,10 +424,10 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, size_sdu += sdu_lengths[0]; } - mac->RA_tx_frame = frame; - mac->RA_tx_subframe = nr_tti_tx; - mac->RA_backoff_frame = frame; - mac->RA_backoff_subframe = nr_tti_tx; + //mac->RA_tx_frame = frame; + //mac->RA_tx_subframe = nr_tti_tx; + //mac->RA_backoff_frame = frame; + //mac->RA_backoff_subframe = nr_tti_tx; if (size_sdu > 0) { @@ -493,7 +471,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, } // Fill in preamble and PRACH resources - if (is_nr_prach_slot) + if (mac->generate_nr_prach) nr_get_prach_resources(mod_id, CC_id, gNB_id, nr_tti_tx, 1, prach_resources, rach_ConfigDedicated); offset = nr_generate_ulsch_pdu((uint8_t *) mac_sdus, // sdus buffer @@ -528,18 +506,20 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, // - handle backoff and raResponseWindow params // - disabled contention resolution as OAI NSA is contention-free based - LOG_D(MAC, "[MAC][UE %d][RAPROC] frame %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n", - mod_id, frame, nr_tti_tx, mac->RA_window_cnt, mac->RA_tx_frame, mac->RA_tx_subframe); + // LOG_D(MAC, "[MAC][UE %d][RAPROC] frame %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n", + // mod_id, frame, nr_tti_tx, mac->RA_window_cnt, mac->RA_tx_frame, mac->RA_tx_subframe); if (mac->RA_BI_found){ - prach_resources->RA_PREAMBLE_BACKOFF = prach_resources->RA_SCALING_FACTOR_BI * mac->RA_backoff_indicator; + prach_resources->RA_PREAMBLE_BACKOFF = prach_resources->RA_SCALING_FACTOR_BI * mac->RA_backoff_indicator; } else { prach_resources->RA_PREAMBLE_BACKOFF = 0; } if (mac->RA_window_cnt > 0 && mac->RA_RAPID_found == 1) { // mac->ra_state = WAIT_CONTENTION_RESOLUTION; + LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: subframe %d: RAR successfully received \n", mod_id, frame, nr_tti_tx); } else { + mac->ra_state = RA_UE_IDLE; LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: subframe %d: RAR reception not successful, (RA window count %d) \n", mod_id, frame, @@ -608,11 +588,11 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, // LOG_D(MAC, "[MAC][UE %d][RAPROC] Frame %d, subframe %d: RA Active, adjusted window cnt %d\n", mod_id, frame, nr_tti_tx, mac->RA_window_cnt); // } - mac->RA_tx_frame = frame; - mac->RA_tx_subframe = nr_tti_tx; + // mac->RA_tx_frame = frame; + // mac->RA_tx_subframe = nr_tti_tx; // Fill in preamble and PRACH resources - if (is_nr_prach_slot) + if (mac->generate_nr_prach) nr_get_prach_resources(mod_id, CC_id, gNB_id, nr_tti_tx, 0, prach_resources, rach_ConfigDedicated); } @@ -621,5 +601,5 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, LOG_D(MAC, "[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...", mod_id); AssertFatal(1 == 0, ""); } - return; + return mac->generate_nr_prach; } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 1b87c37b55..50ea64c724 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -813,6 +813,8 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s &N_dur); if (is_nr_prach_slot) { + mac->generate_nr_prach = 1; + fdm = rach_ConfigGeneric->msg1_FDM; switch (fdm){ @@ -911,6 +913,8 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s } } } + } else { + mac->generate_nr_prach = 0; } mac->scheduled_response.ul_config = ul_config; } diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index b250f84c7b..4cda82366c 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -115,7 +115,7 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ ret = nr_ue_scheduler(NULL, ul_info); - if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && get_softmodem_params()->do_ra) + if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && mac->ra_state <= WAIT_RAR && get_softmodem_params()->do_ra) nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx); switch(ret){ From 08b6211956680d58de451737b096a69a4aac06b6 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 4 May 2020 17:16:18 +0200 Subject: [PATCH 27/42] Scheduling of Msg2 --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 74 ++++++++++++- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 4 + openair2/LAYER2/NR_MAC_UE/mac_defs.h | 4 + openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 100 +++++++++++++++++- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 75 ------------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 4 - openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 10 +- 8 files changed, 189 insertions(+), 84 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index baab2f5809..95690e19e3 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -47,6 +47,8 @@ uint16_t NCS_unrestricted_delta_f_RA_15[16] = {0,2,4,6,8,10,12,13,15,17,19,23,27 const char *prachfmt[]={"A1","A2","A3","B1","B2","B3","B4","C0","C2"}; +const uint16_t nr_slots_per_frame[5] = {10, 20, 40, 80, 160}; + uint16_t get_NCS(uint8_t index, uint16_t format0, uint8_t restricted_set_config) { if (format0 < 3) { @@ -876,7 +878,77 @@ int get_format0(uint8_t index, return format; } - + +void find_monitoring_periodicity_offset_common(NR_SearchSpace_t *ss, + uint16_t *slot_period, + uint16_t *offset) { + + switch(ss->monitoringSlotPeriodicityAndOffset->present) { + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1: + *slot_period = 1; + *offset = 0; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2: + *slot_period = 2; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl2; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4: + *slot_period = 4; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl4; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5: + *slot_period = 5; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl5; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8: + *slot_period = 8; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl8; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10: + *slot_period = 10; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl10; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16: + *slot_period = 16; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl16; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20: + *slot_period = 20; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl20; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40: + *slot_period = 40; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl40; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80: + *slot_period = 80; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl80; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160: + *slot_period = 160; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl160; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320: + *slot_period = 320; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl320; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640: + *slot_period = 640; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl640; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280: + *slot_period = 1280; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl1280; + break; + case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560: + *slot_period = 2560; + *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl2560; + break; + default: + AssertFatal(1==0,"Invalid monitoring slot periodicity and offset value\n"); + break; + } +} int get_nr_prach_info_from_index(uint8_t index, int frame, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index a3114886ba..8f5ee85160 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -78,6 +78,10 @@ int is_nr_UL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slotP); uint16_t nr_dci_size(nr_dci_format_t format, nr_rnti_type_t rnti_type, uint16_t N_RB); +void find_monitoring_periodicity_offset_common(NR_SearchSpace_t *ss, + uint16_t *slot_period, + uint16_t *offset); + int get_nr_prach_info_from_index(uint8_t index, int frame, int slot, diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 8da2d29d75..368eae9682 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -220,6 +220,10 @@ typedef struct { uint32_t RA_tx_frame; /// Random-access variable for window calculation (subframe of last change in window counter) uint8_t RA_tx_subframe; + /// Scheduled RX frame for RA Msg2 + uint16_t msg2_rx_frame; + /// Scheduled RX slot for RA Msg2 + uint16_t msg2_rx_slot; /// Random-access Group B maximum path-loss /// Random-access variable for backoff (frame of last change in backoff counter) uint32_t RA_backoff_frame; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 50ea64c724..c33a469a84 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -42,6 +42,7 @@ #include "NR_RACH-ConfigCommon.h" #include "NR_RACH-ConfigGeneric.h" #include "NR_FrequencyInfoDL.h" +#include "NR_PDCCH-ConfigCommon.h" /* MAC */ #include "mac_defs.h" @@ -73,6 +74,8 @@ //#define ENABLE_MAC_PAYLOAD_DEBUG 1 #define DEBUG_EXTRACT_DCI 1 +extern const uint16_t nr_slots_per_frame[5]; + extern void mac_rlc_data_ind ( const module_id_t module_idP, const rnti_t rntiP, @@ -720,8 +723,6 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in // get Coreset and SearchSpace Information from spCellConfigDedicated // DCI configuration done for BWP 1, Coreset 0, SearchSpace 0 - // TBR first thing to do : schedule msg2 - // TBR program DCI for slot 1 if PDSCH // TBR program DCI for slot 7 if RAR DCI PDSCH @@ -769,6 +770,101 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in return UE_CONNECTION_OK; } +// Note: msg2 is scheduled in the mixed slot or in the last dl slot +// if they are allowed by search space configuration +void nr_ue_msg2_scheduler(module_id_t mod_id, + uint16_t rach_frame, + uint16_t rach_slot, + uint16_t *msg2_frame, + uint16_t *msg2_slot){ + + uint8_t bwp_id = 1; + NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + NR_ServingCellConfig_t *scd = mac->scd; + NR_ServingCellConfigCommon_t *scc = mac->scc; + NR_BWP_Downlink_t *bwp = scd->downlinkBWP_ToAddModList->list.array[bwp_id - 1]; + NR_SearchSpace_t *ss; + struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + uint8_t mu = *scc->ssbSubcarrierSpacing; + uint8_t response_window = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.ra_ResponseWindow; + uint8_t slot_window, slot_limit, frame_limit; + uint16_t start_next_period, monitoring_slot_period, monitoring_offset; + + // number of mixed slot or of last dl slot if there is no mixed slot + uint16_t last_dl_slot_period = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots; + uint16_t nr_dl_symbols = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols; + uint16_t nr_ul_symbols = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols; + + // lenght of tdd period in slots + uint16_t tdd_period_slot = last_dl_slot_period + scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; + + AssertFatal(commonSearchSpaceList->list.count > 0, "PDCCH common SearchSpace list has 0 elements\n"); + + LOG_D(MAC, "Frame %d, Slot %d: Scheduling Msg2 reception \n", rach_frame, rach_slot); + + // Common searchspace list + for (int i = 0; i < commonSearchSpaceList->list.count; i++) { + ss = commonSearchSpaceList->list.array[i]; + if(ss->searchSpaceId == *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace) + // retrieving ra pdcch monitoring period and offset + find_monitoring_periodicity_offset_common(ss, &monitoring_slot_period, &monitoring_offset); + } + + if (nr_dl_symbols == 0) + last_dl_slot_period--; + if ((nr_dl_symbols > 0) || (nr_ul_symbols > 0)) + tdd_period_slot++; + + // computing start of next period + start_next_period = (rach_slot - (rach_slot % tdd_period_slot) + tdd_period_slot) % nr_slots_per_frame[mu]; + *msg2_slot = start_next_period + last_dl_slot_period; // initializing scheduling of slot to next mixed (or last dl) slot + *msg2_frame = (*msg2_slot > rach_slot) ? rach_frame : (rach_frame +1); + + switch(response_window){ + case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl1: + slot_window = 1; + break; + case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl2: + slot_window = 2; + break; + case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl4: + slot_window = 4; + break; + case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl8: + slot_window = 8; + break; + case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl10: + slot_window = 10; + break; + case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl20: + slot_window = 20; + break; + case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl40: + slot_window = 40; + break; + case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl80: + slot_window = 80; + break; + default: + AssertFatal(1==0,"Invalid response window value %d\n",response_window); + } + AssertFatal(slot_window<=nr_slots_per_frame[mu], "Msg2 response window needs to be lower or equal to 10ms"); + + // slot and frame limit to transmit msg2 according to response window + slot_limit = (rach_slot + slot_window)%nr_slots_per_frame[mu]; + frame_limit = (slot_limit>(rach_slot))? rach_frame : (rach_frame +1); + + // go to previous slot if the current scheduled slot is beyond the response window + // and if the slot is not among the PDCCH monitored ones (38.213 10.1) + while ((*msg2_slot > slot_limit) || ((*msg2_frame*nr_slots_per_frame[mu] + *msg2_slot - monitoring_offset) % monitoring_slot_period != 0)) { + if((*msg2_slot % tdd_period_slot) > 0) + *msg2_slot--; + else + AssertFatal(1 == 0, "No available DL slot to schedule reception of msg2 has been found"); + } + LOG_D(MAC, "Scheduled Msg2 reception in Frame %d, Slot %d: \n", *msg2_frame, *msg2_slot); +} + // This function schedules the PRACH according to prach_ConfigurationIndex and TS 38.211, tables 6.3.3.2.x // It fills the PRACH PDU per each FD occasion. // PRACH formats 9, 10, 11 are corresponding to dual PRACH format configurations A1/B1, A2/B2, A3/B3. diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 56c3d27210..719571e29c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -42,7 +42,7 @@ #include "SIMULATION/TOOLS/sim.h" // for taus extern RAN_CONTEXT_t RC; -uint16_t nr_slots_per_frame[5] = {10, 20, 40, 80, 160}; +extern const uint16_t nr_slots_per_frame[5]; uint8_t DELTA[4]= {2,3,4,6}; void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 5575f05e1f..fb0a53b4ce 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -998,81 +998,6 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ return -1; } - -void find_monitoring_periodicity_offset_common(NR_SearchSpace_t *ss, - uint16_t *slot_period, - uint16_t *offset) { - - - switch(ss->monitoringSlotPeriodicityAndOffset->present) { - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1: - *slot_period = 1; - *offset = 0; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2: - *slot_period = 2; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl2; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4: - *slot_period = 4; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl4; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5: - *slot_period = 5; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl5; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8: - *slot_period = 8; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl8; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10: - *slot_period = 10; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl10; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16: - *slot_period = 16; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl16; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20: - *slot_period = 20; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl20; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40: - *slot_period = 40; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl40; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80: - *slot_period = 80; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl80; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160: - *slot_period = 160; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl160; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320: - *slot_period = 320; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl320; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640: - *slot_period = 640; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl640; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280: - *slot_period = 1280; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl1280; - break; - case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560: - *slot_period = 2560; - *offset = ss->monitoringSlotPeriodicityAndOffset->choice.sl2560; - break; - default: - AssertFatal(1==0,"Invalid monitoring slot periodicity and offset value\n"); - break; - } -} - - - /*void fill_nfapi_coresets_and_searchspaces(NR_CellGroupConfig_t *cg, nfapi_nr_coreset_t *coreset, nfapi_nr_search_space_t *search_space) { diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index e3ce305180..37f06e143a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -245,10 +245,6 @@ void nr_schedule_reception_msg3(module_id_t module_idP, int CC_id, frame_t frame int find_aggregation_level (NR_SearchSpace_t *ss); -void find_monitoring_periodicity_offset_common(NR_SearchSpace_t *ss, - uint16_t *slot_period, - uint16_t *offset); - void nr_process_mac_pdu( module_id_t module_idP, uint8_t CC_id, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 4cda82366c..3fba88c984 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -115,8 +115,16 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ ret = nr_ue_scheduler(NULL, ul_info); - if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && mac->ra_state <= WAIT_RAR && get_softmodem_params()->do_ra) + if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && mac->ra_state == RA_UE_IDLE && get_softmodem_params()->do_ra){ nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx); + if (mac->generate_nr_prach){ + uint16_t monitoring_slot_period, monitoring_offset; + uint16_t rach_frame = mac->scheduled_response.ul_config->sfn; + uint16_t rx_rach_frame = (rach_frame + 2) % MAX_FRAME_NUMBER; // compensate 2 frames offset delay at gNB side + uint16_t rach_slot = mac->scheduled_response.ul_config->slot; + nr_ue_msg2_scheduler(module_id, rx_rach_frame, rach_slot, &mac->msg2_rx_frame, &mac->msg2_rx_slot); + } + } switch(ret){ case UE_CONNECTION_OK: From 8394ee82f5fe67c2e56afbeb428ff0e82a6953f4 Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 7 May 2020 11:54:20 +0200 Subject: [PATCH 28/42] More dynamic DCI configuration --- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 2 +- .../NR_MAC_UE/nr_ue_dci_configuration.c | 314 +++++++++++------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 19 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 3 +- 4 files changed, 207 insertions(+), 131 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 1ba5600dae..2d49cc0d76 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -154,7 +154,7 @@ unsigned char nr_generate_ulsch_pdu(uint8_t *sdus_payload, int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_indication_t *dci_ind, void *pduP, uint32_t pdu_len); -void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, int slot); +void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot); void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, int dci_format, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index bb2972c46c..bbae5a5cf4 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -21,11 +21,11 @@ /* \file nr_ue_dci_configuration.c * \brief functions for generating dci search procedures based on RRC Serving Cell Group Configuration - * \author R. Knopp + * \author R. Knopp, G. Casati * \date 2020 - * \version 0.1 - * \company Eurecom - * \email: knopp@eurecom.fr + * \version 0.2 + * \company Eurecom, Fraunhofer IIS + * \email: knopp@eurecom.fr, guido.casati@iis.fraunhofer.de * \note * \warning */ @@ -61,134 +61,212 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd } -void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, int slot) { +void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot) { - // check if DL slot - if (slot == 1 || slot == 7) { + NR_ServingCellConfig_t *scd = mac->scd; + NR_BWP_Downlink_t *bwp; + NR_BWP_DownlinkCommon_t *bwp_Common; + NR_BWP_DownlinkDedicated_t *dl_bwp_Dedicated; + NR_SetupRelease_PDCCH_Config_t *pdcch_Config; + NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon; + struct NR_PDCCH_Config__controlResourceSetToAddModList *controlResourceSetToAddModList; + struct NR_PDCCH_Config__searchSpacesToAddModList *searchSpacesToAddModList; + struct NR_UplinkConfig__uplinkBWP_ToAddModList *uplinkBWP_ToAddModList; + NR_SearchSpace_t *NR_SearchSpace; + NR_ControlResourceSet_t *coreset; - // get BWP 1, Coreset 0, SearchSpace 0 - if (mac->DLbwp[0]==NULL) { - AssertFatal(mac->scd->downlinkBWP_ToAddModList!=NULL,"downlinkBWP_ToAddModList is null\n"); - AssertFatal(mac->scd->downlinkBWP_ToAddModList->list.count==1,"downlinkBWP_ToAddModList->list->count is %d\n", - mac->scd->downlinkBWP_ToAddModList->list.count); - mac->DLbwp[0] = mac->scd->downlinkBWP_ToAddModList->list.array[0]; - AssertFatal(mac->DLbwp[0]->bwp_Dedicated!=NULL,"bwp_Dedicated is null\n"); - AssertFatal(mac->DLbwp[0]->bwp_Dedicated->pdcch_Config!=NULL,"pdcch_Config is null\n"); - AssertFatal(mac->DLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList!=NULL,"controlResourceSetToAddModList is null\n"); - AssertFatal(mac->DLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count==1,"controlResourceSetToAddModList->list.count=%d\n", - mac->DLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count); - mac->coreset[0][0] = mac->DLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[0]; - AssertFatal(mac->coreset[0][0]!=NULL,"coreset[0][0] is null\n"); - - AssertFatal(mac->DLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n"); - AssertFatal(mac->DLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, - "searchPsacesToAddModList is empty\n"); - NR_SearchSpace_t *ss; - int ss_id=0; - AssertFatal(mac->DLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.countDLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count); - for (int i=0;iDLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { - ss=mac->DLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; - AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n"); - AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n"); - AssertFatal(*ss->controlResourceSetId == mac->coreset[0][0]->controlResourceSetId,"ss->controlResourceSetId is unknown\n"); - mac->SSpace[0][0][ss_id] = ss; - ss_id++; - } - } - if (mac->ULbwp[0]==NULL) { - AssertFatal(mac->scd->uplinkConfig->uplinkBWP_ToAddModList!=NULL,"uplinkBWP_ToAddModList is null\n"); - AssertFatal(mac->scd->uplinkConfig->uplinkBWP_ToAddModList->list.count==1,"uplinkBWP_ToAddModList->list->count is %d\n", - mac->scd->uplinkConfig->uplinkBWP_ToAddModList->list.count); - mac->ULbwp[0] = mac->scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]; - AssertFatal(mac->ULbwp[0]->bwp_Dedicated!=NULL,"bwp_Dedicated is null\n"); - } - // check search spaces + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15; - int ss_id=0; - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15; - int sps =mac->DLbwp[0]->bwp_Common->genericParameters.cyclicPrefix == NULL ? 14 : 12; + uint8_t bwp_id = 1; + int ss_id, sps; + + // get PDCCH configuration(s) (Coreset, SearchSpace, etc...) from BWP Dedicated in serving cell config dedicated (scd) + // get BWP 1, Coreset ID 0, SearchSpace ID 0 (i.e. configured in MIB and in ServingCellConfigCommon) + + // Check dedicated DL BWP + if (mac->DLbwp[0] == NULL) { + NR_SearchSpace_t *ss; + int ss_id = 0; + + AssertFatal(scd->downlinkBWP_ToAddModList != NULL, "downlinkBWP_ToAddModList is null\n"); + AssertFatal(scd->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList->list->count is %d\n", scd->downlinkBWP_ToAddModList->list.count); + mac->DLbwp[0] = scd->downlinkBWP_ToAddModList->list.array[bwp_id - 1]; + + dl_bwp_Dedicated = mac->DLbwp[0]->bwp_Dedicated; + AssertFatal(dl_bwp_Dedicated != NULL, "dl_bwp_Dedicated is null\n"); + + bwp_Common = mac->DLbwp[0]->bwp_Common; + AssertFatal(bwp_Common != NULL, "bwp_Common is null\n"); + + pdcch_Config = dl_bwp_Dedicated->pdcch_Config; + AssertFatal(pdcch_Config != NULL, "pdcch_Config is null\n"); + + pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; + AssertFatal(pdcch_ConfigCommon != NULL, "pdcch_ConfigCommon is null\n"); + AssertFatal(pdcch_ConfigCommon->choice.setup->ra_SearchSpace != NULL, "ra_SearchSpace must be available in DL BWP\n"); + + controlResourceSetToAddModList = pdcch_Config->choice.setup->controlResourceSetToAddModList; + AssertFatal(controlResourceSetToAddModList != NULL, "controlResourceSetToAddModList is null\n"); + + AssertFatal(controlResourceSetToAddModList->list.count == 1, "controlResourceSetToAddModList->list.count=%d\n", controlResourceSetToAddModList->list.count); + + mac->coreset[0][0] = controlResourceSetToAddModList->list.array[0]; + coreset = mac->coreset[0][0]; + AssertFatal(coreset != NULL, "coreset[0][0] is null\n"); - while(mac->SSpace[0][0][ss_id]!=NULL && - ss_id < mac->DLbwp[0]->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count) { - - AssertFatal(mac->SSpace[0][0][ss_id]->monitoringSymbolsWithinSlot!=NULL,"ss->monitoringSymbolsWithinSlot is null\n"); - AssertFatal(mac->SSpace[0][0][ss_id]->monitoringSymbolsWithinSlot->buf!=NULL,"ss->monitoringSymbolsWithinSlot->buf is null\n"); - + searchSpacesToAddModList = pdcch_Config->choice.setup->searchSpacesToAddModList; + AssertFatal(searchSpacesToAddModList != NULL, "searchSpacesToAddModList is null\n"); + AssertFatal(searchSpacesToAddModList->list.count > 0, "searchSpacesToAddModList is empty\n"); + AssertFatal(searchSpacesToAddModList->list.count < FAPI_NR_MAX_SS_PER_CORESET, "too many searchpaces per coreset %d\n", searchSpacesToAddModList->list.count); + + for (int i = 0; i < searchSpacesToAddModList->list.count; i++) { + ss = searchSpacesToAddModList->list.array[i]; + AssertFatal(ss->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); + AssertFatal(ss->searchSpaceType != NULL, "ss->searchSpaceType is null\n"); + AssertFatal(*ss->controlResourceSetId == coreset->controlResourceSetId, "ss->controlResourceSetId is unknown\n"); + mac->SSpace[0][0][ss_id] = ss; ss_id++; } - if (mac->ra_state == WAIT_RAR) { - // check for RAR - rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - // rel15->rnti = 2;//get_RA_RNTI(mac,frame,slot); // WIP + } + + // Check dedicated UL BWP + if (mac->ULbwp[0] == NULL) { + uplinkBWP_ToAddModList = scd->uplinkConfig->uplinkBWP_ToAddModList; + AssertFatal(uplinkBWP_ToAddModList != NULL, "uplinkBWP_ToAddModList is null\n"); + AssertFatal(uplinkBWP_ToAddModList->list.count == 1, "uplinkBWP_ToAddModList->list->count is %d\n", uplinkBWP_ToAddModList->list.count); + mac->ULbwp[0] = uplinkBWP_ToAddModList->list.array[bwp_id - 1]; + AssertFatal(mac->ULbwp[0]->bwp_Dedicated != NULL, "UL bwp_Dedicated is null\n"); + } + + bwp = mac->DLbwp[0]; + bwp_Common = bwp->bwp_Common; + pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon; + dl_bwp_Dedicated = bwp->bwp_Dedicated; + pdcch_Config = dl_bwp_Dedicated->pdcch_Config; + searchSpacesToAddModList = pdcch_Config->choice.setup->searchSpacesToAddModList; + + // check USSs + ss_id = 0; + NR_SearchSpace = mac->SSpace[0][0][ss_id]; + while(NR_SearchSpace != NULL && ss_id < searchSpacesToAddModList->list.count) { + AssertFatal(NR_SearchSpace->monitoringSymbolsWithinSlot != NULL, "NR_SearchSpace->monitoringSymbolsWithinSlot is null\n"); + AssertFatal(NR_SearchSpace->monitoringSymbolsWithinSlot->buf != NULL, "NR_SearchSpace->monitoringSymbolsWithinSlot->buf is null\n"); + ss_id++; + } + + if (mac->crnti > 0) { + + NR_SearchSpace_t *css; + NR_SearchSpace_t *uss; + NR_ServingCellConfigCommon_t *scc; + NR_SearchSpaceId_t ra_SearchSpaceId; + rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; + uint16_t monitoringSymbolsWithinSlot; + uint8_t add_dci = 1; + + AssertFatal(mac->scc != NULL, "scc is null\n"); + + scc = mac->scc; + rel15->dci_format = NR_DL_DCI_FORMAT_1_0; + + // CoReSet configuration + coreset = mac->coreset[0][0]; + rel15->coreset.duration = coreset->duration; + for (int i = 0; i < 6; i++) + rel15->coreset.frequency_domain_resource[i] = coreset->frequencyDomainResources.buf[i]; + + rel15->coreset.CceRegMappingType = coreset->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved ? FAPI_NR_CCE_REG_MAPPING_TYPE_INTERLEAVED : FAPI_NR_CCE_REG_MAPPING_TYPE_NON_INTERLEAVED; + + if (rel15->coreset.CceRegMappingType == FAPI_NR_CCE_REG_MAPPING_TYPE_INTERLEAVED) { + struct NR_ControlResourceSet__cce_REG_MappingType__interleaved *interleaved = coreset->cce_REG_MappingType.choice.interleaved; + rel15->coreset.RegBundleSize = (interleaved->reg_BundleSize == NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) ? 6 : (2 + interleaved->reg_BundleSize); + rel15->coreset.InterleaverSize = (interleaved->interleaverSize == NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) ? 6 : (2 + interleaved->interleaverSize); + AssertFatal(scc->physCellId != NULL, "mac->scc->physCellId is null\n"); + rel15->coreset.ShiftIndex = interleaved->shiftIndex != NULL ? *interleaved->shiftIndex : *scc->physCellId; + } else { + rel15->coreset.RegBundleSize = 0; + rel15->coreset.InterleaverSize = 0; + rel15->coreset.ShiftIndex = 0; } - else if (mac->ra_state == WAIT_CONTENTION_RESOLUTION) { - rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - rel15->rnti = mac->t_crnti; - //dl_config->number_pdus = dl_config->number_pdus + 1; + + rel15->coreset.CoreSetType = 1; + rel15->coreset.precoder_granularity = coreset->precoderGranularity; + + // Scrambling RNTI + if (coreset->pdcch_DMRS_ScramblingID) { + rel15->coreset.pdcch_dmrs_scrambling_id = *coreset->pdcch_DMRS_ScramblingID; + rel15->coreset.scrambling_rnti = mac->t_crnti; + } else { + rel15->coreset.pdcch_dmrs_scrambling_id = *scc->physCellId; + rel15->coreset.scrambling_rnti = 0; } - if (mac->crnti>0) { - rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; - rel15->dci_format = NR_DL_DCI_FORMAT_1_0; - if (slot == 0 || slot == 1){ - rel15->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275); - rel15->dci_length = nr_dci_size(rel15->dci_format, NR_RNTI_C, rel15->BWPSize); - } else if (slot == 7){ - rel15->BWPSize = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, 275); - rel15->dci_length = nr_dci_size(rel15->dci_format, NR_RNTI_RA, rel15->BWPSize); - } + if (mac->ra_state == WAIT_RAR){ - rel15->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275); - rel15->SubcarrierSpacing = mac->DLbwp[0]->bwp_Common->genericParameters.subcarrierSpacing; - // get UE-specific search space - for (ss_id=0;ss_idSSpace[0][0][ss_id]!=NULL;ss_id++) - if (mac->SSpace[0][0][ss_id]->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) break; - AssertFatal(ss_idSSpace[0][0][ss_id]->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | - (mac->SSpace[0][0][ss_id]->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); - - for (int i=0; i>(sps-1-i))&1) { - rel15->coreset.StartSymbolIndex=i; - break; - } - rel15->coreset.duration = mac->coreset[0][0]->duration; - for (int i=0;i<6;i++) - rel15->coreset.frequency_domain_resource[i] = mac->coreset[0][0]->frequencyDomainResources.buf[i]; - - rel15->coreset.CceRegMappingType = mac->coreset[0][0]->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved? - FAPI_NR_CCE_REG_MAPPING_TYPE_INTERLEAVED : FAPI_NR_CCE_REG_MAPPING_TYPE_NON_INTERLEAVED; - if (rel15->coreset.CceRegMappingType == FAPI_NR_CCE_REG_MAPPING_TYPE_INTERLEAVED) { - rel15->coreset.RegBundleSize = (mac->coreset[0][0]->cce_REG_MappingType.choice.interleaved->reg_BundleSize == NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) ? 6 : (2+mac->coreset[0][0]->cce_REG_MappingType.choice.interleaved->reg_BundleSize); - rel15->coreset.InterleaverSize = (mac->coreset[0][0]->cce_REG_MappingType.choice.interleaved->interleaverSize==NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) ? 6 : (2+mac->coreset[0][0]->cce_REG_MappingType.choice.interleaved->interleaverSize); - AssertFatal(mac->scc->physCellId != NULL,"mac->scc->physCellId is null\n"); - rel15->coreset.ShiftIndex = mac->coreset[0][0]->cce_REG_MappingType.choice.interleaved->shiftIndex != NULL ? *mac->coreset[0][0]->cce_REG_MappingType.choice.interleaved->shiftIndex : *mac->scc->physCellId; - } - else { - rel15->coreset.RegBundleSize = 0; - rel15->coreset.InterleaverSize = 0; - rel15->coreset.ShiftIndex = 0; - } - rel15->coreset.CoreSetType = 1; - rel15->coreset.precoder_granularity = mac->coreset[0][0]->precoderGranularity; + NR_BWP_DownlinkCommon_t *initialDownlinkBWP = scc->downlinkConfigCommon->initialDownlinkBWP; + struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + AssertFatal(commonSearchSpaceList->list.count > 0, "PDCCH CSS list has 0 elements\n"); - if (mac->coreset[0][0]->pdcch_DMRS_ScramblingID) { - rel15->coreset.pdcch_dmrs_scrambling_id = *mac->coreset[0][0]->pdcch_DMRS_ScramblingID; - rel15->coreset.scrambling_rnti = mac->t_crnti; - } else { - rel15->coreset.pdcch_dmrs_scrambling_id = *mac->scc->physCellId; - rel15->coreset.scrambling_rnti = 0; - } + ra_SearchSpaceId = *pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - if (get_softmodem_params()->do_ra && slot == 7) + // fetch the CSS for RA from the CSS list + for (int i = 0; i < commonSearchSpaceList->list.count; i++) { + css = commonSearchSpaceList->list.array[i]; + if(css->searchSpaceId == ra_SearchSpaceId) + break; + } + + // check CSSs + if(css != NULL) { + AssertFatal(css->monitoringSymbolsWithinSlot != NULL, "css->monitoringSymbolsWithinSlot is null\n"); + AssertFatal(css->monitoringSymbolsWithinSlot->buf != NULL, "css->monitoringSymbolsWithinSlot->buf is null\n"); + } + + if (frame == mac->msg2_rx_frame && slot == mac->msg2_rx_slot){ + sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12; + monitoringSymbolsWithinSlot = (css->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (css->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->ra_rnti; - else - rel15->rnti = mac->crnti; + rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, 275); + rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, 275); // NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, 275); + rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing; + rel15->dci_length = nr_dci_size(rel15->dci_format, NR_RNTI_RA, rel15->BWPSize); + for (int i = 0; i < sps; i++) + if ((monitoringSymbolsWithinSlot >> (sps - 1 - i)) & 1) { + rel15->coreset.StartSymbolIndex = i; + break; + } + fill_dci_search_candidates(css, rel15); + } else { + add_dci = 0; + } + } else if (mac->ra_state == WAIT_CONTENTION_RESOLUTION){ - fill_dci_search_candidates(mac->SSpace[0][0][ss_id],rel15); + rel15->rnti = mac->t_crnti; + + } else { + + rel15->rnti = mac->crnti; + rel15->BWPSize = NRRIV2BW(bwp_Common->genericParameters.locationAndBandwidth, 275); + rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, 275); + rel15->SubcarrierSpacing = bwp_Common->genericParameters.subcarrierSpacing; + rel15->dci_length = nr_dci_size(rel15->dci_format, NR_RNTI_C, rel15->BWPSize); + // get UE-specific search space + for (ss_id = 0; ss_id < FAPI_NR_MAX_SS_PER_CORESET && mac->SSpace[0][0][ss_id] != NULL; ss_id++){ + uss = mac->SSpace[0][0][ss_id]; + if (uss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) break; + } + AssertFatal(ss_id < FAPI_NR_MAX_SS_PER_CORESET, "couldn't find a UE-specific SS\n"); + sps = bwp_Common->genericParameters.cyclicPrefix == NULL ? 14 : 12; + // for SPS=14 8 MSBs in positions 13 down to 6 + monitoringSymbolsWithinSlot = (uss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (uss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); + for (int i = 0; i < sps; i++) + if ((monitoringSymbolsWithinSlot >> (sps - 1 - i)) & 1) { + rel15->coreset.StartSymbolIndex = i; + break; + } + fill_dci_search_candidates(uss, rel15); + } + if (add_dci){ dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI; dl_config->number_pdus = dl_config->number_pdus + 1; } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c33a469a84..0ec27e401c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -668,7 +668,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in nr_dcireq_t dcireq; frame_t rx_frame = dl_info->frame; slot_t rx_slot = dl_info->slot; - + // check type0 from 38.213 13 if we have no CellGroupConfig // TODO: implementation to be completed if (mac->scd == NULL) { @@ -719,17 +719,12 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in dl_config->number_pdus = dl_config->number_pdus + 1; mac->scheduled_response.dl_config = dl_config; } - } else { // get PDCCH configuration(s) from SCGConfig - // get Coreset and SearchSpace Information from spCellConfigDedicated - // DCI configuration done for BWP 1, Coreset 0, SearchSpace 0 - - // TBR program DCI for slot 1 if PDSCH - // TBR program DCI for slot 7 if RAR DCI PDSCH + } else { // we have an scd dcireq.module_id = mod_id; dcireq.gNB_index = 0; dcireq.cc_id = 0; - dcireq.frame = rx_frame; // TBR not needed + dcireq.frame = rx_frame; dcireq.slot = rx_slot; nr_ue_dcireq(&dcireq); //to be replaced with function pointer later @@ -770,8 +765,11 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in return UE_CONNECTION_OK; } -// Note: msg2 is scheduled in the mixed slot or in the last dl slot -// if they are allowed by search space configuration +// Notes: +// - Type1-PDCCH CSS configuration from ra-SearchSpace. +// - Msg2 is scheduled in the mixed slot or in the last dl slot if they are allowed by the Type 1 Common Search Space configuration +// todo: +// - if Type1-PDCCH CSS is not configured in RRC message (Coreset and SearchSpace), UE searches in Type 0 PDCCH CSS. void nr_ue_msg2_scheduler(module_id_t mod_id, uint16_t rach_frame, uint16_t rach_slot, @@ -870,7 +868,6 @@ void nr_ue_msg2_scheduler(module_id_t mod_id, // PRACH formats 9, 10, 11 are corresponding to dual PRACH format configurations A1/B1, A2/B2, A3/B3. // - todo: // - Partial configuration is actually already stored in (fapi_nr_prach_config_t) &mac->phy_config.config_req->prach_config -//// however we need rach_ConfigGeneric to retrieve the config_index void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) { uint8_t config_index, mu, N_dur, N_t_slot, start_symbol; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 3fba88c984..27903d8a3b 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -317,7 +317,8 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq) { printf(" UE_mac->dl_config_request.slot %d VS dcireq->slot %d \n", UE_mac->dl_config_request.slot, dcireq->slot); LOG_D(PHY, "Entering UE DCI configuration frame %d slot %d \n", dcireq->frame, dcireq->slot); - ue_dci_configuration(UE_mac, dl_config, dcireq->slot); + + ue_dci_configuration(UE_mac, dl_config, dcireq->frame, dcireq->slot); return 0; } From 66395ff7b795dc3953d52ea05000e0f2b1e7e70a Mon Sep 17 00:00:00 2001 From: cig Date: Fri, 8 May 2020 11:56:52 +0200 Subject: [PATCH 29/42] Set RA offset at UE to compensate for 2 frames offset introduced by gNB --- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 2 ++ openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 ++ openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 368eae9682..a711561747 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -188,6 +188,8 @@ typedef struct { /* Random Access parameters */ /// state of RA procedure RA_state_t ra_state; + /// RA rx frame offset: compensate RA rx offset introduced by OAI gNB. + uint8_t RA_offset; /// RA-rnti uint16_t ra_rnti; /// Temporary CRNTI diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 0ec27e401c..57a69e836c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -887,6 +887,8 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; config_index = rach_ConfigGeneric->prach_ConfigurationIndex; + mac->RA_offset = 2; // to compensate the rx frame offset at the gNB + if (is_nr_UL_slot(scc, slotP)) { if (setup->msg1_SubcarrierSpacing) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 27903d8a3b..75ae4cd12e 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -120,7 +120,7 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ if (mac->generate_nr_prach){ uint16_t monitoring_slot_period, monitoring_offset; uint16_t rach_frame = mac->scheduled_response.ul_config->sfn; - uint16_t rx_rach_frame = (rach_frame + 2) % MAX_FRAME_NUMBER; // compensate 2 frames offset delay at gNB side + uint16_t rx_rach_frame = (rach_frame + mac->RA_offset) % MAX_FRAME_NUMBER; // compensate 2 frames offset delay at gNB side uint16_t rach_slot = mac->scheduled_response.ul_config->slot; nr_ue_msg2_scheduler(module_id, rx_rach_frame, rach_slot, &mac->msg2_rx_frame, &mac->msg2_rx_slot); } From 4522cd4eb9e5e828869836a0d0559ec664c92c98 Mon Sep 17 00:00:00 2001 From: cig Date: Fri, 8 May 2020 12:03:43 +0200 Subject: [PATCH 30/42] Changes to RA procedures: - monitoring RA window - taking RA_offset into account - workaround to generate PRACH only when the RAR has not been received yet (RA is idle) --- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 109 ++++++++++++------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 3 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 +- 3 files changed, 75 insertions(+), 39 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index b41b966a82..8f01191844 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -64,6 +64,7 @@ extern int64_t table_6_3_3_2_2_prachConfig_Index [256][9]; extern int64_t table_6_3_3_2_3_prachConfig_Index [256][9]; +extern const uint16_t nr_slots_per_frame[5]; //extern uint8_t nfapi_mode; @@ -363,14 +364,13 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, LOG_D(MAC, "nr_ue_get_rach, RA_active value: %d", mac->RA_active); - AssertFatal(setup != NULL, "[UE %d] FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id); + AssertFatal(setup != NULL, "[UE %d] FATAL nr_rach_ConfigCommon is NULL !!!\n", mod_id); if (mac->RA_active == 0) { /* RA not active - checking if RRC is ready to initiate the RA procedure */ LOG_I(MAC, "RA not active. Starting RA preamble initialization.\n"); - mac->ra_state = RA_UE_IDLE; mac->RA_RAPID_found = 0; /* Set RA_PREAMBLE_POWER_RAMPING_STEP */ @@ -442,33 +442,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, mac->RA_active = 1; prach_resources->Msg3 = payload; - ra_ResponseWindow = rach_ConfigGeneric->ra_ResponseWindow; - switch (ra_ResponseWindow) { - case 0: - mac->RA_window_cnt = 1; - break; - case 1: - mac->RA_window_cnt = 2; - break; - case 2: - mac->RA_window_cnt = 4; - break; - case 3: - mac->RA_window_cnt = 8; - break; - case 4: - mac->RA_window_cnt = 10; - break; - case 5: - mac->RA_window_cnt = 20; - break; - case 6: - mac->RA_window_cnt = 40; - break; - case 7: - mac->RA_window_cnt = 80; - break; - } + nr_get_RA_window(mac); // Fill in preamble and PRACH resources if (mac->generate_nr_prach) @@ -515,17 +489,16 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, prach_resources->RA_PREAMBLE_BACKOFF = 0; } - if (mac->RA_window_cnt > 0 && mac->RA_RAPID_found == 1) { + if (mac->RA_window_cnt >= 0 && mac->RA_RAPID_found == 1) { + // mac->ra_state = WAIT_CONTENTION_RESOLUTION; LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: subframe %d: RAR successfully received \n", mod_id, frame, nr_tti_tx); - } else { - mac->ra_state = RA_UE_IDLE; - LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: subframe %d: RAR reception not successful, (RA window count %d) \n", - mod_id, - frame, - nr_tti_tx, - mac->RA_window_cnt); + } else if (mac->RA_window_cnt == 0 && !mac->RA_RAPID_found) { + + LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: subframe %d: RAR reception failed \n", mod_id, frame, nr_tti_tx); + + mac->ra_state = RA_UE_IDLE; mac->RA_PREAMBLE_TRANSMISSION_COUNTER++; preambleTransMax = -1; @@ -565,6 +538,9 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, break; } + // Resetting RA window + nr_get_RA_window(mac); + if (mac->RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax + 1){ LOG_D(MAC, "[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n", mod_id, frame, preambleTransMax); mac->RA_backoff_cnt = rand() % (prach_resources->RA_PREAMBLE_BACKOFF + 1); @@ -595,6 +571,20 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, if (mac->generate_nr_prach) nr_get_prach_resources(mod_id, CC_id, gNB_id, nr_tti_tx, 0, prach_resources, rach_ConfigDedicated); + } else { + + mac->RA_window_cnt--; + + LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: subframe %d: RAR reception not successful, (RA window count %d) \n", + mod_id, + frame, + nr_tti_tx, + mac->RA_window_cnt); + + // Fill in preamble and PRACH resources + if (mac->generate_nr_prach) + nr_get_prach_resources(mod_id, CC_id, gNB_id, nr_tti_tx, 0, prach_resources, rach_ConfigDedicated); + } } } else if (UE_mode == PUSCH) { @@ -603,3 +593,48 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, } return mac->generate_nr_prach; } + +void nr_get_RA_window(NR_UE_MAC_INST_t *mac){ + + uint8_t mu, ra_ResponseWindow; + NR_ServingCellConfigCommon_t *scc = mac->scc; + NR_RACH_ConfigCommon_t *setup = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; + NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; + NR_FrequencyInfoDL_t *frequencyInfoDL = scc->downlinkConfigCommon->frequencyInfoDL; + + ra_ResponseWindow = rach_ConfigGeneric->ra_ResponseWindow; + + if (setup->msg1_SubcarrierSpacing) + mu = *setup->msg1_SubcarrierSpacing; + else + mu = frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + + mac->RA_window_cnt = mac->RA_offset*nr_slots_per_frame[mu]; // taking into account the 2 frames gap introduced by OAI gNB + + switch (ra_ResponseWindow) { + case 0: + mac->RA_window_cnt += 1; + break; + case 1: + mac->RA_window_cnt += 2; + break; + case 2: + mac->RA_window_cnt += 4; + break; + case 3: + mac->RA_window_cnt += 8; + break; + case 4: + mac->RA_window_cnt += 10; + break; + case 5: + mac->RA_window_cnt += 20; + break; + case 6: + mac->RA_window_cnt += 40; + break; + case 7: + mac->RA_window_cnt += 80; + break; + } +} \ No newline at end of file diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 57a69e836c..cfed0b2d72 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -906,7 +906,8 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s &start_symbol, &N_t_slot, &N_dur); - if (is_nr_prach_slot) { + + if (is_nr_prach_slot && mac->ra_state == RA_UE_IDLE) { mac->generate_nr_prach = 1; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 75ae4cd12e..d123c74e0b 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -115,7 +115,7 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ ret = nr_ue_scheduler(NULL, ul_info); - if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && mac->ra_state == RA_UE_IDLE && get_softmodem_params()->do_ra){ + if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && get_softmodem_params()->do_ra){ nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx); if (mac->generate_nr_prach){ uint16_t monitoring_slot_period, monitoring_offset; From 268a35419e4137c4050dfaa4543fa6fcaffb0ce6 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 11 May 2020 16:09:47 +0200 Subject: [PATCH 31/42] Hotfix scrambling rnti - this is needed because in the current implementation of the gNB the scrambling rnti is 0 for the RA and dci rnti otherwise --- .../NR_MAC_UE/nr_ue_dci_configuration.c | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index bbae5a5cf4..8c7be8f725 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -192,15 +192,6 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl rel15->coreset.CoreSetType = 1; rel15->coreset.precoder_granularity = coreset->precoderGranularity; - // Scrambling RNTI - if (coreset->pdcch_DMRS_ScramblingID) { - rel15->coreset.pdcch_dmrs_scrambling_id = *coreset->pdcch_DMRS_ScramblingID; - rel15->coreset.scrambling_rnti = mac->t_crnti; - } else { - rel15->coreset.pdcch_dmrs_scrambling_id = *scc->physCellId; - rel15->coreset.scrambling_rnti = 0; - } - if (mac->ra_state == WAIT_RAR){ NR_BWP_DownlinkCommon_t *initialDownlinkBWP = scc->downlinkConfigCommon->initialDownlinkBWP; @@ -266,6 +257,19 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl } fill_dci_search_candidates(uss, rel15); } + + // Scrambling RNTI + if (coreset->pdcch_DMRS_ScramblingID) { + rel15->coreset.pdcch_dmrs_scrambling_id = *coreset->pdcch_DMRS_ScramblingID; + rel15->coreset.scrambling_rnti = mac->t_crnti; + } else { + rel15->coreset.pdcch_dmrs_scrambling_id = *scc->physCellId; + if(mac->ra_state == WAIT_RAR) + rel15->coreset.scrambling_rnti = 0; + else + rel15->coreset.scrambling_rnti = rel15->rnti; + } + if (add_dci){ dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI; dl_config->number_pdus = dl_config->number_pdus + 1; From 6d710966371eb28d1088e1422d2e3554d7a4a0c6 Mon Sep 17 00:00:00 2001 From: matzakos Date: Sun, 17 May 2020 13:03:24 +0200 Subject: [PATCH 32/42] Change pseudo-subheader byte of random ULSCH PDU (phytest) to an appropriate value - Apply a value which cannot be interpreted as any valid LCID at the MAC layer of the receiver gNB (as per 38.321 Table 6.2.1-2), to avoid forwarding the random PDU to the upper layers in noS1 mode. --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 4 ++-- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index c74bc16754..b098d0c561 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -715,10 +715,10 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, #ifdef DEBUG_ULSCH_DECODING LOG_I(PHY, "Decoder output (payload): \n"); - for (i = 0; i < harq_process->TBS / 8; i++) { + for (i = 0; i < harq_process->TBS ; i++) { //harq_process_ul_ue->a[i] = (unsigned char) rand(); //printf("a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); - printf("0x%02x",harq_process->b[i]); + printf("%02x",harq_process->b[i]); } #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index b84726c82d..0b57067d25 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -193,15 +193,14 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, if (!IS_SOFTMODEM_NOS1 || !data_existing) { //Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid //and block this traffic from being forwarded to the upper layers at the gNB - uint16_t payload_offset = 5; LOG_D(PHY, "Random data to be tranmsitted: \n"); - //Give the header bytes a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2) - //in order to block the random packet at the MAC layer of the receiver - for (i = 0; ia[i] = 64; + //Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2) + //in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should + //have a valid LCID (nr_process_mac_pdu function) + harq_process_ul_ue->a[0] = 0x31; - for (i = payload_offset; i < harq_process_ul_ue->TBS / 8; i++) { + for (i = 1; i < harq_process_ul_ue->TBS / 8; i++) { harq_process_ul_ue->a[i] = (unsigned char) rand(); //printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); } From 783470905de8d2c6e4d83c968876a6c15aa65e47 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 18 May 2020 23:15:31 +0200 Subject: [PATCH 33/42] Bugfix: missing deactivation dlsch after processing is done: - the issue popped up with the new rx/tx implementation at the UE - this was causing false processing of DLSCH PDU and reception of false TA commands --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 2d09fc7135..0158487f3c 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -4278,6 +4278,9 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, #endif + // deactivate dlsch once dlsch proc is done + ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active = 0; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); } From 928dd902e3d5939cefdee72c9ad7221195801c98 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 18 May 2020 23:21:20 +0200 Subject: [PATCH 34/42] Code cleanup --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 10 ++++------ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 0158487f3c..ab9561080f 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -3885,7 +3885,6 @@ void *UE_thread_slot1_dl_processing(void *arg) { } //printf("[slot1 dl processing] AbsSubframe %d.%d LLR Computation Start wait DCI %d\n",frame_rx,nr_tti_rx,wait); - /**** Pdsch Procedure Slot1 ****/ // start slot1 thread for Pdsch Procedure (slot1) // do procedures for C-RNTI @@ -3973,7 +3972,6 @@ void *UE_thread_slot1_dl_processing(void *arg) { #endif #endif - if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); exit_fun("noting to add"); @@ -4120,7 +4118,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if (dci_cnt > 0) { - LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: found %d DCIs\n", ue->Mod_id, frame_rx, nr_tti_rx, dci_cnt); + LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: found %d DCIs\n", ue->Mod_id, frame_rx, nr_tti_rx, dci_cnt); NR_UE_DLSCH_t *dlsch; if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1){ @@ -4167,7 +4165,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, PDSCH, ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0], NULL); - + //printf("phy procedure pdsch start measurement\n"); nr_ue_measurement_procedures(2,ue,proc,eNB_id,nr_tti_rx,mode); @@ -4179,7 +4177,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, write_output("rxF_comp.m","rxFc",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp0[0][0],fp->N_RB_DL*12*14,1,1); write_output("rxF_llr.m","rxFllr",ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->llr[0],(nb_symb_sch-1)*50*12+50*6,1,0); */ - + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); } @@ -4248,7 +4246,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, // do procedures for C-RNTI if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1) { - + LOG_D(PHY, "DLSCH data reception at nr_tti_rx: %d \n \n", nr_tti_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 08d55779bd..964c88ff05 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -402,7 +402,7 @@ int configure_fapi_dl_pdu(int Mod_idP, pdcch_pdu_rel15->dci_pdu.PayloadSizeBits[0]=nr_dci_size(dci_formats[0],rnti_types[0],pdcch_pdu_rel15->BWPSize); fill_dci_pdu_rel15(pdcch_pdu_rel15,&dci_pdu_rel15[0],dci_formats,rnti_types,pdcch_pdu_rel15->BWPSize); - LOG_D(MAC, "DCI params: rnti %d, rnti_type %d, dci_format %d\n \ + LOG_D(MAC, "DCI params: rnti %x, rnti_type %d, dci_format %d\n \ coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n", pdcch_pdu_rel15->dci_pdu.RNTI[0], rnti_types[0], From 89acc094202781a8a51c68cf2556bcac1de8fe76 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Thu, 4 Jun 2020 14:32:41 +0200 Subject: [PATCH 35/42] CI: fix the RAW files usage by NR-UE Signed-off-by: Raphael Defosseux --- ci-scripts/main.py | 18 +++++++++------ ci-scripts/ran.py | 3 +++ ci-scripts/rrc-files/rbconfig.raw | Bin 8 -> 0 bytes ci-scripts/rrc-files/reconfig.raw | Bin 479 -> 0 bytes ci-scripts/runTestOnVM.sh | 23 ++++++++++++++++++-- ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml | 2 +- 6 files changed, 36 insertions(+), 10 deletions(-) delete mode 100644 ci-scripts/rrc-files/rbconfig.raw delete mode 100644 ci-scripts/rrc-files/reconfig.raw diff --git a/ci-scripts/main.py b/ci-scripts/main.py index e9313051fc..b7538097f8 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -332,12 +332,6 @@ class OaiCiTest(): logging.debug('Found a N3xx device --> resetting it') SSH.command('cd ' + self.UESourceCodePath, '\$', 5) # Initialize_OAI_UE_args usually start with -C and followed by the location in repository - # in case of NR-UE, we may have rrc_config_path (Temporary?) - modifiedUeOptions = str(self.Initialize_OAI_UE_args) - if RAN.Getair_interface() == 'nr': - result = re.search('--rrc_config_path ', modifiedUeOptions) - if result is not None: - modifiedUeOptions = modifiedUeOptions.replace('rrc_config_path ', 'rrc_config_path ' + self.UESourceCodePath + '/') SSH.command('source oaienv', '\$', 5) SSH.command('cd cmake_targets/ran_build/build', '\$', 5) if RAN.Getair_interface() == 'lte': @@ -352,7 +346,17 @@ class OaiCiTest(): SSH.command('sed -e "s#93#92#" -e "s#8baf473f2f8fd09487cccbd7097c6862#fec86ba6eb707ed08905757b1bb44b8f#" -e "s#e734f8734007d6c5ce7a0508809e7e9c#C42449363BBAD02B66D16BC975D77CC1#" ../../../openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf > ../../../openair3/NAS/TOOLS/ci-ue_eurecom_test_sfr.conf', '\$', 5) SSH.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf .u*', '\$', 5) SSH.command('echo ' + self.UEPassword + ' | sudo -S ../../../targets/bin/conf2uedata -c ../../../openair3/NAS/TOOLS/ci-ue_eurecom_test_sfr.conf -o .', '\$', 5) - SSH.command('echo "ulimit -c unlimited && ./'+ RAN.Getair_interface() +'-uesoftmodem ' + modifiedUeOptions + '" > ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh', '\$', 5) + else: + SSH.command('if [ -e rbconfig.raw ]; then echo ' + self.UEPassword + ' | sudo -S rm rbconfig.raw; fi', '\$', 5) + SSH.command('if [ -e rbconfig.raw ]; then echo ' + self.UEPassword + ' | sudo -S rm reconfig.raw; fi', '\$', 5) + # Copy the RAW files from gNB running directory (maybe on another machine) + copyin_res = SSH.copyin(RAN.GeteNBIPAddress(), RAN.GeteNBUserName(), RAN.GeteNBPassword(), RAN.GeteNBSourceCodePath() + '/cmake_targets/rbconfig.raw', '.') + if (copyin_res == 0): + SSH.copyout(self.UEIPAddress, self.UEUserName, self.UEPassword, './rbconfig.raw', self.UESourceCodePath + '/cmake_targets/ran_build/build') + copyin_res = SSH.copyin(RAN.GeteNBIPAddress(), RAN.GeteNBUserName(), RAN.GeteNBPassword(), RAN.GeteNBSourceCodePath() + '/cmake_targets/reconfig.raw', '.') + if (copyin_res == 0): + SSH.copyout(self.UEIPAddress, self.UEUserName, self.UEPassword, './reconfig.raw', self.UESourceCodePath + '/cmake_targets/ran_build/build') + SSH.command('echo "ulimit -c unlimited && ./'+ RAN.Getair_interface() +'-uesoftmodem ' + self.Initialize_OAI_UE_args + '" > ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh', '\$', 5) SSH.command('chmod 775 ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh', '\$', 5) SSH.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log', '\$', 5) self.UELogFile = 'ue_' + self.testCase_id + '.log' diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index 5b5add0adb..598f3acfb9 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -546,6 +546,9 @@ class RANManagement(): # Launch eNB with the modified config file mySSH.command('source oaienv', '\$', 5) mySSH.command('cd cmake_targets', '\$', 5) + if self.air_interface == 'nr': + mySSH.command('if [ -e rbconfig.raw ]; then echo ' + lPassWord + ' | sudo -S rm rbconfig.raw; fi', '\$', 5) + mySSH.command('if [ -e rbconfig.raw ]; then echo ' + lPassWord + ' | sudo -S rm reconfig.raw; fi', '\$', 5) mySSH.command('echo "ulimit -c unlimited && ./ran_build/build/' + self.air_interface + '-softmodem -O ' + lSourcePath + '/' + ci_full_config_file + extra_options + '" > ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) mySSH.command('chmod 775 ./my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) mySSH.command('echo ' + lPassWord + ' | sudo -S rm -Rf enb_' + self.testCase_id + '.log', '\$', 5) diff --git a/ci-scripts/rrc-files/rbconfig.raw b/ci-scripts/rrc-files/rbconfig.raw deleted file mode 100644 index b03f18d1219201d789d1c70e1dced3e84a932990..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8 PcmWgP)DUkvz{3Cl2C4z8 diff --git a/ci-scripts/rrc-files/reconfig.raw b/ci-scripts/rrc-files/reconfig.raw deleted file mode 100644 index 97b41d9b6b0f0662487ca39848f85e9c1f7f8594..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 479 zcmZvXK}Zx)0EYiJZ+7;%j_XKUh%ENXDK?21#KRUHp2H>+lyvMMF*~+WLFgem)aA{% zl66`(S%faD6@&yyL3n&?+qPmv2;D@MEa;eCx>&Z|yM5p7`&hU&j$JjxrW$?heDiE# zrp~RxosN$_z1U>h&8!6U&Bpv>RXxWN$Vq{N}IvEipfZ!CNn4gOq0Wp{R}^Kfa2pe-7*}_6@%Q6AZjd^V@W_3Ne!j2yN1Yorg8CJ&MSq*vtF|z9Rf}kw9 zOx9^wP&>JogICi$s@0-2 zPoAI>dgr#}5FkI0;q=V(#{Xt(%cWbI-oqTJ2GB)JI7a5$XTEsf?jL>hsog_Mw{JWI@5GhC+Q#8h* qJUD$YnWS13stM;DOiNO|EftB=CGW!CtAm++osPf`dKT!uA^!qOo0Vh$ diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index 64af11c8ba..aa3f171770 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -1158,6 +1158,10 @@ function start_rf_sim_gnb { local LOC_CONF_FILE=$5 # 1 is with S1 and 0 without S1 aka noS1 local LOC_S1_CONFIGURATION=$6 + + if [ -e rbconfig.raw ]; then rm -f rbconfig.raw; fi + if [ -e reconfig.raw ]; then rm -f reconfig.raw; fi + echo "cd /home/ubuntu/tmp" > $1 echo "echo \"sudo apt-get --yes --quiet install daemon \"" >> $1 echo "sudo apt-get --yes install daemon >> /home/ubuntu/tmp/cmake_targets/log/daemon-install.txt 2>&1" >> $1 @@ -1171,6 +1175,7 @@ function start_rf_sim_gnb { echo "echo \"cd /home/ubuntu/tmp/cmake_targets/ran_build/build/\"" >> $1 echo "sudo chmod 777 /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 + echo "sudo rm -f r*config.raw" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then echo "echo \"RFSIMULATOR=server ./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --phy-test\" > ./my-nr-softmodem-run.sh " >> $1 @@ -1231,6 +1236,9 @@ function start_rf_sim_gnb { fi fi sleep 10 + # Copy the RAW files from the gNB run for the NR-UE + scp -o StrictHostKeyChecking=no ubuntu@$LOC_GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/ran_build/build/rbconfig.raw . + scp -o StrictHostKeyChecking=no ubuntu@$LOC_GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/ran_build/build/reconfig.raw . } function start_rf_sim_nr_ue { @@ -1241,14 +1249,21 @@ function start_rf_sim_nr_ue { local LOC_FREQUENCY=$6 # 1 is with S1 and 0 without S1 aka noS1 local LOC_S1_CONFIGURATION=$7 + + # Copy the RAW files from the gNB run + scp -o StrictHostKeyChecking=no rbconfig.raw ubuntu@$LOC_NR_UE_VM_IP_ADDR:/home/ubuntu/tmp + scp -o StrictHostKeyChecking=no reconfig.raw ubuntu@$LOC_NR_UE_VM_IP_ADDR:/home/ubuntu/tmp + echo "echo \"sudo apt-get --yes --quiet install daemon \"" > $1 echo "sudo apt-get --yes install daemon >> /home/ubuntu/tmp/cmake_targets/log/daemon-install.txt 2>&1" >> $1 echo "echo \"cd /home/ubuntu/tmp/cmake_targets/ran_build/build/\"" >> $1 echo "sudo chmod 777 /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 + echo "sudo cp /home/ubuntu/tmp/r*config.raw /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 + echo "sudo chmod 666 /home/ubuntu/tmp/cmake_targets/ran_build/build/r*config.raw" >> $1 echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./nr-uesoftmodem --nokrnmod 1 --rfsim --phy-test --rrc_config_path /home/ubuntu/tmp/ci-scripts/rrc-files --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./nr-uesoftmodem --nokrnmod 1 --rfsim --phy-test --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/ --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 fi echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1 echo "cat ./my-nr-softmodem-run.sh" >> $1 @@ -2028,7 +2043,7 @@ function run_test_on_vm { NR_STATUS=0 ######### start of loop - while [ $try_cnt -lt 5 ] + while [ $try_cnt -lt 1 ] do SYNC_STATUS=0 PING_STATUS=0 @@ -2050,6 +2065,8 @@ function run_test_on_vm { echo "Problem w/ gNB and NR-UE not syncing" terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 terminate_enb_ue_basic_sim $GNB_VM_CMDS $GNB_VM_IP_ADDR 1 + scp -o StrictHostKeyChecking=no ubuntu@$GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC + scp -o StrictHostKeyChecking=no ubuntu@$NR_UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC SYNC_STATUS=-1 try_cnt=$[$try_cnt+1] continue @@ -2089,6 +2106,8 @@ function run_test_on_vm { echo "DL test not OK" terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 terminate_enb_ue_basic_sim $GNB_VM_CMDS $GNB_VM_IP_ADDR 1 + scp -o StrictHostKeyChecking=no ubuntu@$GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC + scp -o StrictHostKeyChecking=no ubuntu@$NR_UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC try_cnt=$[$try_cnt+1] continue fi diff --git a/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml b/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml index f3e80c576a..c51093c178 100644 --- a/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml +++ b/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml @@ -52,7 +52,7 @@ Initialize_OAI_UE Initialize NR UE USRP - --phy-test --usrp-args "addr=192.168.30.2,second_addr=192.168.50.2,clock_source=external,time_source=external" --threadoffset 16 --rrc_config_path ci-scripts/rrc-files + --phy-test --usrp-args "addr=192.168.30.2,second_addr=192.168.50.2,clock_source=external,time_source=external" --threadoffset 16 --rrc_config_path . NR From 84dfeff40aa561aab3b0de3816910cbcd533c437 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Fri, 5 Jun 2020 10:09:57 +0200 Subject: [PATCH 36/42] fix broken merge from develop in phy_procedures_gNB_common_RX() --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 83 +++++++---------------- 1 file changed, 25 insertions(+), 58 deletions(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 2685d0c37d..702571fef5 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -380,67 +380,34 @@ void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { - nfapi_nr_ul_tti_request_t *UL_tti_req = &gNB->UL_tti_req; - int num_pdus = UL_tti_req->n_pdus; + LOG_D(PHY,"phy_procedures_gNB_uespec_RX frame %d, slot %d\n",frame_rx,slot_rx); - nfapi_nr_uci_indication_t *uci_indication = &gNB->uci_indication; - uci_indication->sfn = frame_rx; - uci_indication->slot = slot_rx; - uci_indication->num_ucis = 0; + for (int ULSCH_id=0;ULSCH_idulsch[ULSCH_id][0]; + int harq_pid; + NR_UL_gNB_HARQ_t *ulsch_harq; + if ((ulsch) && + (ulsch->rnti > 0)) { + // for for an active HARQ process + for (harq_pid=0;harq_pidharq_processes[harq_pid]; + AssertFatal(ulsch_harq!=NULL,"harq_pid %d is not allocated\n",harq_pid); + if ((ulsch_harq->status == NR_ACTIVE) && + (ulsch_harq->frame == frame_rx) && + (ulsch_harq->slot == slot_rx) && + (ulsch_harq->handled == 0)){ - LOG_D(PHY,"phy_procedures_gNB_uespec_RX frame %d, slot %d, num_pdus %d\n",frame_rx,slot_rx,num_pdus); - - gNB->UL_INFO.rx_ind.number_of_pdus = 0; - gNB->UL_INFO.crc_ind.number_crcs = 0; - - for (int i = 0; i < num_pdus; i++) { - switch (UL_tti_req->pdus_list[i].pdu_type) { - case NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE: - { - LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE\n",frame_rx,slot_rx); - - nfapi_nr_pusch_pdu_t *pusch_pdu = &UL_tti_req->pdus_list[0].pusch_pdu; - nr_fill_ulsch(gNB,frame_rx,slot_rx,pusch_pdu); - - uint8_t ULSCH_id = find_nr_ulsch(pusch_pdu->rnti,gNB,SEARCH_EXIST); - uint8_t harq_pid = pusch_pdu->pusch_data.harq_process_id; - uint8_t symbol_start = pusch_pdu->start_symbol_index; - uint8_t symbol_end = symbol_start + pusch_pdu->nr_of_symbols; - - for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) { - nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, symbol, harq_pid); - } - //LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[0]->rxdataF_comp[0],6900,1,1); - //LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[0]->rxdataF_ext[0],6900,1,1); - nr_ulsch_procedures(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid); - } - break; - case NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE: - { - LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE\n",frame_rx,slot_rx); - - nfapi_nr_pucch_pdu_t *pucch_pdu = &UL_tti_req->pdus_list[i].pucch_pdu; - switch (pucch_pdu->format_type) { - case 0: - uci_indication->uci_list[uci_indication->num_ucis].pdu_type = NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE; - uci_indication->uci_list[uci_indication->num_ucis].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); - nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu_format0 = &uci_indication->uci_list[uci_indication->num_ucis].pucch_pdu_format_0_1; - - nr_decode_pucch0(gNB, - slot_rx, - uci_pdu_format0, - pucch_pdu); - - uci_indication->num_ucis += 1; - break; - case 1: - break; - case 2: - break; - default: - AssertFatal(1==0,"Only PUCCH format 0,1 and 2 are currently supported\n"); - } + uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index; + uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols; + for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) { + nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, symbol, harq_pid); + } + //LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[0]->rxdataF_comp[0],6900,1,1); + //LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[0]->rxdataF_ext[0],6900,1,1); + nr_ulsch_procedures(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid); + break; + } } } } From 96dc4a888db2cdebc3ef421aaf863e2516230476 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Tue, 9 Jun 2020 12:38:54 +0200 Subject: [PATCH 37/42] fix broken merge from develop in ulsim --- openair1/SIMULATION/NR_PHY/ulsim.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 959f73be38..9b9001d491 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -611,6 +611,9 @@ int main(int argc, char **argv) pusch_pdu->pusch_ptrs.ptrs_ports_list = (nfapi_nr_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ptrs_ports_t)); pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; + // prepare ULSCH/PUSCH reception + nr_schedule_response(Sched_INFO); + // --------- setting parameters for UE -------- scheduled_response.module_id = 0; From 36f5e80ea38e9669a6249d33921e2f1e6e9317af Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 13 May 2020 14:27:30 +0200 Subject: [PATCH 38/42] cleaning up the UE MAC/PHY interface --- executables/nr-ue.c | 122 ++++--------------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 98 +++++++++++++-- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 + 3 files changed, 113 insertions(+), 109 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index ced533b029..63c3172917 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -366,88 +366,31 @@ static void UE_synch(void *arg) { void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { - uint32_t rb_size, rb_start; - uint16_t rnti, l_prime_mask, n_rb0, n_rb1, pdu_bit_map; - uint8_t nr_of_symbols, start_symbol_index, mcs_index, mcs_table, nrOfLayers, harq_process_id, rv_index, dmrs_config_type; - uint8_t ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, ptrs_time_density, ptrs_freq_density; - module_id_t mod_id; - nr_dcireq_t dcireq; - nr_scheduled_response_t scheduled_response; - fapi_nr_config_request_t *cfg = &UE->nrUE_config; int tx_slot_type = nr_ue_slot_select(cfg, proc->frame_tx, proc->nr_tti_tx); + uint8_t gNB_id = 0; - // program PUSCH. this should actually be done by the MAC upon reception of an UL DCI if (tx_slot_type == NR_UPLINK_SLOT || tx_slot_type == NR_MIXED_SLOT){ - mod_id = UE->Mod_id; + // trigger L2 to run ue_scheduler thru IF module + // [TODO] mapping right after NR initial sync + if(UE->if_inst != NULL && UE->if_inst->ul_indication != NULL) { + nr_uplink_indication_t ul_indication; + memset((void*)&ul_indication, 0, sizeof(ul_indication)); - dcireq.module_id = mod_id; - dcireq.gNB_index = 0; - dcireq.cc_id = 0; - dcireq.frame = proc->frame_rx; - dcireq.slot = proc->nr_tti_rx; + ul_indication.module_id = UE->Mod_id; + ul_indication.gNB_index = gNB_id; + ul_indication.cc_id = UE->CC_id; + ul_indication.frame_rx = proc->frame_rx; + ul_indication.slot_rx = proc->nr_tti_rx; + ul_indication.frame_tx = proc->frame_tx; + ul_indication.slot_tx = proc->nr_tti_tx; - scheduled_response.dl_config = NULL; - scheduled_response.ul_config = &dcireq.ul_config_req; - scheduled_response.tx_request = NULL; - scheduled_response.module_id = mod_id; - scheduled_response.CC_id = 0; - scheduled_response.frame = proc->frame_rx; - scheduled_response.slot = proc->nr_tti_rx; - //--------------------------Temporary configuration-----------------------------// - rnti = 0x1234; - rb_size = 50; - rb_start = 0; - nr_of_symbols = 12; - start_symbol_index = 2; - nrOfLayers = 1; - mcs_index = 9; - mcs_table = 0; - harq_process_id = 0; - rv_index = 0; - l_prime_mask = get_l_prime(nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1); - dmrs_config_type = 0; - ptrs_mcs1 = 2; - ptrs_mcs2 = 4; - ptrs_mcs3 = 10; - n_rb0 = 25; - n_rb1 = 75; - pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; - ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, mcs_index, mcs_table); - ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, rb_size); - //------------------------------------------------------------------------------// - - scheduled_response.ul_config->slot = proc->nr_tti_tx; - scheduled_response.ul_config->number_pdus = 1; - scheduled_response.ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = l_prime_mask << start_symbol_index; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = (nfapi_nr_ue_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ue_ptrs_ports_t)); - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; - - if (1 << ptrs_time_density >= nr_of_symbols) { - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS + UE->if_inst->ul_indication(&ul_indication); } - nr_ue_scheduled_response(&scheduled_response); - if (UE->mode != loop_through_memory) { - uint8_t thread_id = PHY_vars_UE_g[mod_id][0]->current_thread_id[proc->nr_tti_rx]; + uint8_t thread_id = PHY_vars_UE_g[UE->Mod_id][0]->current_thread_id[proc->nr_tti_rx]; phy_procedures_nrUE_TX(UE,proc,0,thread_id); } } @@ -459,20 +402,20 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { int rx_slot_type = nr_ue_slot_select(cfg, proc->frame_rx, proc->nr_tti_rx); uint8_t gNB_id = 0; - nr_downlink_indication_t dl_indication; - memset((void*)&dl_indication, 0, sizeof(dl_indication)); - if (rx_slot_type == NR_DOWNLINK_SLOT || rx_slot_type == NR_MIXED_SLOT){ if(UE->if_inst != NULL && UE->if_inst->dl_indication != NULL) { + nr_downlink_indication_t dl_indication; + memset((void*)&dl_indication, 0, sizeof(dl_indication)); + dl_indication.module_id = UE->Mod_id; dl_indication.gNB_index = gNB_id; dl_indication.cc_id = UE->CC_id; dl_indication.frame = proc->frame_rx; dl_indication.slot = proc->nr_tti_rx; - } - nr_ue_scheduler(&dl_indication, NULL); + UE->if_inst->dl_indication(&dl_indication, NULL); + } // Process Rx data for one sub-frame #ifdef UE_SLOT_PARALLELISATION @@ -513,11 +456,7 @@ void UE_processing(void *arg) { UE_nr_rxtx_proc_t *proc = &rxtxD->proc; PHY_VARS_NR_UE *UE = rxtxD->UE; - uint8_t gNB_id = 0, CC_id = 0; - module_id_t mod_id = 0; - - nr_uplink_indication_t ul_indication; - memset((void*)&ul_indication, 0, sizeof(ul_indication)); + uint8_t gNB_id = 0; // params for UL time alignment procedure NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &UE->ul_time_alignment[gNB_id]; @@ -543,24 +482,7 @@ void UE_processing(void *arg) { } processSlotRX(UE, proc); - - if (UE->mac_enabled == 1) { - // trigger L2 to run ue_scheduler thru IF module - // [TODO] mapping right after NR initial sync - if(UE->if_inst != NULL && UE->if_inst->ul_indication != NULL) { - ul_indication.module_id = mod_id; - ul_indication.gNB_index = gNB_id; - ul_indication.cc_id = CC_id; - ul_indication.frame_rx = proc->frame_rx; - ul_indication.slot_rx = proc->nr_tti_rx; - ul_indication.frame_tx = proc->frame_tx; - ul_indication.slot_tx = proc->nr_tti_tx; - UE->if_inst->ul_indication(&ul_indication); - } - } - processSlotTX(UE, proc); - } void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockSize) { @@ -763,7 +685,7 @@ void *UE_thread(void *arg) { curMsg->UE=UE; // update thread index for received subframe curMsg->UE->current_thread_id[slot_nr] = thread_idx; - curMsg->proc.CC_id = 0; + curMsg->proc.CC_id = UE->CC_id; curMsg->proc.nr_tti_rx= slot_nr; curMsg->proc.subframe_rx=slot_nr/(nb_slot_frame/10); curMsg->proc.nr_tti_tx = (absolute_slot + DURATION_RX_TO_TX) % nb_slot_frame; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index ac10a62396..2ccd1f369b 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -658,14 +658,16 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in if (dl_info){ - module_id_t mod_id = dl_info->module_id; + module_id_t mod_id = dl_info->module_id; + uint32_t gNB_index = dl_info->gNB_index; + int cc_id = dl_info->cc_id; + frame_t rx_frame = dl_info->frame; + slot_t rx_slot = dl_info->slot; NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); - int cc_id = dl_info->cc_id; + fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; nr_scheduled_response_t scheduled_response; nr_dcireq_t dcireq; - frame_t rx_frame = dl_info->frame; - slot_t rx_slot = dl_info->slot; // check type0 from 38.213 13 if we have no CellGroupConfig // TODO: implementation to be completed @@ -720,8 +722,8 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in } else { // we have an scd dcireq.module_id = mod_id; - dcireq.gNB_index = 0; - dcireq.cc_id = 0; + dcireq.gNB_index = gNB_index; + dcireq.cc_id = cc_id; dcireq.frame = rx_frame; dcireq.slot = rx_slot; nr_ue_dcireq(&dcireq); //to be replaced with function pointer later @@ -735,7 +737,9 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in scheduled_response.frame = rx_frame; scheduled_response.slot = rx_slot; - nr_ue_scheduled_response(&scheduled_response); + if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ + mac->if_module->scheduled_response(&scheduled_response); + } /* if(search_space_mask & type0a_pdcch){ @@ -752,12 +756,88 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in */ } } else if (ul_info) { - module_id_t mod_id = ul_info->module_id; + module_id_t mod_id = ul_info->module_id; + uint32_t gNB_index = ul_info->gNB_index; + int cc_id = ul_info->cc_id; + frame_t rx_frame = ul_info->frame_rx; + slot_t rx_slot = ul_info->slot_rx; NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + + // program PUSCH. this should actually be done upon reception of an UL DCI + nr_dcireq_t dcireq; + nr_scheduled_response_t scheduled_response; + + //--------------------------Temporary configuration-----------------------------// + uint16_t rnti = 0x1234; + uint32_t rb_size = 50; + uint32_t rb_start = 0; + uint8_t nr_of_symbols = 12; + uint8_t start_symbol_index = 2; + uint8_t nrOfLayers = 1; + uint8_t mcs_index = 9; + uint8_t mcs_table = 0; + uint8_t harq_process_id = 0; + uint8_t rv_index = 0; + uint16_t l_prime_mask = get_l_prime(nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1); + uint8_t dmrs_config_type = 0; + uint8_t ptrs_mcs1 = 2; + uint8_t ptrs_mcs2 = 4; + uint8_t ptrs_mcs3 = 10; + uint16_t n_rb0 = 25; + uint16_t n_rb1 = 75; + uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; + uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, mcs_index, mcs_table); + uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, rb_size); + //------------------------------------------------------------------------------// + + dcireq.module_id = mod_id; + dcireq.gNB_index = gNB_index; + dcireq.cc_id = cc_id; + dcireq.frame = rx_frame; + dcireq.slot = rx_slot; + + scheduled_response.dl_config = NULL; + scheduled_response.ul_config = &dcireq.ul_config_req; + scheduled_response.tx_request = NULL; + scheduled_response.module_id = mod_id; + scheduled_response.CC_id = cc_id; + scheduled_response.frame = rx_frame; + scheduled_response.slot = rx_slot; + + scheduled_response.ul_config->slot = ul_info->slot_tx; + scheduled_response.ul_config->number_pdus = 1; + scheduled_response.ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = l_prime_mask << start_symbol_index; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = (nfapi_nr_ue_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ue_ptrs_ports_t)); + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; + + if (1 << ptrs_time_density >= nr_of_symbols) { + scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS + } + + if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ + mac->if_module->scheduled_response(&scheduled_response); + } + // TODO: expand // Note: Contention resolution is currently not active if (mac->RA_contention_resolution_timer_active == 1) - ue_contention_resolution(mod_id, ul_info->gNB_index, ul_info->cc_id, ul_info->frame_tx); + ue_contention_resolution(mod_id, gNB_index, cc_id, ul_info->frame_tx); } return UE_CONNECTION_OK; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index d123c74e0b..ad4f0d8d30 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -153,6 +153,8 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; + nr_ue_scheduler(dl_info, NULL); + dl_config->number_pdus = 0; ul_config->number_pdus = 0; //hook up pointers From f4d47b1ea7356f82c1a5bfae2a8e82db7f09432c Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 20 May 2020 14:50:53 +0200 Subject: [PATCH 39/42] Checking in dl_indication if scheduling is needed or any DL PDU was received: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scheduling is needed only when whe it doesn´t fall in dci_ind or rx_ind cases - cleaned up some old commented out code --- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 209 +++++++++----------- 1 file changed, 88 insertions(+), 121 deletions(-) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index ad4f0d8d30..6773c3ee1c 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -145,7 +145,7 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ } int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment){ - + int32_t i; uint32_t ret_mask = 0x0; module_id_t module_id = dl_info->module_id; @@ -153,132 +153,99 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; - nr_ue_scheduler(dl_info, NULL); + if (!dl_info->dci_ind && !dl_info->rx_ind) { + // UL indication to schedule reception DCI reception + nr_ue_scheduler(dl_info, NULL); + } else { + // UL indication after reception of DCI or DL PDU + dl_config->number_pdus = 0; + ul_config->number_pdus = 0; + //hook up pointers + mac->scheduled_response.dl_config = dl_config; + mac->scheduled_response.ul_config = ul_config; + mac->scheduled_response.tx_request = &mac->tx_request; + mac->scheduled_response.module_id = dl_info->module_id; + mac->scheduled_response.CC_id = dl_info->cc_id; + mac->scheduled_response.frame = dl_info->frame; + mac->scheduled_response.slot = dl_info->slot; - dl_config->number_pdus = 0; - ul_config->number_pdus = 0; - //hook up pointers - mac->scheduled_response.dl_config = dl_config; - mac->scheduled_response.ul_config = ul_config; - mac->scheduled_response.tx_request = &mac->tx_request; - mac->scheduled_response.module_id = dl_info->module_id; - mac->scheduled_response.CC_id = dl_info->cc_id; - mac->scheduled_response.frame = dl_info->frame; - mac->scheduled_response.slot = dl_info->slot; + if(dl_info->dci_ind != NULL){ + LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n"); + for(i=0; idci_ind->number_of_dcis; ++i){ + LOG_D(MAC,">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis); - if(dl_info->dci_ind != NULL){ - LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n"); - for(i=0; idci_ind->number_of_dcis; ++i){ - LOG_D(MAC,">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis); - // fapi_nr_dci_pdu_rel15_t *dci = &dl_info->dci_ind->dci_list[i].dci; + ret_mask |= (handle_dci(dl_info->module_id, + dl_info->cc_id, + dl_info->gNB_index, + dl_info->dci_ind->dci_list+i)<< FAPI_NR_DCI_IND); - ret_mask |= (handle_dci(dl_info->module_id, - dl_info->cc_id, - dl_info->gNB_index, - dl_info->dci_ind->dci_list+i)<< FAPI_NR_DCI_IND); - - AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is void!\n" ); - nr_ue_if_module_inst[module_id]->scheduled_response(&mac->scheduled_response); - - - /*switch((dl_info->dci_ind->dci_list+i)->dci_type){ - case FAPI_NR_DCI_TYPE_0_0: - case FAPI_NR_DCI_TYPE_0_1: - case FAPI_NR_DCI_TYPE_1_1: - case FAPI_NR_DCI_TYPE_2_0: - case FAPI_NR_DCI_TYPE_2_1: - case FAPI_NR_DCI_TYPE_2_2: - case FAPI_NR_DCI_TYPE_2_3: - AssertFatal(1==0, "Not yet support at this moment!\n"); - break; - - case FAPI_NR_DCI_TYPE_1_0: - - dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; - - // mapping into DL_CONFIG_REQ for DL-SCH - fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; - - dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = 0x0000; // TX RNTI: UE-spec - memcpy(dlsch_config_pdu, dci, sizeof(fapi_nr_dci_pdu_rel15_t)); - - dl_config->number_pdus = dl_config->number_pdus + 1; - - ret_mask |= (handle_dci( - dl_info->module_id, - dl_info->cc_id, - dl_info->gNB_index, - dci, - (dl_info->dci_ind->dci_list+i)->rnti, - (dl_info->dci_ind->dci_list+i)->dci_type)) << FAPI_NR_DCI_IND; - - - - break; - - default: - break; - }*/ - - //(dl_info->dci_list+i)->rnti - } - } - - if(dl_info->rx_ind != NULL){ - LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], Number of PDUs: %d \n", dl_info->rx_ind->number_pdus); - for(i=0; irx_ind->number_pdus; ++i){ - switch(dl_info->rx_ind->rx_indication_body[i].pdu_type){ - case FAPI_NR_RX_PDU_TYPE_MIB: - ret_mask |= (handle_bcch_bch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, - (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.pdu, - (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.additional_bits, - (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.ssb_index, - (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.ssb_length, - (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.cell_id )) << FAPI_NR_RX_PDU_TYPE_MIB; - LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], MIB case Number of PDUs: %d \n", dl_info->rx_ind->number_pdus); - /*ret_mask |= (handle_bcch_bch( dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, - dl_info->rx_ind->rx_indication_body[i].mib_pdu.pdu, - dl_info->rx_ind->rx_indication_body[i].mib_pdu.additional_bits, - dl_info->rx_ind->rx_indication_body[i].mib_pdu.ssb_index, - dl_info->rx_ind->rx_indication_body[i].mib_pdu.ssb_length, - dl_info->rx_ind->rx_indication_body[i].mib_pdu.cell_id )) << FAPI_NR_RX_PDU_TYPE_MIB;*/ - break; - case FAPI_NR_RX_PDU_TYPE_SIB: - ret_mask |= (handle_bcch_dlsch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, - (dl_info->rx_ind->rx_indication_body+i)->sib_pdu.sibs_mask, - (dl_info->rx_ind->rx_indication_body+i)->sib_pdu.pdu, - (dl_info->rx_ind->rx_indication_body+i)->sib_pdu.pdu_length )) << FAPI_NR_RX_PDU_TYPE_SIB; - break; - case FAPI_NR_RX_PDU_TYPE_DLSCH: - // ret_mask |= (0) << FAPI_NR_RX_PDU_TYPE_DLSCH; - ret_mask |= (handle_dlsch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, dl_info->dci_ind, - (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu, - (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu_length, dl_info->frame, dl_info->slot, ul_time_alignment)) << FAPI_NR_RX_PDU_TYPE_DLSCH; - - LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], DLSCH case Number of PDUs: %d \n", dl_info->rx_ind->number_pdus); - - /* - // dl_config structure just stores what was received - not really needed - dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; - dl_config->number_pdus = dl_config->number_pdus + 1; - */ - break; - - case FAPI_NR_RX_PDU_TYPE_RAR: - ret_mask |= (handle_rar(dl_info)) << FAPI_NR_RX_PDU_TYPE_RAR; - break; - - default: - break; + AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is void!\n" ); + nr_ue_if_module_inst[module_id]->scheduled_response(&mac->scheduled_response); } } + + if(dl_info->rx_ind != NULL){ + + LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], Number of PDUs: %d \n", dl_info->rx_ind->number_pdus); + + for(i=0; irx_ind->number_pdus; ++i){ + + switch(dl_info->rx_ind->rx_indication_body[i].pdu_type){ + + case FAPI_NR_RX_PDU_TYPE_MIB: + ret_mask |= (handle_bcch_bch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, + (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.pdu, + (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.additional_bits, + (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.ssb_index, + (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.ssb_length, + (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.cell_id)) << FAPI_NR_RX_PDU_TYPE_MIB; + + LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], MIB case Number of PDUs: %d \n", dl_info->rx_ind->number_pdus); + + break; + + case FAPI_NR_RX_PDU_TYPE_SIB: + + ret_mask |= (handle_bcch_dlsch(dl_info->module_id, + dl_info->cc_id, dl_info->gNB_index, + (dl_info->rx_ind->rx_indication_body+i)->sib_pdu.sibs_mask, + (dl_info->rx_ind->rx_indication_body+i)->sib_pdu.pdu, + (dl_info->rx_ind->rx_indication_body+i)->sib_pdu.pdu_length)) << FAPI_NR_RX_PDU_TYPE_SIB; + + break; + + case FAPI_NR_RX_PDU_TYPE_DLSCH: + + ret_mask |= (handle_dlsch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, + dl_info->dci_ind, + (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu, + (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu_length, + dl_info->frame, + dl_info->slot, + ul_time_alignment)) << FAPI_NR_RX_PDU_TYPE_DLSCH; + + LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], DLSCH case Number of PDUs: %d \n", dl_info->rx_ind->number_pdus); + + break; + + case FAPI_NR_RX_PDU_TYPE_RAR: + + ret_mask |= (handle_rar(dl_info)) << FAPI_NR_RX_PDU_TYPE_RAR; + + break; + + default: + break; + } + } + } + + //clean up nr_downlink_indication_t *dl_info + dl_info->rx_ind = NULL; + dl_info->dci_ind = NULL; + + return 0; } - - //clean up nr_downlink_indication_t *dl_info - dl_info->rx_ind = NULL; - dl_info->dci_ind = NULL; - - return 0; } nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id){ From dae91c60b88c8260f92f0765ba66594a3a70acb0 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Tue, 9 Jun 2020 14:50:40 +0200 Subject: [PATCH 40/42] Fixing ulsim and rf simulator - no_data_in_dmrs was being used at gNB side, and not handled at UE side - nr_schedule_response wasn't being called in ulsim --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 10 +++++++--- openair1/SIMULATION/NR_PHY/ulsim.c | 16 +++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 04a08d91aa..49ba3a83b2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -114,6 +114,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint8_t data_existing =0; uint8_t L_ptrs, K_ptrs; // PTRS parameters uint16_t beta_ptrs; // PTRS parameter related to power control + uint8_t no_data_in_dmrs = 1; NR_UE_ULSCH_t *ulsch_ue; NR_UL_UE_HARQ_t *harq_process_ul_ue=NULL; @@ -147,7 +148,11 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, rnti = harq_process_ul_ue->pusch_pdu.rnti; ulsch_ue->Nid_cell = Nid_cell; - nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4); + + if(no_data_in_dmrs) + nb_dmrs_re_per_rb = 12; + else + nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4); N_RE_prime = NR_NB_SC_PER_RB*number_of_symbols - nb_dmrs_re_per_rb*number_dmrs_symbols - N_PRB_oh; @@ -223,7 +228,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, unsigned int G = nr_get_G(nb_rb, number_of_symbols, nb_dmrs_re_per_rb, number_dmrs_symbols, mod_order, Nl); - nr_ulsch_encoding(ulsch_ue, frame_parms, harq_pid, G); /////////// @@ -267,7 +271,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////////////////////DMRS Modulation///////////////////////// /////////// pusch_dmrs = UE->nr_gold_pusch_dmrs[slot]; - n_dmrs = (nb_rb*nb_dmrs_re_per_rb*number_dmrs_symbols); + n_dmrs = (nb_rb*((dmrs_type == pusch_dmrs_type1) ? 6:4)*number_dmrs_symbols); int16_t mod_dmrs[n_dmrs<<1]; /////////// //////////////////////////////////////////////////////////////////////// diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 9b9001d491..97cc22264a 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -510,9 +510,9 @@ int main(int argc, char **argv) fapi_nr_ul_config_request_t ul_config; unsigned int TBS; - uint16_t number_dmrs_symbols = 1; + uint16_t number_dmrs_symbols = 0; unsigned int available_bits; - uint8_t nb_re_dmrs; + uint8_t nb_re_dmrs, no_data_in_dmrs = 1; unsigned char mod_order; uint16_t code_rate; uint8_t ptrs_mcs1 = 2; @@ -611,8 +611,6 @@ int main(int argc, char **argv) pusch_pdu->pusch_ptrs.ptrs_ports_list = (nfapi_nr_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ptrs_ports_t)); pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; - // prepare ULSCH/PUSCH reception - nr_schedule_response(Sched_INFO); // --------- setting parameters for UE -------- @@ -648,12 +646,20 @@ int main(int argc, char **argv) //there are plenty of other parameters that we don't seem to be using for now. e.g. ul_config.ul_config_list[0].pusch_config_pdu.absolute_delta_PUSCH = 0; - nb_re_dmrs = ((ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type == pusch_dmrs_type1) ? 6 : 4); + if(no_data_in_dmrs) + nb_re_dmrs = 12; + else + nb_re_dmrs = ((ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type == pusch_dmrs_type1) ? 6 : 4); + available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, mod_order, 1); TBS = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs * number_dmrs_symbols, 0, 0, precod_nbr_layers); pusch_pdu->pusch_data.tb_size = TBS>>3; ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS; + + // prepare ULSCH/PUSCH reception + nr_schedule_response(Sched_INFO); + // set FAPI parameters for UE, put them in the scheduled response and call nr_ue_scheduled_response(&scheduled_response); From 5f87b73451c63e98a9ea218f860a72bb9d8f6bc8 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 12 Jun 2020 08:43:17 +0200 Subject: [PATCH 41/42] small fixes --- cmake_targets/autotests/test_case_list.xml | 5 ++--- openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index 88c7a40351..296e8d8854 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1205,9 +1205,8 @@ -R 106 -i 1 -P 2 -b 8 -s4 -n1000 -R 106 -i 1 -P 2 -b 9 -s5 -n1000 -R 106 -i 1 -P 2 -b 10 -s6 -n1000 - -R 106 -i 1 -P 2 -b 11 -s6 -n1000 - - nr_pucchsim.test1 nr_pucchsim.test2 nr_pucchsim.test3 nr_pucchsim.test4 nr_pucchsim.test5 nr_pucchsim.test6 nr_pucchsim.test7 nr_pucchsim.test8 nr_pucchsim.test9 nr_pucchsim.test10 nr_pucchsim.test11 nr_pucchsim.test12 + -R 106 -i 1 -P 2 -b 11 -s6 -n1000 + nr_pucchsim.test1 nr_pucchsim.test2 nr_pucchsim.test3 nr_pucchsim.test4 nr_pucchsim.test5 nr_pucchsim.test6 nr_pucchsim.test7 nr_pucchsim.test8 nr_pucchsim.test9 nr_pucchsim.test10 nr_pucchsim.test11 nr_pucchsim.test12 PUCCH test OK segmentation fault|assertion|exiting|fatal 3 diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 61748a8e56..b2d0467d14 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -135,7 +135,7 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini stop_meas(&ue->dlsch_channel_estimation_stats); #endif - current_ssb->metric = current_ssb->c_re*current_ssb->c_re + current_ssb->c_im+current_ssb->c_re; + current_ssb->metric = current_ssb->c_re*current_ssb->c_re + current_ssb->c_im+current_ssb->c_im; // generate a list of SSB structures if (best_ssb == NULL) From 14a0b772f3b0768befac4ca0156f174e120c2a0f Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sat, 13 Jun 2020 11:48:50 +0200 Subject: [PATCH 42/42] fix for 36864 size dfts (missing initialization) --- openair1/PHY/NR_TRANSPORT/nr_prach.c | 4 ++-- openair1/PHY/NR_UE_TRANSPORT/nr_prach.c | 2 +- openair1/PHY/TOOLS/oai_dfts.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c index 2f874c7602..0ade2993a9 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c @@ -800,7 +800,7 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, if (LOG_DUMPFLAG(PRACH)) { int en = dB_fixed(signal_energy((int32_t*)&rxsigF[0][0],840)); - if (en>60) { + // if (en>60) { int k = (12*n_ra_prb) - 6*fp->N_RB_UL; if (k<0) k+=fp->ofdm_symbol_size; @@ -814,7 +814,7 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, LOG_M("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1); LOG_M("Xu.m","xu",Xu,N_ZC,1,1); LOG_M("prach_ifft0.m","prach_t0",prach_ifft,1024,1,1); - } + // } } /* LOG_DUMPFLAG(PRACH) */ stop_meas(&gNB->rx_prach); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c index 214ebd9716..b98aa9050d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c @@ -44,7 +44,7 @@ #include "T.h" #include -#define NR_PRACH_DEBUG 1 +//#define NR_PRACH_DEBUG 1 extern uint16_t NCS_unrestricted_delta_f_RA_125[16]; extern uint16_t NCS_restricted_TypeA_delta_f_RA_125[15]; diff --git a/openair1/PHY/TOOLS/oai_dfts.c b/openair1/PHY/TOOLS/oai_dfts.c index 7d3cf0d2c0..25244eeff5 100644 --- a/openair1/PHY/TOOLS/oai_dfts.c +++ b/openair1/PHY/TOOLS/oai_dfts.c @@ -9607,6 +9607,7 @@ int dfts_autoinit(void) init_rad3(12288,twa12288,twb12288); init_rad3(18432,twa18432,twb18432); init_rad3(24576,twa24576,twb24576); + init_rad3(36864,twa36864,twb36864); init_rad3(49152,twa49152,twb49152); init_rad3(98304,twa98304,twb98304); @@ -10588,7 +10589,7 @@ int main(int argc, char**argv) reset_meas(&ts); for (i=0; i<10000; i++) { start_meas(&ts); - idft36864((int16_t *)x,(int16_t *)y,1); + dft36864((int16_t *)x,(int16_t *)y,1); stop_meas(&ts); }