srsLTE/srsue/hdr/phy/phy.h

182 lines
5.2 KiB
C
Raw Normal View History

2017-05-30 06:38:04 -07:00
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 Software Radio Systems Limited
*
* \section LICENSE
*
* This file is part of the srsUE library.
*
* srsUE is free software: you can redistribute it and/or modify
* 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.
*
* srsUE is distributed in the hope that it will be useful,
* 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 "async_scell_recv.h"
#include "phy_common.h"
#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"
#include "srslte/common/task_dispatcher.h"
#include "srslte/common/trace.h"
#include "srslte/interfaces/ue_interfaces.h"
2019-04-23 01:53:11 -07:00
#include "srslte/radio/radio.h"
#include "srslte/srslte.h"
#include "sync.h"
2017-05-30 06:38:04 -07:00
namespace srsue {
typedef _Complex float cf_t;
2017-05-30 06:38:04 -07:00
class phy
: public phy_interface_mac
, public phy_interface_rrc
, public thread
2017-05-30 06:38:04 -07:00
{
public:
phy();
2019-04-23 01:53:11 -07:00
bool init(srslte::radio* radio_handler,
mac_interface_phy* mac,
rrc_interface_phy* rrc,
2018-03-08 08:55:48 -08:00
std::vector<srslte::log_filter*> log_vec,
2019-04-23 01:53:11 -07:00
phy_args_t* args = NULL);
2017-05-30 06:38:04 -07:00
void stop();
void wait_initialize();
bool is_initiated();
2017-05-30 06:38:04 -07:00
void set_agc_enable(bool enabled);
void get_metrics(phy_metrics_t &m);
void srslte_phy_logger(phy_logger_level_t log_level, char *str);
2017-05-30 06:38:04 -07:00
void enable_pregen_signals(bool enable);
2017-06-21 09:29:17 -07:00
void set_earfcn(std::vector<uint32_t> earfcns);
void force_freq(float dl_freq, float ul_freq);
2017-06-21 09:29:17 -07:00
2018-02-02 01:58:40 -08:00
void radio_overflow();
2017-05-30 06:38:04 -07:00
/********** RRC INTERFACE ********************/
void reset();
cell_search_ret_t cell_search(phy_cell_t *cell);
bool cell_select(phy_cell_t *cell);
2017-06-21 09:29:17 -07:00
void meas_reset();
int meas_start(uint32_t earfcn, int pci);
int meas_stop(uint32_t earfcn, int pci);
// also MAC interface
bool cell_is_camping();
2017-05-30 06:38:04 -07:00
/********** MAC INTERFACE ********************/
2017-05-30 06:38:04 -07:00
/* Sets a C-RNTI allowing the PHY to pregenerate signals if necessary */
void set_crnti(uint16_t rnti);
2017-05-30 06:38:04 -07:00
/* Instructs the PHY to configure using the parameters written by set_param() */
void configure_prach_params();
/* Transmits PRACH in the next opportunity */
2019-04-23 01:53:11 -07:00
void prach_send(uint32_t preamble_idx, int allowed_subframe = -1, float target_power_dbm = 0.0);
prach_info_t prach_get_info();
2017-05-30 06:38:04 -07:00
/* Indicates the transmission of a SR signal in the next opportunity */
void sr_send();
int sr_last_tx_tti();
// Time advance commands
void set_timeadv_rar(uint32_t ta_cmd);
void set_timeadv(uint32_t ta_cmd);
2019-04-23 01:53:11 -07:00
/* Activate / Disactivate SCell*/
void set_activation_deactivation_scell(uint32_t ta_cmd);
/* Sets RAR dci payload */
void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti);
2017-05-30 06:38:04 -07:00
/* Get/Set PHY parameters interface from RRC */
2019-01-17 03:42:01 -08:00
void set_config(phy_cfg_t *phy_cfg);
2019-04-23 01:53:11 -07:00
void set_config_scell(asn1::rrc::scell_to_add_mod_r10_s* scell_config);
2019-01-17 03:42:01 -08:00
void set_config_tdd(asn1::rrc::tdd_cfg_s* tdd);
void set_config_mbsfn_sib2(asn1::rrc::sib_type2_s* sib2);
void set_config_mbsfn_sib13(asn1::rrc::sib_type13_r9_s* sib13);
void set_config_mbsfn_mcch(asn1::rrc::mcch_msg_s* mcch);
2018-05-15 08:16:28 -07:00
/*Set MAC->PHY MCH period stopping point*/
void set_mch_period_stop(uint32_t stop);
2017-05-30 06:38:04 -07:00
float get_phr();
float get_pathloss_db();
uint32_t get_current_tti();
2017-11-25 01:40:53 -08:00
void get_current_cell(srslte_cell_t *cell, uint32_t *current_earfcn = NULL);
2017-11-25 01:40:53 -08:00
uint32_t get_current_earfcn();
uint32_t get_current_pci();
2017-05-30 06:38:04 -07:00
void start_plot();
2019-04-23 01:53:11 -07:00
const static int MAX_WORKERS = 4;
const static int DEFAULT_WORKERS = 4;
private:
void run_thread();
bool initiated;
2019-04-23 01:53:11 -07:00
uint32_t nof_workers;
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;
srslte::radio* radio_handler;
2018-03-08 08:55:48 -08:00
std::vector<srslte::log_filter*> log_vec;
2019-04-23 01:53:11 -07:00
srslte::log* log_h;
srslte::log *log_phy_lib_h;
srsue::mac_interface_phy *mac;
srsue::rrc_interface_phy *rrc;
2017-05-30 06:38:04 -07:00
2019-04-23 01:53:11 -07:00
srslte::thread_pool workers_pool;
std::vector<sf_worker*> workers;
phy_common common;
sync sfsync;
async_scell_recv scell_sync[SRSLTE_MAX_RADIOS - 1];
uint32_t scell_earfcn[SRSLTE_MAX_CARRIERS - 1];
prach prach_buffer;
srslte_prach_cfg_t prach_cfg;
srslte_tdd_config_t tdd_config;
phy_args_t* args;
phy_args_t default_args;
2017-05-30 06:38:04 -07:00
/* Current time advance */
uint32_t n_ta;
2017-05-30 06:38:04 -07:00
bool init_(srslte::radio *radio_handler, mac_interface_phy *mac, srslte::log *log_h, bool do_agc, uint32_t nof_workers);
void set_default_args(phy_args_t *args);
bool check_args(phy_args_t *args);
};
} // namespace srsue
2018-03-31 10:04:04 -07:00
#endif // SRSUE_PHY_H