Commit 03b556fb authored by Bartosz Podrygajlo's avatar Bartosz Podrygajlo

Add google test testcases for nr_get_Pcmax.

parent 5c4bde3d
add_subdirectory(nr_rlc) add_subdirectory(nr_rlc)
add_subdirectory(NR_MAC_UE)
...@@ -232,7 +232,16 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, ...@@ -232,7 +232,16 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
PUCCH_sched_t *pucch, PUCCH_sched_t *pucch,
fapi_nr_ul_config_pucch_pdu *pucch_pdu); fapi_nr_ul_config_pucch_pdu *pucch_pdu);
int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs, int N_RB_UL, bool is_transform_precoding, int n_prbs, int start_prb); int nr_get_Pcmax(int p_Max,
uint16_t nr_band,
frequency_range_t frequency_range,
int Qm,
bool powerBoostPi2BPSK,
int scs,
int N_RB_UL,
bool is_transform_precoding,
int n_prbs,
int start_prb);
/* Random Access */ /* Random Access */
......
...@@ -79,7 +79,16 @@ void init_RA(NR_UE_MAC_INST_t *mac, ...@@ -79,7 +79,16 @@ void init_RA(NR_UE_MAC_INST_t *mac,
int n_prbs = get_N_RA_RB(prach_scs, mac->current_UL_BWP->scs); int n_prbs = get_N_RA_RB(prach_scs, mac->current_UL_BWP->scs);
int start_prb = rach_ConfigGeneric->msg1_FrequencyStart + mac->current_UL_BWP->BWPStart; int start_prb = rach_ConfigGeneric->msg1_FrequencyStart + mac->current_UL_BWP->BWPStart;
// 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, 2, false, prach_scs, cfg->carrier_config.dl_grid_size[prach_scs], true, n_prbs, start_prb); prach_resources->RA_PCMAX = nr_get_Pcmax(mac->p_Max,
mac->nr_band,
mac->frequency_range,
2,
false,
prach_scs,
cfg->carrier_config.dl_grid_size[prach_scs],
true,
n_prbs,
start_prb);
prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER = 1; prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER = 1;
prach_resources->RA_PREAMBLE_POWER_RAMPING_COUNTER = 1; prach_resources->RA_PREAMBLE_POWER_RAMPING_COUNTER = 1;
prach_resources->POWER_OFFSET_2STEP_RA = 0; prach_resources->POWER_OFFSET_2STEP_RA = 0;
......
...@@ -51,16 +51,24 @@ ...@@ -51,16 +51,24 @@
// -- Powerclass 3 capable UE (which is default power class unless otherwise stated) // -- Powerclass 3 capable UE (which is default power class unless otherwise stated)
// -- Maximum power reduction (MPR_c) for power class 3 // -- Maximum power reduction (MPR_c) for power class 3
// -- no additional MPR (A_MPR_c) // -- no additional MPR (A_MPR_c)
int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs, int N_RB_UL, bool is_transform_precoding, int n_prbs, int start_prb) int nr_get_Pcmax(int p_Max,
uint16_t nr_band,
frequency_range_t frequency_range,
int Qm,
bool powerBoostPi2BPSK,
int scs,
int N_RB_UL,
bool is_transform_precoding,
int n_prbs,
int start_prb)
{ {
int nr_band = mac->nr_band; if (frequency_range == FR1) {
if(mac->frequency_range == FR1) { // TODO configure P-MAX from the upper layers according to 38.331
//TODO configure P-MAX from the upper layers according to 38.331
int p_powerclass = 23; // dBm assuming poweclass 3 UE int p_powerclass = 23; // dBm assuming poweclass 3 UE
int p_emax = mac->p_Max != INT_MIN ? mac->p_Max : p_powerclass; int p_emax = p_Max != INT_MIN ? p_Max : p_powerclass;
int delta_P_powerclass = 0; // for powerclass 2 needs to be changed int delta_P_powerclass = 0; // for powerclass 2 needs to be changed
if(mac->p_Max && Qm == 1 && powerBoostPi2BPSK && (nr_band == 40 || nr_band == 41 || nr_band == 77 || nr_band == 78 || nr_band == 79)) { if (p_Max && Qm == 1 && powerBoostPi2BPSK
&& (nr_band == 40 || nr_band == 41 || nr_band == 77 || nr_band == 78 || nr_band == 79)) {
p_emax += 3; p_emax += 3;
delta_P_powerclass -= 3; delta_P_powerclass -= 3;
} }
...@@ -69,54 +77,53 @@ int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs, ...@@ -69,54 +77,53 @@ int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs,
int delta_T_IB = 0; int delta_T_IB = 0;
// TODO in case of band 41 and PRB allocation within 4MHz of the upper or lower limit of the band -> delta_TC = 1.5 // TODO in case of band 41 and PRB allocation within 4MHz of the upper or lower limit of the band -> delta_TC = 1.5
if(nr_band == 41) if (nr_band == 41)
LOG_E(NR_MAC, "Need to implement delta_TC for band 41\n"); LOG_E(NR_MAC, "Need to implement delta_TC for band 41\n");
int delta_TC = 0; int delta_TC = 0;
float MPR = 0; float MPR = 0;
frame_type_t frame_type = get_frame_type(nr_band, scs); 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)) {
int rb_low = (n_prbs / 2) > 1 ? (n_prbs / 2) : 1; int rb_low = (n_prbs / 2) > 1 ? (n_prbs / 2) : 1;
int rb_high = N_RB_UL - rb_low - n_prbs; int rb_high = N_RB_UL - rb_low - n_prbs;
bool is_inner_rb = start_prb >= rb_low && start_prb <= rb_high && n_prbs <= ((N_RB_UL / 2) + (N_RB_UL & 1)); bool is_inner_rb = start_prb >= rb_low && start_prb <= rb_high && n_prbs <= ((N_RB_UL / 2) + (N_RB_UL & 1));
// Table 6.2.2-1 in 38.101 // Table 6.2.2-1 in 38.101
printf("rb_low, rb_high, inner_rb %d %d %d\n", rb_low, rb_high, is_inner_rb);
switch (Qm) { switch (Qm) {
case 1 : case 1:
AssertFatal(false, "MPR for Pi/2 BPSK not implemented yet\n"); AssertFatal(false, "MPR for Pi/2 BPSK not implemented yet\n");
break; break;
case 2 : case 2:
if (is_transform_precoding) { if (is_transform_precoding) {
if(!is_inner_rb) if (!is_inner_rb)
MPR = 1; MPR = 1;
} } else {
else { if (is_inner_rb)
if(is_inner_rb)
MPR = 1.5; MPR = 1.5;
else else
MPR = 3; MPR = 3;
} }
break; break;
case 4 : case 4:
if (is_transform_precoding) { if (is_transform_precoding) {
if(is_inner_rb) if (is_inner_rb)
MPR = 1; MPR = 1;
else else
MPR = 2; MPR = 2;
} } else {
else { if (is_inner_rb)
if(is_inner_rb)
MPR = 2; MPR = 2;
else else
MPR = 3; MPR = 3;
} }
break; break;
case 6 : case 6:
if (is_transform_precoding) if (is_transform_precoding)
MPR = 2.5; MPR = 2.5;
else else
MPR = 3.5; MPR = 3.5;
break; break;
case 8 : case 8:
if (is_transform_precoding) if (is_transform_precoding)
MPR = 4.5; MPR = 4.5;
else else
...@@ -136,12 +143,12 @@ int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs, ...@@ -136,12 +143,12 @@ int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs,
if (P_MPR > total_reduction) if (P_MPR > total_reduction)
total_reduction = P_MPR; total_reduction = P_MPR;
int pcmax_high, pcmax_low; int pcmax_high, pcmax_low;
if(mac->p_Max) { if (p_Max) {
pcmax_high = p_emax < (p_powerclass - delta_P_powerclass) ? p_emax : (p_powerclass - delta_P_powerclass); pcmax_high = p_emax < (p_powerclass - delta_P_powerclass) ? p_emax : (p_powerclass - delta_P_powerclass);
pcmax_low = (p_emax - delta_TC) < (p_powerclass - delta_P_powerclass - total_reduction) ? pcmax_low = (p_emax - delta_TC) < (p_powerclass - delta_P_powerclass - total_reduction)
(p_emax - delta_TC) : (p_powerclass - delta_P_powerclass - total_reduction); ? (p_emax - delta_TC)
} : (p_powerclass - delta_P_powerclass - total_reduction);
else { } else {
pcmax_high = p_powerclass - delta_P_powerclass; pcmax_high = p_powerclass - delta_P_powerclass;
pcmax_low = p_powerclass - delta_P_powerclass - total_reduction; pcmax_low = p_powerclass - delta_P_powerclass - total_reduction;
} }
...@@ -149,10 +156,8 @@ int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs, ...@@ -149,10 +156,8 @@ int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs,
int pcmax = (pcmax_low + pcmax_high) / 2; int pcmax = (pcmax_low + pcmax_high) / 2;
LOG_D(MAC, "Configured maximum output power: %d dBm <= PCMAX %d dBm <= %d dBm \n", pcmax_low, pcmax, pcmax_high); LOG_D(MAC, "Configured maximum output power: %d dBm <= PCMAX %d dBm <= %d dBm \n", pcmax_low, pcmax, pcmax_high);
return pcmax; return pcmax;
} } else {
else {
// FR2 TODO it is even more complex because it is radiated power // FR2 TODO it is even more complex because it is radiated power
return 23; return 23;
} }
} }
add_executable(test_nr_ue_power_procedures
test_nr_ue_power_procedures.cpp)
target_link_libraries(test_nr_ue_power_procedures PRIVATE NR_L2_UE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs gtest minimal_lib nr_l2_common UTIL)
add_test(NAME test_nr_ue_power_procedures
COMMAND ./test_nr_ue_power_procedures
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
#include "gtest/gtest.h"
extern "C" {
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
}
#include <cstdio>
#include "common/utils/LOG/log.h"
TEST(power_procedures_fr1, test_prach_max_tx_power_mpr)
{
// Inner PRB, MPR = 1.5
int prb_start = 4;
int N_RB_UL = 51; // 10Mhz
EXPECT_EQ(22, nr_get_Pcmax(23, 20, FR1, 2, false, 1, N_RB_UL, false, 6, prb_start));
// Outer PRB, MPR = 3
prb_start = 0;
EXPECT_EQ(21, nr_get_Pcmax(23, 20, FR1, 2, false, 1, N_RB_UL, false, 6, prb_start));
// Channel bandwidth conditon not met, no MPR
N_RB_UL = 106;
EXPECT_EQ(23, nr_get_Pcmax(23, 20, FR1, 2, false, 1, N_RB_UL, false, 6, prb_start));
}
TEST(power_procedures_fr1, 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");
}
int main(int argc, char** argv)
{
logInit();
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
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