Commit 49ea6c42 authored by Hongzhi Wang's avatar Hongzhi Wang

update SSB ID for RO

parent c2b06701
...@@ -148,6 +148,7 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, ...@@ -148,6 +148,7 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue,
ue->measurements.ue_beam_cnt = 0; ue->measurements.ue_beam_cnt = 0;
ue->measurements.first_beam_meas = 1; ue->measurements.first_beam_meas = 1;
ue->measurements.frame_last_beam = 0; ue->measurements.frame_last_beam = 0;
ue->measurements.beam_select_ready = 0;
// Setting UE mode to NOT_SYNCHED by default // Setting UE mode to NOT_SYNCHED by default
for (gNB_id = 0; gNB_id < nb_connected_gNB; gNB_id++){ for (gNB_id = 0; gNB_id < nb_connected_gNB; gNB_id++){
......
...@@ -268,6 +268,8 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, ...@@ -268,6 +268,8 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg,
int Ncp = NFAPI_CP_NORMAL; int Ncp = NFAPI_CP_NORMAL;
int mu = cfg->ssb_config.scs_common.value; int mu = cfg->ssb_config.scs_common.value;
LOG_I(PHY,"Initializing frame parms for mu %d, N_RB %d, Ncp %d l_ssb %lx \n",mu, fp->N_RB_DL, Ncp, fp->L_ssb);
#if DISABLE_LOG_X #if DISABLE_LOG_X
printf("Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, fp->N_RB_DL, Ncp); printf("Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, fp->N_RB_DL, Ncp);
#else #else
......
...@@ -100,7 +100,7 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, ...@@ -100,7 +100,7 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
//printf("adjust sync count_max_pos_ok = %d\n",count_max_pos_ok); //printf("adjust sync count_max_pos_ok = %d\n",count_max_pos_ok);
if(count_max_pos_ok > 10 && first_time == 1) if((count_max_pos_ok > 10) && (first_time == 1)&& (ue->measurements.beam_select_ready))
{ {
first_time = 0; first_time = 0;
ue->time_sync_cell = 1; ue->time_sync_cell = 1;
......
...@@ -444,6 +444,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -444,6 +444,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
// FT ?? cppcheck fix memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); // FT ?? cppcheck fix memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS);
//printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell); //printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell);
// NR_UE_MAC_INST_t *mac = get_mac_inst(0);
pbch_e_rx = &nr_ue_pbch_vars->llr[0]; pbch_e_rx = &nr_ue_pbch_vars->llr[0];
// clear LLR buffer // clear LLR buffer
memset(nr_ue_pbch_vars->llr,0,NR_POLAR_PBCH_E); memset(nr_ue_pbch_vars->llr,0,NR_POLAR_PBCH_E);
...@@ -606,6 +608,14 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -606,6 +608,14 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
} }
#endif #endif
//if (ue->measurements.best_beam_gnb == ue->measurements.gnb_beam_cnt)
//mac->best_init_ssb_id = i_ssb;
//if (ue->measurements.best_beam_gnb == ue->measurements.gnb_beam_cnt || ue->measurements.first_beam_meas)
//if (ue->measurements.best_beam_gnb == ue->measurements.gnb_beam_cnt || ue->measurements.first_beam_meas)
{
nr_downlink_indication_t dl_indication; nr_downlink_indication_t dl_indication;
fapi_nr_rx_indication_t rx_ind; fapi_nr_rx_indication_t rx_ind;
...@@ -628,6 +638,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -628,6 +638,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
if (ue->if_inst && ue->if_inst->dl_indication) if (ue->if_inst && ue->if_inst->dl_indication)
ue->if_inst->dl_indication(&dl_indication, NULL); ue->if_inst->dl_indication(&dl_indication, NULL);
}
return 0; return 0;
} }
...@@ -195,6 +195,7 @@ typedef struct { ...@@ -195,6 +195,7 @@ typedef struct {
int frame_last_beam; int frame_last_beam;
int best_beam_ue; int best_beam_ue;
int best_beam_gnb; int best_beam_gnb;
int beam_select_ready;
// common measurements // common measurements
//! estimated noise power (linear) //! estimated noise power (linear)
unsigned int n0_power[NB_ANTENNAS_RX]; unsigned int n0_power[NB_ANTENNAS_RX];
......
...@@ -1684,6 +1684,8 @@ int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL ...@@ -1684,6 +1684,8 @@ int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL
int ssb_slot_decoded = (fp->ssb_index>>1) + ((fp->ssb_index>>4)<<1); //slot in which the decoded SSB can be found int ssb_slot_decoded = (fp->ssb_index>>1) + ((fp->ssb_index>>4)<<1); //slot in which the decoded SSB can be found
printf("ssb_slot_decoded %d fp ssb index %d period %d\n", ssb_slot_decoded,fp->ssb_index,config->ssb_table.ssb_period);
if (config->ssb_table.ssb_period == 0) { if (config->ssb_table.ssb_period == 0) {
// check for pbch in corresponding slot each half frame // check for pbch in corresponding slot each half frame
if (fp->half_frame_bit) if (fp->half_frame_bit)
...@@ -1712,6 +1714,9 @@ void nr_get_beam_cnt(PHY_VARS_NR_UE *ue, int frame_rx, uint16_t nb_ssbri_cri) { ...@@ -1712,6 +1714,9 @@ void nr_get_beam_cnt(PHY_VARS_NR_UE *ue, int frame_rx, uint16_t nb_ssbri_cri) {
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); 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.ue_beam_cnt == -1)
// ue->measurements.beam_select_ready = 0;
if (ue->measurements.frame_last_beam == frame_rx){ if (ue->measurements.frame_last_beam == frame_rx){
ue->measurements.gnb_beam_cnt++; ue->measurements.gnb_beam_cnt++;
} }
...@@ -1722,7 +1727,7 @@ void nr_get_beam_cnt(PHY_VARS_NR_UE *ue, int frame_rx, uint16_t nb_ssbri_cri) { ...@@ -1722,7 +1727,7 @@ void nr_get_beam_cnt(PHY_VARS_NR_UE *ue, int frame_rx, uint16_t nb_ssbri_cri) {
ue->measurements.gnb_beam_cnt = 0; 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); printf("ue procedure gnb beam cnt %d frame_temp %d ue beam %d ready %d\n", ue->measurements.gnb_beam_cnt, ue->measurements.frame_last_beam,ue->measurements.ue_beam_cnt,ue->measurements.beam_select_ready);
} }
void nr_get_best_beam(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint16_t nb_ssbri_cri) { void nr_get_best_beam(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint16_t nb_ssbri_cri) {
...@@ -1730,6 +1735,7 @@ void nr_get_best_beam(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint16_t nb_ssbri_cri) ...@@ -1730,6 +1735,7 @@ void nr_get_best_beam(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint16_t nb_ssbri_cri)
uint32_t rsrp_temp = 0; uint32_t rsrp_temp = 0;
int ue_beam_temp = 0; int ue_beam_temp = 0;
int gnb_beam_temp = 0; int gnb_beam_temp = 0;
printf("nb_ssbri_cri %d\n", nb_ssbri_cri);
if ((ue->measurements.ue_beam_cnt ==3) && ((nb_ssbri_cri-1)==ue->measurements.gnb_beam_cnt)){ 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 i = 0; i < 4; i++){
...@@ -1746,7 +1752,8 @@ void nr_get_best_beam(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint16_t nb_ssbri_cri) ...@@ -1746,7 +1752,8 @@ void nr_get_best_beam(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint16_t nb_ssbri_cri)
ue->measurements.best_beam_ue = ue_beam_temp; ue->measurements.best_beam_ue = ue_beam_temp;
ue->measurements.best_beam_gnb = gnb_beam_temp; ue->measurements.best_beam_gnb = gnb_beam_temp;
ue->measurements.ue_beam_cnt = -1; ue->measurements.ue_beam_cnt = -1;
printf("best ue beam %d\n",ue_beam_temp); ue->measurements.beam_select_ready = 1;
printf("best ue beam %d gnb %d ready %d\n",ue_beam_temp, gnb_beam_temp, ue->measurements.beam_select_ready);
} }
} }
...@@ -1771,7 +1778,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, ...@@ -1771,7 +1778,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
NR_UE_MAC_INST_t *mac = get_mac_inst(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; 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; nb_ssbri_cri = 4; //*(csi_MeasConfig->csi_ReportConfigToAddModList->list.array[0]->groupBasedBeamReporting.choice.disabled->nrofReportedRS)+1;
//printf("nb ssbri cri %d\n", nb_ssbri_cri); //printf("nb ssbri cri %d\n", nb_ssbri_cri);
...@@ -1823,13 +1830,23 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, ...@@ -1823,13 +1830,23 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
nr_get_best_beam(ue, gNB_id, nb_ssbri_cri); nr_get_best_beam(ue, gNB_id, nb_ssbri_cri);
if ((ue->decode_MIB == 1) && slot_pbch) { //mac->best_init_ssb_id = ue->measurements.best_beam_gnb;
//if (ue->measurements.best_beam_gnb == ue->measurements.gnb_beam_cnt || ue->measurements.first_beam_meas)
//LOG_I(PHY," ------ before frame.slot %d.%d ------ best beam %d gnb beam cnt %d\n", frame_rx%1024, nr_slot_rx, ue->measurements.best_beam_gnb, ue->measurements.gnb_beam_cnt);
LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
//if ((ue->decode_MIB == 1) && (ue->measurements.best_beam_gnb == ue->measurements.gnb_beam_cnt)) { //&& slot_pbch
if ((ue->decode_MIB == 1) ) { //&& slot_pbch
LOG_I(PHY," ------ Decode MIB: frame.slot %d.%d ------ best beam %d gnb beam cnt %d\n", frame_rx%1024, nr_slot_rx, ue->measurements.best_beam_gnb, ue->measurements.gnb_beam_cnt);
nr_ue_pbch_procedures(gNB_id, ue, proc, 0); nr_ue_pbch_procedures(gNB_id, ue, proc, 0);
if (ue->measurements.best_beam_gnb == ue->measurements.gnb_beam_cnt)
mac->best_init_ssb_id = mac->mib_ssb;
if (ue->no_timing_correction==0) { if (ue->no_timing_correction==0) {
LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction);
nr_adjust_synch_ue(fp, nr_adjust_synch_ue(fp,
ue, ue,
gNB_id, gNB_id,
......
...@@ -254,6 +254,8 @@ typedef struct { ...@@ -254,6 +254,8 @@ typedef struct {
uint8_t mib_ssb; uint8_t mib_ssb;
/// TCI ssb index /// TCI ssb index
uint8_t tci_ssb_id; uint8_t tci_ssb_id;
/// Best init ssb index
uint8_t best_init_ssb_id;
//// FAPI-like interface message //// FAPI-like interface message
fapi_nr_ul_config_request_t *ul_config_request; fapi_nr_ul_config_request_t *ul_config_request;
......
...@@ -1784,6 +1784,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s ...@@ -1784,6 +1784,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
uint16_t format, format0, format1, ncs; uint16_t format, format0, format1, ncs;
int is_nr_prach_slot; int is_nr_prach_slot;
prach_occasion_info_t *prach_occasion_info_p; prach_occasion_info_t *prach_occasion_info_p;
int best_ssb_id;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
...@@ -1801,6 +1802,9 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s ...@@ -1801,6 +1802,9 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
mac->RA_offset = 2; // to compensate the rx frame offset at the gNB mac->RA_offset = 2; // to compensate the rx frame offset at the gNB
mac->generate_nr_prach = 0; // Reset flag for PRACH generation mac->generate_nr_prach = 0; // Reset flag for PRACH generation
best_ssb_id = mac->best_init_ssb_id;
printf("mac best init beam id %d\n", best_ssb_id);
if (is_nr_UL_slot(scc, slotP)) { if (is_nr_UL_slot(scc, slotP)) {
uint8_t selected_gnb_ssb_idx = mac->mib_ssb; uint8_t selected_gnb_ssb_idx = mac->mib_ssb;
......
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