diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index 1088563091529b89c9cb452468acf5408cda1636..24b18e41dc59f2c89f1124d26acbdd2992af668d 100755 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -442,7 +442,8 @@ (Test21: 3GPP G-FR1-A5-13, PUSCH Type B, 40 MHz BW, 30 kHz SCS, 8 RX Antennas Requirements Test), (Test22: 3GPP G-FR1-A5-14, PUSCH Type B, 100 MHz BW, 30 kHz SCS, 2 RX Antennas Requirements Test), (Test23: 3GPP G-FR1-A5-14, PUSCH Type B, 100 MHz BW, 30 kHz SCS, 4 RX Antennas Requirements Test), - (Test24: 3GPP G-FR1-A5-14, PUSCH Type B, 100 MHz BW, 30 kHz SCS, 8 RX Antennas Requirements Test)</desc> + (Test24: 3GPP G-FR1-A5-14, PUSCH Type B, 100 MHz BW, 30 kHz SCS, 8 RX Antennas Requirements Test), + (Test25: 3GPP G-FR1-A4-27, PUSCH Type B, 40 MHz BW, 30 kHz SCS, 2 RX Antennas Requirements Test, 2 layers)</desc> <main_exec>nr_ulsim</main_exec> <main_exec_args>-n100 -b14 -I7 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R106 -r106 -U 0,1,1,2 -z2 -s12.4 -S12.4 -n100 -b14 -I7 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R106 -r106 -U 0,1,1,2 -z4 -s8.5 -S8.5 @@ -467,8 +468,9 @@ -n100 -b14 -I7 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R106 -r106 -U 1,1,1,2 -z8 -s5.5 -S5.5 -n100 -b14 -I7 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R273 -r273 -U 1,1,1,2 -z2 -s13.1 -S13.1 -n100 -b14 -I7 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R273 -r273 -U 1,1,1,2 -z4 -s9.2 -S9.2 - -n100 -b14 -I8 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R273 -r273 -U 1,1,1,2 -z8 -s5.9 -S5.9</main_exec_args> - <tags>test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 test20 test21 test22 test23 test24</tags> + -n100 -b14 -I8 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R273 -r273 -U 1,1,1,2 -z8 -s5.9 -S5.9 + -n100 -b14 -I15 -i 0,1 -g C,l -t70 -u 1 -m16 -R106 -r106 -U 1,1,1,2 -W2 -y2 -z2 -s18.7 -S18.7</main_exec_args> + <tags>test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 test20 test21 test22 test23 test24 test25</tags> <search_expr_true>PUSCH test OK</search_expr_true> <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false> <nruns>3</nruns> diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index 750bdd82876f4c5f352f30d59a73cbddfaa33140..ca9d735fcaada1e92e5c778341832dc5f73e4e14 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -723,6 +723,18 @@ void get_samplerate_and_bw(int mu, } } +void get_K1_K2(int N1, int N2, int *K1, int *K2) +{ + // num of allowed k1 and k2 according to 5.2.2.2.1-3 and -4 in 38.214 + if(N2 == N1 || N1 == 2) + *K1 = 2; + else if (N2 == 1) + *K1 = 5; + else + *K1 = 3; + *K2 = N2 > 1 ? 2 : 1; +} + // from start symbol index and nb or symbols to symbol occupation bitmap in a slot uint16_t SL_to_bitmap(int startSymbolIndex, int nrOfSymbols) { return ((1<<nrOfSymbols)-1)<<startSymbolIndex; diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index e27543365a55da0f03aa54f048e07483cace3377..fc3e5c3fa4fc222f40f44e1dfc0a950b5f476bb9 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -92,6 +92,7 @@ uint16_t SL_to_bitmap(int startSymbolIndex, int nrOfSymbols); int get_nb_periods_per_frame(uint8_t tdd_period); int get_supported_band_index(int scs, int band, int n_rbs); long rrc_get_max_nr_csrs(const int max_rbs, long b_SRS); +void get_K1_K2(int N1, int N2, int *K1, int *K2); void get_samplerate_and_bw(int mu, int n_rb, int8_t threequarter_fs, diff --git a/doc/NR_SA_Tutorial_COTS_UE.md b/doc/NR_SA_Tutorial_COTS_UE.md index 3d9781a7dbb73024e3aabde5e9c99df2dfce3a00..88ca97e863125ef4430fa8cc5f921e0eb7f5ba67 100644 --- a/doc/NR_SA_Tutorial_COTS_UE.md +++ b/doc/NR_SA_Tutorial_COTS_UE.md @@ -90,7 +90,7 @@ cd ~/openairinterface5g/cmake_targets cd ~/openairinterface5g source oaienv cd cmake_targets -./build_oai -w USRP --ninja --gNB --build-lib "nrscope" -c +./build_oai -w USRP --ninja --gNB -c ``` # 4. Run OAI CN5G and OAI gNB diff --git a/doc/NR_SA_Tutorial_OAI_nrUE.md b/doc/NR_SA_Tutorial_OAI_nrUE.md index 86aede9f238f332311d4985617e9ea83561b985e..f49b57354bf40517ef8910a041078ae058d57967 100644 --- a/doc/NR_SA_Tutorial_OAI_nrUE.md +++ b/doc/NR_SA_Tutorial_OAI_nrUE.md @@ -74,11 +74,14 @@ git checkout develop cd ~/openairinterface5g/cmake_targets ./build_oai -I +# nrscope dependencies +sudo apt install -y libforms-dev libforms-bin + # Build OAI gNB cd ~/openairinterface5g source oaienv cd cmake_targets -./build_oai -w USRP --ninja --nrUE --gNB --build-lib "telnetsrv nrscope" -c +./build_oai -w USRP --ninja --nrUE --gNB --build-lib "nrscope" -c ``` # 4. Run OAI CN5G and OAI gNB diff --git a/doc/SW_archi.md b/doc/SW_archi.md index 3886b04099b201ae2e0bcc181ee834bf72a908e8..7f16edab1164c9a88614be4077310ac207ea28c3 100644 --- a/doc/SW_archi.md +++ b/doc/SW_archi.md @@ -315,7 +315,7 @@ Still on DL (gNB side), PDCP push incoming data into RLC by calling: rlc_data_re For UL, the low layer push data into rlc by: mac_rlc_data_ind() Then, rlc push it to pdcp by calling pdcp_data_ind() from a complex rlc internal call back (deliver_sdu()) -When adding a UE, external code have to call nr_rrc_rlc_config_asn1_req(), to remove it: rrc_rlc_remove_ue() +When adding a UE, external code have to call `add_rlc_srb()` and/or `add_rlc_drb()`, to remove it: `rrc_rlc_remove_ue()` Inside UE, channels called drd or srb can be created: ??? and deleted: rrc_rlc_config_req() nr_rlc_tick() must be called periodically to manage the internal timers diff --git a/executables/nr-cuup.c b/executables/nr-cuup.c index 99229e6a1377a44395125dc98cdd4c8c56757a7a..25ebe6df135b74af7a4ab024d0debc7b27d8e73f 100644 --- a/executables/nr-cuup.c +++ b/executables/nr-cuup.c @@ -99,14 +99,9 @@ void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChann abort(); } -rlc_op_status_t nr_rrc_rlc_config_asn1_req(const protocol_ctxt_t *const ctxt_pP, - const NR_SRB_ToAddModList_t *const srb2add_listP, - const NR_DRB_ToAddModList_t *const drb2add_listP, - const NR_DRB_ToReleaseList_t *const drb2release_listP, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list) +void nr_rlc_add_drb(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig) { abort(); - return 0; } int nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(const protocol_ctxt_t *const ctxt_pP, const gtpv1u_gnb_create_tunnel_resp_t *const create_tunnel_resp_p, int offset) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index e9d9e5fa4ac2a2066c3f79c6a97a792b934e3e8c..37f29ce1eadaf6d508f0a4e27e68c91b32366e0a 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -558,7 +558,7 @@ void init_eNB_afterRU(void) { for (i=0; i<gNB->RU_list[ru_id]->nb_rx; aa++,i++) { LOG_I(PHY,"Attaching RU %d antenna %d to gNB antenna %d\n",gNB->RU_list[ru_id]->idx,i,aa); gNB->prach_vars.rxsigF[aa] = gNB->RU_list[ru_id]->prach_rxsigF[0][i]; - gNB->common_vars.rxdataF[aa] = gNB->RU_list[ru_id]->common.rxdataF[i]; + gNB->common_vars.rxdataF[aa] = (c16_t *)gNB->RU_list[ru_id]->common.rxdataF[i]; } } diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 2e6e85f1d5e489b7e9538a4e46af4c926fd7248c..b02c2e039721b83eea29c17fd2f9ff1ae2df0216 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -632,17 +632,17 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB) } } - common_vars->txdataF = (int32_t **)malloc16(Ptx*sizeof(int32_t*)); - common_vars->rxdataF = (int32_t **)malloc16(Prx*sizeof(int32_t*)); + common_vars->txdataF = (c16_t **)malloc16(Ptx*sizeof(c16_t*)); + common_vars->rxdataF = (c16_t **)malloc16(Prx*sizeof(c16_t*)); /* Do NOT allocate per-antenna txdataF/rxdataF: the gNB gets a pointer to the * RU to copy/recover freq-domain memory from there */ common_vars->beam_id = (uint8_t **)malloc16(Ptx*sizeof(uint8_t*)); for (i=0;i<Ptx;i++){ - common_vars->txdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); // [hna] samples_per_frame without CP + common_vars->txdataF[i] = (c16_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(c16_t)); // [hna] samples_per_frame without CP LOG_D(PHY,"[INIT] common_vars->txdataF[%d] = %p (%lu bytes)\n", i,common_vars->txdataF[i], - fp->samples_per_frame_wCP*sizeof(int32_t)); + fp->samples_per_frame_wCP*sizeof(c16_t)); common_vars->beam_id[i] = (uint8_t*)malloc16_clear(fp->symbols_per_slot*fp->slots_per_frame*sizeof(uint8_t)); memset(common_vars->beam_id[i],255,fp->symbols_per_slot*fp->slots_per_frame); } diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 20cc35ffb014113c07c159017724add73b8d025d..32e5647b693d2e3e5278d272dba21437a3dbf11f 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -298,19 +298,21 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) ue->tx_power_dBm[i]=-127; // init TX buffers - common_vars->txdata = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) ); - common_vars->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) ); + common_vars->txdata = (c16_t **)malloc16(fp->nb_antennas_tx*sizeof(c16_t *)); + common_vars->txdataF = (c16_t **)malloc16(fp->nb_antennas_tx*sizeof(c16_t *)); for (i=0; i<fp->nb_antennas_tx; i++) { - common_vars->txdata[i] = (int32_t *)malloc16_clear( fp->samples_per_subframe*10*sizeof(int32_t) ); - common_vars->txdataF[i] = (int32_t *)malloc16_clear( fp->samples_per_slot_wCP*sizeof(int32_t) ); + common_vars->txdata[i] = (c16_t *)malloc16_clear((fp->samples_per_frame) * sizeof(c16_t)); + common_vars->txdataF[i] = (c16_t *)malloc16_clear((fp->samples_per_frame) * sizeof(c16_t)); } // init RX buffers - common_vars->rxdata = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + common_vars->rxdata = (c16_t **)malloc16( fp->nb_antennas_rx*sizeof(c16_t *)); + common_vars->rxdataF = (c16_t **)malloc16( fp->nb_antennas_rx*sizeof(c16_t *)); for (i=0; i<fp->nb_antennas_rx; i++) { - common_vars->rxdata[i] = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+fp->ofdm_symbol_size)*sizeof(int32_t) ); + common_vars->rxdata[i] = (c16_t *)malloc16_clear((2 * (fp->samples_per_frame)+fp->ofdm_symbol_size) * sizeof(c16_t)); + common_vars->rxdataF[i] = (c16_t *)malloc16_clear((2 * (fp->samples_per_frame)+fp->ofdm_symbol_size) * sizeof(c16_t)); } // ceil(((NB_RB<<1)*3)/32) // 3 RE *2(QPSK) @@ -426,8 +428,10 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) for (int i = 0; i < fp->nb_antennas_rx; i++) { free_and_zero(common_vars->rxdata[i]); + free_and_zero(common_vars->rxdataF[i]); } free_and_zero(common_vars->rxdata); + free_and_zero(common_vars->rxdataF); for (int slot = 0; slot < fp->slots_per_frame; slot++) { for (int symb = 0; symb < fp->symbols_per_slot; symb++) diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c index d592aa466e416da54d805dd279de0519158594c0..12517d0a9730590907208670779fab771cd3bbc6 100644 --- a/openair1/PHY/MODULATION/beamforming.c +++ b/openair1/PHY/MODULATION/beamforming.c @@ -137,8 +137,8 @@ int beam_precoding_one_eNB(int32_t **txdataF, } -int nr_beam_precoding(int32_t **txdataF, - int32_t **txdataF_BF, +int nr_beam_precoding(c16_t **txdataF, + c16_t **txdataF_BF, NR_DL_FRAME_PARMS *frame_parms, int32_t ***beam_weights, int slot, @@ -152,7 +152,7 @@ int nr_beam_precoding(int32_t **txdataF, uint8_t p; // clear txdata_BF[aa][re] for each call of ue_spec_beamforming - memset(&txdataF_BF[aa][symbol*frame_parms->ofdm_symbol_size],0,sizeof(int32_t)*(frame_parms->ofdm_symbol_size)); + memset(&txdataF_BF[aa][symbol*frame_parms->ofdm_symbol_size], 0, sizeof(c16_t) *(frame_parms->ofdm_symbol_size)); for (p=0; p<nb_antenna_ports; p++) { //if ((frame_parms->L_ssb >> (63-p)) & 0x01) { diff --git a/openair1/PHY/MODULATION/modulation_common.h b/openair1/PHY/MODULATION/modulation_common.h index 1a19bec78c83ea5b2772f91685d6235a0d5a994d..7c214fa8212e116d8f78d5e8d33fdd0cd5ca7a2b 100644 --- a/openair1/PHY/MODULATION/modulation_common.h +++ b/openair1/PHY/MODULATION/modulation_common.h @@ -49,7 +49,7 @@ void PHY_ofdm_mod(int *input, void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRAME_PARMS *frame_parms); -void nr_normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,NR_DL_FRAME_PARMS *frame_parms, uint32_t slot); +void nr_normal_prefix_mod(c16_t *txdataF, c16_t *txdata, uint8_t nsymb, NR_DL_FRAME_PARMS *frame_parms, uint32_t slot); void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms); diff --git a/openair1/PHY/MODULATION/nr_modulation.h b/openair1/PHY/MODULATION/nr_modulation.h index 435251868e63f1d3967a4d410b7c543f6bc8727d..086ad19afc65b73412445e69d0869278a1cad4dc 100644 --- a/openair1/PHY/MODULATION/nr_modulation.h +++ b/openair1/PHY/MODULATION/nr_modulation.h @@ -97,8 +97,8 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, */ void nr_dft(int32_t *z,int32_t *d, uint32_t Msc_PUSCH); -int nr_beam_precoding(int32_t **txdataF, - int32_t **txdataF_BF, +int nr_beam_precoding(c16_t **txdataF, + c16_t **txdataF_BF, NR_DL_FRAME_PARMS *frame_parms, int32_t ***beam_weights, int slot, @@ -109,7 +109,7 @@ int nr_beam_precoding(int32_t **txdataF, ); void apply_nr_rotation(NR_DL_FRAME_PARMS *fp, - int16_t* txdata, + c16_t* txdata, int slot, int first_symbol, int nsymb); @@ -119,7 +119,7 @@ void init_symbol_rotation(NR_DL_FRAME_PARMS *fp); void init_timeshift_rotation(NR_DL_FRAME_PARMS *fp); void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms, - int32_t *rxdataF, + c16_t *rxdataF, int slot, int first_symbol, int nsymb); diff --git a/openair1/PHY/MODULATION/ofdm_mod.c b/openair1/PHY/MODULATION/ofdm_mod.c index 93994b9ab6f867beab8655a5b691812ff2ccaeed..8e17fc0a4a5b355c91983a383ff3822c6826e1f0 100644 --- a/openair1/PHY/MODULATION/ofdm_mod.c +++ b/openair1/PHY/MODULATION/ofdm_mod.c @@ -63,60 +63,60 @@ void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRA } -void nr_normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,NR_DL_FRAME_PARMS *frame_parms, uint32_t slot) +void nr_normal_prefix_mod(c16_t *txdataF, c16_t *txdata, uint8_t nsymb, NR_DL_FRAME_PARMS *frame_parms, uint32_t slot) { // This function works only slot wise. For more generic symbol generation refer nr_feptx0() if (frame_parms->numerology_index != 0) { // case where numerology != 0 if (!(slot%(frame_parms->slots_per_subframe/2))) { - PHY_ofdm_mod(txdataF, - txdata, - frame_parms->ofdm_symbol_size, - 1, - frame_parms->nb_prefix_samples0, - CYCLIC_PREFIX); - PHY_ofdm_mod(txdataF+frame_parms->ofdm_symbol_size, - txdata + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples0, - frame_parms->ofdm_symbol_size, - nsymb - 1, - frame_parms->nb_prefix_samples, - CYCLIC_PREFIX); + PHY_ofdm_mod((int *)txdataF, + (int *)txdata, + frame_parms->ofdm_symbol_size, + 1, + frame_parms->nb_prefix_samples0, + CYCLIC_PREFIX); + PHY_ofdm_mod((int *)txdataF + frame_parms->ofdm_symbol_size, + (int *)txdata + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples0, + frame_parms->ofdm_symbol_size, + nsymb - 1, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); } else { - PHY_ofdm_mod(txdataF, - txdata, - frame_parms->ofdm_symbol_size, - nsymb, - frame_parms->nb_prefix_samples, - CYCLIC_PREFIX); + PHY_ofdm_mod((int *)txdataF, + (int *)txdata, + frame_parms->ofdm_symbol_size, + nsymb, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); } } else { // numerology = 0, longer CP for every 7th symbol - PHY_ofdm_mod(txdataF, - txdata, - frame_parms->ofdm_symbol_size, - 1, - frame_parms->nb_prefix_samples0, - CYCLIC_PREFIX); - PHY_ofdm_mod(txdataF+frame_parms->ofdm_symbol_size, - txdata + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples0, - frame_parms->ofdm_symbol_size, - 6, - frame_parms->nb_prefix_samples, - CYCLIC_PREFIX); - PHY_ofdm_mod(txdataF + 7*frame_parms->ofdm_symbol_size, - txdata + 6*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples) + - frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples0, - frame_parms->ofdm_symbol_size, - 1, - frame_parms->nb_prefix_samples0, - CYCLIC_PREFIX); - PHY_ofdm_mod(txdataF + 8*frame_parms->ofdm_symbol_size, - txdata + 6*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples) + - 2*(frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples0), - frame_parms->ofdm_symbol_size, - 6, - frame_parms->nb_prefix_samples, - CYCLIC_PREFIX); + PHY_ofdm_mod((int *)txdataF, + (int *)txdata, + frame_parms->ofdm_symbol_size, + 1, + frame_parms->nb_prefix_samples0, + CYCLIC_PREFIX); + PHY_ofdm_mod((int *)txdataF + frame_parms->ofdm_symbol_size, + (int *)txdata + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples0, + frame_parms->ofdm_symbol_size, + 6, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); + PHY_ofdm_mod((int *)txdataF + 7*frame_parms->ofdm_symbol_size, + (int *)txdata + 6*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples) + + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples0, + frame_parms->ofdm_symbol_size, + 1, + frame_parms->nb_prefix_samples0, + CYCLIC_PREFIX); + PHY_ofdm_mod((int *)txdataF + 8 * frame_parms->ofdm_symbol_size, + (int *)txdata + 6 * (frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples) + + 2*(frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples0), + frame_parms->ofdm_symbol_size, + 6, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); } } @@ -334,7 +334,7 @@ void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t ne } void apply_nr_rotation(NR_DL_FRAME_PARMS *fp, - int16_t* txdataF, + c16_t *txdataF, int slot, int first_symbol, int nsymb) @@ -345,7 +345,7 @@ void apply_nr_rotation(NR_DL_FRAME_PARMS *fp, for (int sidx = first_symbol; sidx < first_symbol + nsymb; sidx++) { c16_t *this_rotation = symbol_rotation + sidx; - c16_t *this_symbol = ((c16_t*) txdataF) + sidx * fp->ofdm_symbol_size; + c16_t *this_symbol = (txdataF) + sidx * fp->ofdm_symbol_size; LOG_D(PHY,"Rotating symbol %d, slot %d, symbol_subframe_index %d (%d,%d)\n", sidx, diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index d902c2af479d8e92dda6a62592070725bbe0690a..dee825338896e6d76a2b95654711cbe9940f0ecb 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -72,7 +72,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, //#ifdef DEBUG_FEP // if (ue->frame <100) LOG_D(PHY,"slot_fep: slot %d, symbol %d, nb_prefix_samples %u, nb_prefix_samples0 %u, rx_offset %u energy %d\n", - Ns, symbol, nb_prefix_samples, nb_prefix_samples0, rx_offset, dB_fixed(signal_energy(&common_vars->rxdata[0][rx_offset],frame_parms->ofdm_symbol_size))); + Ns, symbol, nb_prefix_samples, nb_prefix_samples0, rx_offset, dB_fixed(signal_energy((int32_t *)&common_vars->rxdata[0][rx_offset],frame_parms->ofdm_symbol_size))); //#endif for (unsigned char aa=0; aa<frame_parms->nb_antennas_rx; aa++) { @@ -311,7 +311,7 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, } void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms, - int32_t *rxdataF, + c16_t *rxdataF, int slot, int first_symbol, int nsymb) @@ -326,7 +326,7 @@ void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms, LOG_D(PHY,"slot %d, symb_offset %d rotating by %d.%d\n",slot,symb_offset,rot2.r,rot2.i); c16_t *shift_rot = frame_parms->timeshift_symbol_rotation; - c16_t *this_symbol = (c16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)]; + c16_t *this_symbol = &rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)]; if (frame_parms->N_RB_UL & 1) { rotate_cpx_vector(this_symbol, &rot2, this_symbol, diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index c443fabb3c01d68318ab1f5c5a0b1e840fc2b36c..ddd5d33a86935880b23d24d8d0a6fd902427740d 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -45,9 +45,8 @@ void nr_est_timing_advance_pusch(const NR_DL_FRAME_PARMS *frame_parms, const int const int sync_pos = 0; for (int i = 0; i < frame_parms->ofdm_symbol_size; i++) { - int Re = ((int16_t *)ul_ch_estimates_time)[(i << 1)]; - int Im = ((int16_t *)ul_ch_estimates_time)[1 + (i << 1)]; - int temp = (Re * Re / 2) + (Im * Im / 2); + c16_t *sample = (c16_t *)&ul_ch_estimates_time[i]; + int temp = (sample->r * sample->r / 2) + (sample->i * sample->i / 2); if (temp > max_val) { max_pos = i; max_val = temp; @@ -157,12 +156,12 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB,int slot, int first_symb,int num_symb int offset = offset0 + (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size; nb_symb[rb]++; for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - int32_t *ul_ch = &common_vars->rxdataF[aarx][offset]; + int32_t *ul_ch = (int32_t *)&common_vars->rxdataF[aarx][offset]; int32_t signal_energy; if (((frame_parms->N_RB_UL&1) == 1) && (rb==(frame_parms->N_RB_UL>>1))) { signal_energy = signal_energy_nodc(ul_ch, 6); - ul_ch = &common_vars->rxdataF[aarx][offset0]; + ul_ch = (int32_t *)&common_vars->rxdataF[aarx][offset0]; signal_energy += signal_energy_nodc(ul_ch, 6); } else { signal_energy = signal_energy_nodc(ul_ch, 12); diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 81abf5f1eeb8288c6cb8202c81a53661f6f2b1d3..fd2ed4f675b9de8d39b6a4c606a1bb5365a7f62e 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -102,9 +102,11 @@ __attribute__((always_inline)) inline c16_t c32x16cumulVectVectWithSteps(c16_t * int get_delay_idx(int delay) { int delay_idx = MAX_UL_DELAY_COMP + delay; + // If the measured delay is less than -MAX_UL_DELAY_COMP, a -MAX_UL_DELAY_COMP delay is compensated. if (delay_idx < 0) { delay_idx = 0; } + // If the measured delay is greater than +MAX_UL_DELAY_COMP, a +MAX_UL_DELAY_COMP delay is compensated. if (delay_idx > MAX_UL_DELAY_COMP<<1) { delay_idx = MAX_UL_DELAY_COMP<<1; } diff --git a/openair1/PHY/NR_REFSIG/pss_nr.h b/openair1/PHY/NR_REFSIG/pss_nr.h index b78a89b12c8085304c26b6f2bee0345b09557269..3b0e87109e6e8c1a71617a7a41052bf0afcc7613 100644 --- a/openair1/PHY/NR_REFSIG/pss_nr.h +++ b/openair1/PHY/NR_REFSIG/pss_nr.h @@ -126,7 +126,7 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue); void free_context_pss_nr(void); int set_pss_nr(int ofdm_symbol_size); int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change); -int pss_search_time_nr(int **rxdata, ///rx data in time domain +int pss_search_time_nr(c16_t **rxdata, ///rx data in time domain NR_DL_FRAME_PARMS *frame_parms, int fo_flag, int is, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c index 9b6adb870235457533b3e336b394759172ffdd0f..47ef721befdef0fc3a63fe0d6ecf31c555754b50 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c @@ -59,7 +59,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, PHY_VARS_gNB *gNB = msgTx->gNB; NR_gNB_DLSCH_t *dlsch; - int32_t** txdataF = gNB->common_vars.txdataF; + c16_t** txdataF = gNB->common_vars.txdataF; int16_t amp = AMP; int xOverhead = 0; NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 64c1d31902791ce0101a123279fba62c8712312c..e34102e0c7316516e9a771d21b1011b7c434170c 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -48,7 +48,7 @@ const uint8_t nr_pbch_payload_interleaving_pattern[32] = {16, 23, 18, 17, 8, 30, }; int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, - int32_t *txdataF, + c16_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, nfapi_nr_config_request_scf_t *config, @@ -222,7 +222,7 @@ void nr_init_pbch_interleaver(uint8_t *interleaver) { int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, uint8_t *interleaver, - int32_t *txdataF, + c16_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, uint8_t n_hf, diff --git a/openair1/PHY/NR_TRANSPORT/nr_prs.c b/openair1/PHY/NR_TRANSPORT/nr_prs.c index 2167990abfc6c0d96110a54af7bf41577bb9e684..4a93e4d66a49651e862921605a895ef337504032 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prs.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prs.c @@ -10,7 +10,7 @@ extern short nr_qpsk_mod_table[8]; int nr_generate_prs(uint32_t **nr_gold_prs, - int32_t *txdataF, + c16_t *txdataF, int16_t amp, prs_config_t *prs_cfg, nfapi_nr_config_request_scf_t *config, diff --git a/openair1/PHY/NR_TRANSPORT/nr_pss.c b/openair1/PHY/NR_TRANSPORT/nr_pss.c index 8564efe3de0d4fd73a45fe1610b0f07938e2c6be..965ac51c21bfc9942e2d8e39e4f4bc8d1a03b431 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pss.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pss.c @@ -24,7 +24,7 @@ //#define NR_PSS_DEBUG -int nr_generate_pss( int32_t *txdataF, +int nr_generate_pss( c16_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, nfapi_nr_config_request_scf_t* config, diff --git a/openair1/PHY/NR_TRANSPORT/nr_sss.c b/openair1/PHY/NR_TRANSPORT/nr_sss.c index 5181f6bac18de7af72c174310e5811459ebb28b8..45835f82069a2533982db1132585e789717fe8a1 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_sss.c +++ b/openair1/PHY/NR_TRANSPORT/nr_sss.c @@ -23,7 +23,7 @@ //#define NR_SSS_DEBUG -int nr_generate_sss( int32_t *txdataF, +int nr_generate_sss( c16_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, nfapi_nr_config_request_scf_t* config, diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 75bf46d243f5fd9076ddcdd5e8ec0b2333691ad4..2f0e46a13fbcad88cd6438d9a31d4b859b857df6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -40,7 +40,7 @@ int nr_generate_prs(uint32_t **nr_gold_prs, - int32_t *txdataF, + c16_t *txdataF, int16_t amp, prs_config_t *prs_cfg, nfapi_nr_config_request_scf_t *config, @@ -52,7 +52,7 @@ int nr_generate_prs(uint32_t **nr_gold_prs, @param @returns 0 on success */ -int nr_generate_pss(int32_t *txdataF, +int nr_generate_pss(c16_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, nfapi_nr_config_request_scf_t *config, @@ -64,7 +64,7 @@ int nr_generate_pss(int32_t *txdataF, @param @returns 0 on success */ -int nr_generate_sss(int32_t *txdataF, +int nr_generate_sss(c16_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, nfapi_nr_config_request_scf_t *config, @@ -77,7 +77,7 @@ int nr_generate_sss(int32_t *txdataF, @returns 0 on success */ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, - int32_t *txdataF, + c16_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, nfapi_nr_config_request_scf_t *config, @@ -91,7 +91,7 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, */ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, uint8_t *interleaver, - int32_t *txdataF, + c16_t *txdataF, int16_t amp, uint8_t ssb_start_symbol, uint8_t n_hf, @@ -140,7 +140,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, @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(int32_t **rxdataF, +void nr_ulsch_extract_rbs(c16_t **rxdataF, NR_gNB_PUSCH *pusch_vars, int slot, unsigned char symbol, @@ -359,7 +359,7 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms, void free_nr_prach_entry(PHY_VARS_gNB *gNB, int prach_id); -void nr_decode_pucch1(int32_t **rxdataF, +void nr_decode_pucch1(c16_t **rxdataF, pucch_GroupHopping_t pucch_GroupHopping, uint32_t n_id, // hoppingID higher layer parameter uint64_t *payload, diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index 89cfc2f0aec6f7ade88ae2dffab83104cd65d633..47d778903e216384468d007ca28434f4568ffc9c 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -302,7 +302,7 @@ void nr_idft(int32_t *z, uint32_t Msc_PUSCH) } -void nr_ulsch_extract_rbs(int32_t **rxdataF, +void nr_ulsch_extract_rbs(c16_t **rxdataF, NR_gNB_PUSCH *pusch_vars, int slot, unsigned char symbol, @@ -547,7 +547,19 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext, #endif } - +__m128i a_mult_conjb(__m128i a, __m128i b, unsigned char output_shift) +{ + __m128i mmtmpD0 = _mm_madd_epi16(b, a); + __m128i mmtmpD1 = _mm_shufflelo_epi16(b, _MM_SHUFFLE(2, 3, 0, 1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1, _MM_SHUFFLE(2, 3, 0, 1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1, *(__m128i *)&conjugate[0]); + mmtmpD1 = _mm_madd_epi16(mmtmpD1, a); + mmtmpD0 = _mm_srai_epi32(mmtmpD0, output_shift); + mmtmpD1 = _mm_srai_epi32(mmtmpD1, output_shift); + __m128i mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0, mmtmpD1); + __m128i mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0, mmtmpD1); + return _mm_packs_epi32(mmtmpD2, mmtmpD3); +} //============================================================================================== // Pre-processing for LLR computation @@ -689,71 +701,16 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, } - // multiply by conjugated channel - mmtmpD0 = _mm_madd_epi16(ul_ch128[0],rxdataF128[0]); - // print_ints("re",&mmtmpD0); - - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpD1); - mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - // print_ints("re(shift)",&mmtmpD0); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - // print_ints("im(shift)",&mmtmpD1); - mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - // print_ints("c0",&mmtmpD2); - // print_ints("c1",&mmtmpD3); - rxdataF_comp128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - // print_shorts("rx:",rxdataF128); - // print_shorts("ch:",ul_ch128); - // print_shorts("pack:",rxdataF_comp128); - - // multiply by conjugated channel - mmtmpD0 = _mm_madd_epi16(ul_ch128[1],rxdataF128[1]); - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); - mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - - rxdataF_comp128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - // print_shorts("rx:",rxdataF128+1); - // print_shorts("ch:",ul_ch128+1); - // print_shorts("pack:",rxdataF_comp128+1); - - // multiply by conjugated channel - mmtmpD0 = _mm_madd_epi16(ul_ch128[2],rxdataF128[2]); - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); - mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[2]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - - rxdataF_comp128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - //print_shorts("rx:",rxdataF128+2); - //print_shorts("ch:",ul_ch128+2); - //print_shorts("pack:",rxdataF_comp128+2); + // Multiply received data by conjugated channel + rxdataF_comp128[0] = a_mult_conjb(rxdataF128[0], ul_ch128[0], output_shift); + rxdataF_comp128[1] = a_mult_conjb(rxdataF128[1], ul_ch128[1], output_shift); + rxdataF_comp128[2] = a_mult_conjb(rxdataF128[2], ul_ch128[2], output_shift); - ul_ch128+=3; - ul_ch_mag128+=3; - ul_ch_mag128b+=3; - rxdataF128+=3; - rxdataF_comp128+=3; + ul_ch128 += 3; + ul_ch_mag128 += 3; + ul_ch_mag128b += 3; + rxdataF128 += 3; + rxdataF_comp128 += 3; } } } @@ -1375,13 +1332,14 @@ __m128i nr_ulsch_comp_muli_sum(__m128i input_x, //printf("det_%d = %d log2 =%d \n",k,(((int *)&det[0])[k]),log2_approx(((int *)&det[0])[k])); } - xy_re_128 = _mm_slli_epi32(xy_re_128,5); - xy_re_128 = _mm_srai_epi32(xy_re_128,log2_approx(sum_det)); - xy_re_128 = _mm_slli_epi32(xy_re_128,5); - - xy_im_128 = _mm_slli_epi32(xy_im_128,5); - xy_im_128 = _mm_srai_epi32(xy_im_128,log2_approx(sum_det)); - xy_im_128 = _mm_slli_epi32(xy_im_128,5); + int b = log2_approx(sum_det) - 8; + if (b > 0) { + xy_re_128 = _mm_srai_epi32(xy_re_128, b); + xy_im_128 = _mm_srai_epi32(xy_im_128, b); + } else { + xy_re_128 = _mm_slli_epi32(xy_re_128, -b); + xy_im_128 = _mm_slli_epi32(xy_im_128, -b); + } tmp_z0 = _mm_unpacklo_epi32(xy_re_128,xy_im_128); //print_ints("unpack lo:",&tmp_z0[0]); @@ -1514,16 +1472,17 @@ void nr_ulsch_construct_HhH_elements(int *conjch00_ch00, * * * */ -uint8_t nr_ulsch_zero_forcing_rx_2layers(int **rxdataF_comp, - int **ul_ch_mag, - int **ul_ch_magb, - int **ul_ch_estimates_ext, - unsigned short nb_rb, - unsigned char n_rx, - unsigned char mod_order, - int shift, - unsigned char symbol, - int length) +uint8_t nr_ulsch_zero_forcing_rx_2layers(NR_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + int **ul_ch_mag, + int **ul_ch_magb, + int **ul_ch_estimates_ext, + unsigned short nb_rb, + unsigned char n_rx, + unsigned char mod_order, + int shift, + unsigned char symbol, + int length) { int *ch00, *ch01, *ch10, *ch11; int *ch20, *ch30, *ch21, *ch31; @@ -1765,10 +1724,10 @@ uint8_t nr_ulsch_zero_forcing_rx_2layers(int **rxdataF_comp, * * **************************************************************************/ - __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*ul_ch_mag128_0=NULL,*ul_ch_mag128b_0=NULL,*determ_fin_128;//*dl_ch_mag128_1,*dl_ch_mag128b_1,*dl_ch_mag128r_1 - __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3; - __m128i *after_mf_a_128,*after_mf_b_128, *after_mf_c_128, *after_mf_d_128; - __m128i QAM_amp128={0},QAM_amp128b={0}; + __m128i *rxdataF_comp128_0, *rxdataF_comp128_1, *ul_ch_mag128_0 = NULL, *ul_ch_mag128b_0 = NULL, *ul_ch_mag128_1 = NULL, *ul_ch_mag128b_1 = NULL, *determ_fin_128; + __m128i mmtmpD0, mmtmpD1, mmtmpD2, mmtmpD3; + __m128i *after_mf_a_128, *after_mf_b_128, *after_mf_c_128, *after_mf_d_128; + __m128i QAM_amp128 = {0}, QAM_amp128b = {0}; determ_fin_128 = (__m128i *)&determ_fin[0]; @@ -1787,45 +1746,50 @@ uint8_t nr_ulsch_zero_forcing_rx_2layers(int **rxdataF_comp, } else if (mod_order == 6) { QAM_amp128 = _mm_set1_epi16(QAM64_n1); //4/sqrt{42} QAM_amp128b = _mm_set1_epi16(QAM64_n2); //2/sqrt{42} - } - ul_ch_mag128_0 = (__m128i *)&ul_ch_mag[0][symbol*(off+nb_rb*12)]; - ul_ch_mag128b_0 = (__m128i *)&ul_ch_magb[0][symbol*(off+nb_rb*12)]; + } + ul_ch_mag128_0 = (__m128i *)&ul_ch_mag[0][symbol * (off + nb_rb * 12)]; + ul_ch_mag128b_0 = (__m128i *)&ul_ch_magb[0][symbol * (off + nb_rb * 12)]; + ul_ch_mag128_1 = (__m128i *)&ul_ch_mag[frame_parms->nb_antennas_rx][symbol * (off + nb_rb * 12)]; + ul_ch_mag128b_1 = (__m128i *)&ul_ch_magb[frame_parms->nb_antennas_rx][symbol * (off + nb_rb * 12)]; } - for (int rb=0; rb<3*nb_rb_0; rb++) { - if (mod_order>2) { - int sum_det =0; - for (int k=0; k<4;k++) { - sum_det += ((((int *)&determ_fin_128[0])[k])>>2); - //printf("det_%d = %d\n",k,sum_det); - } - - mmtmpD2 = _mm_slli_epi32(determ_fin_128[0],5); - mmtmpD2 = _mm_srai_epi32(mmtmpD2,log2_approx(sum_det)); - mmtmpD2 = _mm_slli_epi32(mmtmpD2,5); + for (int rb = 0; rb < 3 * nb_rb_0; rb++) { - mmtmpD3 = _mm_unpacklo_epi32(mmtmpD2,mmtmpD2); + // Magnitude computation + if (mod_order > 2) { - mmtmpD2 = _mm_unpackhi_epi32(mmtmpD2,mmtmpD2); + int sum_det = 0; + for (int k = 0; k < 4; k++) { + sum_det += ((((int *)&determ_fin_128[0])[k]) >> 2); + } - mmtmpD2 = _mm_packs_epi32(mmtmpD3,mmtmpD2); + int b = log2_approx(sum_det) - 8; + if (b > 0) { + mmtmpD2 = _mm_srai_epi32(determ_fin_128[0], b); + } else { + mmtmpD2 = _mm_slli_epi32(determ_fin_128[0], -b); + } + mmtmpD3 = _mm_unpacklo_epi32(mmtmpD2, mmtmpD2); + mmtmpD2 = _mm_unpackhi_epi32(mmtmpD2, mmtmpD2); + mmtmpD2 = _mm_packs_epi32(mmtmpD3, mmtmpD2); + // Layer 0 ul_ch_mag128_0[0] = mmtmpD2; ul_ch_mag128b_0[0] = mmtmpD2; - - ul_ch_mag128_0[0] = _mm_mulhi_epi16(ul_ch_mag128_0[0],QAM_amp128); - ul_ch_mag128_0[0] = _mm_slli_epi16(ul_ch_mag128_0[0],1); - - ul_ch_mag128b_0[0] = _mm_mulhi_epi16(ul_ch_mag128b_0[0],QAM_amp128b); - ul_ch_mag128b_0[0] = _mm_slli_epi16(ul_ch_mag128b_0[0],1); - - //print_shorts("mag layer 1:",(int16_t*)&dl_ch_mag128_0[0]); - //print_shorts("mag layer 2:",(int16_t*)&dl_ch_mag128_1[0]); - //print_shorts("magb layer 1:",(int16_t*)&dl_ch_mag128b_0[0]); - //print_shorts("magb layer 2:",(int16_t*)&dl_ch_mag128b_1[0]); - //print_shorts("magr layer 1:",(int16_t*)&dl_ch_mag128r_0[0]); - //print_shorts("magr layer 2:",(int16_t*)&dl_ch_mag128r_1[0]); + ul_ch_mag128_0[0] = _mm_mulhi_epi16(ul_ch_mag128_0[0], QAM_amp128); + ul_ch_mag128_0[0] = _mm_slli_epi16(ul_ch_mag128_0[0], 1); + ul_ch_mag128b_0[0] = _mm_mulhi_epi16(ul_ch_mag128b_0[0], QAM_amp128b); + ul_ch_mag128b_0[0] = _mm_slli_epi16(ul_ch_mag128b_0[0], 1); + + // Layer 1 + ul_ch_mag128_1[0] = mmtmpD2; + ul_ch_mag128b_1[0] = mmtmpD2; + ul_ch_mag128_1[0] = _mm_mulhi_epi16(ul_ch_mag128_1[0], QAM_amp128); + ul_ch_mag128_1[0] = _mm_slli_epi16(ul_ch_mag128_1[0], 1); + ul_ch_mag128b_1[0] = _mm_mulhi_epi16(ul_ch_mag128b_1[0], QAM_amp128b); + ul_ch_mag128b_1[0] = _mm_slli_epi16(ul_ch_mag128b_1[0], 1); } + // multiply by channel Inv //rxdataF_zf128_0 = rxdataF_comp128_0*d - b*rxdataF_comp128_1 //rxdataF_zf128_1 = rxdataF_comp128_1*a - c*rxdataF_comp128_0 @@ -1844,12 +1808,7 @@ uint8_t nr_ulsch_zero_forcing_rx_2layers(int **rxdataF_comp, determ_fin_128[0]); rxdataF_comp128_0[0] = mmtmpD0; - if (mod_order > 2) { - // We need to check why it is a shift of 3 - rxdataF_comp128_1[0] = simde_mm_srai_epi16(mmtmpD1, 3); - } else { - rxdataF_comp128_1[0] = mmtmpD1; - } + rxdataF_comp128_1[0] = mmtmpD1; #ifdef DEBUG_DLSCH_DEMOD printf("\n Rx signal after ZF l%d rb%d\n",symbol,rb); @@ -1858,7 +1817,9 @@ uint8_t nr_ulsch_zero_forcing_rx_2layers(int **rxdataF_comp, #endif determ_fin_128 += 1; ul_ch_mag128_0 += 1; - ul_ch_mag128b_0 += 1; + ul_ch_mag128_1 += 1; + ul_ch_mag128b_0 += 1; + ul_ch_mag128b_1 += 1; rxdataF_comp128_0 += 1; rxdataF_comp128_1 += 1; after_mf_a_128 += 1; @@ -1964,7 +1925,13 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, int off = ((rel15_ul->rb_size&1) == 1)? 4:0; uint32_t rxdataF_ext_offset = 0; uint8_t shift_ch_ext = rel15_ul->nrOfLayers > 1 ? log2_approx(max_ch >> 11) : 0; - uint8_t ad_shift = 1 + log2_approx(frame_parms->nb_antennas_rx >> 2) + (rel15_ul->nrOfLayers == 2); + + int ad_shift = 0; + if (rel15_ul->nrOfLayers == 1) { + ad_shift = 1 + log2_approx(frame_parms->nb_antennas_rx >> 2); + } else { + ad_shift = -3; // For 2-layers, we are already doing a bit shift in the nr_ulsch_zero_forcing_rx_2layers() function, so we can use more bits + } for(uint8_t symbol = rel15_ul->start_symbol_index; symbol < (rel15_ul->start_symbol_index + rel15_ul->nr_of_symbols); symbol++) { uint8_t dmrs_symbol_flag = (rel15_ul->ul_dmrs_symb_pos >> symbol) & 0x01; @@ -2033,7 +2000,10 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) avgs = cmax(avgs,avg[aatx*frame_parms->nb_antennas_rx+aarx]); - gNB->pusch_vars[ulsch_id]->log2_maxh = (log2_approx(avgs) / 2) + ad_shift; + gNB->pusch_vars[ulsch_id]->log2_maxh = (log2_approx(avgs) >> 1) + ad_shift; + if (gNB->pusch_vars[ulsch_id]->log2_maxh < 0) { + gNB->pusch_vars[ulsch_id]->log2_maxh = 0; + } gNB->pusch_vars[ulsch_id]->cl_done = 1; } @@ -2071,7 +2041,8 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, //Apply zero forcing for 2 Tx layers if (rel15_ul->nrOfLayers == 2) { - nr_ulsch_zero_forcing_rx_2layers(gNB->pusch_vars[ulsch_id]->rxdataF_comp, + nr_ulsch_zero_forcing_rx_2layers(frame_parms, + gNB->pusch_vars[ulsch_id]->rxdataF_comp, gNB->pusch_vars[ulsch_id]->ul_ch_mag0, gNB->pusch_vars[ulsch_id]->ul_ch_magb0, gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext, diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 03ed927c37015df3804ff2df3897282672983cc7..99a343942027363795c8e09fd6406051ed5fefe5 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -183,7 +183,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, nfapi_nr_uci_pucch_pdu_format_0_1_t* uci_pdu, nfapi_nr_pucch_pdu_t* pucch_pdu) { - int32_t **rxdataF = gNB->common_vars.rxdataF; + c16_t **rxdataF = gNB->common_vars.rxdataF; NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; int soffset=(slot&3)*frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size; int nr_sequences; @@ -295,7 +295,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, re_offset[l]-=frame_parms->ofdm_symbol_size; for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) { - tmp_rp = &rxdataF[aa][soffset + l2*frame_parms->ofdm_symbol_size]; + tmp_rp = (int32_t *)&rxdataF[aa][soffset + l2*frame_parms->ofdm_symbol_size]; if(re_offset[l] + nb_re_pucch > frame_parms->ofdm_symbol_size) { int neg_length = frame_parms->ofdm_symbol_size-re_offset[l]; int pos_length = nb_re_pucch-neg_length; @@ -502,7 +502,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, -void nr_decode_pucch1( int32_t **rxdataF, +void nr_decode_pucch1( c16_t **rxdataF, pucch_GroupHopping_t pucch_GroupHopping, uint32_t n_id, // hoppingID higher layer parameter uint64_t *payload, @@ -1148,7 +1148,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, nfapi_nr_uci_pucch_pdu_format_2_3_4_t* uci_pdu, nfapi_nr_pucch_pdu_t* pucch_pdu) { - int32_t **rxdataF = gNB->common_vars.rxdataF; + c16_t **rxdataF = gNB->common_vars.rxdataF; NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; //pucch_GroupHopping_t pucch_GroupHopping = pucch_pdu->group_hop_flag + (pucch_pdu->sequence_hop_flag<<1); @@ -1720,7 +1720,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, // estimate CQI for MAC (from antenna port 0 only) // TODO this computation is wrong -> to be ignored at MAC for now - int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]], + int SNRtimes10 = dB_fixed_times10(signal_energy_nodc((int32_t *)&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]], 12*pucch_pdu->prb_size)) - (10*gNB->measurements.n0_power_tot_dB); int cqi,bit_left; @@ -1735,7 +1735,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, uci_pdu->pucch_format=0; uci_pdu->ul_cqi=cqi; uci_pdu->timing_advance=0xffff; // currently not valid - uci_pdu->rssi=1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]],12*pucch_pdu->prb_size))); + uci_pdu->rssi=1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc((int32_t *)&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]],12*pucch_pdu->prb_size))); if (pucch_pdu->bit_len_harq>0) { int harq_bytes=pucch_pdu->bit_len_harq>>3; if ((pucch_pdu->bit_len_harq&7) > 0) harq_bytes++; diff --git a/openair1/PHY/NR_TRANSPORT/srs_rx.c b/openair1/PHY/NR_TRANSPORT/srs_rx.c index 94f1e29993e1a3cacce665bb2025145992336b42..5521619a8f92772cc17d73a89b92797990645447 100644 --- a/openair1/PHY/NR_TRANSPORT/srs_rx.c +++ b/openair1/PHY/NR_TRANSPORT/srs_rx.c @@ -106,7 +106,7 @@ int nr_get_srs_signal(PHY_VARS_gNB *gNB, LOG_I(NR_PHY,"Calling %s function\n", __FUNCTION__); #endif - int32_t **rxdataF = gNB->common_vars.rxdataF; + c16_t **rxdataF = gNB->common_vars.rxdataF; const NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; const uint16_t n_symbols = (slot&3)*frame_parms->symbols_per_slot; // number of symbols until this slot @@ -124,7 +124,7 @@ int nr_get_srs_signal(PHY_VARS_gNB *gNB, for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { memset(srs_received_signal[ant], 0, frame_parms->ofdm_symbol_size*sizeof(int32_t)); - rx_signal = &rxdataF[ant][symbol_offset]; + rx_signal = (int32_t *)&rxdataF[ant][symbol_offset]; for (int p_index = 0; p_index < N_ap; p_index++) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 6b62fe4f84e7ea76343b4d064e906e8baffd2236..9d0982689bc94ad4c68f292a4b4bb4193b5427ca 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -122,7 +122,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, int sample_offsetF, N_RE_prime; NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms; - int32_t **txdataF = UE->common_vars.txdataF; + c16_t **txdataF = UE->common_vars.txdataF; int N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig uint16_t number_dmrs_symbols = 0; @@ -595,8 +595,8 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, uint8_t n_antenna_ports) { int tx_offset, ap; - int32_t **txdata; - int32_t **txdataF; + c16_t **txdata; + c16_t **txdataF; /////////////////////////IFFT/////////////////////// /////////// @@ -616,7 +616,7 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, int symb_offset = (slot%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot; for(ap = 0; ap < n_antenna_ports; ap++) { for (int s=0;s<NR_NUMBER_OF_SYMBOLS_PER_SLOT;s++){ - c16_t *this_symbol = (c16_t *)&txdataF[ap][frame_parms->ofdm_symbol_size * s]; + c16_t *this_symbol = &txdataF[ap][frame_parms->ofdm_symbol_size * s]; c16_t rot=frame_parms->symbol_rotation[1][s + symb_offset]; LOG_D(PHY,"rotating txdataF symbol %d (%d) => (%d.%d)\n", s, @@ -643,8 +643,8 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, for (ap = 0; ap < n_antenna_ports; ap++) { if (frame_parms->Ncp == 1) { // extended cyclic prefix - PHY_ofdm_mod(txdataF[ap], - &txdata[ap][tx_offset], + PHY_ofdm_mod((int *)txdataF[ap], + (int *)&txdata[ap][tx_offset], frame_parms->ofdm_symbol_size, 12, frame_parms->nb_prefix_samples, diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index 9031ad3f12b5b6ae54af29bce3b1db4a51d6423d..fbb4a8a625caf5c5086df0a1c9043a584e2408c4 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -512,7 +512,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) { NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms); int synchro_position; - int **rxdata = NULL; + c16_t **rxdata = NULL; int fo_flag = PHY_vars_UE->UE_fo_compensation; // flag to enable freq offset estimation and compensation VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PSS_SYNCHRO_NR, VCD_FUNCTION_IN); @@ -524,10 +524,10 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) if (rate_change != 1) { - rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*)); + rxdata = (c16_t**)malloc16(frame_parms->nb_antennas_rx * sizeof(c16_t*)); - for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) { - rxdata[aa] = (int32_t*) malloc16_clear( (frame_parms->samples_per_frame+8192)*sizeof(int32_t)); + for (int aa = 0; aa < frame_parms->nb_antennas_rx; aa++) { + rxdata[aa] = (c16_t*)malloc16_clear((frame_parms->samples_per_frame + 8192) * sizeof(c16_t)); } #ifdef SYNCHRO_DECIMAT @@ -651,7 +651,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) * *********************************************************************/ -int pss_search_time_nr(int **rxdata, ///rx data in time domain +int pss_search_time_nr(c16_t **rxdata, ///rx data in time domain NR_DL_FRAME_PARMS *frame_parms, int fo_flag, int is, @@ -701,7 +701,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain for (ar=0; ar<frame_parms->nb_antennas_rx; ar++) { /* perform correlation of rx data and pss sequence ie it is a dot product */ - const c32_t result = dot_product((c16_t *)primary_synchro_time_nr[pss_index], (c16_t *)&(rxdata[ar][n + is * frame_parms->samples_per_frame]), frame_parms->ofdm_symbol_size, shift); + const c32_t result = dot_product((c16_t *)primary_synchro_time_nr[pss_index], &(rxdata[ar][n + is * frame_parms->samples_per_frame]), frame_parms->ofdm_symbol_size, shift); const c64_t r64 = {.r = result.r, .i = result.i}; pss_corr_ue += squaredMod(r64); //((short*)pss_corr_ue[pss_index])[2*n] += ((short*) &result)[0]; /* real part */ @@ -731,11 +731,11 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain // Shoujun Huang, Yongtao Su, Ying He and Shan Tang, "Joint time and frequency offset estimation in LTE downlink," 7th International Conference on Communications and Networking in China, 2012. // Computing cross-correlation at peak on half the symbol size for first half of data - c32_t r1 = dot_product((c16_t *)primary_synchro_time_nr[pss_source], (c16_t *)&(rxdata[0][peak_position + is * frame_parms->samples_per_frame]), frame_parms->ofdm_symbol_size >> 1, shift); + c32_t r1 = dot_product((c16_t *)primary_synchro_time_nr[pss_source], &(rxdata[0][peak_position + is * frame_parms->samples_per_frame]), frame_parms->ofdm_symbol_size >> 1, shift); // Computing cross-correlation at peak on half the symbol size for data shifted by half symbol size // as it is real and complex it is necessary to shift by a value equal to symbol size to obtain such shift c32_t r2 = dot_product((c16_t *)primary_synchro_time_nr[pss_source] + (frame_parms->ofdm_symbol_size >> 1), - (c16_t *)&(rxdata[0][peak_position + is * frame_parms->samples_per_frame]) + (frame_parms->ofdm_symbol_size >> 1), + &(rxdata[0][peak_position + is * frame_parms->samples_per_frame]) + (frame_parms->ofdm_symbol_size >> 1), frame_parms->ofdm_symbol_size >> 1, shift); cd_t r1d = {r1.r, r1.i}, r2d = {r2.r, r2.i}; diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index 10d7b7d98d3444b894ab8ecb47e02908e95cd91e..b443c4dfbf6fc99fdc0f5ff813932faaf8344c50 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -51,7 +51,7 @@ //#define ONE_OVER_SQRT2 23170 // 32767/sqrt(2) = 23170 (ONE_OVER_SQRT2) void nr_generate_pucch0(PHY_VARS_NR_UE *ue, - int32_t **txdataF, + c16_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, int16_t amp, int nr_slot_tx, @@ -169,7 +169,7 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue, } void nr_generate_pucch1(PHY_VARS_NR_UE *ue, - int32_t **txdataF, + c16_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, int16_t amp, int nr_slot_tx, @@ -955,7 +955,7 @@ static void nr_uci_encoding(uint64_t payload, } //#if 0 void nr_generate_pucch2(PHY_VARS_NR_UE *ue, - int32_t **txdataF, + c16_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, int16_t amp, int nr_slot_tx, @@ -1125,7 +1125,7 @@ void nr_generate_pucch2(PHY_VARS_NR_UE *ue, } //#if 0 void nr_generate_pucch3_4(PHY_VARS_NR_UE *ue, - int32_t **txdataF, + c16_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, int16_t amp, int nr_slot_tx, diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h index 078a95605f59f36bb561e9fbf564122a0b1d0e5b..7eb836505ee22ad22ff8606a78999ef9e1e2bf3c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h @@ -46,28 +46,28 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue, - int32_t **txdataF, + c16_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, int16_t amp, int nr_slot_tx, fapi_nr_ul_config_pucch_pdu *pucch_pdu); void nr_generate_pucch1(PHY_VARS_NR_UE *ue, - int32_t **txdataF, + c16_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, int16_t amp, int nr_slot_tx, fapi_nr_ul_config_pucch_pdu *pucch_pdu); void nr_generate_pucch2(PHY_VARS_NR_UE *ue, - int32_t **txdataF, + c16_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, int16_t amp, int nr_slot_tx, fapi_nr_ul_config_pucch_pdu *pucch_pdu); void nr_generate_pucch3_4(PHY_VARS_NR_UE *ue, - int32_t **txdataF, + c16_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, int16_t amp, int nr_slot_tx, diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c index 5e60ae29407502b266dfcb8f7aff69f588e07642..7b602c2e81ae7208c7425fed852102c45d16fa57 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c @@ -471,7 +471,7 @@ int ue_srs_procedures_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc) NR_DL_FRAME_PARMS *frame_parms = &(ue->frame_parms); uint16_t symbol_offset = (frame_parms->symbols_per_slot - 1 - srs_config_pdu->time_start_position)*frame_parms->ofdm_symbol_size; - if (generate_srs_nr(srs_config_pdu, frame_parms, ue->common_vars.txdataF, symbol_offset, ue->nr_srs_info, + if (generate_srs_nr(srs_config_pdu, frame_parms, (int32_t **)ue->common_vars.txdataF, symbol_offset, ue->nr_srs_info, AMP, proc->frame_tx, proc->nr_slot_tx) == 0) { return 0; } else { diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 9c338b5d3f09b9821f708a17b059d753273f701e..2badbd0868ed252bc0824df2008559f371fdfede 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -265,13 +265,13 @@ typedef struct { /// \brief Pointers (dynamic) to the received data in the frequency domain. /// - first index: rx antenna [0..nb_antennas_rx[ /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ - int32_t **rxdataF; + c16_t **rxdataF; /// \brief holds the transmit data in the frequency domain. /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. //? /// - first index: eNB id [0..2] (hard coded) /// - second index: tx antenna [0..14[ where 14 is the total supported antenna ports. /// - third index: sample [0..samples_per_frame_woCP] - int32_t **txdataF; + c16_t **txdataF; /// \brief Anaglogue beam ID for each OFDM symbol (used when beamforming not done in RU) /// - first index: antenna port /// - second index: beam_id [0.. symbols_per_frame[ diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index e8259b5dae06e03e05375cd4254da454b102eb03..79e75ee3250435bccbc64d625d8531cc6c251ad7 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -217,18 +217,24 @@ typedef struct { /// For IFFT_FPGA this points to the same memory as PHY_vars->tx_vars[a].TX_DMA_BUFFER. /// - first index: tx antenna [0..nb_antennas_tx[ /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES[ - int32_t **txdata; + c16_t **txdata; /// \brief Holds the transmit data in the frequency domain. /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. /// - first index: tx antenna [0..nb_antennas_tx[ /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX[ - int32_t **txdataF; + c16_t **txdataF; /// \brief Holds the received data in time domain. /// Should point to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. /// - first index: rx antenna [0..nb_antennas_rx[ /// - second index: sample [0..2*FRAME_LENGTH_COMPLEX_SAMPLES+2048[ - int32_t **rxdata; + c16_t **rxdata; + + /// \brief Holds the received data in time domain. + /// Should point to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: sample [0..2*FRAME_LENGTH_COMPLEX_SAMPLES+2048[ + c16_t **rxdataF; /// holds output of the sync correlator int32_t *sync_corr; diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index 551bc60d950b2e272b2ed085b0d8d36f0e408c59..08ed56db8d8ac9169be1e17ccc2e8c1d0ac94fbd 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -212,8 +212,8 @@ void nr_feptx_prec(RU_t *ru,int frame_tx,int tti_tx) { bw = ru->beam_weights[0]; for (l=0;l<fp->symbols_per_slot;l++) { for (aa=0;aa<ru->nb_tx;aa++) { - nr_beam_precoding(ru->common.txdataF, - ru->common.txdataF_BF, + nr_beam_precoding((c16_t **)ru->common.txdataF, + (c16_t **)ru->common.txdataF_BF, fp, bw, tti_tx, @@ -307,8 +307,8 @@ void nr_feptx(void *arg) { AssertFatal(1==0,"This needs to be fixed, do not use beamforming.\n"); int32_t ***bw = ru->beam_weights[0]; for(int i=0; i<fp->symbols_per_slot; ++i){ - nr_beam_precoding(ru->gNB_list[0]->common_vars.txdataF, - ru->common.txdataF_BF, + nr_beam_precoding((c16_t **)ru->gNB_list[0]->common_vars.txdataF, + (c16_t **)ru->common.txdataF_BF, fp, bw, slot, diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index f1a4c518a2f83dc9f7f11b592cad6f3f84ca3cba..fc36ad3f79edb6fed94c439542645c46afda0ac8 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -55,7 +55,7 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_ NR_DL_FRAME_PARMS *fp=&gNB->frame_parms; nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; - int **txdataF = gNB->common_vars.txdataF; + c16_t **txdataF = gNB->common_vars.txdataF; uint8_t ssb_index, n_hf; uint16_t ssb_start_symbol; int txdataF_offset = slot*fp->samples_per_slot_wCP; @@ -170,7 +170,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_PDCCH_TX,1); nr_generate_dci_top(msgTx, slot, - &gNB->common_vars.txdataF[0][txdataF_offset], + (int32_t *)&gNB->common_vars.txdataF[0][txdataF_offset], AMP, fp); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_PDCCH_TX,0); @@ -188,7 +188,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, if (csirs->active == 1) { LOG_D(PHY, "CSI-RS generation started in frame %d.%d\n",frame,slot); nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params = &csirs->csirs_pdu.csi_rs_pdu_rel15; - nr_generate_csi_rs(&gNB->frame_parms, gNB->common_vars.txdataF, AMP, gNB->nr_csi_info, csi_params, slot, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + nr_generate_csi_rs(&gNB->frame_parms, (int32_t **)gNB->common_vars.txdataF, AMP, gNB->nr_csi_info, csi_params, slot, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); csirs->active = 0; } } @@ -197,7 +197,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, //apply the OFDM symbol rotation here for (aa=0; aa<cfg->carrier_config.num_tx_ant.value; aa++) { - apply_nr_rotation(fp,(int16_t*) &gNB->common_vars.txdataF[aa][txdataF_offset],slot,0,fp->Ncp==EXTENDED?12:14); + apply_nr_rotation(fp, &gNB->common_vars.txdataF[aa][txdataF_offset], slot, 0, fp->Ncp == EXTENDED ? 12 : 14); T(T_GNB_PHY_DL_OUTPUT_SIGNAL, T_INT(0), T_INT(frame), T_INT(slot), @@ -707,7 +707,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { const int soffset = (slot_rx&3) * gNB->frame_parms.symbols_per_slot * gNB->frame_parms.ofdm_symbol_size; int offset = 10*gNB->frame_parms.ofdm_symbol_size + gNB->frame_parms.first_carrier_offset; - int power_rxF = signal_energy_nodc(&gNB->common_vars.rxdataF[0][soffset+offset+(47*12)],12*18); + int power_rxF = signal_energy_nodc((int32_t *)&gNB->common_vars.rxdataF[0][soffset+offset+(47*12)],12*18); LOG_D(PHY,"frame %d, slot %d: UL signal energy %d\n",frame_rx,slot_rx,power_rxF); start_meas(&gNB->phy_proc_rx); @@ -736,7 +736,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu_format0 = &gNB->uci_pdu_list[num_ucis].pucch_pdu_format_0_1; offset = pucch_pdu->start_symbol_index*gNB->frame_parms.ofdm_symbol_size + (gNB->frame_parms.first_carrier_offset+pucch_pdu->prb_start*12); - power_rxF = signal_energy_nodc(&gNB->common_vars.rxdataF[0][soffset+offset],12); + power_rxF = signal_energy_nodc((int32_t *)&gNB->common_vars.rxdataF[0][soffset+offset],12); LOG_D(PHY,"frame %d, slot %d: PUCCH signal energy %d\n",frame_rx,slot_rx,power_rxF); nr_decode_pucch0(gNB, diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 077490c3a955be817f8b820b9c92a30ea448583d..80ff799ab06343721dbaf4afda93a4f53341be10 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -137,7 +137,7 @@ void update_dmrs_config(NR_CellGroupConfig_t *scg, int8_t* dmrs_arg); extern void fix_scd(NR_ServingCellConfig_t *scd);// forward declaration /* specific dlsim DL preprocessor: uses rbStart/rbSize/mcs/nrOfLayers from command line of dlsim */ -int g_mcsIndex = -1, g_mcsTableIdx = 0, g_rbStart = -1, g_rbSize = -1, g_nrOfLayers = 1; +int g_mcsIndex = -1, g_mcsTableIdx = 0, g_rbStart = -1, g_rbSize = -1, g_nrOfLayers = 1, g_pmi = 0; void nr_dlsim_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot) { @@ -183,6 +183,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, sched_pdsch->rbSize = g_rbSize; sched_pdsch->mcs = g_mcsIndex; sched_pdsch->nrOfLayers = g_nrOfLayers; + sched_pdsch->pm_index = g_pmi; /* the following might override the table that is mandated by RRC * configuration */ current_BWP->mcsTableIdx = g_mcsTableIdx; @@ -235,8 +236,39 @@ nrUE_params_t *get_nrUE_params(void) { return &nrUE_params; } -void do_nothing(void *args) { + +void validate_input_pmi(rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts, int nrOfLayers, int pmi) +{ + if (pmi == 0) + return; + + int num_antenna_ports = pdsch_AntennaPorts.N1 * pdsch_AntennaPorts.N2 * pdsch_AntennaPorts.XP; + int N1 = pdsch_AntennaPorts.N1; + int N2 = pdsch_AntennaPorts.N2; + int O1 = N1 > 1 ? 4 : 1; + int O2 = N2 > 1 ? 4 : 1; + int K1, K2; + if (num_antenna_ports > 2) + get_K1_K2(N1, N2, &K1, &K2); + else { + K1 = 1; K2 = 1; + } + int num_pmi = 1; // pmi = 0 is the identity matrix + switch (nrOfLayers) { + case 1 : + num_pmi += N1 * O1 * N2 * O2 * 4; + AssertFatal(pmi < num_pmi, "Input PMI index %d exceeds the limit of configured matrices %d for %d layers\n", pmi, num_pmi, nrOfLayers); + return; + case 2 : + num_pmi += N1 * O1 * N2 * O2 * K1 * K2 * 2; + AssertFatal(pmi < num_pmi, "Input PMI index %d exceeds the limit of conigured matrices %d for %d layers\n", pmi, num_pmi, nrOfLayers); + break; + default : + AssertFatal(false, "Precoding with more than 2 nrOfLayers not yet supported\n"); + } } + + int NB_UE_INST = 1; int main(int argc, char **argv) @@ -250,7 +282,7 @@ int main(int argc, char **argv) //float psnr; float eff_tp_check = 0.7; uint32_t TBS = 0; - int **txdata; + c16_t **txdata; double **s_re,**s_im,**r_re,**r_im; //double iqim = 0.0; //unsigned char pbch_pdu[6]; @@ -327,7 +359,7 @@ int main(int argc, char **argv) FILE *scg_fd=NULL; - while ((c = getopt(argc, argv, "f:hA:pf:g:i:n:s:S:t:v:x:y:z:M:N:F:GR:d:PI:L:a:b:e:m:w:T:U:q:X:Y")) != -1) { + while ((c = getopt(argc, argv, "f:hA:p:f:g:i:n:s:S:t:v:x:y:z:M:N:F:GR:d:PI:L:a:b:e:m:w:T:U:q:X:Y")) != -1) { switch (c) { case 'f': scg_fd = fopen(optarg,"r"); @@ -404,35 +436,19 @@ int main(int argc, char **argv) printf("Setting SNR1 to %f\n",snr1); break; - /* - case 't': - Td= atof(optarg); - break; - */ - /*case 'p': - extended_prefix_flag=1; - break;*/ - - /* - case 'r': - ricean_factor = pow(10,-.1*atof(optarg)); - if (ricean_factor>1) { - printf("Ricean factor must be between 0 and 1\n"); - exit(-1); - } - break; - */ case 'x': - g_nrOfLayers=atoi(optarg); + g_nrOfLayers = atoi(optarg); - if ((g_nrOfLayers==0) || - (g_nrOfLayers>4)) { - printf("Unsupported nr Of Layers %d\n",g_nrOfLayers); + if ((g_nrOfLayers == 0) || (g_nrOfLayers > 4)) { + printf("Unsupported nr Of Layers %d\n", g_nrOfLayers); exit(-1); } - break; + case 'p': + g_pmi = atoi(optarg); + break; + case 'v': num_rounds = atoi(optarg); @@ -559,6 +575,7 @@ int main(int argc, char **argv) printf("-y Number of TX antennas used in gNB\n"); printf("-z Number of RX antennas used in UE\n"); printf("-x Num of layer for PDSCH\n"); + printf("-p Precoding matrix index\n"); printf("-i Change channel estimation technique. Arguments list: Frequency domain {0:Linear interpolation, 1:PRB based averaging}, Time domain {0:Estimates of last DMRS symbol, 1:Average of DMRS symbols}\n"); //printf("-j Relative strength of second intefering gNB (in dB) - cell_id mod 3 = 2\n"); printf("-R N_RB_DL\n"); @@ -688,6 +705,8 @@ int main(int argc, char **argv) gNB->ap_N2 = pdsch_AntennaPorts.N2; gNB->ap_XP = pdsch_AntennaPorts.XP; + validate_input_pmi(pdsch_AntennaPorts, g_nrOfLayers, g_pmi); + NR_UE_NR_Capability_t* UE_Capability_nr = CALLOC(1,sizeof(NR_UE_NR_Capability_t)); prepare_sim_uecap(UE_Capability_nr,scc,mu, N_RB_DL,g_mcsTableIdx); @@ -1031,8 +1050,8 @@ int main(int argc, char **argv) for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) { if (cyclic_prefix_type == 1) { - PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][txdataF_offset], - &txdata[aa][tx_offset], + PHY_ofdm_mod((int *)&gNB->common_vars.txdataF[aa][txdataF_offset], + (int *)&txdata[aa][tx_offset], frame_parms->ofdm_symbol_size, 12, frame_parms->nb_prefix_samples, @@ -1062,7 +1081,7 @@ int main(int argc, char **argv) int txlev_sum = 0; int l_ofdm = 6; for (aa=0; aa<n_tx; aa++) { - txlev[aa] = signal_energy(&txdata[aa][tx_offset+l_ofdm*frame_parms->ofdm_symbol_size + (l_ofdm-1)*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], + txlev[aa] = signal_energy((int32_t *)&txdata[aa][tx_offset+l_ofdm*frame_parms->ofdm_symbol_size + (l_ofdm-1)*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); txlev_sum += txlev[aa]; if (n_trials==1) printf("txlev[%d] = %d (%f dB) txlev_sum %d\n",aa,txlev[aa],10*log10((double)txlev[aa]),txlev_sum); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index f127c74818a83b9325f2019139ee6a2be9b60fef..ee67e8d52ed633630695cf755100704c4f5015b9 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -636,12 +636,12 @@ int main(int argc, char **argv) for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) { if (cyclic_prefix_type == 1) { apply_nr_rotation(frame_parms, - (int16_t*)gNB->common_vars.txdataF[aa], + gNB->common_vars.txdataF[aa], slot, 0, 12); - PHY_ofdm_mod(gNB->common_vars.txdataF[aa], + PHY_ofdm_mod((int *)gNB->common_vars.txdataF[aa], &txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)], frame_parms->ofdm_symbol_size, 12, @@ -649,7 +649,7 @@ int main(int argc, char **argv) CYCLIC_PREFIX); } else { apply_nr_rotation(frame_parms, - (int16_t*)gNB->common_vars.txdataF[aa], + gNB->common_vars.txdataF[aa], slot, 0, 14); @@ -659,14 +659,14 @@ int main(int argc, char **argv) 14, frame_parms);*/ - PHY_ofdm_mod(gNB->common_vars.txdataF[aa], + PHY_ofdm_mod((int *)gNB->common_vars.txdataF[aa], (int*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)], frame_parms->ofdm_symbol_size, 1, frame_parms->nb_prefix_samples0, CYCLIC_PREFIX); - PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][frame_parms->ofdm_symbol_size], + PHY_ofdm_mod((int *)&gNB->common_vars.txdataF[aa][frame_parms->ofdm_symbol_size], (int*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)+frame_parms->nb_prefix_samples0+frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size, 13, diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index cd346ded3abf34e775810e693aa8ec42a106fcfd..d72bf2ed4f8eb0dc38b9235f3ed5a06d00dc1a3f 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -129,7 +129,8 @@ int main(int argc, char **argv){ double sigma2, sigma2_dB = 0, SNR, snr0 = -2.0, snr1 = 0.0, ue_speed0 = 0.0, ue_speed1 = 0.0; double **s_re, **s_im, **r_re, **r_im, iqim = 0.0, delay_avg = 0, ue_speed = 0, fs=-1, bw; - int i, l, aa, aarx, **txdata, trial, n_frames = 1, prach_start, rx_prach_start; //, ntrials=1; + int i, l, aa, aarx, trial, n_frames = 1, prach_start, rx_prach_start; //, ntrials=1; + c16_t **txdata; int N_RB_UL = 106, delay = 0, NCS_config = 13, rootSequenceIndex = 1, threequarter_fs = 0, mu = 1, fd_occasion = 0, loglvl = OAILOG_INFO, numRA = 0, prachStartSymbol = 0; uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format=0; uint8_t config_index = 98, prach_sequence_length = 1, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol; @@ -759,8 +760,8 @@ int main(int argc, char **argv){ for (l = 0; l < frame_parms->symbols_per_slot; l++) { for (aa = 0; aa < frame_parms->nb_antennas_rx; aa++) { nr_slot_fep_ul(frame_parms, - ru->common.rxdata[aa], - ru->common.rxdataF[aa], + (int32_t *)ru->common.rxdata[aa], + (int32_t *)ru->common.rxdataF[aa], l, slot, ru->N_TA_offset); diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 29a8b7cbe6be1233628f2e13fe6a6ecbbee0b935..68ba96ab88365b60d62c3910ba5866ddca4826ea 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -415,7 +415,7 @@ int main(int argc, char **argv) /* RU handles rxdataF, and gNB just has a pointer. Here, we don't have an RU, * so we need to allocate that memory as well. */ for (i = 0; i < n_rx; i++) - gNB->common_vars.rxdataF[i] = malloc16_clear(gNB->frame_parms.samples_per_frame_wCP*sizeof(int32_t)); + gNB->common_vars.rxdataF[i] = malloc16_clear(gNB->frame_parms.samples_per_frame_wCP*sizeof(c16_t)); double fs,txbw,rxbw; uint32_t samples; @@ -523,7 +523,7 @@ int main(int argc, char **argv) ack_nack_errors=0; sr_errors=0; n_errors = 0; - int **txdataF = gNB->common_vars.txdataF; + c16_t **txdataF = gNB->common_vars.txdataF; for (trial=0; trial<n_trials; trial++) { for (int aatx=0;aatx<1;aatx++) bzero(txdataF[aatx],frame_parms->ofdm_symbol_size*sizeof(int)); @@ -538,7 +538,7 @@ int main(int argc, char **argv) // SNR Computation // standard says: SNR = S / N, where S is the total signal energy, N is the noise energy in the transmission bandwidth (i.e. N_RB_DL resource blocks) // txlev = S. - int txlev = signal_energy(&txdataF[0][startingSymbolIndex*frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size); + int txlev = signal_energy((int32_t *)&txdataF[0][startingSymbolIndex*frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size); // sigma2 is variance per dimension, so N/(N_RB*12) // so, sigma2 = N/(N_RB_DL*12) => (S/SNR)/(N_RB*12) @@ -548,7 +548,7 @@ int main(int argc, char **argv) if (n_trials==1) printf("txlev %d (%f dB), offset %d, sigma2 %f ( %f dB)\n",txlev,10*log10(txlev),startingSymbolIndex*frame_parms->ofdm_symbol_size,sigma2,sigma2_dB); - c16_t **rxdataF = (struct complex16 **)gNB->common_vars.rxdataF; + c16_t **rxdataF = gNB->common_vars.rxdataF; for (int symb=0; symb<gNB->frame_parms.symbols_per_slot;symb++) { if (symb<startingSymbolIndex || symb >= startingSymbolIndex+nrofSymbols) { int i0 = symb*gNB->frame_parms.ofdm_symbol_size; @@ -669,7 +669,7 @@ int main(int argc, char **argv) free(uci_pdu.harq); } else if (format==1) { - nr_decode_pucch1((int32_t **)rxdataF,PUCCH_GroupHopping,hopping_id, + nr_decode_pucch1((c16_t **)rxdataF,PUCCH_GroupHopping,hopping_id, &(payload_received),frame_parms,amp,nr_slot_tx, m0,nrofSymbols,startingSymbolIndex,startingPRB, startingPRB_intraSlotHopping,timeDomainOCC,nr_bit); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index cdeba14486e8af015b1820c8b465c6275049eb97..4ec8fc3ccacef03011071d6e5885f998a63bff38 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -1272,8 +1272,8 @@ int main(int argc, char **argv) for(uint8_t symbol = 0; symbol < (gNB->frame_parms.Ncp == EXTENDED ? 12 : 14); symbol++) { for (int aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) nr_slot_fep_ul(&gNB->frame_parms, - (int32_t*) rxdata[aa], - gNB->common_vars.rxdataF[aa], + (int32_t *)rxdata[aa], + (int32_t *)gNB->common_vars.rxdataF[aa], symbol, slot, 0); diff --git a/openair1/SIMULATION/TOOLS/multipath_channel.c b/openair1/SIMULATION/TOOLS/multipath_channel.c index 433021970684ad678c6b0248577346eab2e4f024..22cd5ce01c1643d6a35385784434e9748b84d6ef 100644 --- a/openair1/SIMULATION/TOOLS/multipath_channel.c +++ b/openair1/SIMULATION/TOOLS/multipath_channel.c @@ -220,15 +220,18 @@ void __attribute__ ((no_sanitize_address)) multipath_channel(channel_desc_t *des rx_tmp.r += (tx.r * chan[l].r) - (tx.i * chan[l].i); rx_tmp.i += (tx.i * chan[l].r) + (tx.r * chan[l].i); } + #if 0 if (i==0 && log_channel == 1) { printf("channel[%d][%d][%d] = %f dB \t(%e, %e)\n", ii, j, l, 10 * log10(pow(chan[l].r, 2.0) + pow(chan[l].i, 2.0)), chan[l].r, chan[l].i); } + #endif } //l } // j - +#if 0 if (desc->max_Doppler != 0.0) rx_tmp = cdMul(rx_tmp, cexp_doppler[i]); +#endif #ifdef DOPPLER_DEBUG printf("[k %2i] cexp_doppler = (%7.4f, %7.4f), abs(cexp_doppler) = %.4f\n", diff --git a/openair2/COMMON/rrc_messages_def.h b/openair2/COMMON/rrc_messages_def.h index 35caf3c34274b8603fb4e9fccce25c8b924b88e7..d93f07d8f8c78e0abf763c0ce8c808dfd4083893 100644 --- a/openair2/COMMON/rrc_messages_def.h +++ b/openair2/COMMON/rrc_messages_def.h @@ -81,5 +81,3 @@ MESSAGE_DEF(RRC_SUBFRAME_PROCESS, MESSAGE_PRIORITY_MED, RrcSubframeP // eNB: RLC -> RRC messages MESSAGE_DEF(RLC_SDU_INDICATION, MESSAGE_PRIORITY_MED, RlcSduIndication, rlc_sdu_indication) - -MESSAGE_DEF(NR_DU_RRC_DL_INDICATION, MESSAGE_PRIORITY_MED, NRDuDlReq_t, nr_du_dl_req) diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c index c10571c4e881288db40fce23d307df88c53ed9e7..c2fefec662648118268d7bc52a6b3bf27c386484 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c @@ -139,19 +139,7 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, .rnti = f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id), .srb_id = srb_id }; - int rc = dl_rrc_message(instance, &dl_rrc); - if (rc == 0) - return 0; /* has been handled, otherwise continue below */ - - // decode RRC Container and act on the message type - AssertFatal(srb_id<3,"illegal srb_id\n"); - MessageDef *msg = itti_alloc_new_message(TASK_DU_F1, 0, NR_DU_RRC_DL_INDICATION); - NRDuDlReq_t *req=&NRDuDlReq(msg); - req->rnti=f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id); - req->srb_id=srb_id; - req->buf= get_free_mem_block( ie->value.choice.RRCContainer.size, __func__); - memcpy(req->buf->data, ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size); - itti_send_msg_to_task(TASK_RRC_GNB, instance, msg); + dl_rrc_message(instance, &dl_rrc); return 0; } diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index ac55771b0e6f202282a216eec335d2344197eb4e..38ae19c72a6c56ff587344b7fbdbb081cf99e5fd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -141,8 +141,7 @@ void process_phr_Config(NR_UE_sched_ctrl_t *sched_ctrl,NR_SetupRelease_PHR_Confi void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl) { AssertFatal(CellGroup, "CellGroup is null\n"); - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = CellGroup->mac_CellGroupConfig; - + NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = CellGroup->mac_CellGroupConfig; if (mac_CellGroupConfig) { process_drx_Config(sched_ctrl,mac_CellGroupConfig->drx_Config); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index c7d5b8614c3b5fdfd3ac67a26112640fb5d66da1..7981db7522ad869d2f79b06c519b8edfac2f7494 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2908,30 +2908,16 @@ void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCom } } -void send_initial_ul_rrc_message(module_id_t module_id, - int CC_id, - int rnti, - int uid, - const uint8_t *sdu, - sdu_size_t sdu_len) { - const gNB_MAC_INST *mac = RC.nrmac[module_id]; - LOG_W(MAC, - "[RAPROC] Received SDU for CCCH length %d for UE %04x\n", - sdu_len, rnti); - - /* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */ - if (NODE_IS_DU(RC.nrrrc[module_id]->node_type)) - rrc_gNB_create_ue_context(rnti, RC.nrrrc[module_id], rnti); +void send_initial_ul_rrc_message(gNB_MAC_INST *mac, int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *rawUE) +{ + LOG_W(MAC, "[RAPROC] Received SDU for CCCH length %d for UE %04x\n", sdu_len, rnti); - const NR_ServingCellConfigCommon_t *scc = RC.nrrrc[module_id]->carrier.servingcellconfigcommon; - const NR_ServingCellConfig_t *sccd = RC.nrrrc[module_id]->configuration.scd; - NR_CellGroupConfig_t cellGroupConfig = {0}; - fill_initial_cellGroupConfig(uid, &cellGroupConfig, scc, sccd, &RC.nrrrc[module_id]->configuration); + NR_UE_info_t *UE = (NR_UE_info_t *)rawUE; uint8_t du2cu_rrc_container[1024]; asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, - &cellGroupConfig, + UE->CellGroup, du2cu_rrc_container, sizeof(du2cu_rrc_container)); AssertFatal(enc_rval.encoded > 0, @@ -2947,5 +2933,48 @@ void send_initial_ul_rrc_message(module_id_t module_id, .du2cu_rrc_container = (uint8_t *) du2cu_rrc_container, .du2cu_rrc_container_length = (enc_rval.encoded + 7) / 8 }; - mac->mac_rrc.initial_ul_rrc_message_transfer(module_id, &ul_rrc_msg); + mac->mac_rrc.initial_ul_rrc_message_transfer(0, &ul_rrc_msg); +} + +void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t *UE) +{ + /* create this UE's initial CellGroup */ + /* Note: relying on the RRC is a hack, as we are in the DU; there should be + * no RRC, remove in the future */ + module_id_t mod_id = 0; + gNB_RRC_INST *rrc = RC.nrrrc[mod_id]; + const NR_ServingCellConfigCommon_t *scc = rrc->carrier.servingcellconfigcommon; + const NR_ServingCellConfig_t *sccd = rrc->configuration.scd; + NR_CellGroupConfig_t *cellGroupConfig = calloc(1, sizeof(*cellGroupConfig)); + AssertFatal(cellGroupConfig != NULL, "out of memory\n"); + fill_initial_cellGroupConfig(UE->uid, cellGroupConfig, scc, sccd, &rrc->configuration); + + uint8_t du2cu_rrc_container[1024]; + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, + NULL, + cellGroupConfig, + du2cu_rrc_container, + sizeof(du2cu_rrc_container)); + AssertFatal(enc_rval.encoded > 0, + "Could not encode cellGroupConfig for UE %04x, failed element %s\n", + UE->rnti, + enc_rval.failed_type->name); + + UE->CellGroup = cellGroupConfig; + nr_mac_update_cellgroup(mac, UE->rnti, cellGroupConfig); + + /* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */ + if (NODE_IS_DU(rrc->node_type)) { + rrc_gNB_ue_context_t *ue = rrc_gNB_create_ue_context(UE->rnti, rrc, UE->rnti); + ue->ue_context.masterCellGroup = cellGroupConfig; + } + + /* activate SRB0 */ + nr_rlc_activate_srb0(UE->rnti, mac, UE, send_initial_ul_rrc_message); + + /* the cellGroup sent to CU specifies there is SRB1, so create it */ + DevAssert(cellGroupConfig->rlc_BearerToAddModList->list.count == 1); + const NR_RLC_BearerConfig_t *bearer = cellGroupConfig->rlc_BearerToAddModList->list.array[0]; + DevAssert(bearer->servedRadioBearer->choice.srb_Identity == 1); + nr_rlc_add_srb(UE->rnti, DCCH, bearer); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index d6fe0e62332e937b5b34e5f5b1ce75ed1b352aa0..bc86fded1bf0f2f7d33edfe4ed5b2da6b06125fe 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -372,8 +372,9 @@ int nr_process_mac_pdu(instance_t module_idP, mac_len = 6; } - nr_rlc_activate_srb0(UE->rnti, module_idP, CC_id, UE->uid, send_initial_ul_rrc_message); + LOG_W(MAC, "[RAPROC] Received SDU for CCCH length %d for UE %04x\n", mac_len, UE->rnti); + prepare_initial_ul_rrc_message(RC.nrmac[module_idP], UE); mac_rlc_data_ind(module_idP, UE->rnti, module_idP, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 400f2776be94da719083b9a05ce7e9974027de8d..fe880785aaf014f9fec8c77d50be828f71783447 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -486,12 +486,8 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); -void send_initial_ul_rrc_message(module_id_t module_id, - int CC_id, - int rnti, - int uid, - const uint8_t *sdu, - sdu_size_t sdu_len); +void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t *UE); +void send_initial_ul_rrc_message(gNB_MAC_INST *mac, int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *rawUE); void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c index 98d4cf8141e2f8f5760a568b95496b226a68aec3..0a47699591de0670766db89972f695578a541e14 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c @@ -29,96 +29,10 @@ #include "NR_DL-CCCH-Message.h" #include "NR_CellGroupConfig.h" -int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc, NR_RRCSetup_t *rrcSetup); - int dl_rrc_message(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc) { - /* dispatch message to dl_rrc_message_rrcSetup() and others, similar to as is - * done in the DU (should be the same here) */ - - LOG_D(NR_MAC, "DL RRC Message Transfer with %d bytes for RNTI %04x SRB %d\n", dl_rrc->rrc_container_length, dl_rrc->rnti, dl_rrc->srb_id); - - if (dl_rrc->srb_id == CCCH) { // SRB 0 - - NR_DL_CCCH_Message_t *dl_ccch_msg = NULL; - asn_dec_rval_t dec_rval = uper_decode(NULL, - &asn_DEF_NR_DL_CCCH_Message, - (void **) &dl_ccch_msg, - dl_rrc->rrc_container, - dl_rrc->rrc_container_length, - 0, - 0); - AssertFatal(dec_rval.code == RC_OK, "could not decode F1AP message\n"); - - switch (dl_ccch_msg->message.choice.c1->present) { - case NR_DL_CCCH_MessageType__c1_PR_NOTHING: - LOG_W(NR_MAC, "Received NOTHING on DL-CCCH-Message\n"); - break; - case NR_DL_CCCH_MessageType__c1_PR_rrcReject: - LOG_D(NR_MAC, "DL-CCCH/SRB0, received rrcReject for RNTI %04x\n", dl_rrc->rnti); - AssertFatal(0, "rrcReject not implemented yet\n"); - break; - case NR_DL_CCCH_MessageType__c1_PR_rrcSetup: - LOG_D(NR_MAC, "DL-CCCH/SRB0, received rrcSetup for RNTI %04x\n", dl_rrc->rnti); - return dl_rrc_message_rrcSetup(module_id, dl_rrc, dl_ccch_msg->message.choice.c1->choice.rrcSetup); - break; - case NR_DL_CCCH_MessageType__c1_PR_spare2: - LOG_W(NR_MAC, "DL-CCCH/SRB0, received spare2\n"); - break; - case NR_DL_CCCH_MessageType__c1_PR_spare1: - LOG_W(NR_MAC, "DL-CCCH/SRB0, received spare1\n"); - break; - default: - AssertFatal(0 == 1, "Unknown DL-CCCH/SRB0 message %d\n", dl_ccch_msg->message.choice.c1->present); - break; - } - return 0; - } else if (dl_rrc->srb_id == DCCH) { // SRB 1 - nr_rlc_srb_recv_sdu(dl_rrc->rnti, DCCH, dl_rrc->rrc_container, dl_rrc->rrc_container_length); - return 0; - } else if (dl_rrc->srb_id == DCCH1) { // SRB 2 - nr_rlc_srb_recv_sdu(dl_rrc->rnti, DCCH1, dl_rrc->rrc_container, dl_rrc->rrc_container_length); - return 0; - } - - return -1; /* not handled yet */ -} - -int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t *dl_rrc, NR_RRCSetup_t *rrcSetup) -{ - DevAssert(rrcSetup != NULL); - - NR_RRCSetup_IEs_t *rrcSetup_ies = rrcSetup->criticalExtensions.choice.rrcSetup; - AssertFatal(rrcSetup_ies->masterCellGroup.buf != NULL,"masterCellGroup is NULL\n"); - NR_CellGroupConfig_t *cellGroup = NULL; - asn_dec_rval_t dec_rval = uper_decode(NULL, - &asn_DEF_NR_CellGroupConfig, - (void **)&cellGroup, - rrcSetup_ies->masterCellGroup.buf, - rrcSetup_ies->masterCellGroup.size, - 0, - 0); - AssertFatal(dec_rval.code == RC_OK, "could not decode masterCellGroup\n"); - - /* there might be a memory leak for the cell group if we call this multiple - * times. */ - nr_mac_update_cellgroup(RC.nrmac[module_id], dl_rrc->rnti, cellGroup); - - /* TODO: drop the RRC context */ - gNB_RRC_INST *rrc = RC.nrrrc[module_id]; - rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, dl_rrc->rnti); - gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; - ue_p->SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList; - ue_p->masterCellGroup = cellGroup; - - nr_rlc_srb_recv_sdu(dl_rrc->rnti, CCCH, dl_rrc->rrc_container, dl_rrc->rrc_container_length); - - protocol_ctxt_t ctxt = {.module_id = module_id, .rntiMaybeUEid = dl_rrc->rnti}; - nr_rrc_rlc_config_asn1_req(&ctxt, - ue_context_p->ue_context.SRB_configList, - NULL, - NULL, - cellGroup->rlc_BearerToAddModList); + LOG_I(NR_MAC, "DL RRC Message Transfer with %d bytes for RNTI %04x SRB %d\n", dl_rrc->rrc_container_length, dl_rrc->rnti, dl_rrc->srb_id); + nr_rlc_srb_recv_sdu(dl_rrc->rnti, dl_rrc->srb_id, dl_rrc->rrc_container, dl_rrc->rrc_container_length); return 0; } diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index 32c3a70ea7bc28cccdaa87a075348e5cba08bfb3..84d4b89b1c4a6aa194676e29ad6b5f3686c9340e 100644 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -184,13 +184,6 @@ rlc_op_status_t rrc_rlc_config_req(const protocol_ctxt_t *const, const srb_flag_ */ rlc_op_status_t rrc_rlc_data_req (const protocol_ctxt_t *const, const MBMS_flag_t, const rb_id_t, mui_t, confirm_t, sdu_size_t, char *); -/*! \fn void rrc_rlc_register_rrc ( void (*rrc_data_indP) (const protocol_ctxt_t* const ctxtP, const rb_id_t rb_idP, sdu_size_t sdu_sizeP, char* sduP), void (*rrc_data_confP) (const protocol_ctxt_t* const ctxtP, const rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP) -* \brief This function is called by RRC to register its DATA-INDICATE and DATA-CONFIRM handlers to RLC layer. -* \param[in] rrc_data_indP Pointer on RRC data indicate function. -* \param[in] rrc_data_confP Pointer on RRC data confirm callback function. -*/ -void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_data_conf_cb_t rrc_data_confP); - //----------------------------------------------------------------------------- // PUBLIC INTERFACE WITH MAC //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 87e3d53ff512d4416f5b360a7206b3e669b6b12e..e4bb7bb4f50e20a559d80735f282a0352c4c65a5 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -1121,7 +1121,7 @@ void nr_DRB_preconfiguration(ue_id_t crntiMaybeUEid) nr_pdcp_add_drbs(ctxt.enb_flag, ctxt.rntiMaybeUEid, 0, rbconfig->drb_ToAddModList, 0, NULL, NULL, Rlc_Bearer_ToAdd_list); - nr_rrc_rlc_config_asn1_req(&ctxt, (NR_SRB_ToAddModList_t *)NULL, rbconfig->drb_ToAddModList, rbconfig->drb_ToReleaseList, Rlc_Bearer_ToAdd_list); + nr_rlc_add_drb(ctxt.rntiMaybeUEid, drb_ToAddMod->drb_Identity, RLC_BearerConfig); LOG_D(PDCP, "%s:%d: done RRC PDCP/RLC ASN1 request for UE ID/RNTI %ld\n", __FUNCTION__, __LINE__, ctxt.rntiMaybeUEid); } diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 60c002537ac9237c1dbbfe43fb8875319b6776a1..dab6f9fe581ceb9710823cb8c70e1179d7949449 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -683,14 +683,13 @@ rb_found: #endif } -static void add_rlc_srb(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig_t *rlc_BearerConfig) +void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig) { nr_rlc_entity_t *nr_rlc_am; nr_rlc_ue_t *ue; struct NR_RLC_Config *r = rlc_BearerConfig->rlc_Config; struct NR_LogicalChannelConfig *l = rlc_BearerConfig->mac_LogicalChannelConfig; - int srb_id = s->srb_Identity; int channel_id = rlc_BearerConfig->logicalChannelIdentity; int logical_channel_group; @@ -774,14 +773,13 @@ static void add_rlc_srb(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig nr_rlc_manager_unlock(nr_rlc_ue_manager); } -static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_t *rlc_BearerConfig) +static void add_drb_am(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig) { nr_rlc_entity_t *nr_rlc_am; nr_rlc_ue_t *ue; struct NR_RLC_Config *r = rlc_BearerConfig->rlc_Config; struct NR_LogicalChannelConfig *l = rlc_BearerConfig->mac_LogicalChannelConfig; - int drb_id = s->drb_Identity; int channel_id = rlc_BearerConfig->logicalChannelIdentity; int logical_channel_group; @@ -856,14 +854,13 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ nr_rlc_manager_unlock(nr_rlc_ue_manager); } -static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_t *rlc_BearerConfig) +static void add_drb_um(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig) { nr_rlc_entity_t *nr_rlc_um; nr_rlc_ue_t *ue; struct NR_RLC_Config *r = rlc_BearerConfig->rlc_Config; struct NR_LogicalChannelConfig *l = rlc_BearerConfig->mac_LogicalChannelConfig; - int drb_id = s->drb_Identity; int channel_id = rlc_BearerConfig->logicalChannelIdentity; int logical_channel_group; @@ -924,14 +921,14 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ nr_rlc_manager_unlock(nr_rlc_ue_manager); } -static void add_drb(int rnti, struct NR_DRB_ToAddMod *s, struct NR_RLC_BearerConfig *rlc_BearerConfig) +void nr_rlc_add_drb(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig) { switch (rlc_BearerConfig->rlc_Config->present) { case NR_RLC_Config_PR_am: - add_drb_am(rnti, s, rlc_BearerConfig); + add_drb_am(rnti, drb_id, rlc_BearerConfig); break; case NR_RLC_Config_PR_um_Bi_Directional: - add_drb_um(rnti, s, rlc_BearerConfig); + add_drb_um(rnti, drb_id, rlc_BearerConfig); break; default: LOG_E(RLC, "%s:%d:%s: fatal: unhandled DRB type\n", @@ -953,96 +950,32 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP return 0; } -rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP, - const NR_SRB_ToAddModList_t * const srb2add_listP, - const NR_DRB_ToAddModList_t * const drb2add_listP, - const NR_DRB_ToReleaseList_t * const drb2release_listP, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list) -{ - int rnti = ctxt_pP->rntiMaybeUEid; - int i; - int j; - - if (/*ctxt_pP->enb_flag != 1 ||*/ ctxt_pP->module_id != 0 /*|| - ctxt_pP->instance != 0 || ctxt_pP->eNB_index != 0 || - ctxt_pP->brOption != 0 */) { - LOG_E(RLC, "%s: ctxt_pP not handled (%d %d %ld %d %d)\n", __FUNCTION__, - ctxt_pP->enb_flag , ctxt_pP->module_id, ctxt_pP->instance, - ctxt_pP->eNB_index, ctxt_pP->brOption); - exit(1); - } - - if (drb2release_listP != NULL) { - LOG_E(RLC, "%s:%d:%s: TODO\n", __FILE__, __LINE__, __FUNCTION__); - //exit(1); - } - - if (srb2add_listP != NULL) { - for (i = 0; i < srb2add_listP->list.count; i++) { - if (rlc_bearer2add_list != NULL) { - for(j = 0; j < rlc_bearer2add_list->list.count; j++){ - if(rlc_bearer2add_list->list.array[j]->servedRadioBearer != NULL){ - if(rlc_bearer2add_list->list.array[j]->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity){ - if(srb2add_listP->list.array[i]->srb_Identity == rlc_bearer2add_list->list.array[j]->servedRadioBearer->choice.srb_Identity){ - add_rlc_srb(rnti, srb2add_listP->list.array[i], rlc_bearer2add_list->list.array[j]); - LOG_D(RLC, "Add srb %ld\n", srb2add_listP->list.array[i]->srb_Identity); - } - } - } - } - } - - } - } - - if ((drb2add_listP != NULL) && (rlc_bearer2add_list != NULL)) { - for (i = 0; i < drb2add_listP->list.count; i++) { - if (rlc_bearer2add_list != NULL) { - for(j = 0; j < rlc_bearer2add_list->list.count; j++){ - if(rlc_bearer2add_list->list.array[j]->servedRadioBearer != NULL){ - if(rlc_bearer2add_list->list.array[j]->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity){ - if(drb2add_listP->list.array[i]->drb_Identity == rlc_bearer2add_list->list.array[j]->servedRadioBearer->choice.drb_Identity){ - add_drb(rnti, drb2add_listP->list.array[i], rlc_bearer2add_list->list.array[j]); - } - } - } - } - } - } - } - - return RLC_OP_STATUS_OK; -} - struct srb0_data { - int module_id; - int CC_id; + struct gNB_MAC_INST_s *mac; int rnti; - int uid; - void (*send_initial_ul_rrc_message)(module_id_t module_id, - int CC_id, - int rnti, - int uid, - const uint8_t *sdu, - sdu_size_t sdu_len); + void *rawUE; + void (*send_initial_ul_rrc_message)(struct gNB_MAC_INST_s *mac, + int rnti, + const uint8_t *sdu, + sdu_size_t sdu_len, + void *rawUE); }; void deliver_sdu_srb0(void *deliver_sdu_data, struct nr_rlc_entity_t *entity, char *buf, int size) { struct srb0_data *s0 = (struct srb0_data *)deliver_sdu_data; - s0->send_initial_ul_rrc_message(s0->module_id, s0->CC_id, s0->rnti, s0->uid, - (unsigned char *)buf, size); + s0->send_initial_ul_rrc_message(s0->mac, s0->rnti, (unsigned char *)buf, + size, s0->rawUE); } -void nr_rlc_activate_srb0(int rnti, int module_id, int cc_id, int uid, +void nr_rlc_activate_srb0(int rnti, struct gNB_MAC_INST_s *mac, void *rawUE, void (*send_initial_ul_rrc_message)( - module_id_t module_id, - int CC_id, - int rnti, - int uid, - const uint8_t *sdu, - sdu_size_t sdu_len)) + struct gNB_MAC_INST_s *mac, + int rnti, + const uint8_t *sdu, + sdu_size_t sdu_len, + void *rawUE)) { nr_rlc_entity_t *nr_rlc_tm; nr_rlc_ue_t *ue; @@ -1051,10 +984,9 @@ void nr_rlc_activate_srb0(int rnti, int module_id, int cc_id, int uid, srb0_data = calloc(1, sizeof(struct srb0_data)); AssertFatal(srb0_data != NULL, "out of memory\n"); - srb0_data->module_id = module_id; - srb0_data->CC_id = cc_id; + srb0_data->mac = mac; srb0_data->rnti = rnti; - srb0_data->uid = uid; + srb0_data->rawUE = rawUE; srb0_data->send_initial_ul_rrc_message = send_initial_ul_rrc_message; nr_rlc_manager_lock(nr_rlc_ue_manager); @@ -1132,11 +1064,6 @@ rlc_op_status_t rrc_rlc_config_req ( return RLC_OP_STATUS_OK; } -void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_data_conf_cb_t rrc_data_confP) -{ - /* nothing to do */ -} - void nr_rlc_remove_ue(int rnti) { LOG_W(RLC, "remove UE %x\n", rnti); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h index f6d280c908d416c9ae912759d2a3626bf4c8f920..38a99dc86f40b016b140c75a1c1da511abe6fedc 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h @@ -36,9 +36,6 @@ #include "NR_CellGroupConfig.h" #include "openair2/RRC/NR/nr_rrc_proto.h" -/* from OAI */ -#include "pdcp.h" - struct NR_RLC_Config; struct NR_LogicalChannelConfig; @@ -48,6 +45,9 @@ void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChannelConfig); +void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig); +void nr_rlc_add_drb(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig); + void nr_rlc_remove_ue(int rnti); int nr_rlc_get_available_tx_space( @@ -61,11 +61,11 @@ void nr_rlc_activate_avg_time_to_tx( void nr_rlc_srb_recv_sdu(const int rnti, const logical_chan_id_t channel_id, unsigned char *buf, int size); -void nr_rlc_activate_srb0(int rnti, int module_id, int cc_id, int uid, +struct gNB_MAC_INST_s; +void nr_rlc_activate_srb0(int rnti, struct gNB_MAC_INST_s *mac, void *rawUE, void (*send_initial_ul_rrc_message)( - module_id_t module_id, - int CC_id, - int rnti, - int uid, - const uint8_t *sdu, - sdu_size_t sdu_len)); + struct gNB_MAC_INST_s *mac, + int rnti, + const uint8_t *sdu, + sdu_size_t sdu_len, + void *rawUE)); diff --git a/openair2/LAYER2/rlc_v2/rlc_oai_api.c b/openair2/LAYER2/rlc_v2/rlc_oai_api.c index d45640bbfa05bfd5309fd373cfbf5efa5af8cad5..3e191595dd1b1440046b64aa3aaa070f8a810067 100644 --- a/openair2/LAYER2/rlc_v2/rlc_oai_api.c +++ b/openair2/LAYER2/rlc_v2/rlc_oai_api.c @@ -976,11 +976,6 @@ rlc_op_status_t rrc_rlc_config_req ( return RLC_OP_STATUS_OK; } -void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_data_conf_cb_t rrc_data_confP) -{ - /* nothing to do */ -} - rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const x) { LOG_D(RLC, "%s:%d:%s: remove UE %ld\n", __FILE__, __LINE__, __FUNCTION__, x->rntiMaybeUEid); diff --git a/openair2/RRC/LTE/rrc_common.c b/openair2/RRC/LTE/rrc_common.c index 5bc27147a9a03011cd6a076389c2d3448b0265ae..7509aeae4fd92400274ee63a9ed441942e9e944a 100644 --- a/openair2/RRC/LTE/rrc_common.c +++ b/openair2/RRC/LTE/rrc_common.c @@ -56,7 +56,6 @@ rrc_init_global_param( ) //----------------------------------------------------------------------------- { - rrc_rlc_register_rrc (rrc_data_ind, NULL); //register with rlc DCCH_LCHAN_DESC.transport_block_size = 4; DCCH_LCHAN_DESC.max_transport_blocks = 16; DCCH_LCHAN_DESC.Delay_class = 1; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 4872e729c8e3899bb3ef40d19e76a58166410cad..283b1b9b79f59f3f32c22dfc15e8ae4f351068c2 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -735,7 +735,7 @@ void fill_initial_SpCellConfig(int uid, initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); config_srs(scc, initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, maxMIMO_Layers, 0); - scheduling_request_config(scc, pucch_Config); + scheduling_request_config(scc, pucch_Config, scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing); set_dl_DataToUL_ACK(pucch_Config, configuration->minRXTXTIME, scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing); @@ -1152,43 +1152,21 @@ void fill_initial_cellGroupConfig(int uid, const NR_ServingCellConfig_t *servingcellconfigdedicated, const gNB_RrcConfigurationReq *configuration) { - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = NULL; - NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig = NULL; - + + NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig = NULL; + cellGroupConfig->cellGroupId = 0; - + /* Rlc Bearer Config */ /* TS38.331 9.2.1 Default SRB configurations */ cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); NR_RLC_BearerConfig_t *rlc_BearerConfig = get_SRB_RLC_BearerConfig(1, 1, NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms1000); asn1cSeqAdd(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); - + cellGroupConfig->rlc_BearerToReleaseList = NULL; - + /* mac CellGroup Config */ - mac_CellGroupConfig = calloc(1, sizeof(*mac_CellGroupConfig)); - - mac_CellGroupConfig->bsr_Config = calloc(1, sizeof(*mac_CellGroupConfig->bsr_Config)); - mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; - mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf80; - mac_CellGroupConfig->tag_Config = calloc(1, sizeof(*mac_CellGroupConfig->tag_Config)); - mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL; - mac_CellGroupConfig->tag_Config->tag_ToAddModList = calloc(1,sizeof(*mac_CellGroupConfig->tag_Config->tag_ToAddModList)); - struct NR_TAG *tag=calloc(1,sizeof(*tag)); - tag->tag_Id = 0; - tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity; - asn1cSeqAdd(&mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag); - set_phr_config(mac_CellGroupConfig); - - mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); - mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); - struct NR_SchedulingRequestToAddMod *schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist)); - schedulingrequestlist->schedulingRequestId = 0; - schedulingrequestlist->sr_ProhibitTimer = NULL; - schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64; - asn1cSeqAdd(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist); - - cellGroupConfig->mac_CellGroupConfig = mac_CellGroupConfig; + cellGroupConfig->mac_CellGroupConfig = configure_mac_cellgroup(); physicalCellGroupConfig = calloc(1,sizeof(*physicalCellGroupConfig)); physicalCellGroupConfig->p_NR_FR1 = NULL; diff --git a/openair2/RRC/NR/nr_rrc_common.c b/openair2/RRC/NR/nr_rrc_common.c index d67d15acc1f2685c1180883e7ac63c7a5b26dde8..1d231f20bfdd2de0f3bbb016e5522bc77a84547b 100644 --- a/openair2/RRC/NR/nr_rrc_common.c +++ b/openair2/RRC/NR/nr_rrc_common.c @@ -50,8 +50,6 @@ extern mui_t rrc_gNB_mui; //----------------------------------------------------------------------------- void rrc_init_nr_srb_param(NR_LCHAN_DESC *chan) { - rrc_rlc_register_rrc (rrc_data_ind, NULL); //register with rlc - chan->transport_block_size = 4; chan->max_transport_blocks = 16; chan->Delay_class = 1; diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index a930dc40ed42c438bef68fabbfee5679c6840b39..3e506b964c126abe5651de2b8ea75ad66dae6eee 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -35,6 +35,35 @@ const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160}; +NR_MAC_CellGroupConfig_t *configure_mac_cellgroup(void) +{ + NR_MAC_CellGroupConfig_t * mac_CellGroupConfig = calloc(1, sizeof(*mac_CellGroupConfig)); + + mac_CellGroupConfig->bsr_Config = calloc(1, sizeof(*mac_CellGroupConfig->bsr_Config)); + mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; + mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf80; + mac_CellGroupConfig->tag_Config = calloc(1, sizeof(*mac_CellGroupConfig->tag_Config)); + mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL; + mac_CellGroupConfig->tag_Config->tag_ToAddModList = calloc(1,sizeof(*mac_CellGroupConfig->tag_Config->tag_ToAddModList)); + struct NR_TAG *tag=calloc(1,sizeof(*tag)); + tag->tag_Id = 0; + tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity; + asn1cSeqAdd(&mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag); + + set_phr_config(mac_CellGroupConfig); + + mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); + mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); + struct NR_SchedulingRequestToAddMod *schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist)); + schedulingrequestlist->schedulingRequestId = 0; + schedulingrequestlist->sr_ProhibitTimer = NULL; + schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64; + asn1cSeqAdd(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist); + + mac_CellGroupConfig->skipUplinkTxDynamic=false; + mac_CellGroupConfig->ext1 = NULL; + return mac_CellGroupConfig; +} NR_SearchSpace_t *rrc_searchspace_config(bool is_common, int searchspaceid, @@ -883,7 +912,7 @@ void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs) { asn1cSeqAdd(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial); } -static void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig, const NR_ServingCellConfigCommon_t *scc) +static void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig, const NR_ServingCellConfigCommon_t *scc, int scs) { const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; int sr_slot = 1; // in FDD SR in slot 1 @@ -892,43 +921,46 @@ static void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedul schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); - if(sr_slot<10){ + if(sr_slot < 10 && scs < NR_SubcarrierSpacing_kHz60){ schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10; schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = sr_slot; return; } - if(sr_slot<20){ + else if(sr_slot < 20 && scs < NR_SubcarrierSpacing_kHz120){ schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20; schedulingRequestResourceConfig->periodicityAndOffset->choice.sl20 = sr_slot; return; } - if(sr_slot<40){ + else if(sr_slot < 40){ schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40; schedulingRequestResourceConfig->periodicityAndOffset->choice.sl40 = sr_slot; return; } - if(sr_slot<80){ + else if(sr_slot < 80 || scs == NR_SubcarrierSpacing_kHz15){ schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80; schedulingRequestResourceConfig->periodicityAndOffset->choice.sl80 = sr_slot; return; } - if(sr_slot<160){ + else if(sr_slot < 160 || scs == NR_SubcarrierSpacing_kHz30){ schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160; schedulingRequestResourceConfig->periodicityAndOffset->choice.sl160 = sr_slot; return; } - if(sr_slot<320){ + else if(sr_slot < 320 || NR_SubcarrierSpacing_kHz60){ schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320; schedulingRequestResourceConfig->periodicityAndOffset->choice.sl320 = sr_slot; return; } - schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640; - schedulingRequestResourceConfig->periodicityAndOffset->choice.sl640 = sr_slot; + else { + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl640 = sr_slot; + } } void scheduling_request_config(const NR_ServingCellConfigCommon_t *scc, - NR_PUCCH_Config_t *pucch_Config) { - + NR_PUCCH_Config_t *pucch_Config, + int scs) +{ // format with <=2 bits in pucch resource set 0 NR_PUCCH_ResourceSet_t *pucchresset = pucch_Config->resourceSetToAddModList->list.array[0]; // assigning the 1st pucch resource in the set to scheduling request @@ -939,7 +971,7 @@ void scheduling_request_config(const NR_ServingCellConfigCommon_t *scc, schedulingRequestResourceConfig->schedulingRequestResourceId = 1; schedulingRequestResourceConfig->schedulingRequestID = 0; - set_SR_periodandoffset(schedulingRequestResourceConfig, scc); + set_SR_periodandoffset(schedulingRequestResourceConfig, scc, scs); schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); *schedulingRequestResourceConfig->resource = *pucchressetid; @@ -1250,7 +1282,7 @@ void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, config_pucch_resset0(pucch_Config, uid, curr_bwp, uecap); config_pucch_resset1(pucch_Config, uecap); set_pucch_power_config(pucch_Config, configuration->do_CSIRS); - scheduling_request_config(scc, pucch_Config); + scheduling_request_config(scc, pucch_Config, ubwp->bwp_Common->genericParameters.subcarrierSpacing); set_dl_DataToUL_ACK(pucch_Config, configuration->minRXTXTIME, ubwp->bwp_Common->genericParameters.subcarrierSpacing); NR_PUSCH_Config_t *pusch_Config = NULL; diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 96b885ed15401cdf3ccb12286d21d81ab5ce1af4..b64f953814305e4d02c5b8b9c41344a576c972dd 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -53,7 +53,8 @@ void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time, NR_SubcarrierSpacing_t subcarrierSpacing); void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs); void scheduling_request_config(const NR_ServingCellConfigCommon_t *scc, - NR_PUCCH_Config_t *pucch_Config); + NR_PUCCH_Config_t *pucch_Config, + int scs); void config_rsrp_meas_report(NR_CSI_MeasConfig_t *csi_MeasConfig, const NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_PUCCH_CSI_Resource_t *pucchcsires, int do_csi, int rep_id, int uid); void config_csi_meas_report(NR_CSI_MeasConfig_t *csi_MeasConfig, const NR_ServingCellConfigCommon_t *servingcellconfigcommon, @@ -104,5 +105,6 @@ void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, const NR_ServingCellConfig_t *servingcellconfigdedicated, const NR_ServingCellConfigCommon_t *scc, NR_UE_NR_Capability_t *uecap); +NR_MAC_CellGroupConfig_t *configure_mac_cellgroup(void); #endif diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 7da8b44af776ad53e8d5a16810ae3619aa286bcb..e53ad606857706a7579dcd636f538ddd307d95cb 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -280,7 +280,6 @@ typedef struct gNB_RRC_UE_s { NR_DRB_ToReleaseList_t *DRB_Release_configList2[NR_RRC_TRANSACTION_IDENTIFIER_NUMBER]; uint8_t DRB_active[NGAP_MAX_DRBS_PER_UE]; - NR_SRB_INFO SI; NR_SRB_INFO_TABLE_ENTRY Srb[maxSRBs]; // 3gpp max is 3 SRBs, number 1..3, we waste the entry 0 for code simplicity NR_MeasConfig_t *measConfig; NR_HANDOVER_INFO *handover_info; @@ -435,7 +434,6 @@ typedef struct { NR_ServingCellConfigCommon_t *servingcellconfigcommon; NR_ServingCellConfig_t *servingcellconfig; NR_CellGroupConfig_t *secondaryCellGroup[MAX_NR_RRC_UE_CONTEXTS]; - NR_SRB_INFO SI; int p_gNB; } rrc_gNB_carrier_data_t; diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index eb2b73a642fe59aead696492358c9a06d46cfaf4..5ad9a71e3950828d5cf7ffe280df9ad898cf22cb 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -177,12 +177,6 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( rrc_gNB_ue_context_t *ue_context_pP, NR_CellGroupConfig_t *cell_groupConfig_from_DU); -rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP, - const NR_SRB_ToAddModList_t * const srb2add_listP, - const NR_DRB_ToAddModList_t * const drb2add_listP, - const NR_DRB_ToReleaseList_t * const drb2release_listP, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); - void bearer_context_setup_direct(e1ap_bearer_setup_req_t *req, instance_t instance); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index e234d48a6a961bf2185acc39dffcb1ca173fb157..a4f57b0faedc344742ef600209afc6036a55e007 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -139,14 +139,47 @@ bool DURecvCb(protocol_ctxt_t *ctxt_pP, return true; } -static void openair_nr_rrc_on(gNB_RRC_INST *rrc) +static void nr_rrc_addmod_srbs(int rnti, + const NR_SRB_ToAddModList_t *srb_list, + const struct NR_CellGroupConfig__rlc_BearerToAddModList *bearer_list) { - NR_SRB_INFO *si = &rrc->carrier.SI; - si->Rx_buffer.payload_size = 0; - si->Tx_buffer.payload_size = 0; - si->Active = 1; + if (srb_list == NULL || bearer_list == NULL) + return; + + for (int i = 0; i < srb_list->list.count; i++) { + const NR_SRB_ToAddMod_t *srb = srb_list->list.array[i]; + for (int j = 0; j < bearer_list->list.count; j++) { + const NR_RLC_BearerConfig_t *bearer = bearer_list->list.array[j]; + if (bearer->servedRadioBearer != NULL + && bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity + && srb->srb_Identity == bearer->servedRadioBearer->choice.srb_Identity) { + nr_rlc_add_srb(rnti, srb->srb_Identity, bearer); + } + } + } +} + +static void nr_rrc_addmod_drbs(int rnti, + const NR_DRB_ToAddModList_t *drb_list, + const struct NR_CellGroupConfig__rlc_BearerToAddModList *bearer_list) +{ + if (drb_list == NULL || bearer_list == NULL) + return; + + for (int i = 0; i < drb_list->list.count; i++) { + const NR_DRB_ToAddMod_t *drb = drb_list->list.array[i]; + for (int j = 0; j < bearer_list->list.count; j++) { + const NR_RLC_BearerConfig_t *bearer = bearer_list->list.array[j]; + if (bearer->servedRadioBearer != NULL + && bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity + && drb->drb_Identity == bearer->servedRadioBearer->choice.drb_Identity) { + nr_rlc_add_drb(rnti, drb->drb_Identity, bearer); + } + } + } } + ///---------------------------------------------------------------------------------------------------------------/// ///---------------------------------------------------------------------------------------------------------------/// @@ -254,7 +287,6 @@ static void openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_Rrc rrc->cell_info_configured = 0; LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_FMT" Checking release \n",PROTOCOL_NR_RRC_CTXT_ARGS(&ctxt)); init_NR_SI(rrc, configuration); - openair_nr_rrc_on(rrc); return; } // END openair_rrc_gNB_configuration @@ -301,22 +333,17 @@ static void apply_macrlc_config(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const u NR_CellGroupConfig_t *cgc = get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : NULL; nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_context_pP->ue_context.rnti, cgc); - nr_rrc_rlc_config_asn1_req(ctxt_pP, - ue_context_pP->ue_context.SRB_configList, - ue_context_pP->ue_context.DRB_configList, - NULL, - get_softmodem_params()->sa ? cgc->rlc_BearerToAddModList : NULL); + nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid, ue_context_pP->ue_context.SRB_configList, cgc->rlc_BearerToAddModList); + nr_rrc_addmod_drbs(ctxt_pP->rntiMaybeUEid, ue_context_pP->ue_context.DRB_configList, cgc->rlc_BearerToAddModList); } void apply_macrlc_config_reest(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP, ue_id_t ue_id) { nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_id, ue_context_pP->ue_context.masterCellGroup); - nr_rrc_rlc_config_asn1_req(ctxt_pP, - ue_context_pP->ue_context.SRB_configList, - NULL, - NULL, - get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); + nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid, + ue_context_pP->ue_context.SRB_configList, + ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList); } //----------------------------------------------------------------------------- @@ -465,7 +492,6 @@ static void rrc_gNB_process_RRCSetupComplete(const protocol_ctxt_t *const ctxt_p LOG_A(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing NR_RRCSetupComplete from UE (SRB1 Active)\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); ue_context_pP->ue_context.Srb[1].Active = 1; - ue_context_pP->ue_context.Srb[1].Srb_info.Srb_id = 1; ue_context_pP->ue_context.Srb[2].Active = 0; ue_context_pP->ue_context.StatusRrc = NR_RRC_CONNECTED; @@ -549,30 +575,14 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co } } - LOG_I(NR_RRC, "[gNB %d] Frame %d, Logical Channel DL-DCCH, Generate NR_RRCReconfiguration (bytes %d, UE id %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_p->rnti); - switch (RC.nrrrc[ctxt_pP->module_id]->node_type) { - case ngran_gNB_CU: - case ngran_gNB_CUCP: - case ngran_gNB: - nr_rrc_data_req(ctxt_pP, - DCCH, - rrc_gNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - // rrc_pdcp_config_asn1_req - - break; - - case ngran_gNB_DU: - // nothing to do for DU - AssertFatal(1==0,"nothing to do for DU\n"); - break; + LOG_I(NR_RRC, "[gNB %d] Frame %d, Logical Channel DL-DCCH, Generate NR_RRCReconfiguration (bytes %d, UE id %x)\n", + ctxt_pP->module_id, + ctxt_pP->frame, + size, + ue_context_pP->ue_context.rnti); + AssertFatal(!NODE_IS_DU(rrc->node_type), "illegal node type DU!\n"); - default : - LOG_W(NR_RRC, "Unknown node type %d\n", RC.nrrrc[ctxt_pP->module_id]->node_type); - } + nr_rrc_data_req(ctxt_pP, DCCH, rrc_gNB_mui++, SDU_CONFIRM_NO, size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; @@ -1105,12 +1115,11 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co /* Refresh SRBs/DRBs */ if (!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) { - LOG_D(NR_RRC, "Configuring RLC DRBs/SRBs for UE %04x\n", ue_p->rnti); - nr_rrc_rlc_config_asn1_req(ctxt_pP, - SRB_configList, // NULL, - DRB_configList, - DRB_Release_configList2, - get_softmodem_params()->sa ? ue_p->masterCellGroup->rlc_BearerToAddModList : NULL); + LOG_D(NR_RRC,"Configuring RLC DRBs/SRBs for UE %04x\n",ue_context_pP->ue_context.rnti); + const struct NR_CellGroupConfig__rlc_BearerToAddModList *bearer_list = + ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList; + nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid, SRB_configList, bearer_list); + nr_rrc_addmod_drbs(ctxt_pP->rntiMaybeUEid, DRB_configList, bearer_list); } /* Set the SRB active in UE context */ @@ -1118,10 +1127,8 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co for (int i = 0; (i < SRB_configList->list.count) && (i < 3); i++) { if (SRB_configList->list.array[i]->srb_Identity == 1) { ue_p->Srb[1].Active = 1; - ue_p->Srb[1].Srb_info.Srb_id = 1; } else if (SRB_configList->list.array[i]->srb_Identity == 2) { ue_p->Srb[2].Active = 1; - ue_p->Srb[2].Srb_info.Srb_id = 2; LOG_I(NR_RRC, "[gNB %d] Frame %d CC %d : SRB2 is now active\n", ctxt_pP->module_id, ctxt_pP->frame, ue_p->primaryCC_id); } else { LOG_W(NR_RRC, "[gNB %d] Frame %d CC %d: invalid SRB identity %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ue_p->primaryCC_id, SRB_configList->list.array[i]->srb_Identity); @@ -1382,7 +1389,6 @@ void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctx } ue_p->Srb[1].Active = 1; - // ue_p->Srb[2].Srb_info.Srb_id = 2; if (get_softmodem_params()->sa) { LOG_W(NR_RRC, "Rework identity mapping need to be done properly!\n"); @@ -1824,14 +1830,8 @@ static int nr_rrc_gNB_decode_ccch(module_id_t module_id, rnti_t rnti, const uint Idx = DCCH; // SRB1 UE->Srb[1].Active = 1; - UE->Srb[1].Srb_info.Srb_id = Idx; - rrc_init_nr_srb_param(&UE->Srb[1].Srb_info.Lchan_desc[0]); - rrc_init_nr_srb_param(&UE->Srb[1].Srb_info.Lchan_desc[1]); // SRB2: set it to go through SRB1 with id 1 (DCCH) UE->Srb[2].Active = 1; - UE->Srb[2].Srb_info.Srb_id = Idx; - rrc_init_nr_srb_param(&UE->Srb[2].Srb_info.Lchan_desc[0]); - rrc_init_nr_srb_param(&UE->Srb[2].Srb_info.Lchan_desc[1]); protocol_ctxt_t ctxt = {.rntiMaybeUEid = rnti, .module_id = module_id, .instance = module_id, .enb_flag = 1, .eNB_index = module_id}; rrc_gNB_generate_RRCReestablishment(&ctxt, ue_context_p, du_to_cu_rrc_container, gnb_rrc_inst->carrier.servingcellconfigcommon, 0); @@ -2542,196 +2542,6 @@ void rrc_gNB_process_dc_overall_timeout(const module_id_t gnb_mod_idP, x2ap_ENDC rrc_remove_nsa_user(rrc, m->rnti); } -static int rrc_process_DU_DL(MessageDef *msg_p, instance_t instance) -{ - NRDuDlReq_t * req=&NRDuDlReq(msg_p); - protocol_ctxt_t ctxt = {.rntiMaybeUEid = req->rnti, .module_id = instance, .instance = instance, .enb_flag = 1, .eNB_index = instance}; - gNB_RRC_INST *rrc = RC.nrrrc[instance]; - rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, req->rnti); - gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - - if (req->srb_id == 0) { - AssertFatal(0 == 1, "should pass through dl_rrc_message()\n"); - } else if (req->srb_id == 1) { - NR_DL_DCCH_Message_t *dl_dcch_msg=NULL; - asn_dec_rval_t dec_rval; - dec_rval = uper_decode(NULL, - &asn_DEF_NR_DL_DCCH_Message, - (void **)&dl_dcch_msg, - &req->buf->data[2], // buf[0] includes the pdcp header - req->buf->size-6,0,0); - - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) - LOG_E(F1AP," Failed to decode DL-DCCH (%zu bytes)\n",dec_rval.consumed); - else - LOG_D(F1AP, "Received message: present %d and c1 present %d\n", - dl_dcch_msg->message.present, dl_dcch_msg->message.choice.c1->present); - - if (dl_dcch_msg->message.present == NR_DL_DCCH_MessageType_PR_c1) { - switch (dl_dcch_msg->message.choice.c1->present) { - case NR_DL_DCCH_MessageType__c1_PR_NOTHING: - LOG_I(F1AP, "Received PR_NOTHING on DL-DCCH-Message\n"); - return 0; - - case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration: - // handle RRCReconfiguration - LOG_I(F1AP, "Logical Channel DL-DCCH (SRB1), Received RRCReconfiguration RNTI %x\n", - req->rnti); - NR_RRCReconfiguration_t *rrcReconfiguration = dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration; - - if (rrcReconfiguration->criticalExtensions.present == NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration) { - NR_RRCReconfiguration_IEs_t *rrcReconfiguration_ies = - rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration; - - if (rrcReconfiguration_ies->measConfig != NULL) { - LOG_I(F1AP, "Measurement Configuration is present\n"); - } - - if (rrcReconfiguration_ies->radioBearerConfig) { - LOG_I(F1AP, "Radio Resource Configuration is present\n"); - long drb_id; - int i; - NR_DRB_ToAddModList_t *DRB_configList = rrcReconfiguration_ies->radioBearerConfig->drb_ToAddModList; - NR_SRB_ToAddModList_t *SRB_configList = rrcReconfiguration_ies->radioBearerConfig->srb_ToAddModList; - - // NR_DRB_ToReleaseList_t *DRB_ReleaseList = rrcReconfiguration_ies->radioBearerConfig->drb_ToReleaseList; - - // rrc_rlc_config_asn1_req - - if (SRB_configList != NULL) { - for (i = 0; (i < SRB_configList->list.count) && (i < 3); i++) { - if (SRB_configList->list.array[i]->srb_Identity == 1 ) { - UE->Srb[1].Active = 1; - } else if (SRB_configList->list.array[i]->srb_Identity == 2) { - UE->Srb[2].Active = 1; - UE->Srb[2].Srb_info.Srb_id = 2; - LOG_I(F1AP, "[DU %d] SRB2 is now active\n", ctxt.module_id); - } else { - LOG_W(F1AP, "[DU %d] invalide SRB identity %ld\n", ctxt.module_id, SRB_configList->list.array[i]->srb_Identity); - } - } - } - - if (DRB_configList != NULL) { - for (i = 0; i < DRB_configList->list.count; i++) { // num max DRB (11-3-8) - if (DRB_configList->list.array[i]) { - drb_id = (int)DRB_configList->list.array[i]->drb_Identity; - LOG_I(F1AP, - "[DU %d] Logical Channel UL-DCCH, Received RRCConnectionReconfiguration for UE rnti %lx, reconfiguring DRB %d\n", - ctxt.module_id, - ctxt.rntiMaybeUEid, - (int)DRB_configList->list.array[i]->drb_Identity); - - // (int)*DRB_configList->list.array[i]->logicalChannelIdentity); - - if (UE->DRB_active[drb_id] == 0) { - UE->DRB_active[drb_id] = 1; - // logicalChannelIdentity - // rrc_mac_config_req_eNB - } - } else { // remove LCHAN from MAC/PHY - AssertFatal(1==0,"Can't handle this yet in DU\n"); - } - } - } - } - } - - break; - - case NR_DL_DCCH_MessageType__c1_PR_rrcResume: - LOG_I(F1AP,"Received rrcResume\n"); - break; - - case NR_DL_DCCH_MessageType__c1_PR_rrcRelease: - LOG_I(F1AP,"Received rrcRelease\n"); - break; - - case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: - LOG_I(F1AP,"Received rrcReestablishment\n"); - break; - - case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand: - LOG_I(F1AP,"Received securityModeCommand\n"); - break; - - case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: - LOG_I(F1AP, "Received dlInformationTransfer\n"); - break; - - case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: - LOG_I(F1AP, "Received ueCapabilityEnquiry\n"); - break; - - case NR_DL_DCCH_MessageType__c1_PR_counterCheck: - LOG_I(F1AP, "Received counterCheck\n"); - break; - - case NR_DL_DCCH_MessageType__c1_PR_mobilityFromNRCommand: - case NR_DL_DCCH_MessageType__c1_PR_dlDedicatedMessageSegment_r16: - case NR_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r16: - case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransferMRDC_r16: - case NR_DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r16: - case NR_DL_DCCH_MessageType__c1_PR_spare3: - case NR_DL_DCCH_MessageType__c1_PR_spare2: - case NR_DL_DCCH_MessageType__c1_PR_spare1: - break; - } - } - } else if (req->srb_id == 2) { - // TODO - //abort(); - } - - LOG_I(F1AP, "Received DL RRC Transfer on srb_id %ld\n", req->srb_id); - // rlc_op_status_t rlc_status; - - //LOG_I(F1AP, "PRRCContainer size %lu:", ie->value.choice.RRCContainer.size); - //for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) - // printf("%02x ", ie->value.choice.RRCContainer.buf[i]); - - //printf (", PDCP PDU size %d:", rrc_dl_sdu_len); - //for (int i=0;i<rrc_dl_sdu_len;i++) printf("%2x ",pdcp_pdu_p->data[i]); - //printf("\n"); - - du_rlc_data_req(&ctxt, 1, 0, req->srb_id , 1, 0, req->buf->size, req->buf); - // rlc_status = rlc_data_req(&ctxt - // , 1 - // , MBMS_FLAG_NO - // , srb_id - // , 0 - // , 0 - // , rrc_dl_sdu_len - // , pdcp_pdu_p - // ,NULL - // ,NULL - // ); - // switch (rlc_status) { - // case RLC_OP_STATUS_OK: - // //LOG_I(F1AP, "Data sending request over RLC succeeded!\n"); - // ret=true; - // break; - // case RLC_OP_STATUS_BAD_PARAMETER: - // LOG_W(F1AP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n"); - // ret= false; - // break; - // case RLC_OP_STATUS_INTERNAL_ERROR: - // LOG_W(F1AP, "Data sending request over RLC failed with 'Internal Error' reason!\n"); - // ret= false; - // break; - // case RLC_OP_STATUS_OUT_OF_RESSOURCES: - // LOG_W(F1AP, "Data sending request over RLC failed with 'Out of Resources' reason!\n"); - // ret= false; - // break; - // default: - // LOG_W(F1AP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status); - // ret= false; - // break; - // } // switch case - // return ret; -return 0; -} - static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, instance_t instance) { f1ap_ue_context_setup_t * req=&F1AP_UE_CONTEXT_SETUP_REQ(msg_p); @@ -3628,8 +3438,6 @@ void *rrc_gnb_task(void *args_p) { MessageDef *msg_p; instance_t instance; int result; - //SRB_INFO *srb_info_p; - //int CC_id; protocol_ctxt_t ctxt = {.module_id = 0, .enb_flag = 1, .instance = 0, .rntiMaybeUEid = 0, .frame = -1, .subframe = -1, .eNB_index = 0, .brOption = false}; /* timer to write stats to file */ @@ -3720,10 +3528,6 @@ void *rrc_gnb_task(void *args_p) { rrc_gNB_process_f1_setup_req(&F1AP_SETUP_REQ(msg_p)); break; - case NR_DU_RRC_DL_INDICATION: - rrc_process_DU_DL(msg_p, instance); - break; - case F1AP_UE_CONTEXT_SETUP_REQ: rrc_DU_process_ue_context_setup_request(msg_p, instance); break; @@ -3816,48 +3620,10 @@ rrc_gNB_generate_SecurityModeCommand( LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Security Mode Command\n"); LOG_I(NR_RRC, "UE %04x Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d)\n", ue_p->rnti, size); - switch (RC.nrrrc[ctxt_pP->module_id]->node_type) { - case ngran_gNB_CU: - case ngran_gNB_CUCP: - // create an ITTI message - memcpy(ue_p->Srb[1].Srb_info.Tx_buffer.Payload, buffer, size); - ue_p->Srb[1].Srb_info.Tx_buffer.payload_size = size; - - LOG_I(NR_RRC,"calling rrc_data_req :securityModeCommand\n"); - nr_rrc_data_req(ctxt_pP, - DCCH, - rrc_gNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - break; - - case ngran_gNB_DU: - // nothing to do for DU - AssertFatal(1==0,"nothing to do for DU\n"); - break; - - case ngran_gNB: - LOG_D(NR_RRC, - PROTOCOL_NR_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (securityModeCommand to UE MUI %d) --->[PDCP][RB %02d]\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - size, - rrc_gNB_mui, - DCCH); - LOG_D(NR_RRC,"calling rrc_data_req :securityModeCommand\n"); - nr_rrc_data_req(ctxt_pP, - DCCH, - rrc_gNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - break; + gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; + AssertFatal(!NODE_IS_DU(rrc->node_type), "illegal node type DU!\n"); - default : - LOG_W(NR_RRC, "Unknown node type %d\n", RC.nrrrc[ctxt_pP->module_id]->node_type); - } + nr_rrc_data_req(ctxt_pP, DCCH, rrc_gNB_mui++, SDU_CONFIRM_NO, size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); } void @@ -3879,44 +3645,11 @@ rrc_gNB_generate_UECapabilityEnquiry( PROTOCOL_NR_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate NR UECapabilityEnquiry (bytes %d)\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), size); - switch (RC.nrrrc[ctxt_pP->module_id]->node_type) { - case ngran_gNB_CU: - case ngran_gNB_CUCP: - nr_rrc_data_req( - ctxt_pP, - DCCH, - rrc_gNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - break; - - case ngran_gNB_DU: - // nothing to do for DU - AssertFatal(1==0,"nothing to do for DU\n"); - break; - case ngran_gNB: - // rrc_mac_config_req_gNB - LOG_D(NR_RRC, - PROTOCOL_NR_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (NR UECapabilityEnquiry MUI %d) --->[PDCP][RB %02d]\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - size, - rrc_gNB_mui, - DCCH); - nr_rrc_data_req(ctxt_pP, - DCCH, - rrc_gNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - break; + gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; + AssertFatal(!NODE_IS_DU(rrc->node_type), "illegal node type DU!\n"); - default : - LOG_W(NR_RRC, "Unknown node type %d\n", RC.nrrrc[ctxt_pP->module_id]->node_type); - } + nr_rrc_data_req(ctxt_pP, DCCH, rrc_gNB_mui++, SDU_CONFIRM_NO, size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); } //----------------------------------------------------------------------------- @@ -3950,6 +3683,11 @@ rrc_gNB_generate_RRCRelease( rrc_gNB_mui, DCCH); + nr_rrc_data_req(ctxt_pP, DCCH, rrc_gNB_mui++, SDU_CONFIRM_NO, size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); + + rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_COMPLETE(ctxt_pP->instance, ue_context_pP->ue_context.gNB_ue_ngap_id); + ue_context_pP->ue_context.ue_release_timer_rrc = 1; + if (NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) { uint8_t *message_buffer = itti_malloc (TASK_RRC_GNB, TASK_CU_F1, size); memcpy (message_buffer, buffer, size); @@ -3960,17 +3698,6 @@ rrc_gNB_generate_RRCRelease( F1AP_UE_CONTEXT_RELEASE_CMD(m).rrc_container = message_buffer; F1AP_UE_CONTEXT_RELEASE_CMD(m).rrc_container_length = size; itti_send_msg_to_task(TASK_CU_F1, ctxt_pP->module_id, m); - } else { - nr_rrc_data_req(ctxt_pP, - DCCH, - rrc_gNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - - rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_COMPLETE(ctxt_pP->instance, ue_p->gNB_ue_ngap_id); - ue_p->ue_release_timer_rrc = 1; } } diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 262bfec2a9ed1da09c3cbabbf1466c6f4600238d..d3efb4b4974bad9b37124e751b4a081792ba1466 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -622,29 +622,11 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu /* * switch UL or DL NAS message without RRC piggybacked to SRB2 if active. */ - switch (RC.nrrrc[ctxt.module_id]->node_type) { - case ngran_gNB_CU: - case ngran_gNB_CUCP: - case ngran_gNB: { - long srb_id; - if (UE->Srb[2].Active) - srb_id = UE->Srb[2].Srb_info.Srb_id; - else - srb_id = UE->Srb[1].Srb_info.Srb_id; - AssertFatal(srb_id > 0 && srb_id < maxSRBs, ""); - /* Transfer data to PDCP */ - nr_rrc_data_req(&ctxt, srb_id, (*rrc_gNB_mui)++, SDU_CONFIRM_NO, length, buffer, PDCP_TRANSMISSION_MODE_CONTROL); - free(buffer); // nr_rrc_data_req do a second malloc and copy - } break; - - case ngran_gNB_DU: - // nothing to do for DU - break; - - default: - LOG_W(NR_RRC, "Unknown node type %d\n", RC.nrrrc[ctxt.module_id]->node_type); - } - return (0); + AssertFatal(!NODE_IS_DU(RC.nrrrc[ctxt.module_id]->node_type), "illegal node type DU: receiving NGAP messages at this node\n"); + /* Transfer data to PDCP */ + rb_id_t srb_id = UE->Srb[2].Active ? DCCH1 : DCCH; + nr_rrc_data_req(&ctxt, srb_id, (*rrc_gNB_mui)++, SDU_CONFIRM_NO, length, buffer, PDCP_TRANSMISSION_MODE_CONTROL); + return 0; } //------------------------------------------------------------------------------ diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index 89c5b448588c49346dfae2a87d0a0c47ca6d43f2..0a6eb050e523a2fc68be48337ec941d7b1a32b40 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -33,9 +33,11 @@ #include "NR_UE-NR-Capability.h" //#include "NR_UE-CapabilityRAT-ContainerList.h" #include "LTE_UE-CapabilityRAT-ContainerList.h" +#include "NR_CellGroupConfig.h" #include "NR_CG-Config.h" //#include "NR_SRB-ToAddModList.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" +#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h" #include "openair2/RRC/LTE/rrc_eNB_GTPV1U.h" #include "executables/softmodem-common.h" #include "executables/nr-softmodem.h" @@ -109,6 +111,7 @@ RB_PROTOTYPE(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s, entries, void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2ap_ENDC_sgnb_addition_req_t *m) { + AssertFatal(!get_softmodem_params()->sa, "%s() cannot be called in SA mode, it is intrinsically for NSA\n", __func__); // generate nr-Config-r15 containers for LTE RRC : inside message for X2 EN-DC (CG-Config Message from 38.331) rrc_gNB_carrier_data_t *carrier=&rrc->carrier; const gNB_RrcConfigurationReq *configuration = &rrc->configuration; @@ -351,11 +354,25 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a ctxt.subframe, ctxt.eNB_index); - nr_pdcp_add_drbs( - ctxt.enb_flag, ctxt.rntiMaybeUEid, 0, UE->rb_config->drb_ToAddModList, (UE->integrity_algorithm << 4) | UE->ciphering_algorithm, kUPenc, kUPint, UE->secondaryCellGroup->rlc_BearerToAddModList); - - nr_rrc_rlc_config_asn1_req( - &ctxt, get_softmodem_params()->sa ? UE->rb_config->srb_ToAddModList : NULL, UE->rb_config->drb_ToAddModList, UE->rb_config->drb_ToReleaseList, UE->secondaryCellGroup->rlc_BearerToAddModList); + nr_pdcp_add_drbs(ctxt.enb_flag, + ctxt.rntiMaybeUEid, + 0, + ue_context_p->ue_context.rb_config->drb_ToAddModList, + (ue_context_p->ue_context.integrity_algorithm << 4) | ue_context_p->ue_context.ciphering_algorithm, + kUPenc, + kUPint, + ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList); + + // assume only a single bearer + const NR_DRB_ToAddModList_t *drb_list = ue_context_p->ue_context.rb_config->drb_ToAddModList; + DevAssert(drb_list->list.count == 1); + const NR_DRB_ToAddMod_t *drb = drb_list->list.array[0]; + const struct NR_CellGroupConfig__rlc_BearerToAddModList *bearer_list = + ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList; + const NR_RLC_BearerConfig_t *bearer = bearer_list->list.array[0]; + DevAssert(bearer_list->list.count == 1); + DevAssert(drb->drb_Identity == bearer->servedRadioBearer->choice.drb_Identity); + nr_rlc_add_drb(ctxt.rntiMaybeUEid, drb->drb_Identity, bearer); LOG_D(RRC, "%s:%d: done RRC PDCP/RLC ASN1 request for UE rnti %lx\n", __FUNCTION__, __LINE__, ctxt.rntiMaybeUEid); } diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 76eca8e71ec425a4e705797179365fc38d388c16..4995662e71c4f6bc76d2bc0af9cdb8c2557403d6 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -119,24 +119,8 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->rlc_BearerToAddModList = calloc(1,sizeof(*secondaryCellGroup->rlc_BearerToAddModList)); asn1cSeqAdd(&secondaryCellGroup->rlc_BearerToAddModList->list, RLC_BearerConfig); - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = secondaryCellGroup->mac_CellGroupConfig; - - mac_CellGroupConfig=calloc(1,sizeof(*mac_CellGroupConfig)); - mac_CellGroupConfig->drx_Config = NULL; - - mac_CellGroupConfig->bsr_Config=calloc(1,sizeof(*mac_CellGroupConfig->bsr_Config)); - mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; - mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf160; - mac_CellGroupConfig->tag_Config=calloc(1,sizeof(*mac_CellGroupConfig->tag_Config)); - mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL; - mac_CellGroupConfig->tag_Config->tag_ToAddModList = calloc(1,sizeof(*mac_CellGroupConfig->tag_Config->tag_ToAddModList)); - struct NR_TAG *tag=calloc(1,sizeof(*tag)); - tag->tag_Id = 0; - tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity; - asn1cSeqAdd(&mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag); - set_phr_config(mac_CellGroupConfig); - mac_CellGroupConfig->skipUplinkTxDynamic=false; - mac_CellGroupConfig->ext1 = NULL; + secondaryCellGroup->mac_CellGroupConfig = configure_mac_cellgroup(); + secondaryCellGroup->physicalCellGroupConfig = calloc(1,sizeof(*secondaryCellGroup->physicalCellGroupConfig)); secondaryCellGroup->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH=NULL; secondaryCellGroup->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUSCH=NULL; @@ -296,14 +280,6 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToReleaseList= NULL; secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToReleaseList = NULL; - mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); - mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); - struct NR_SchedulingRequestToAddMod *schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist)); - schedulingrequestlist->schedulingRequestId = 0; - schedulingrequestlist->sr_ProhibitTimer = NULL; - schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64; - asn1cSeqAdd(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist); - secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig)); NR_PUSCH_ServingCellConfig_t *pusch_scc = calloc(1,sizeof(*pusch_scc)); secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->present = NR_SetupRelease_PUSCH_ServingCellConfig_PR_setup; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 859d2727153b7875d4dd40b845014933bc0d5604..ecbaeea17e754a45c4311cab2be0fc67af487f7f 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -54,6 +54,7 @@ #include "intertask_interface.h" +#include "LAYER2/nr_rlc/nr_rlc_oai_api.h" #include "nr-uesoftmodem.h" #include "executables/softmodem-common.h" #include "plmn_data.h" @@ -179,6 +180,46 @@ static int nr_rrc_set_sub_state( module_id_t ue_mod_idP, Rrc_Sub_State_NR_t subS return (0); } +static void nr_rrc_addmod_srbs(int rnti, + const NR_SRB_ToAddModList_t *srb_list, + const struct NR_CellGroupConfig__rlc_BearerToAddModList *bearer_list) +{ + if (srb_list == NULL || bearer_list == NULL) + return; + + for (int i = 0; i < srb_list->list.count; i++) { + const NR_SRB_ToAddMod_t *srb = srb_list->list.array[i]; + for (int j = 0; j < bearer_list->list.count; j++) { + const NR_RLC_BearerConfig_t *bearer = bearer_list->list.array[j]; + if (bearer->servedRadioBearer != NULL + && bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity + && srb->srb_Identity == bearer->servedRadioBearer->choice.srb_Identity) { + nr_rlc_add_srb(rnti, srb->srb_Identity, bearer); + } + } + } +} + +static void nr_rrc_addmod_drbs(int rnti, + const NR_DRB_ToAddModList_t *drb_list, + const struct NR_CellGroupConfig__rlc_BearerToAddModList *bearer_list) +{ + if (drb_list == NULL || bearer_list == NULL) + return; + + for (int i = 0; i < drb_list->list.count; i++) { + const NR_DRB_ToAddMod_t *drb = drb_list->list.array[i]; + for (int j = 0; j < bearer_list->list.count; j++) { + const NR_RLC_BearerConfig_t *bearer = bearer_list->list.array[j]; + if (bearer->servedRadioBearer != NULL + && bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity + && drb->drb_Identity == bearer->servedRadioBearer->choice.drb_Identity) { + nr_rlc_add_drb(rnti, drb->drb_Identity, bearer); + } + } + } +} + // from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded) int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const module_id_t module_id, const uint8_t *buffer, @@ -1947,35 +1988,31 @@ nr_rrc_ue_establish_srb2( } } + NR_UE_RRC_INST_t *ue_rrc = &NR_UE_rrc_inst[ctxt_pP->module_id]; if (radioBearerConfig->srb_ToAddModList != NULL) { if (radioBearerConfig->securityConfig != NULL) { if (*radioBearerConfig->securityConfig->keyToUse == NR_SecurityConfig__keyToUse_master) { - NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm = radioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm; - NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm = *radioBearerConfig->securityConfig->securityAlgorithmConfig->integrityProtAlgorithm; + ue_rrc->cipheringAlgorithm = radioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm; + ue_rrc->integrityProtAlgorithm = *radioBearerConfig->securityConfig->securityAlgorithmConfig->integrityProtAlgorithm; } } uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; - nr_derive_key_rrc_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm, - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCenc); - nr_derive_key_rrc_int(NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm, - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCint); + nr_derive_key_rrc_enc(ue_rrc->cipheringAlgorithm, ue_rrc->kgnb, &kRRCenc); + nr_derive_key_rrc_int(ue_rrc->integrityProtAlgorithm, ue_rrc->kgnb, &kRRCint); // Refresh SRBs nr_pdcp_add_srbs(ctxt_pP->enb_flag, ctxt_pP->rntiMaybeUEid, radioBearerConfig->srb_ToAddModList, - NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm | (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), + ue_rrc->cipheringAlgorithm | (ue_rrc->integrityProtAlgorithm << 4), kRRCenc, kRRCint); // Refresh SRBs - nr_rrc_rlc_config_asn1_req(ctxt_pP, - radioBearerConfig->srb_ToAddModList, - NULL, - NULL, - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList - ); + nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid, + radioBearerConfig->srb_ToAddModList, + ue_rrc->cell_group_config->rlc_BearerToAddModList); for (cnt = 0; cnt < radioBearerConfig->srb_ToAddModList->list.count; cnt++) { SRB_id = radioBearerConfig->srb_ToAddModList->list.array[cnt]->srb_Identity; @@ -2054,22 +2091,24 @@ nr_rrc_ue_establish_srb2( uint8_t *kUPenc = NULL; uint8_t *kUPint = NULL; - nr_derive_key_up_enc(NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm, - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kUPenc); - nr_derive_key_up_int(NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm, - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kUPint); + NR_UE_RRC_INST_t *ue_rrc = &NR_UE_rrc_inst[ctxt_pP->module_id]; + nr_derive_key_up_enc(ue_rrc->cipheringAlgorithm, ue_rrc->kgnb, &kUPenc); + nr_derive_key_up_int(ue_rrc->integrityProtAlgorithm, ue_rrc->kgnb, &kUPint); - // Refresh DRBs + // Refresh DRBs nr_pdcp_add_drbs(ctxt_pP->enb_flag, ctxt_pP->rntiMaybeUEid, 0, radioBearerConfig->drb_ToAddModList, - NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm | (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), + ue_rrc->cipheringAlgorithm | (ue_rrc->integrityProtAlgorithm << 4), kUPenc, kUPint, - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList); + ue_rrc->cell_group_config->rlc_BearerToAddModList); // Refresh DRBs - nr_rrc_rlc_config_asn1_req(ctxt_pP, NULL, radioBearerConfig->drb_ToAddModList, NULL, NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList); + nr_rrc_addmod_drbs(ctxt_pP->rntiMaybeUEid, + radioBearerConfig->drb_ToAddModList, + ue_rrc->cell_group_config->rlc_BearerToAddModList); + } // drb_ToAddModList // if (radioBearerConfig->drb_ToReleaseList != NULL) { diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap_ports1.xml b/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap_ports1.xml index ec0288fd26327001e51553320fd409b6bae1285c..b8e895aef58941fc942935032f327976810e6063 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap_ports1.xml +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap_ports1.xml @@ -93,7 +93,7 @@ <bandNR>78</bandNR> <mimo-ParametersPerBand> <tci-StatePDSCH> - <maxNumberConfiguredTCIstatesPerCC><n16/></maxNumberConfiguredTCIstatesPerCC> + <maxNumberConfiguredTCI-StatesPerCC><n16/></maxNumberConfiguredTCI-StatesPerCC> <maxNumberActiveTCI-PerBWP><n1/></maxNumberActiveTCI-PerBWP> </tci-StatePDSCH> <pusch-TransCoherence><nonCoherent/></pusch-TransCoherence> diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap_ports2.xml b/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap_ports2.xml index baca6649cbf10848fd327d49b926a8f6ba11d3ab..d877d91dab943c42b1c07d273fe73ae7efd5afcc 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap_ports2.xml +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap_ports2.xml @@ -93,7 +93,7 @@ <bandNR>78</bandNR> <mimo-ParametersPerBand> <tci-StatePDSCH> - <maxNumberConfiguredTCIstatesPerCC><n16/></maxNumberConfiguredTCIstatesPerCC> + <maxNumberConfiguredTCI-StatesPerCC><n16/></maxNumberConfiguredTCI-StatesPerCC> <maxNumberActiveTCI-PerBWP><n1/></maxNumberActiveTCI-PerBWP> </tci-StatePDSCH> <pusch-TransCoherence><nonCoherent/></pusch-TransCoherence>