diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 4b29e01348..6b849415f8 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -243,6 +243,7 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, float nr_get_Pcmax(int p_Max, uint16_t nr_band, + frame_type_t frame_type, frequency_range_t frequency_range, int Qm, bool powerBoostPi2BPSK, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 1fc6f4b6e8..ebf3ee2703 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -81,6 +81,7 @@ void init_RA(NR_UE_MAC_INST_t *mac, // PRACH shall be as specified for QPSK modulated DFT-s-OFDM of equivalent RB allocation (38.101-1) prach_resources->RA_PCMAX = nr_get_Pcmax(mac->p_Max, mac->nr_band, + mac->frame_type, mac->frequency_range, 2, false, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c index 0dbaa5debf..02aea8dd4d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c @@ -66,9 +66,8 @@ static int get_deltatf(uint16_t nb_of_prbs, int O_UCI); // ∆MPR according to Table 6.2.2-3 38.101-1 -static float get_delta_mpr(uint16_t nr_band, int scs, int N_RB_UL, int n_prbs, int start_prb, int power_class) +static float get_delta_mpr(uint16_t nr_band, frame_type_t frame_type, int scs, int N_RB_UL, int n_prbs, int start_prb, int power_class) { - frame_type_t frame_type = get_frame_type(nr_band, scs); if (compare_relative_ul_channel_bw(nr_band, scs, N_RB_UL, frame_type)) { if (power_class == 3) { if ((nr_band == 28 || nr_band == 83) && get_supported_bw_mhz(nr_band > 256 ? FR2 : FR1, scs, N_RB_UL) == 30) { @@ -167,6 +166,7 @@ static float get_mpr(int Qm, int N_RB_UL, bool is_transform_precoding, int n_prb // -- no additional MPR (A_MPR_c) float nr_get_Pcmax(int p_Max, uint16_t nr_band, + frame_type_t frame_type, frequency_range_t frequency_range, int Qm, bool powerBoostPi2BPSK, @@ -197,7 +197,7 @@ float nr_get_Pcmax(int p_Max, int delta_TC = 0; float MPR = get_mpr(Qm, N_RB_UL, is_transform_precoding, n_prbs, start_prb, power_class); - float delta_MPR = get_delta_mpr(nr_band, scs, N_RB_UL, n_prbs, start_prb, power_class); + float delta_MPR = get_delta_mpr(nr_band, frame_type, scs, N_RB_UL, n_prbs, start_prb, power_class); int A_MPR = 0; // TODO too complicated to implement for now (see 6.2.3 in 38.101-1) int delta_rx_SRS = 0; // TODO for SRS int P_MPR = 0; // to ensure compliance with applicable electromagnetic energy absorption requirements @@ -339,6 +339,7 @@ int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, // modulated CP-OFDM of equivalent RB allocation. int P_CMAX = nr_get_Pcmax(mac->p_Max, mac->nr_band, + mac->frame_type, mac->frequency_range, 2, false, @@ -519,6 +520,7 @@ int get_pusch_tx_power_ue(NR_UE_MAC_INST_t *mac, int M_pusch_component = 10 * log10((pow(2, mu)) * num_rb); int P_CMAX = nr_get_Pcmax(mac->p_Max, mac->nr_band, + mac->frame_type, mac->frequency_range, 2, false, diff --git a/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_power_procedures.cpp b/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_power_procedures.cpp index 49f2d58f27..3f865ec597 100644 --- a/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_power_procedures.cpp +++ b/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_power_procedures.cpp @@ -43,24 +43,25 @@ TEST(test_pcmax, test_mpr) int N_RB_UL = 51; // 10Mhz int nr_band = 20; float expected_power = 23 - (1.5 / 2); - EXPECT_EQ(expected_power, nr_get_Pcmax(23, nr_band, FR1, 2, false, 1, N_RB_UL, false, 6, prb_start)); + frame_type_t frame_type = TDD; + EXPECT_EQ(expected_power, nr_get_Pcmax(23, nr_band, frame_type, FR1, 2, false, 1, N_RB_UL, false, 6, prb_start)); // Outer PRB, MPR = 3, no delta MPR prb_start = 0; expected_power = 23 - (3.0 / 2); - EXPECT_EQ(expected_power, nr_get_Pcmax(23, nr_band, FR1, 2, false, 1, N_RB_UL, false, 6, prb_start)); + EXPECT_EQ(expected_power, nr_get_Pcmax(23, nr_band, frame_type, FR1, 2, false, 1, N_RB_UL, false, 6, prb_start)); // Outer PRB on band 28, MPR = 3, delta MPR = 0.5 dB N_RB_UL = 78; nr_band = 28; expected_power = 23 - ((3.0 + 0.5) / 2); - EXPECT_EQ(expected_power, nr_get_Pcmax(23, nr_band, FR1, 2, false, 1, N_RB_UL, false, 100, prb_start)); + EXPECT_EQ(expected_power, nr_get_Pcmax(23, nr_band, frame_type, FR1, 2, false, 1, N_RB_UL, false, 100, prb_start)); } TEST(test_pcmax, test_not_implemented) { int N_RB_UL = 51; - EXPECT_DEATH(nr_get_Pcmax(23, 20, FR1, 1, false, 1, N_RB_UL, false, 6, 0), "MPR for Pi/2 BPSK not implemented yet"); + EXPECT_DEATH(nr_get_Pcmax(23, 20, TDD, FR1, 1, false, 1, N_RB_UL, false, 6, 0), "MPR for Pi/2 BPSK not implemented yet"); } TEST(test_pcmax, test_pucch_max_power) @@ -69,11 +70,11 @@ TEST(test_pcmax, test_pucch_max_power) int prb_start = 0; int N_RB_UL = 51; // 10Mhz float expected_power = 23 - (1.0 / 2); - EXPECT_EQ(expected_power, nr_get_Pcmax(23, 20, FR1, 2, false, 1, N_RB_UL, true, 1, prb_start)); + EXPECT_EQ(expected_power, nr_get_Pcmax(23, 20, TDD, FR1, 2, false, 1, N_RB_UL, true, 1, prb_start)); // Other fromats, no transform precoding, MPR = 3 expected_power = 23 - (3.0 / 2); - EXPECT_EQ(expected_power, nr_get_Pcmax(23, 20, FR1, 2, false, 1, N_RB_UL, false, 1, prb_start)); + EXPECT_EQ(expected_power, nr_get_Pcmax(23, 20, TDD, FR1, 2, false, 1, N_RB_UL, false, 1, prb_start)); } TEST(test_pucch_power_state, test_accumulated_delta_pucch) @@ -91,6 +92,7 @@ TEST(test_pucch_power_state, test_accumulated_delta_pucch) pucch_Config.pucch_PowerControl = &power_config; mac.G_b_f_c = 0; mac.pucch_power_control_initialized = true; + mac.frame_type = TDD; int scs = 1; int sum_delta_pucch = 3; @@ -102,8 +104,17 @@ TEST(test_pucch_power_state, test_accumulated_delta_pucch) int subframe_number = 0; int O_uci = 2; uint16_t start_prb = 0; - int P_CMAX = - nr_get_Pcmax(23, mac.nr_band, FR1, 2, false, current_UL_BWP.scs, current_UL_BWP.BWPSize, false, nb_of_prbs, start_prb); + int P_CMAX = nr_get_Pcmax(23, + mac.nr_band, + mac.frame_type, + FR1, + 2, + false, + current_UL_BWP.scs, + current_UL_BWP.BWPSize, + false, + nb_of_prbs, + start_prb); int pucch_power_prev = get_pucch_tx_power_ue(&mac, scs, &pucch_Config, @@ -187,6 +198,7 @@ TEST(pusch_power_control, pusch_power_control_msg3) NR_PUSCH_PowerControl pusch_PowerControl = {0}; pusch_Config.pusch_PowerControl = &pusch_PowerControl; pusch_PowerControl.tpc_Accumulation = (long*)1; + mac.frame_type = TDD; // msg3 cofiguration as in 5g_rfsimulator testcase int num_rb = 8; @@ -201,7 +213,17 @@ TEST(pusch_power_control, pusch_power_control_msg3) int delta_pusch = 0; bool is_rar_tx_retx = true; - int P_CMAX = nr_get_Pcmax(23, mac.nr_band, FR1, Qm, false, current_UL_BWP.scs, current_UL_BWP.BWPSize, false, num_rb, start_prb); + int P_CMAX = nr_get_Pcmax(23, + mac.nr_band, + mac.frame_type, + FR1, + Qm, + false, + current_UL_BWP.scs, + current_UL_BWP.BWPSize, + false, + num_rb, + start_prb); long preambleReceivedTargetPower = -96; nr_rach_ConfigCommon.rach_ConfigGeneric.preambleReceivedTargetPower = preambleReceivedTargetPower; @@ -236,26 +258,24 @@ TEST(pusch_power_control, pusch_power_control_msg3) delta_pusch, is_rar_tx_retx, false); - EXPECT_EQ(std::min(P_CMAX, power - 2), reduced_power) - << "Incorrect handling of preambleReceivedTargetPower"; + EXPECT_EQ(std::min(P_CMAX, power - 2), reduced_power) << "Incorrect handling of preambleReceivedTargetPower"; EXPECT_LT(reduced_power, P_CMAX) << "Power above P_CMAX"; delta_pusch = 4; int increased_power = get_pusch_tx_power_ue(&mac, - num_rb, - start_prb, - nb_symb_sch, - nb_dmrs_prb, - nb_ptrs_prb, - Qm, - R, - beta_offset_csi1, - sum_bits_in_codeblocks, - delta_pusch, - is_rar_tx_retx, - false); - EXPECT_EQ(std::min(P_CMAX, reduced_power + delta_pusch), increased_power) - << "delta_pusch should increase tx power"; + num_rb, + start_prb, + nb_symb_sch, + nb_dmrs_prb, + nb_ptrs_prb, + Qm, + R, + beta_offset_csi1, + sum_bits_in_codeblocks, + delta_pusch, + is_rar_tx_retx, + false); + EXPECT_EQ(std::min(P_CMAX, reduced_power + delta_pusch), increased_power) << "delta_pusch should increase tx power"; EXPECT_LT(increased_power, P_CMAX) << "Power above P_CMAX"; } @@ -269,6 +289,7 @@ TEST(pusch_power_control, pusch_power_data) NR_RACH_ConfigCommon_t nr_rach_ConfigCommon = {0}; current_UL_BWP.rach_ConfigCommon = &nr_rach_ConfigCommon; mac.nr_band = 78; + mac.frame_type = TDD; bool is_rar_tx_retx = false; int num_rb = 5; @@ -291,7 +312,17 @@ TEST(pusch_power_control, pusch_power_data) current_UL_BWP.p0_NominalWithGrant = &p0_NominalWithGrant; pusch_PowerControl.deltaMCS = (long*)1; - int P_CMAX = nr_get_Pcmax(23, mac.nr_band, FR1, Qm, false, current_UL_BWP.scs, current_UL_BWP.BWPSize, transform_precoding, num_rb, start_prb); + int P_CMAX = nr_get_Pcmax(23, + mac.nr_band, + mac.frame_type, + FR1, + Qm, + false, + current_UL_BWP.scs, + current_UL_BWP.BWPSize, + transform_precoding, + num_rb, + start_prb); int power = get_pusch_tx_power_ue(&mac, num_rb,