diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index cbb1e6045..d5d2115df 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -460,8 +460,10 @@ typedef struct { std::string type = "lte"; srslte::phy_log_args_t log; - std::string dl_earfcn = "3400"; // comma-separated list of EARFCNs - std::vector earfcn_list = {3400}; // vectorized version of dl_earfcn that gets populated during init + std::string dl_earfcn = "3400"; // comma-separated list of DL EARFCNs + std::string ul_earfcn = ""; // comma-separated list of UL EARFCNs + std::vector dl_earfcn_list = {3400}; // vectorized version of dl_earfcn that gets populated during init + std::map ul_earfcn_map; // Map linking DL EARFCN and UL EARFCN float dl_freq = -1.0f; float ul_freq = -1.0f; diff --git a/srsue/hdr/phy/phy.h b/srsue/hdr/phy/phy.h index f33c25640..e942a16df 100644 --- a/srsue/hdr/phy/phy.h +++ b/srsue/hdr/phy/phy.h @@ -61,8 +61,6 @@ public: void enable_pregen_signals(bool enable) final; - void set_earfcn(std::vector earfcns) final; - void radio_overflow() final; void radio_failure() final; diff --git a/srsue/hdr/phy/phy_common.h b/srsue/hdr/phy/phy_common.h index 8d64b6e72..2081d682a 100644 --- a/srsue/hdr/phy/phy_common.h +++ b/srsue/hdr/phy/phy_common.h @@ -168,6 +168,15 @@ public: bool is_mbsfn_sf(srslte_mbsfn_cfg_t* cfg, uint32_t tti); void set_mch_period_stop(uint32_t stop); + /** + * Deduces the UL EARFCN from a DL EARFCN. If the UL-EARFCN was defined in the UE PHY arguments it will use the + * corresponding UL-EARFCN to the DL-EARFCN. Otherwise, it will use default. + * + * @param dl_earfcn + * @return the deduced UL EARFCN + */ + uint32_t get_ul_earfcn(uint32_t dl_earfcn); + private: bool have_mtch_stop = false; std::mutex mtch_mutex; diff --git a/srsue/hdr/phy/sync.h b/srsue/hdr/phy/sync.h index da5c8928a..a171056ae 100644 --- a/srsue/hdr/phy/sync.h +++ b/srsue/hdr/phy/sync.h @@ -83,7 +83,6 @@ public: // From UE configuration void set_agc_enable(bool enable); - void set_earfcn(std::vector earfcn); void force_freq(float dl_freq, float ul_freq); // Other functions @@ -155,8 +154,6 @@ private: * measurements offline using sync object and finding multiple cells for each N_id_2 */ - std::vector earfcn; - void reset(); void radio_error(); void set_ue_sync_opts(srslte_ue_sync_t* q, float cfo); diff --git a/srsue/hdr/phy/ue_lte_phy_base.h b/srsue/hdr/phy/ue_lte_phy_base.h index f7cf43458..91ac9bf92 100644 --- a/srsue/hdr/phy/ue_lte_phy_base.h +++ b/srsue/hdr/phy/ue_lte_phy_base.h @@ -45,8 +45,6 @@ public: virtual int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) = 0; virtual void stop() = 0; - virtual void set_earfcn(std::vector earfcns) = 0; - virtual void wait_initialize() = 0; virtual void start_plot() = 0; diff --git a/srsue/hdr/phy/ue_phy_base.h b/srsue/hdr/phy/ue_phy_base.h index c63dd33c1..53b77f6a6 100644 --- a/srsue/hdr/phy/ue_phy_base.h +++ b/srsue/hdr/phy/ue_phy_base.h @@ -45,8 +45,6 @@ public: virtual void stop() = 0; - virtual void set_earfcn(std::vector earfcns) = 0; - virtual void wait_initialize() = 0; virtual void start_plot() = 0; diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 53aec6c14..c1c4687fd 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -72,6 +72,7 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) ("ue.stack", bpo::value(&args->stack.type)->default_value("lte"), "Type of the upper stack [lte]") ("rf.dl_earfcn", bpo::value(&args->phy.dl_earfcn)->default_value("3400"), "Downlink EARFCN list") + ("rf.ul_earfcn", bpo::value(&args->phy.ul_earfcn), "Uplink EARFCN list. Optional.") ("rf.freq_offset", bpo::value(&args->rf.freq_offset)->default_value(0), "(optional) Frequency offset") ("rf.dl_freq", bpo::value(&args->phy.dl_freq)->default_value(-1), "Downlink Frequency (if positive overrides EARFCN)") ("rf.ul_freq", bpo::value(&args->phy.ul_freq)->default_value(-1), "Uplink Frequency (if positive overrides EARFCN)") diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index 02d61c1d4..08ae97df0 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -126,8 +126,6 @@ int phy::init(const phy_args_t& args_) args = args_; - set_earfcn(args.earfcn_list); - // Force frequency if given as argument if (args.dl_freq > 0 && args.ul_freq > 0) { sfsync.force_freq(args.dl_freq, args.ul_freq); @@ -382,11 +380,6 @@ int phy::sr_last_tx_tti() return common.sr_last_tx_tti; } -void phy::set_earfcn(vector earfcns) -{ - sfsync.set_earfcn(earfcns); -} - void phy::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) { common.set_rar_grant(grant_payload, rnti, tdd_config); @@ -454,7 +447,7 @@ void phy::set_config(srslte::phy_cfg_t& config_, uint32_t cc_idx, uint32_t earfc // Change frequency only if the earfcn was modified if (common.scell_cfg[cc_idx].earfcn != earfcn) { double dl_freq = srslte_band_fd(earfcn) * 1e6; - double ul_freq = srslte_band_fu(srslte_band_ul_earfcn(earfcn)) * 1e6; + double ul_freq = srslte_band_fu(common.get_ul_earfcn(earfcn)) * 1e6; radio->set_rx_freq(cc_idx, dl_freq); radio->set_tx_freq(cc_idx, ul_freq); } diff --git a/srsue/src/phy/phy_common.cc b/srsue/src/phy/phy_common.cc index 9122c71f4..0c705287c 100644 --- a/srsue/src/phy/phy_common.cc +++ b/srsue/src/phy/phy_common.cc @@ -742,6 +742,21 @@ void phy_common::set_mch_period_stop(uint32_t stop) mtch_cvar.notify_one(); } +uint32_t phy_common::get_ul_earfcn(uint32_t dl_earfcn) +{ + // Set default UL-EARFCN + uint32_t ul_earfcn = srslte_band_ul_earfcn(dl_earfcn); + + // Try to find current DL-EARFCN in the map + auto it = args->ul_earfcn_map.find(dl_earfcn); + if (it != args->ul_earfcn_map.end()) { + // If found UL EARFCN in the map, use it + ul_earfcn = it->second; + } + + return ul_earfcn; +} + bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) { uint32_t sfn; // System Frame Number diff --git a/srsue/src/phy/sync.cc b/srsue/src/phy/sync.cc index e5a5eeba5..26b951eb6 100644 --- a/srsue/src/phy/sync.cc +++ b/srsue/src/phy/sync.cc @@ -185,7 +185,7 @@ phy_interface_rrc_lte::cell_search_ret_t sync::cell_search(phy_interface_rrc_lte ret.last_freq = phy_interface_rrc_lte::cell_search_ret_t::NO_MORE_FREQS; // Move state to IDLE - Info("Cell Search: Start EARFCN index=%u/%zd\n", cellsearch_earfcn_index, earfcn.size()); + Info("Cell Search: Start EARFCN index=%u/%zd\n", cellsearch_earfcn_index, worker_com->args->dl_earfcn_list.size()); phy_state.go_idle(); worker_com->reset(); @@ -200,8 +200,8 @@ phy_interface_rrc_lte::cell_search_ret_t sync::cell_search(phy_interface_rrc_lte } try { - if (current_earfcn != (int)earfcn.at(cellsearch_earfcn_index)) { - current_earfcn = (int)earfcn[cellsearch_earfcn_index]; + if (current_earfcn != (int)worker_com->args->dl_earfcn_list.at(cellsearch_earfcn_index)) { + current_earfcn = (int)worker_com->args->dl_earfcn_list[cellsearch_earfcn_index]; Info("Cell Search: changing frequency to EARFCN=%d\n", current_earfcn); set_frequency(); } @@ -236,7 +236,7 @@ phy_interface_rrc_lte::cell_search_ret_t sync::cell_search(phy_interface_rrc_lte } cellsearch_earfcn_index++; - if (cellsearch_earfcn_index >= earfcn.size()) { + if (cellsearch_earfcn_index >= worker_com->args->dl_earfcn_list.size()) { Info("Cell Search: No more frequencies in the current EARFCN set\n"); cellsearch_earfcn_index = 0; ret.last_freq = phy_interface_rrc_lte::cell_search_ret_t::NO_MORE_FREQS; @@ -735,11 +735,6 @@ bool sync::set_cell(float cfo) return true; } -void sync::set_earfcn(std::vector earfcn_) -{ - earfcn = earfcn_; -} - void sync::force_freq(float dl_freq_, float ul_freq_) { dl_freq = dl_freq_; @@ -759,7 +754,7 @@ bool sync::set_frequency() if (srslte_band_is_tdd(srslte_band_get_band(current_earfcn))) { set_ul_freq = set_dl_freq; } else { - set_ul_freq = 1e6 * srslte_band_fu(srslte_band_ul_earfcn(current_earfcn)); + set_ul_freq = 1e6 * srslte_band_fu(worker_com->get_ul_earfcn(current_earfcn)); } } if (set_dl_freq > 0 && set_ul_freq > 0) { diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index ce1e5a702..61be0e839 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -173,18 +173,18 @@ int ue::parse_args(const all_args_t& args_) args.phy.nof_rx_ant = args.rf.nof_antennas; args.phy.agc_enable = args.rf.rx_gain < 0.0f; - // populate EARFCN list + // populate DL EARFCN list if (!args.phy.dl_earfcn.empty()) { - args.phy.earfcn_list.clear(); + args.phy.dl_earfcn_list.clear(); std::stringstream ss(args.phy.dl_earfcn); uint32_t idx = 0; while (ss.good()) { std::string substr; getline(ss, substr, ','); - auto earfcn = (uint32_t)strtoul(substr.c_str(), nullptr, 10); + uint32_t earfcn = (uint32_t)strtoul(substr.c_str(), nullptr, 10); args.stack.rrc.supported_bands[idx] = srslte_band_get_band(earfcn); args.stack.rrc.nof_supported_bands = ++idx; - args.phy.earfcn_list.push_back(earfcn); + args.phy.dl_earfcn_list.push_back(earfcn); } } else { log.error("Error: dl_earfcn list is empty\n"); @@ -192,6 +192,25 @@ int ue::parse_args(const all_args_t& args_) return SRSLTE_ERROR; } + // populate UL EARFCN list + if (!args.phy.ul_earfcn.empty()) { + args.phy.ul_earfcn_map.clear(); + std::stringstream ss(args.phy.ul_earfcn); + uint32_t idx = 0; + while (ss.good()) { + std::string substr; + getline(ss, substr, ','); + uint32_t ul_earfcn = (uint32_t)strtoul(substr.c_str(), nullptr, 10); + + if (idx < args.phy.dl_earfcn_list.size()) { + // If it can be matched with a DL EARFCN, otherwise ignore entry + uint32_t dl_earfcn = args.phy.dl_earfcn_list[idx]; + args.phy.ul_earfcn_map[dl_earfcn] = ul_earfcn; + idx++; + } + } + } + // Set UE category args.stack.rrc.ue_category = (uint32_t)strtoul(args.stack.rrc.ue_category_str.c_str(), nullptr, 10); diff --git a/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h b/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h index 0ba81211f..d2595ae95 100644 --- a/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h +++ b/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h @@ -49,63 +49,58 @@ public: int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, syssim_interface_phy* syssim_); - int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, radio_interface_phy* radio_); + int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) override; // ue_phy_base interface - int init(const phy_args_t& args_); - void stop(); - void set_earfcn(std::vector earfcns); - void force_freq(float dl_freq, float ul_freq); - void wait_initialize(); - void start_plot(); - void get_metrics(phy_metrics_t* m); - std::string get_type(); + int init(const phy_args_t& args_) override; + void stop() override; + void wait_initialize() override; + void start_plot() override; + void get_metrics(phy_metrics_t* m) override; + std::string get_type() override; // The interface for the SS void set_cell_map(const cell_list_t& cells_); // phy_interface_rrc_lte - uint32_t get_current_earfcn(); - uint32_t get_current_pci(); - void set_config_scell(asn1::rrc::scell_to_add_mod_r10_s* scell_config); - void enable_pregen_signals(bool enable); - void set_activation_deactivation_scell(uint32_t cmd); - void - set_config(srslte::phy_cfg_t& config, uint32_t cc_idx = 0, uint32_t earfcn = 0, srslte_cell_t* cell_info = nullptr); - void set_config_tdd(srslte_tdd_config_t& tdd_config); - void set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs){}; - void set_config_mbsfn_sib13(const srslte::sib13_t& sib13){}; - void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch){}; + void enable_pregen_signals(bool enable) override; + void set_activation_deactivation_scell(uint32_t cmd) override; + void set_config(srslte::phy_cfg_t& config, + uint32_t cc_idx = 0, + uint32_t earfcn = 0, + srslte_cell_t* cell_info = nullptr) override; + void set_config_tdd(srslte_tdd_config_t& tdd_config) override; + void set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override{}; + void set_config_mbsfn_sib13(const srslte::sib13_t& sib13) override{}; + void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) override{}; // Measurements interface - void meas_stop(); - int meas_start(uint32_t earfcn, int pci = -1); - int meas_stop(uint32_t earfcn, int pci = -1); + void meas_stop() override; // phy_interface_mac_lte - void set_mch_period_stop(uint32_t stop){}; + void set_mch_period_stop(uint32_t stop) override{}; // Cell search and selection procedures - cell_search_ret_t cell_search(phy_cell_t* found_cell); + cell_search_ret_t cell_search(phy_cell_t* found_cell) override; bool cell_select(const phy_cell_t* cell) override; - bool cell_is_camping(); - void reset(); + bool cell_is_camping() override; + void reset() override; // phy_interface_mac_lte - void configure_prach_params(); - void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm, float ta_base_sec); - prach_info_t prach_get_info(); - void sr_send(); - int sr_last_tx_tti(); + void configure_prach_params() override; + void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm, float ta_base_sec) override; + prach_info_t prach_get_info() override; + void sr_send() override; + int sr_last_tx_tti() override; // phy_interface_mac_common - void set_crnti(uint16_t rnti); - void set_timeadv_rar(uint32_t ta_cmd); - void set_timeadv(uint32_t ta_cmd); - void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti); - uint32_t get_current_tti(); - float get_phr(); - float get_pathloss_db(); + void set_crnti(uint16_t rnti) override; + void set_timeadv_rar(uint32_t ta_cmd) override; + void set_timeadv(uint32_t ta_cmd) override; + void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) override; + uint32_t get_current_tti() override; + float get_phr() override; + float get_pathloss_db() override; // phy_interface_syssim void set_current_tti(uint32_t tti); @@ -114,14 +109,12 @@ public: void new_tb(const srsue::mac_interface_phy_lte::mac_grant_dl_t, const uint8_t* data); // Radio interface - void radio_overflow(); - void radio_failure(); + void radio_overflow() override; + void radio_failure() override; void run_tti(); private: - void select_pcell(); - srslte::logger* logger = nullptr; srslte::log_filter log; @@ -130,13 +123,12 @@ private: uint32_t cell_idx = 0; // The current PCell - cell_t pcell = {}; - bool pcell_set = false; + cell_t pcell = {}; + bool pcell_set = false; - phy_cfg_t phy_cfg = {}; + srslte::phy_cfg_t phy_cfg = {}; uint32_t current_tti = 0; - uint16_t current_temp_rnti = 0; uint32_t cc_idx = 0; int prach_tti_tx = -1; diff --git a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc index 99e118a3b..d9804b761 100644 --- a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc +++ b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc @@ -36,7 +36,7 @@ int lte_ttcn3_phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_ return init(args_); } -int lte_ttcn3_phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_, radio_interface_phy* radio_) +int lte_ttcn3_phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) { return init(args_); @@ -53,10 +53,6 @@ int lte_ttcn3_phy::init(const phy_args_t& args_) void lte_ttcn3_phy::stop(){}; -void lte_ttcn3_phy::set_earfcn(std::vector earfcns) {} - -void lte_ttcn3_phy::force_freq(float dl_freq, float ul_freq) {} - void lte_ttcn3_phy::wait_initialize() {} void lte_ttcn3_phy::start_plot() {} @@ -70,23 +66,8 @@ void lte_ttcn3_phy::set_cell_map(const cell_list_t& cells_) cells = cells_; } -uint32_t lte_ttcn3_phy::get_current_earfcn() -{ - return pcell.earfcn; -} - -uint32_t lte_ttcn3_phy::get_current_pci() -{ - return pcell.info.id; -} - void lte_ttcn3_phy::set_config_tdd(srslte_tdd_config_t& tdd_config) {} -void lte_ttcn3_phy::set_config_scell(asn1::rrc::scell_to_add_mod_r10_s* scell_config) -{ - log.debug("%s not implemented.\n", __FUNCTION__); -} - void lte_ttcn3_phy::enable_pregen_signals(bool enable) { log.debug("%s not implemented.\n", __FUNCTION__); @@ -105,16 +86,6 @@ void lte_ttcn3_phy::set_config(srslte::phy_cfg_t& config, uint32_t cc_idx, uint3 // Measurements interface void lte_ttcn3_phy::meas_stop(){}; -int lte_ttcn3_phy::meas_start(uint32_t earfcn, int pci) -{ - return 0; -} - -int lte_ttcn3_phy::meas_stop(uint32_t earfcn, int pci) -{ - return 0; -}; - /* Cell search and selection procedures */ phy_interface_rrc_lte::cell_search_ret_t lte_ttcn3_phy::cell_search(phy_cell_t* found_cell) { @@ -236,7 +207,6 @@ int lte_ttcn3_phy::sr_last_tx_tti() /* Sets a C-RNTI allowing the PHY to pregenerate signals if necessary */ void lte_ttcn3_phy::set_crnti(uint16_t rnti) { - current_temp_rnti = rnti; log.info("Set Temp-RNTI=%d\n", rnti); }