2019-04-26 12:27:38 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2013-2019 Software Radio Systems Limited
|
2017-05-30 06:38:04 -07:00
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* This file is part of srsLTE.
|
2017-05-30 06:38:04 -07:00
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2017-05-30 06:38:04 -07:00
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
2017-05-30 06:38:04 -07:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* A copy of the GNU Affero General Public License can be found in
|
|
|
|
* the LICENSE file in the top-level directory of this distribution
|
|
|
|
* and at http://www.gnu.org/licenses/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#ifndef SRSUE_PHY_H
|
|
|
|
#define SRSUE_PHY_H
|
2017-05-30 06:38:04 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
#include "phy_common.h"
|
2018-04-01 09:08:24 -07:00
|
|
|
#include "phy_metrics.h"
|
|
|
|
#include "prach.h"
|
2019-04-23 01:53:11 -07:00
|
|
|
#include "sf_worker.h"
|
|
|
|
#include "srslte/common/log_filter.h"
|
2017-05-31 14:39:17 -07:00
|
|
|
#include "srslte/common/trace.h"
|
2020-03-06 06:26:48 -08:00
|
|
|
#include "srslte/interfaces/radio_interfaces.h"
|
2017-06-01 03:25:42 -07:00
|
|
|
#include "srslte/interfaces/ue_interfaces.h"
|
2019-04-23 01:53:11 -07:00
|
|
|
#include "srslte/radio/radio.h"
|
|
|
|
#include "srslte/srslte.h"
|
2019-05-22 02:26:24 -07:00
|
|
|
#include "srsue/hdr/phy/ue_lte_phy_base.h"
|
2019-04-23 01:53:11 -07:00
|
|
|
#include "sync.h"
|
2017-05-30 06:38:04 -07:00
|
|
|
|
|
|
|
namespace srsue {
|
2017-11-20 01:02:39 -08:00
|
|
|
|
|
|
|
typedef _Complex float cf_t;
|
2017-05-30 06:38:04 -07:00
|
|
|
|
2020-02-17 13:12:02 -08:00
|
|
|
class phy : public ue_lte_phy_base, public srslte::thread
|
2017-05-30 06:38:04 -07:00
|
|
|
{
|
|
|
|
public:
|
2019-12-17 06:49:56 -08:00
|
|
|
explicit phy(srslte::logger* logger_) : logger(logger_), workers_pool(MAX_WORKERS), common(), thread("PHY"){};
|
|
|
|
~phy() final { stop(); }
|
2019-05-07 01:11:57 -07:00
|
|
|
|
|
|
|
// Init defined in base class
|
2019-07-16 13:43:36 -07:00
|
|
|
int init(const phy_args_t& args_) final;
|
2019-05-07 01:11:57 -07:00
|
|
|
|
|
|
|
// Init for LTE PHYs
|
2019-12-16 07:04:22 -08:00
|
|
|
int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) final;
|
2019-04-23 01:53:11 -07:00
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
void stop() final;
|
2017-05-30 06:38:04 -07:00
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
void wait_initialize() final;
|
2017-09-01 04:29:11 -07:00
|
|
|
bool is_initiated();
|
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
void get_metrics(phy_metrics_t* m) final;
|
2019-12-16 07:04:22 -08:00
|
|
|
void srslte_phy_logger(phy_logger_level_t log_level, char* str);
|
2017-05-30 06:38:04 -07:00
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
void enable_pregen_signals(bool enable) final;
|
2017-06-21 09:29:17 -07:00
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
void set_earfcn(std::vector<uint32_t> earfcns) final;
|
2017-06-21 09:29:17 -07:00
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
void radio_overflow() final;
|
|
|
|
void radio_failure() final;
|
2017-10-13 08:59:12 -07:00
|
|
|
|
2017-05-30 06:38:04 -07:00
|
|
|
/********** RRC INTERFACE ********************/
|
2019-06-10 15:45:39 -07:00
|
|
|
void reset() final;
|
|
|
|
cell_search_ret_t cell_search(phy_cell_t* cell) final;
|
2020-02-17 07:29:06 -08:00
|
|
|
bool cell_select(const phy_cell_t* cell) final;
|
2017-06-21 09:29:17 -07:00
|
|
|
|
2020-01-28 01:13:44 -08:00
|
|
|
void set_cells_to_meas(uint32_t earfcn, const std::set<uint32_t>& pci) final;
|
2019-12-13 04:04:47 -08:00
|
|
|
void meas_stop() final;
|
2017-11-20 01:02:39 -08:00
|
|
|
|
2018-03-19 06:14:51 -07:00
|
|
|
// also MAC interface
|
2019-06-10 15:45:39 -07:00
|
|
|
bool cell_is_camping() final;
|
2017-05-30 06:38:04 -07:00
|
|
|
|
2018-03-19 06:14:51 -07:00
|
|
|
/********** MAC INTERFACE ********************/
|
2017-05-30 06:38:04 -07:00
|
|
|
/* Sets a C-RNTI allowing the PHY to pregenerate signals if necessary */
|
2019-06-10 15:45:39 -07:00
|
|
|
void set_crnti(uint16_t rnti) final;
|
|
|
|
|
2017-05-30 06:38:04 -07:00
|
|
|
/* Instructs the PHY to configure using the parameters written by set_param() */
|
2019-06-10 15:45:39 -07:00
|
|
|
void configure_prach_params() final;
|
|
|
|
|
2017-05-30 06:38:04 -07:00
|
|
|
/* Transmits PRACH in the next opportunity */
|
2019-06-10 15:45:39 -07:00
|
|
|
void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm) final;
|
|
|
|
prach_info_t prach_get_info() final;
|
2019-04-23 01:53:11 -07:00
|
|
|
|
2017-05-30 06:38:04 -07:00
|
|
|
/* Indicates the transmission of a SR signal in the next opportunity */
|
2019-06-10 15:45:39 -07:00
|
|
|
void sr_send() final;
|
|
|
|
int sr_last_tx_tti() final;
|
2017-05-30 06:38:04 -07:00
|
|
|
|
|
|
|
// Time advance commands
|
2019-06-10 15:45:39 -07:00
|
|
|
void set_timeadv_rar(uint32_t ta_cmd) final;
|
|
|
|
void set_timeadv(uint32_t ta_cmd) final;
|
2019-04-23 01:53:11 -07:00
|
|
|
|
|
|
|
/* Activate / Disactivate SCell*/
|
2019-06-10 15:45:39 -07:00
|
|
|
void set_activation_deactivation_scell(uint32_t ta_cmd) final;
|
2019-04-23 01:53:11 -07:00
|
|
|
|
|
|
|
/* Sets RAR dci payload */
|
2019-06-10 15:45:39 -07:00
|
|
|
void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) final;
|
2019-04-23 01:53:11 -07:00
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
/* Get/Set PHY parameters interface from RRC */
|
2019-09-04 07:59:10 -07:00
|
|
|
void set_config(srslte::phy_cfg_t& config, uint32_t cc_idx, uint32_t earfcn, srslte_cell_t* cell_info) final;
|
|
|
|
void set_config_tdd(srslte_tdd_config_t& tdd_config) final;
|
|
|
|
|
2019-09-30 03:34:55 -07:00
|
|
|
void set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) final;
|
|
|
|
void set_config_mbsfn_sib13(const srslte::sib13_t& sib13) final;
|
|
|
|
void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) final;
|
2019-01-17 03:42:01 -08:00
|
|
|
|
2018-05-15 08:16:28 -07:00
|
|
|
/*Set MAC->PHY MCH period stopping point*/
|
2019-06-10 15:45:39 -07:00
|
|
|
void set_mch_period_stop(uint32_t stop) final;
|
|
|
|
|
|
|
|
float get_phr() final;
|
|
|
|
float get_pathloss_db() final;
|
|
|
|
|
|
|
|
uint32_t get_current_tti() final;
|
2017-05-30 06:38:04 -07:00
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
void start_plot() final;
|
2017-09-01 04:29:11 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
const static int MAX_WORKERS = 4;
|
|
|
|
const static int DEFAULT_WORKERS = 4;
|
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
std::string get_type() final { return "lte_soft"; }
|
2019-05-07 01:11:57 -07:00
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
private:
|
2019-06-10 15:45:39 -07:00
|
|
|
void run_thread() final;
|
2017-09-01 04:29:11 -07:00
|
|
|
|
2019-12-17 07:06:35 -08:00
|
|
|
std::mutex config_mutex;
|
|
|
|
std::condition_variable config_cond;
|
|
|
|
bool is_configured = false;
|
2020-01-28 01:13:44 -08:00
|
|
|
uint32_t nof_workers = 0;
|
2018-06-06 07:59:00 -07:00
|
|
|
|
2017-05-30 06:38:04 -07:00
|
|
|
const static int SF_RECV_THREAD_PRIO = 1;
|
2019-04-23 01:53:11 -07:00
|
|
|
const static int WORKERS_THREAD_PRIO = 2;
|
|
|
|
|
2019-09-04 07:59:10 -07:00
|
|
|
srslte::radio_interface_phy* radio = nullptr;
|
2019-07-08 05:36:33 -07:00
|
|
|
std::vector<std::unique_ptr<srslte::log_filter> > log_vec;
|
|
|
|
srslte::logger* logger = nullptr;
|
2019-05-07 01:11:57 -07:00
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
srslte::log* log_h = nullptr;
|
|
|
|
srslte::log* log_phy_lib_h = nullptr;
|
|
|
|
srsue::stack_interface_phy_lte* stack = nullptr;
|
2017-05-30 06:38:04 -07:00
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
srslte::thread_pool workers_pool;
|
2019-06-10 15:45:39 -07:00
|
|
|
std::vector<std::unique_ptr<sf_worker> > workers;
|
2019-12-16 07:04:22 -08:00
|
|
|
phy_common common;
|
|
|
|
sync sfsync;
|
|
|
|
prach prach_buffer;
|
2019-04-23 01:53:11 -07:00
|
|
|
|
2019-06-10 15:45:39 -07:00
|
|
|
srslte_prach_cfg_t prach_cfg = {};
|
|
|
|
srslte_tdd_config_t tdd_config = {};
|
2019-04-23 01:53:11 -07:00
|
|
|
|
2019-09-04 07:59:10 -07:00
|
|
|
srslte::phy_cfg_t config = {};
|
|
|
|
phy_args_t args = {};
|
2019-04-23 01:53:11 -07:00
|
|
|
|
2017-05-30 06:38:04 -07:00
|
|
|
/* Current time advance */
|
2019-06-10 15:45:39 -07:00
|
|
|
uint32_t n_ta = 0;
|
2017-10-10 03:33:10 -07:00
|
|
|
|
2020-03-06 06:26:48 -08:00
|
|
|
static void set_default_args(phy_args_t& args);
|
2019-05-07 01:11:57 -07:00
|
|
|
bool check_args(const phy_args_t& args);
|
2017-05-30 06:38:04 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace srsue
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#endif // SRSUE_PHY_H
|