Commit 42b6576d authored by francescomani's avatar francescomani

fix RSRP computation at UE (let the higher layers compute the index)

parent 55a56002
......@@ -88,8 +88,6 @@ static inline const char *rnti_types(nr_rnti_type_t rr)
#define NR_NUMBER_OF_SYMBOLS_PER_SLOT_EXTENDED_CP 12
#define NR_MAX_NB_LAYERS 4 // 8
#define BOUNDED_EVAL(a, b, c) (min(c, max(a, b)))
// Since the IQ samples are represented by SQ15 R+I (see https://en.wikipedia.org/wiki/Q_(number_format)) we need to compensate when
// calcualting signal energy. Instead of shifting each sample right by 15, we can normalize the result in dB scale once its
// calcualted. Signal energy is calculated using RMS^2, where each sample is squared before taking the average of the sum, therefore
......
......@@ -236,11 +236,10 @@ void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue,
.gNB_index = proc->gNB_id,
.meas_type = NFAPI_NR_SS_MEAS,
.Nid_cell = ue->frame_parms.Nid_cell,
.rsrp_dBm = ue->measurements.ssb_rsrp_dBm[ssb_index],
.ssb_index = ssb_index,
.is_neighboring_cell = false,
};
int ssb_rsrp_dBm = ue->measurements.ssb_rsrp_dBm[ssb_index];
l1_measurements.rsrp_dBm = BOUNDED_EVAL(16, ssb_rsrp_dBm + 157, 113); // TS 38.133 - Table 10.1.6.1-1
nr_downlink_indication_t dl_indication = {0};
fapi_nr_rx_indication_t rx_ind = {0};
nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, NULL);
......
......@@ -987,7 +987,7 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue,
.meas_type = NFAPI_NR_CSI_MEAS,
.Nid_cell = frame_parms->Nid_cell,
.is_neighboring_cell = false,
.rsrp_dBm = BOUNDED_EVAL(16, rsrp_dBm + 157, 113), // TS 38.133 - Table 10.1.6.1-1
.rsrp_dBm = rsrp_dBm,
.rank_indicator = rank_indicator,
.i1 = *i1,
.i2 = *i2,
......
......@@ -184,6 +184,6 @@ void nr_mac_rrc_meas_ind_ue(module_id_t module_id,
uint16_t Nid_cell,
bool csi_meas,
bool is_neighboring_cell,
uint8_t rsrp_dBm)
int rsrp_dBm)
{
}
......@@ -146,7 +146,7 @@ typedef struct NRRrcMacSBcchDataInd_s {
typedef struct NRRrcMacMeasDataInd_s {
uint8_t gnb_index;
uint8_t rsrp_dBm;
int rsrp_dBm;
uint16_t Nid_cell;
bool is_csi_meas;
bool is_neighboring_cell;
......
......@@ -139,7 +139,6 @@ static csi_payload_t get_csirs_RSRP_payload(NR_UE_MAC_INST_t *mac,
struct NR_CSI_ReportConfig *csi_reportconfig,
NR_CSI_ResourceConfigId_t csi_ResourceConfigId,
const NR_CSI_MeasConfig_t *csi_MeasConfig);
static uint8_t get_rsrp_index(int rsrp);
static uint8_t get_rsrp_diff_index(int best_rsrp, int current_rsrp);
......@@ -2917,6 +2916,18 @@ static int compare_ssb_rsrp(const void *a, const void *b)
return mb->ssb_rsrp_dBm - ma->ssb_rsrp_dBm;
}
// returns index from RSRP
// according to Table 10.1.6.1-1 in 38.133
static uint8_t get_rsrp_index(int rsrp)
{
int index = rsrp + 157;
if (rsrp > -44)
index = 113;
if (rsrp < -140)
index = 16;
return index;
}
static csi_payload_t get_ssb_rsrp_payload(NR_UE_MAC_INST_t *mac,
struct NR_CSI_ReportConfig *csi_reportconfig,
NR_CSI_ResourceConfigId_t csi_ResourceConfigId,
......@@ -3126,15 +3137,14 @@ static csi_payload_t get_csirs_RSRP_payload(NR_UE_MAC_INST_t *mac,
}
// TODO: Improvements will be needed to cri_ssbri_bitlen>0
temp_payload = reverse_bits(mac->l1_measurements.rsrp_dBm, n_bits); // rsrp_dBm as in TS 38.133 - Table 10.1.6.1-1
temp_payload = get_rsrp_index(mac->l1_measurements.rsrp_dBm);
temp_payload = reverse_bits(temp_payload, n_bits);
LOG_D(NR_MAC, "cri_ssbri_bitlen = %d\n", cri_ssbri_bitlen);
LOG_D(NR_MAC, "rsrp_bitlen = %d\n", rsrp_bitlen);
LOG_D(NR_MAC, "diff_rsrp_bitlen = %d\n", diff_rsrp_bitlen);
LOG_D(NR_MAC, "n_bits = %d\n", n_bits);
LOG_D(NR_MAC, "csi_part1_payload = 0x%lx\n", temp_payload);
break;
}
}
......@@ -3145,20 +3155,6 @@ static csi_payload_t get_csirs_RSRP_payload(NR_UE_MAC_INST_t *mac,
return csi;
}
// returns index from RSRP
// according to Table 10.1.6.1-1 in 38.133
static uint8_t get_rsrp_index(int rsrp)
{
int index = rsrp + 157;
if (rsrp>-44)
index = 113;
if (rsrp<-140)
index = 16;
return index;
}
// returns index from differential RSRP
// according to Table 10.1.6.1-2 in 38.133
static uint8_t get_rsrp_diff_index(int best_rsrp, int current_rsrp)
......
......@@ -37,7 +37,7 @@
typedef uint32_t channel_t;
void nr_mac_rrc_meas_ind_ue(module_id_t module_id, uint32_t gNB_index, uint16_t Nid_cell, bool csi_meas, bool is_neighboring_cell, uint8_t rsrp_dBm)
void nr_mac_rrc_meas_ind_ue(module_id_t module_id, uint32_t gNB_index, uint16_t Nid_cell, bool csi_meas, bool is_neighboring_cell, int rsrp_dBm)
{
MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_MEAS_DATA_IND);
NR_RRC_MAC_MEAS_DATA_IND(message_p).gnb_index = gNB_index;
......
......@@ -42,7 +42,7 @@ void nr_mac_rrc_meas_ind_ue(module_id_t module_id,
uint16_t Nid_cell,
bool csi_meas,
bool is_neighboring_cell,
uint8_t rsrp_dBm);
int rsrp_dBm);
void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id);
void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, bool prepare_payload);
void nr_ue_rrc_timer_trigger(int instance, int frame, int gnb_id);
......
......@@ -2589,14 +2589,14 @@ void *rrc_nrue(void *notUsed)
NR_RRC_MAC_MEAS_DATA_IND(msg_p).is_neighboring_cell? "Neighboring cell" : "Active cell",
NR_RRC_MAC_MEAS_DATA_IND(msg_p).Nid_cell,
NR_RRC_MAC_MEAS_DATA_IND(msg_p).is_csi_meas ? "CSI meas" : "SSB meas",
NR_RRC_MAC_MEAS_DATA_IND(msg_p).rsrp_dBm - 157);
NR_RRC_MAC_MEAS_DATA_IND(msg_p).rsrp_dBm);
rrcPerNB_t *rrcNB = rrc->perNB + NR_RRC_MAC_MEAS_DATA_IND(msg_p).gnb_index;
nr_ue_meas_filtering(rrcNB,
NR_RRC_MAC_MEAS_DATA_IND(msg_p).is_neighboring_cell,
NR_RRC_MAC_MEAS_DATA_IND(msg_p).Nid_cell,
NR_RRC_MAC_MEAS_DATA_IND(msg_p).is_csi_meas,
NR_RRC_MAC_MEAS_DATA_IND(msg_p).rsrp_dBm - 157);
NR_RRC_MAC_MEAS_DATA_IND(msg_p).rsrp_dBm);
nr_ue_check_meas_report(rrc, NR_RRC_MAC_MEAS_DATA_IND(msg_p).gnb_index);
break;
......
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