diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index 5ff6a0b323..7297fc1759 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -47,7 +47,7 @@ #define CONFIG_HLP_UETXG "set UE TX gain\n" #define CONFIG_HLP_UENANTR "set UE number of rx antennas\n" #define CONFIG_HLP_UENANTT "set UE number of tx antennas\n" -#define CONFIG_HLP_UESCAN "set UE to scan around carrier\n" +#define CONFIG_HLP_UESCAN "set UE to scan all possible GSCN in current bandwidth\n" #define CONFIG_HLP_UEFO "set UE to enable estimation and compensation of frequency offset\n" #define CONFIG_HLP_DUMPFRAME "dump UE received frame to rxsig_frame0.dat and exit\n" #define CONFIG_HLP_DLSHIFT "dynamic shift for LLR compuation for TM3/4 (default 0)\n" diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index a286347e37..6663b011e9 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -49,7 +49,6 @@ #include "PHY_INTERFACE/phy_interface_vars.h" #include "gnb_config.h" #include "SIMULATION/TOOLS/sim.h" -#include "executables/lte-softmodem.h" #ifdef SMBV #include "PHY/TOOLS/smbv.h" @@ -604,6 +603,7 @@ static void initialize_agent(ngran_node_t node_type, e2_agent_args_t oai_args) } #endif +void init_eNB_afterRU(void); configmodule_interface_t *uniqCfg = NULL; int main( int argc, char **argv ) { int ru_id, CC_id = 0; diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 975d8ea26e..04e506207d 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -348,7 +348,13 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) * \param arg is a pointer to a \ref PHY_VARS_NR_UE structure. */ -typedef nr_rxtx_thread_data_t syncData_t; +typedef struct { + PHY_VARS_NR_UE *UE; + UE_nr_rxtx_proc_t proc; + nr_gscn_info_t gscnInfo[MAX_GSCN_BAND]; + int numGscn; + int rx_offset; +} syncData_t; static void UE_synch(void *arg) { syncData_t *syncD=(syncData_t *) arg; @@ -431,7 +437,7 @@ static void UE_synch(void *arg) { uint64_t dl_carrier, ul_carrier; nr_get_carrier_frequencies(UE, &dl_carrier, &ul_carrier); - nr_initial_sync_t ret = nr_initial_sync(&syncD->proc, UE, 2, get_softmodem_params()->sa); + nr_initial_sync_t ret = nr_initial_sync(&syncD->proc, UE, 2, get_softmodem_params()->sa, syncD->gscnInfo, syncD->numGscn); if (ret.cell_detected) { syncD->rx_offset = ret.rx_offset; freq_offset = UE->common_vars.freq_offset; // frequency offset computed with pss in initial sync @@ -451,24 +457,7 @@ static void UE_synch(void *arg) { openair0_cfg[UE->rf_map.card].tx_freq[0]); UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0]); - if (UE->UE_scan_carrier == 1) - UE->UE_scan_carrier = 0; - else - UE->is_synchronized = 1; - } else { - if (UE->UE_scan_carrier == 1) { - - if (freq_offset >= 0) - freq_offset += 100; - - freq_offset *= -1; - - nr_rf_card_config_freq(&openair0_cfg[UE->rf_map.card], ul_carrier, dl_carrier, freq_offset); - - LOG_I(PHY, "Initial sync failed: trying carrier off %d Hz\n", freq_offset); - - UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0]); - } + UE->is_synchronized = 1; } break; @@ -601,6 +590,7 @@ static int UE_dl_preprocessing(PHY_VARS_NR_UE *UE, const UE_nr_rxtx_proc_t *proc // Start synchronization with a target gNB if (UE->synch_request.received_synch_request == 1) { UE->is_synchronized = 0; + UE->UE_scan_carrier = UE->synch_request.synch_req.ssb_bw_scan; UE->target_Nid_cell = UE->synch_request.synch_req.target_Nid_cell; clean_UE_harq(UE); UE->synch_request.received_synch_request = 0; @@ -818,6 +808,20 @@ void *UE_thread(void *arg) readFrame(UE, &sync_timestamp, false); notifiedFIFO_elt_t *Msg = newNotifiedFIFO_elt(sizeof(syncData_t), 0, &nf, UE_synch); syncData_t *syncMsg = (syncData_t *)NotifiedFifoData(Msg); + NR_DL_FRAME_PARMS *fp = &UE->frame_parms; + if (UE->UE_scan_carrier) { + // Get list of GSCN in this band for UE's bandwidth and center frequency. + LOG_W(PHY, "UE set to scan all GSCN in current bandwidth\n"); + syncMsg->numGscn = + get_scan_ssb_first_sc(fp->dl_CarrierFreq, fp->N_RB_DL, fp->nr_band, fp->numerology_index, syncMsg->gscnInfo); + } else { + LOG_W(PHY, "SSB position provided\n"); + nr_gscn_info_t *g = syncMsg->gscnInfo; + g->ssbFirstSC = fp->ssb_start_subcarrier; + g->gscn = 0; + g->ssRef = 0; + syncMsg->numGscn = 1; + } syncMsg->UE = UE; memset(&syncMsg->proc, 0, sizeof(syncMsg->proc)); pushTpool(&(get_nrUE_params()->Tpool), Msg); diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 44669564d6..00622f3a29 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -688,6 +688,7 @@ typedef struct typedef struct { int16_t target_Nid_cell; + bool ssb_bw_scan; } fapi_nr_synch_request_t; typedef struct { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 353db588d6..979448f048 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -293,13 +293,15 @@ void nr_scan_ssb(void *arg) } } -nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, int n_frames, int sa) +nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, + PHY_VARS_NR_UE *ue, + int n_frames, + int sa, + nr_gscn_info_t gscnInfo[MAX_GSCN_BAND], + int numGscn) { NR_DL_FRAME_PARMS *fp = &ue->frame_parms; - // Get list of GSCN in this band, current UE's bandwidth and center frequency. - nr_gscn_info_t gscnInfo[MAX_GSCN_BAND]; - int numScans = get_scan_ssb_first_sc(fp->dl_CarrierFreq, fp->N_RB_DL, fp->nr_band, fp->numerology_index, gscnInfo); notifiedFIFO_t nf; initNotifiedFIFO(&nf); @@ -308,8 +310,8 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i "Starting cell search with center freq: %ld, bandwidth: %d. Scanning for %d number of GSCN.\n", fp->dl_CarrierFreq, fp->N_RB_DL, - numScans); - for (int s = 0; s < numScans; s++) { + numGscn); + for (int s = 0; s < numGscn; s++) { notifiedFIFO_elt_t *req = newNotifiedFIFO_elt(sizeof(nr_ue_ssb_scan_t), gscnInfo[s].gscn, &nf, &nr_scan_ssb); nr_ue_ssb_scan_t *ssbInfo = (nr_ue_ssb_scan_t *)NotifiedFifoData(req); ssbInfo->gscnInfo = gscnInfo[s]; @@ -334,7 +336,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i // Collect the scan results nr_ue_ssb_scan_t res = {0}; - while (numScans) { + while (numGscn) { notifiedFIFO_elt_t *req = pullTpool(&nf, &get_nrUE_params()->Tpool); nr_ue_ssb_scan_t *ssbInfo = (nr_ue_ssb_scan_t *)NotifiedFifoData(req); if (ssbInfo->syncRes.cell_detected) { @@ -354,7 +356,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i } free(ssbInfo->rxdata); delNotifiedFIFO_elt(req); - numScans--; + numGscn--; } // Set globals based on detected cell @@ -446,15 +448,6 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i if (res.syncRes.cell_detected) { LOG_I(PHY, "[UE%d] In synch, rx_offset %d samples\n", ue->Mod_id, res.syncRes.rx_offset); - if (ue->UE_scan_carrier == 0) { -#if UE_AUTOTEST_TRACE - LOG_I(PHY, - "[UE %d] AUTOTEST Cell Sync : rx_offset %d, freq_offset %d \n", - ue->Mod_id, - ue->rx_offset, - ue->common_vars.freq_offset); -#endif - } LOG_I(PHY, "[UE %d] Measured Carrier Frequency offset %d Hz\n", ue->Mod_id, res.freqOffset); } else { #ifdef DEBUG_INITIAL_SYNC diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index b4315d292b..0e2100171c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -325,7 +325,12 @@ int dump_ue_stats(PHY_VARS_NR_UE *phy_vars_ue, @param n_frames @param sa current running mode */ -nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *phy_vars_ue, int n_frames, int sa); +nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, + PHY_VARS_NR_UE *phy_vars_ue, + int n_frames, + int sa, + nr_gscn_info_t gscnInfo[MAX_GSCN_BAND], + int numGscn); /*! \brief This function gets the carrier frequencies either from FP or command-line-set global variables, depending on the diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 766cfa1ecb..4c1228c1df 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1420,6 +1420,7 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id, NR_UE_MAC_reset_cause_t cause) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + fapi_nr_synch_request_t sync_req = {.target_Nid_cell = -1, .ssb_bw_scan = true}; switch (cause) { case GO_TO_IDLE: reset_ra(mac, true); @@ -1427,7 +1428,7 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id, nr_ue_init_mac(mac); nr_ue_mac_default_configs(mac); // new sync but no target cell id -> -1 - nr_ue_send_synch_request(mac, module_id, 0, -1); + nr_ue_send_synch_request(mac, module_id, 0, &sync_req); break; case DETACH: LOG_A(NR_MAC, "Received detach indication\n"); @@ -1448,7 +1449,9 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id, nr_ue_reset_sync_state(mac); release_mac_configuration(mac, cause); // new sync with old cell ID (re-establishment on the same cell) - nr_ue_send_synch_request(mac, module_id, 0, mac->physCellId); + sync_req.target_Nid_cell = mac->physCellId; + sync_req.ssb_bw_scan = false; + nr_ue_send_synch_request(mac, module_id, 0, &sync_req); break; default: AssertFatal(false, "Invalid MAC reset cause %d\n", cause); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index ea30052058..1eac68350c 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -295,7 +295,7 @@ void prepare_msg4_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack); void configure_initial_pucch(PUCCH_sched_t *pucch, int res_ind); void release_PUCCH_SRS(NR_UE_MAC_INST_t *mac); void nr_ue_reset_sync_state(NR_UE_MAC_INST_t *mac); -void nr_ue_send_synch_request(NR_UE_MAC_INST_t *mac, module_id_t module_id, int cc_id, int cell_id); +void nr_ue_send_synch_request(NR_UE_MAC_INST_t *mac, module_id_t module_id, int cc_id, const fapi_nr_synch_request_t *sync_req); /** * @brief Get UE sync state diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 79086da5a9..cc602ed240 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -98,12 +98,12 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) mac->scheduling_info.prohibitPHR_Timer = NR_PHR_Config__phr_ProhibitTimer_sf10; } -void nr_ue_send_synch_request(NR_UE_MAC_INST_t *mac, module_id_t module_id, int cc_id, int cell_id) +void nr_ue_send_synch_request(NR_UE_MAC_INST_t *mac, module_id_t module_id, int cc_id, const fapi_nr_synch_request_t *sync_req) { // Sending to PHY a request to resync mac->synch_request.Mod_id = module_id; mac->synch_request.CC_id = cc_id; - mac->synch_request.synch_req.target_Nid_cell = cell_id; + mac->synch_request.synch_req = *sync_req; mac->if_module->synch_request(&mac->synch_request); }