Commit 4d4843e7 authored by Hongzhi Wang's avatar Hongzhi Wang

adding rsrp measurement and csi report

parent 69221575
...@@ -87,6 +87,10 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, ...@@ -87,6 +87,10 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue,
unsigned char rank_adaptation, unsigned char rank_adaptation,
uint8_t subframe); uint8_t subframe);
void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue,
uint8_t slot,
uint8_t abstraction_flag);
void phy_adjust_gain_nr(PHY_VARS_NR_UE *ue, void phy_adjust_gain_nr(PHY_VARS_NR_UE *ue,
uint32_t rx_power_fil_dB, uint32_t rx_power_fil_dB,
uint8_t eNB_id); uint8_t eNB_id);
...@@ -94,4 +98,6 @@ void phy_adjust_gain_nr(PHY_VARS_NR_UE *ue, ...@@ -94,4 +98,6 @@ void phy_adjust_gain_nr(PHY_VARS_NR_UE *ue,
int16_t get_nr_PL(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_index); int16_t get_nr_PL(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_index);
float_t get_nr_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t gNB_index);
#endif #endif
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "PHY/phy_extern_nr_ue.h" #include "PHY/phy_extern_nr_ue.h"
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
#include "PHY/sse_intrin.h" #include "PHY/sse_intrin.h"
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
//#define k1 1000 //#define k1 1000
#define k1 ((long long int) 1000) #define k1 ((long long int) 1000)
...@@ -76,6 +77,35 @@ int16_t get_nr_PL(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_index){ ...@@ -76,6 +77,35 @@ int16_t get_nr_PL(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_index){
//(ue->frame_parms.pdsch_config_common.referenceSignalPower*10))/10)); //(ue->frame_parms.pdsch_config_common.referenceSignalPower*10))/10));
} }
uint32_t get_nr_rx_total_gain_dB (module_id_t Mod_id,uint8_t CC_id)
{
PHY_VARS_NR_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
if (ue)
return ue->rx_total_gain_dB;
return 0xFFFFFFFF;
}
float_t get_nr_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t gNB_index)
{
AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is null\n");
AssertFatal(PHY_vars_UE_g[Mod_id]!=NULL,"PHY_vars_UE_g[%d] is null\n",Mod_id);
AssertFatal(PHY_vars_UE_g[Mod_id][CC_id]!=NULL,"PHY_vars_UE_g[%d][%d] is null\n",Mod_id,CC_id);
PHY_VARS_NR_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
if (ue)
return (10*log10(ue->measurements.rsrp[gNB_index])-
get_nr_rx_total_gain_dB(Mod_id,0) -
10*log10(20*12));
return -140.0;
}
void nr_ue_measurements(PHY_VARS_NR_UE *ue, void nr_ue_measurements(PHY_VARS_NR_UE *ue,
unsigned int subframe_offset, unsigned int subframe_offset,
unsigned char N0_symbol, unsigned char N0_symbol,
...@@ -192,3 +222,73 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, ...@@ -192,3 +222,73 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue,
_m_empty(); _m_empty();
#endif #endif
} }
void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue,
uint8_t slot,
uint8_t abstraction_flag)
{
int aarx,rb, symbol_offset;
int16_t *rxF;
uint16_t Nid_cell = ue->frame_parms.Nid_cell;
uint8_t eNB_offset=0,l,nushift;
uint16_t off,nb_rb;
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[slot]].rxdataF;
nushift = ue->frame_parms.Nid_cell%4;
ue->frame_parms.nushift = nushift;
unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier;
if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size;
symbol_offset = ue->frame_parms.ofdm_symbol_size*(ue->symbol_offset+1);
ue->measurements.rsrp[eNB_offset] = 0;
//if (mac->csirc->reportQuantity.choice.ssb_Index_RSRP){
nb_rb = 20;
//} else{
// LOG_E(PHY,"report quantity not supported \n");
//}
if (abstraction_flag == 0) {
for (l=0; l<1; l++) {
LOG_D(PHY,"[UE %d] slot %d Doing ue_rrc_measurements rsrp/rssi (Nid_cell %d, nushift %d, eNB_offset %d, l %d)\n",ue->Mod_id,slot,Nid_cell,nushift,
eNB_offset,l);
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+ssb_offset+nushift)];
off = 0;
if (l==0) {
for (rb=0; rb<nb_rb; rb++) {
ue->measurements.rsrp[eNB_offset] += (((int32_t)(rxF[off])*rxF[off])+((int32_t)(rxF[off+1])*rxF[off+1]));
//printf("rb %d, off %d : %d\n",rb,off,((((int32_t)rxF[off])*rxF[off])+((int32_t)(rxF[off+1])*rxF[off+1])));
off = (off+4) % ue->frame_parms.ofdm_symbol_size;
}
}
}
}
ue->measurements.rsrp[eNB_offset]/=nb_rb;
} else {
ue->measurements.rsrp[eNB_offset] = -93 ;
}
if (eNB_offset == 0)
LOG_I(PHY,"[UE %d] slot %d RRC Measurements (idx %d, Cell id %d) => rsrp: %3.1f dBm/RE (%d)\n",
ue->Mod_id,
slot,eNB_offset,
(eNB_offset>0) ? ue->measurements.adj_cell_id[eNB_offset-1] : ue->frame_parms.Nid_cell,
10*log10(ue->measurements.rsrp[eNB_offset])-ue->rx_total_gain_dB,
ue->measurements.rsrp[eNB_offset]);
}
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
#include "SCHED/phy_procedures_emos.h" #include "SCHED/phy_procedures_emos.h"
#endif #endif
#include "executables/softmodem-common.h" #include "executables/softmodem-common.h"
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
//#define DEBUG_PHY_PROC //#define DEBUG_PHY_PROC
#define NR_PDCCH_SCHED #define NR_PDCCH_SCHED
...@@ -4044,6 +4046,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, ...@@ -4044,6 +4046,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
uint8_t dci_cnt = 0; uint8_t dci_cnt = 0;
NR_DL_FRAME_PARMS *fp = &ue->frame_parms; NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN);
LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx%1024, nr_tti_rx); LOG_D(PHY," ****** start RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx%1024, nr_tti_rx);
...@@ -4084,8 +4088,14 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, ...@@ -4084,8 +4088,14 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
#endif #endif
} }
//if (mac->csirc->reportQuantity.choice.ssb_Index_RSRP){
nr_ue_rsrp_measurements(ue,nr_tti_rx,0);
//}
nr_ue_pbch_procedures(eNB_id,ue,proc,0); nr_ue_pbch_procedures(eNB_id,ue,proc,0);
if (ue->no_timing_correction==0) { if (ue->no_timing_correction==0) {
LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction); LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction);
nr_adjust_synch_ue(fp, nr_adjust_synch_ue(fp,
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include "PHY/defs_nr_UE.h" #include "PHY/defs_nr_UE.h"
#include <openair1/SCHED/sched_common.h> #include <openair1/SCHED/sched_common.h>
#include <openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h> #include <openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h>
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
#include "openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h"
#ifndef NO_RAT_NR #ifndef NO_RAT_NR
...@@ -44,9 +46,9 @@ ...@@ -44,9 +46,9 @@
#include "SCHED_NR_UE/harq_nr.h" #include "SCHED_NR_UE/harq_nr.h"
#include "SCHED_NR_UE/pucch_power_control_ue_nr.h" #include "SCHED_NR_UE/pucch_power_control_ue_nr.h"
#define DEFINE_VARIABLES_PUCCH_UE_NR_H //#define DEFINE_VARIABLES_PUCCH_UE_NR_H
#include "SCHED_NR_UE/pucch_uci_ue_nr.h" #include "SCHED_NR_UE/pucch_uci_ue_nr.h"
#undef DEFINE_VARIABLES_PUCCH_UE_NR_H //#undef DEFINE_VARIABLES_PUCCH_UE_NR_H
#endif #endif
...@@ -54,6 +56,44 @@ ...@@ -54,6 +56,44 @@
uint8_t nr_is_cqi_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id); uint8_t nr_is_cqi_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id);
uint8_t nr_is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id); uint8_t nr_is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id);
long
binary_search_float_nr(
float elements[],
long numElem,
float value
)
//-----------------------------------------------------------------------------
{
long first, last, middle;
first = 0;
last = numElem-1;
middle = (first+last)/2;
if(value < elements[0]) {
return first;
}
if(value >= elements[last]) {
return last;
}
while (last - first > 1) {
if (elements[middle] > value) {
last = middle;
} else {
first = middle;
}
middle = (first+last)/2;
}
if (first < 0 || first >= numElem) {
LOG_E(RRC,"\n Error in binary search float!");
}
return first;
}
/* /*
void nr_generate_pucch0(int32_t **txdataF, void nr_generate_pucch0(int32_t **txdataF,
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
...@@ -1242,7 +1282,7 @@ int trigger_periodic_scheduling_request(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_n ...@@ -1242,7 +1282,7 @@ int trigger_periodic_scheduling_request(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_n
* *
*********************************************************************/ *********************************************************************/
int dummy_csi_status = 0; int dummy_csi_status = 1;
uint32_t dummy_csi_payload = 0; uint32_t dummy_csi_payload = 0;
/* FFS TODO_NR code that should be developed */ /* FFS TODO_NR code that should be developed */
...@@ -1251,12 +1291,18 @@ int get_csi_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint32_t *csi_payload) ...@@ -1251,12 +1291,18 @@ int get_csi_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint32_t *csi_payload)
{ {
VOID_PARAMETER ue; VOID_PARAMETER ue;
VOID_PARAMETER gNB_id; VOID_PARAMETER gNB_id;
float rsrp_db[7];
int nElem = 98;
int rsrp_offset = 17;
rsrp_db[0] = get_nr_RSRP(0,0,0);
if (dummy_csi_status == 0) { if (dummy_csi_status == 0) {
*csi_payload = 0; *csi_payload = 0;
} }
else { else {
*csi_payload = dummy_csi_payload; *csi_payload = binary_search_float_nr(RSRP_meas_mapping_nr,nElem, rsrp_db[0]) + rsrp_offset;
} }
return (dummy_csi_status); return (dummy_csi_status);
......
...@@ -60,6 +60,111 @@ ...@@ -60,6 +60,111 @@
/************** VARIABLES *****************************************/ /************** VARIABLES *****************************************/
float RSRP_meas_mapping_nr[98]
#ifdef INIT_VARIABLES_PUCCH_UE_NR_H
= {
-140,
-139,
-138,
-137,
-136,
-135,
-134,
-133,
-132,
-131,
-130,
-129,
-128,
-127,
-126,
-125,
-124,
-123,
-122,
-121,
-120,
-119,
-118,
-117,
-116,
-115,
-114,
-113,
-112,
-111,
-110,
-109,
-108,
-107,
-106,
-105,
-104,
-103,
-102,
-101,
-100,
-99,
-98,
-97,
-96,
-95,
-94,
-93,
-92,
-91,
-90,
-89,
-88,
-87,
-86,
-85,
-84,
-83,
-82,
-81,
-80,
-79,
-78,
-77,
-76,
-75,
-74,
-73,
-72,
-71,
-70,
-69,
-68,
-67,
-66,
-65,
-64,
-63,
-62,
-61,
-60,
-59,
-58,
-57,
-56,
-55,
-54,
-53,
-52,
-51,
-50,
-49,
-48,
-47,
-46,
-45,
-44,
-43
}
#endif
;
/* TS 36.213 Table 9.2.1-1: PUCCH resource sets before dedicated PUCCH resource configuration */ /* TS 36.213 Table 9.2.1-1: PUCCH resource sets before dedicated PUCCH resource configuration */
const initial_pucch_resource_t initial_pucch_resource[NB_INITIAL_PUCCH_RESOURCE] const initial_pucch_resource_t initial_pucch_resource[NB_INITIAL_PUCCH_RESOURCE]
#ifdef INIT_VARIABLES_PUCCH_UE_NR_H #ifdef INIT_VARIABLES_PUCCH_UE_NR_H
......
...@@ -63,7 +63,11 @@ ...@@ -63,7 +63,11 @@
#include "NR_PhysicalCellGroupConfig.h" #include "NR_PhysicalCellGroupConfig.h"
#include "NR_CellGroupConfig.h" #include "NR_CellGroupConfig.h"
#include "NR_ServingCellConfig.h" #include "NR_ServingCellConfig.h"
#include "NR_MeasConfig.h"
#include "fapi_nr_ue_interface.h"
#include "NR_IF_Module.h"
#include "PHY/defs_nr_common.h"
#include "openair2/LAYER2/NR_MAC_COMMON/nr_mac.h"
#define NB_NR_UE_MAC_INST 1 #define NB_NR_UE_MAC_INST 1
/*!\brief Maximum number of logical channl group IDs */ /*!\brief Maximum number of logical channl group IDs */
...@@ -158,6 +162,7 @@ typedef struct { ...@@ -158,6 +162,7 @@ typedef struct {
NR_CellGroupConfig_t *scg; NR_CellGroupConfig_t *scg;
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated; NR_RACH_ConfigDedicated_t *rach_ConfigDedicated;
int servCellIndex; int servCellIndex;
NR_CSI_ReportConfig_t *csirc;
//// MAC config //// MAC config
NR_DRX_Config_t *drx_Config; NR_DRX_Config_t *drx_Config;
NR_SchedulingRequestConfig_t *schedulingRequestConfig; NR_SchedulingRequestConfig_t *schedulingRequestConfig;
......
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