Commit c2b06701 authored by Hongzhi Wang's avatar Hongzhi Wang

nr ue beam selection

parent a597412e
......@@ -144,6 +144,10 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue,
ue->Mod_id = UE_id;
ue->mac_enabled = 1;
ue->if_inst = nr_ue_if_module_init(0);
ue->measurements.gnb_beam_cnt = -1;
ue->measurements.ue_beam_cnt = 0;
ue->measurements.first_beam_meas = 1;
ue->measurements.frame_last_beam = 0;
// Setting UE mode to NOT_SYNCHED by default
for (gNB_id = 0; gNB_id < nb_connected_gNB; gNB_id++){
......
......@@ -116,6 +116,6 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue,
uint16_t rnti,
RX_type_t rx_type);
float_t get_nr_RSRP(module_id_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,int i, int j);
#endif
......@@ -72,7 +72,7 @@ int16_t get_nr_PL(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_index){
10*log10((double)ue->measurements.rsrp[eNB_index]),
ue->frame_parms.pdsch_config_common.referenceSignalPower);*/
return((int16_t)(((10*ue->rx_total_gain_dB) - dB_fixed_times10(ue->measurements.rsrp[gNB_index]))/10));
return((int16_t)(((10*ue->rx_total_gain_dB) - dB_fixed_times10(ue->measurements.rsrp[gNB_index][0][0]))/10));
// dB_fixed_times10(RSoffset*12*ue_g[Mod_id][CC_id]->frame_parms.N_RB_DL) +
//(ue->frame_parms.pdsch_config_common.referenceSignalPower*10))/10));
}
......@@ -89,7 +89,7 @@ uint32_t get_nr_rx_total_gain_dB (module_id_t Mod_id,uint8_t CC_id)
}
float_t get_nr_RSRP(module_id_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,int i, int j)
{
AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is null\n");
......@@ -99,7 +99,7 @@ float_t get_nr_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t gNB_index)
PHY_VARS_NR_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
if (ue)
return (10*log10(ue->measurements.rsrp[gNB_index])-
return (10*log10(ue->measurements.rsrp[gNB_index][i][j])-
get_nr_rx_total_gain_dB(Mod_id,0) -
10*log10(20*12));
return -140.0;
......@@ -231,9 +231,11 @@ void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue,
{
int aarx,rb, symbol_offset;
int16_t *rxF;
int beam_idx_gnb = ue->measurements.gnb_beam_cnt;
int beam_idx_ue = ue->measurements.ue_beam_cnt;
uint16_t Nid_cell = ue->frame_parms.Nid_cell;
uint8_t eNB_offset=0,l,nushift;
uint8_t gNB_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[proc->thread_id].rxdataF;
......@@ -245,7 +247,7 @@ void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue,
symbol_offset = ue->frame_parms.ofdm_symbol_size*((ue->symbol_offset+1)%(ue->frame_parms.symbols_per_slot));
ue->measurements.rsrp[eNB_offset] = 0;
ue->measurements.rsrp[gNB_offset][beam_idx_ue][beam_idx_gnb] = 0;
//if (mac->csirc->reportQuantity.choice.ssb_Index_RSRP){
nb_rb = 20;
......@@ -257,8 +259,8 @@ void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue,
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);
LOG_D(PHY,"[UE %d] slot %d Doing ue_rrc_measurements rsrp/rssi (Nid_cell %d, nushift %d, gNB_offset %d, l %d)\n",ue->Mod_id,slot,Nid_cell,nushift,
gNB_offset,l);
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+ssb_offset+nushift)];
......@@ -267,7 +269,7 @@ void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue,
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]));
ue->measurements.rsrp[gNB_offset][beam_idx_ue][beam_idx_gnb] += (((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;
......@@ -276,21 +278,21 @@ void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue,
}
}
ue->measurements.rsrp[eNB_offset]/=nb_rb;
ue->measurements.rsrp[gNB_offset][beam_idx_ue][beam_idx_gnb]/=nb_rb;
} else {
ue->measurements.rsrp[eNB_offset] = -93 ;
ue->measurements.rsrp[gNB_offset][beam_idx_ue][beam_idx_gnb] = -93 ;
}
if (eNB_offset == 0)
if (gNB_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]);
slot,gNB_offset,
(gNB_offset>0) ? ue->measurements.adj_cell_id[gNB_offset-1] : ue->frame_parms.Nid_cell,
10*log10(ue->measurements.rsrp[gNB_offset][beam_idx_ue][beam_idx_gnb])-ue->rx_total_gain_dB,
ue->measurements.rsrp[gNB_offset][beam_idx_ue][beam_idx_gnb]);
}
......@@ -395,8 +395,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode,
10*log10(ue->measurements.rssi),
ue->rx_total_gain_dB,
ue->measurements.n0_power_tot_dBm,
10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB,
(10*log10(ue->measurements.rsrq[0])));
10*log10(ue->measurements.rsrp[0][0][0])-ue->rx_total_gain_dB,
(10*log10(ue->measurements.rsrq[0][0][0])));
/* LOG_I(PHY, "[UE %d] Frame %d MIB Information => %s, %s, NidCell %d, N_RB_DL %d, PHICH DURATION %d, PHICH RESOURCE %s, TX_ANT %d\n",
ue->Mod_id,
......
......@@ -185,10 +185,16 @@ typedef struct {
uint32_t rssi;
int n_adj_cells;
unsigned int adj_cell_id[6];
uint32_t rsrq[7];
uint32_t rsrp[7];
uint32_t rsrq[7][8][64];
uint32_t rsrp[7][8][64];
float rsrp_filtered[7]; // after layer 3 filtering
float rsrq_filtered[7];
int gnb_beam_cnt;
int ue_beam_cnt;
int first_beam_meas;
int frame_last_beam;
int best_beam_ue;
int best_beam_gnb;
// common measurements
//! estimated noise power (linear)
unsigned int n0_power[NB_ANTENNAS_RX];
......
......@@ -261,7 +261,7 @@ void nr_ue_measurement_procedures(uint16_t l, // symbol index of each slot [0
#if T_TRACER
if(slot == 0)
T(T_UE_PHY_MEAS, T_INT(eNB_id), T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(nr_slot_rx),
T_INT((int)(10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB)),
T_INT((int)(10*log10(ue->measurements.rsrp[0][0][0])-ue->rx_total_gain_dB)),
T_INT((int)ue->measurements.rx_rssi_dBm[0]),
T_INT((int)(ue->measurements.rx_power_avg_dB[0] - ue->measurements.n0_power_avg_dB)),
T_INT((int)ue->measurements.rx_power_avg_dB[0]),
......@@ -1701,6 +1701,55 @@ int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL
}
void nr_get_beam_cnt(PHY_VARS_NR_UE *ue, int frame_rx, uint16_t nb_ssbri_cri) {
printf("before frame temp %d frame rx %d first_beam_meas %d \n", ue->measurements.frame_last_beam, frame_rx, ue->measurements.first_beam_meas);
if (ue->measurements.first_beam_meas)
{
ue->measurements.frame_last_beam = frame_rx;
ue->measurements.first_beam_meas = 0;
}
printf("frame temp %d frame rx %d gnb beam %d ue beam %d\n", ue->measurements.frame_last_beam, frame_rx, ue->measurements.gnb_beam_cnt,ue->measurements.ue_beam_cnt);
if (ue->measurements.frame_last_beam == frame_rx){
ue->measurements.gnb_beam_cnt++;
}
else
{
ue->measurements.ue_beam_cnt++;
ue->measurements.frame_last_beam = frame_rx;
ue->measurements.gnb_beam_cnt = 0;
}
printf("ue procedure gnb beam cnt %d frame_temp %d ue beam %d\n", ue->measurements.gnb_beam_cnt, ue->measurements.frame_last_beam,ue->measurements.ue_beam_cnt);
}
void nr_get_best_beam(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint16_t nb_ssbri_cri) {
uint32_t rsrp_temp = 0;
int ue_beam_temp = 0;
int gnb_beam_temp = 0;
if ((ue->measurements.ue_beam_cnt ==3) && ((nb_ssbri_cri-1)==ue->measurements.gnb_beam_cnt)){
for (int i = 0; i < 4; i++){
for (int j = 0; j < nb_ssbri_cri; j++){
if (ue->measurements.rsrp[gNB_id][i][j] > rsrp_temp){
rsrp_temp = ue->measurements.rsrp[gNB_id][i][j];
ue_beam_temp = i;
gnb_beam_temp = j;
//beam_pair[cnt_gnb_beam]= cnt_ue_beam;
printf("loop temp %d beam ue %d gnb %d rsrp %d\n",ue_beam_temp,i,j,rsrp_temp);
}
}
}
ue->measurements.best_beam_ue = ue_beam_temp;
ue->measurements.best_beam_gnb = gnb_beam_temp;
ue->measurements.ue_beam_cnt = -1;
printf("best ue beam %d\n",ue_beam_temp);
}
}
int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
uint8_t gNB_id,
......@@ -1717,7 +1766,14 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
uint8_t dci_cnt = 0;
NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
//NR_UE_MAC_INST_t *mac = get_mac_inst(0);
uint16_t nb_ssbri_cri = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
NR_CSI_MeasConfig_t *csi_MeasConfig = mac->scg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup;
nb_ssbri_cri = *(csi_MeasConfig->csi_ReportConfigToAddModList->list.array[0]->groupBasedBeamReporting.choice.disabled->nrofReportedRS)+1;
//printf("nb ssbri cri %d\n", nb_ssbri_cri);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN);
......@@ -1739,7 +1795,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
// looking for pbch only in slot where it is supposed to be
if (slot_ssb) {
LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
LOG_I(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
for (int i=1; i<4; i++) {
nr_slot_fep(ue,
......@@ -1757,11 +1813,16 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
stop_meas(&ue->dlsch_channel_estimation_stats);
#endif
}
nr_get_beam_cnt(ue,frame_rx, nb_ssbri_cri);
//if (mac->csirc->reportQuantity.choice.ssb_Index_RSRP){
nr_ue_rsrp_measurements(ue,proc,nr_slot_rx,0);
if (ue->measurements.gnb_beam_cnt<nb_ssbri_cri)
nr_ue_rsrp_measurements(ue,proc,nr_slot_rx, 0);
//}
nr_get_best_beam(ue, gNB_id, nb_ssbri_cri);
if ((ue->decode_MIB == 1) && slot_pbch) {
LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
......
......@@ -95,6 +95,8 @@ binary_search_float_nr(
return first;
}
float diff_rsrp_meas[16] = {0,-2,-4,-6,-8,-10,-12,-14,-16,-18,-20,-22,-24,-26,-28,-30};
/*
void nr_generate_pucch0(int32_t **txdataF,
NR_DL_FRAME_PARMS *frame_parms,
......@@ -1361,9 +1363,18 @@ int get_csi_nr(NR_UE_MAC_INST_t *mac, PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint32
int nElem = 98;
int rsrp_offset = 17;
int csi_status = 0;
uint16_t nb_ssbri_cri = 0;
int best_beam_ue = ue->measurements.best_beam_ue;
int best_beam_gnb = ue->measurements.best_beam_gnb;
NR_CSI_MeasConfig_t *csi_MeasConfig = mac->scg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup;
if (NULL != csi_MeasConfig->csi_ReportConfigToAddModList->list.array[0]->groupBasedBeamReporting.choice.disabled->nrofReportedRS)
nb_ssbri_cri = *(csi_MeasConfig->csi_ReportConfigToAddModList->list.array[0]->groupBasedBeamReporting.choice.disabled->nrofReportedRS)+1;
else
nb_ssbri_cri = 1;
csi_status = get_nr_csi_bitlen(mac);
rsrp_db[0] = get_nr_RSRP(0,0,0);
rsrp_db[0] = get_nr_RSRP(0,0,0,best_beam_ue,best_beam_gnb);
if (csi_status == 0) {
......@@ -1371,6 +1382,12 @@ int get_csi_nr(NR_UE_MAC_INST_t *mac, PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint32
}
else {
*csi_payload = binary_search_float_nr(RSRP_meas_mapping_nr,nElem, rsrp_db[0]) + rsrp_offset;
for (int i=1; i < nb_ssbri_cri; i++){
if (i==best_beam_gnb) i++;
rsrp_db[i] = get_nr_RSRP(0,0,0,best_beam_ue,i);
*csi_payload = *csi_payload | binary_search_float_nr(diff_rsrp_meas,16,(rsrp_db[i]-rsrp_db[0]));
}
}
return (csi_status);
......
......@@ -252,6 +252,8 @@ typedef struct {
uint8_t generate_nr_prach;
/// SSB index from MIB decoding
uint8_t mib_ssb;
/// TCI ssb index
uint8_t tci_ssb_id;
//// FAPI-like interface message
fapi_nr_ul_config_request_t *ul_config_request;
......
......@@ -4715,6 +4715,11 @@ void nr_ue_process_mac_pdu(module_id_t module_idP,
uint16_t mac_ce_len, mac_subheader_len, mac_sdu_len;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated;
NR_BWP_DownlinkDedicated_t *dl_bwp_Dedicated = scd->downlinkBWP_ToAddModList->list.array[0]->bwp_Dedicated;
NR_SetupRelease_PDSCH_Config_t *pdsch_Config = dl_bwp_Dedicated->pdsch_Config;
//NR_UE_MAC_INST_t *UE_mac_inst = get_mac_inst(module_idP);
//uint8_t scs = UE_mac_inst->mib->subCarrierSpacingCommon;
//uint16_t bwp_ul_NB_RB = UE_mac_inst->initial_bwp_ul.N_RB;
......@@ -4829,6 +4834,9 @@ void nr_ue_process_mac_pdu(module_id_t module_idP,
case DL_SCH_LCID_TCI_STATE_IND_UE_SPEC_PDCCH:
// 38.321 Ch6.1.3.15
mac_ce_len = 2;
uint8_t tci_stateid = ((NR_TCI_PDCCH *)pdu_ptr)[1].TciStateId;
uint8_t ssb_id = pdsch_Config->choice.setup->tci_StatesToAddModList->list.array[tci_stateid]->qcl_Type1.referenceSignal.choice.ssb;
mac->tci_ssb_id = ssb_id;
break;
case DL_SCH_LCID_DUPLICATION_ACT:
// 38.321 Ch6.1.3.11
......
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