Commit 6ce94be8 authored by Bartosz Podrygajlo's avatar Bartosz Podrygajlo

Use mac->frame_type instead of calcualting frame_type on the fly in nr_get_Pcmax

parent 514537e6
...@@ -243,6 +243,7 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, ...@@ -243,6 +243,7 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
float nr_get_Pcmax(int p_Max, float nr_get_Pcmax(int p_Max,
uint16_t nr_band, uint16_t nr_band,
frame_type_t frame_type,
frequency_range_t frequency_range, frequency_range_t frequency_range,
int Qm, int Qm,
bool powerBoostPi2BPSK, bool powerBoostPi2BPSK,
......
...@@ -81,6 +81,7 @@ void init_RA(NR_UE_MAC_INST_t *mac, ...@@ -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 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, prach_resources->RA_PCMAX = nr_get_Pcmax(mac->p_Max,
mac->nr_band, mac->nr_band,
mac->frame_type,
mac->frequency_range, mac->frequency_range,
2, 2,
false, false,
......
...@@ -66,9 +66,8 @@ static int get_deltatf(uint16_t nb_of_prbs, ...@@ -66,9 +66,8 @@ static int get_deltatf(uint16_t nb_of_prbs,
int O_UCI); int O_UCI);
// ∆MPR according to Table 6.2.2-3 38.101-1 // ∆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 (compare_relative_ul_channel_bw(nr_band, scs, N_RB_UL, frame_type)) {
if (power_class == 3) { 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) { 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 ...@@ -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) // -- no additional MPR (A_MPR_c)
float nr_get_Pcmax(int p_Max, float nr_get_Pcmax(int p_Max,
uint16_t nr_band, uint16_t nr_band,
frame_type_t frame_type,
frequency_range_t frequency_range, frequency_range_t frequency_range,
int Qm, int Qm,
bool powerBoostPi2BPSK, bool powerBoostPi2BPSK,
...@@ -197,7 +197,7 @@ float nr_get_Pcmax(int p_Max, ...@@ -197,7 +197,7 @@ float nr_get_Pcmax(int p_Max,
int delta_TC = 0; int delta_TC = 0;
float MPR = get_mpr(Qm, N_RB_UL, is_transform_precoding, n_prbs, start_prb, power_class); 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 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 delta_rx_SRS = 0; // TODO for SRS
int P_MPR = 0; // to ensure compliance with applicable electromagnetic energy absorption requirements 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, ...@@ -339,6 +339,7 @@ int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac,
// modulated CP-OFDM of equivalent RB allocation. // modulated CP-OFDM of equivalent RB allocation.
int P_CMAX = nr_get_Pcmax(mac->p_Max, int P_CMAX = nr_get_Pcmax(mac->p_Max,
mac->nr_band, mac->nr_band,
mac->frame_type,
mac->frequency_range, mac->frequency_range,
2, 2,
false, false,
...@@ -519,6 +520,7 @@ int get_pusch_tx_power_ue(NR_UE_MAC_INST_t *mac, ...@@ -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 M_pusch_component = 10 * log10((pow(2, mu)) * num_rb);
int P_CMAX = nr_get_Pcmax(mac->p_Max, int P_CMAX = nr_get_Pcmax(mac->p_Max,
mac->nr_band, mac->nr_band,
mac->frame_type,
mac->frequency_range, mac->frequency_range,
2, 2,
false, false,
......
...@@ -43,24 +43,25 @@ TEST(test_pcmax, test_mpr) ...@@ -43,24 +43,25 @@ TEST(test_pcmax, test_mpr)
int N_RB_UL = 51; // 10Mhz int N_RB_UL = 51; // 10Mhz
int nr_band = 20; int nr_band = 20;
float expected_power = 23 - (1.5 / 2); 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 // Outer PRB, MPR = 3, no delta MPR
prb_start = 0; prb_start = 0;
expected_power = 23 - (3.0 / 2); 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 // Outer PRB on band 28, MPR = 3, delta MPR = 0.5 dB
N_RB_UL = 78; N_RB_UL = 78;
nr_band = 28; nr_band = 28;
expected_power = 23 - ((3.0 + 0.5) / 2); 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) TEST(test_pcmax, test_not_implemented)
{ {
int N_RB_UL = 51; 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) TEST(test_pcmax, test_pucch_max_power)
...@@ -69,11 +70,11 @@ TEST(test_pcmax, test_pucch_max_power) ...@@ -69,11 +70,11 @@ TEST(test_pcmax, test_pucch_max_power)
int prb_start = 0; int prb_start = 0;
int N_RB_UL = 51; // 10Mhz int N_RB_UL = 51; // 10Mhz
float expected_power = 23 - (1.0 / 2); 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 // Other fromats, no transform precoding, MPR = 3
expected_power = 23 - (3.0 / 2); 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) TEST(test_pucch_power_state, test_accumulated_delta_pucch)
...@@ -91,6 +92,7 @@ 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; pucch_Config.pucch_PowerControl = &power_config;
mac.G_b_f_c = 0; mac.G_b_f_c = 0;
mac.pucch_power_control_initialized = true; mac.pucch_power_control_initialized = true;
mac.frame_type = TDD;
int scs = 1; int scs = 1;
int sum_delta_pucch = 3; int sum_delta_pucch = 3;
...@@ -102,8 +104,17 @@ TEST(test_pucch_power_state, test_accumulated_delta_pucch) ...@@ -102,8 +104,17 @@ TEST(test_pucch_power_state, test_accumulated_delta_pucch)
int subframe_number = 0; int subframe_number = 0;
int O_uci = 2; int O_uci = 2;
uint16_t start_prb = 0; uint16_t start_prb = 0;
int P_CMAX = int P_CMAX = nr_get_Pcmax(23,
nr_get_Pcmax(23, mac.nr_band, FR1, 2, false, current_UL_BWP.scs, current_UL_BWP.BWPSize, false, nb_of_prbs, start_prb); 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, int pucch_power_prev = get_pucch_tx_power_ue(&mac,
scs, scs,
&pucch_Config, &pucch_Config,
...@@ -187,6 +198,7 @@ TEST(pusch_power_control, pusch_power_control_msg3) ...@@ -187,6 +198,7 @@ TEST(pusch_power_control, pusch_power_control_msg3)
NR_PUSCH_PowerControl pusch_PowerControl = {0}; NR_PUSCH_PowerControl pusch_PowerControl = {0};
pusch_Config.pusch_PowerControl = &pusch_PowerControl; pusch_Config.pusch_PowerControl = &pusch_PowerControl;
pusch_PowerControl.tpc_Accumulation = (long*)1; pusch_PowerControl.tpc_Accumulation = (long*)1;
mac.frame_type = TDD;
// msg3 cofiguration as in 5g_rfsimulator testcase // msg3 cofiguration as in 5g_rfsimulator testcase
int num_rb = 8; int num_rb = 8;
...@@ -201,7 +213,17 @@ TEST(pusch_power_control, pusch_power_control_msg3) ...@@ -201,7 +213,17 @@ TEST(pusch_power_control, pusch_power_control_msg3)
int delta_pusch = 0; int delta_pusch = 0;
bool is_rar_tx_retx = true; 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; long preambleReceivedTargetPower = -96;
nr_rach_ConfigCommon.rach_ConfigGeneric.preambleReceivedTargetPower = preambleReceivedTargetPower; nr_rach_ConfigCommon.rach_ConfigGeneric.preambleReceivedTargetPower = preambleReceivedTargetPower;
...@@ -236,26 +258,24 @@ TEST(pusch_power_control, pusch_power_control_msg3) ...@@ -236,26 +258,24 @@ TEST(pusch_power_control, pusch_power_control_msg3)
delta_pusch, delta_pusch,
is_rar_tx_retx, is_rar_tx_retx,
false); false);
EXPECT_EQ(std::min(P_CMAX, power - 2), reduced_power) EXPECT_EQ(std::min(P_CMAX, power - 2), reduced_power) << "Incorrect handling of preambleReceivedTargetPower";
<< "Incorrect handling of preambleReceivedTargetPower";
EXPECT_LT(reduced_power, P_CMAX) << "Power above P_CMAX"; EXPECT_LT(reduced_power, P_CMAX) << "Power above P_CMAX";
delta_pusch = 4; delta_pusch = 4;
int increased_power = get_pusch_tx_power_ue(&mac, int increased_power = get_pusch_tx_power_ue(&mac,
num_rb, num_rb,
start_prb, start_prb,
nb_symb_sch, nb_symb_sch,
nb_dmrs_prb, nb_dmrs_prb,
nb_ptrs_prb, nb_ptrs_prb,
Qm, Qm,
R, R,
beta_offset_csi1, beta_offset_csi1,
sum_bits_in_codeblocks, sum_bits_in_codeblocks,
delta_pusch, delta_pusch,
is_rar_tx_retx, is_rar_tx_retx,
false); false);
EXPECT_EQ(std::min(P_CMAX, reduced_power + delta_pusch), increased_power) EXPECT_EQ(std::min(P_CMAX, reduced_power + delta_pusch), increased_power) << "delta_pusch should increase tx power";
<< "delta_pusch should increase tx power";
EXPECT_LT(increased_power, P_CMAX) << "Power above P_CMAX"; EXPECT_LT(increased_power, P_CMAX) << "Power above P_CMAX";
} }
...@@ -269,6 +289,7 @@ TEST(pusch_power_control, pusch_power_data) ...@@ -269,6 +289,7 @@ TEST(pusch_power_control, pusch_power_data)
NR_RACH_ConfigCommon_t nr_rach_ConfigCommon = {0}; NR_RACH_ConfigCommon_t nr_rach_ConfigCommon = {0};
current_UL_BWP.rach_ConfigCommon = &nr_rach_ConfigCommon; current_UL_BWP.rach_ConfigCommon = &nr_rach_ConfigCommon;
mac.nr_band = 78; mac.nr_band = 78;
mac.frame_type = TDD;
bool is_rar_tx_retx = false; bool is_rar_tx_retx = false;
int num_rb = 5; int num_rb = 5;
...@@ -291,7 +312,17 @@ TEST(pusch_power_control, pusch_power_data) ...@@ -291,7 +312,17 @@ TEST(pusch_power_control, pusch_power_data)
current_UL_BWP.p0_NominalWithGrant = &p0_NominalWithGrant; current_UL_BWP.p0_NominalWithGrant = &p0_NominalWithGrant;
pusch_PowerControl.deltaMCS = (long*)1; 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, int power = get_pusch_tx_power_ue(&mac,
num_rb, num_rb,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment