SRSUE: removed CLang tidy warnings in phy.h and phy.cc except unused. Use smaer pointers for workers.

master
Xavier Arteaga 6 years ago committed by Xavier Arteaga
parent bb26a42fb6
commit 810ce0358e

@ -22,6 +22,7 @@
#ifndef SRSUE_PHY_H
#define SRSUE_PHY_H
#include "scell/async_scell_recv.h"
#include "phy_common.h"
#include "phy_metrics.h"
#include "prach.h"
@ -31,7 +32,6 @@
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/radio/radio.h"
#include "srslte/srslte.h"
#include "srsue/hdr/phy/scell/async_scell_recv.h"
#include "srsue/hdr/phy/ue_lte_phy_base.h"
#include "sync.h"
@ -42,131 +42,130 @@ typedef _Complex float cf_t;
class phy : public ue_lte_phy_base, public thread
{
public:
phy();
~phy() = default;
phy() : workers_pool(MAX_WORKERS), common(MAX_WORKERS), scell_sync(), thread("PHY"){};
~phy() override = default;
// Init defined in base class
int init(const phy_args_t& args_, srslte::logger* logger_);
int init(const phy_args_t& args_, srslte::logger* logger_) final;
// Init for LTE PHYs
int init(const phy_args_t& args_,
srslte::logger* logger_,
stack_interface_phy_lte* stack_,
radio_interface_phy* radio_);
radio_interface_phy* radio_) final;
void stop();
void stop() final;
void wait_initialize();
void wait_initialize() final;
bool is_initiated();
void get_metrics(phy_metrics_t* m);
void get_metrics(phy_metrics_t* m) final;
void srslte_phy_logger(phy_logger_level_t log_level, char *str);
void enable_pregen_signals(bool enable);
void enable_pregen_signals(bool enable) final;
void set_earfcn(std::vector<uint32_t> earfcns);
void set_earfcn(std::vector<uint32_t> earfcns) final;
void radio_overflow();
void radio_failure();
void radio_overflow() final;
void radio_failure() final;
/********** RRC INTERFACE ********************/
void reset();
cell_search_ret_t cell_search(phy_cell_t *cell);
bool cell_select(phy_cell_t *cell);
void reset() final;
cell_search_ret_t cell_search(phy_cell_t* cell) final;
bool cell_select(phy_cell_t* cell) final;
void meas_reset();
int meas_start(uint32_t earfcn, int pci);
int meas_stop(uint32_t earfcn, int pci);
void meas_reset() final;
int meas_start(uint32_t earfcn, int pci) final;
int meas_stop(uint32_t earfcn, int pci) final;
// also MAC interface
bool cell_is_camping();
bool cell_is_camping() final;
/********** MAC INTERFACE ********************/
/* Sets a C-RNTI allowing the PHY to pregenerate signals if necessary */
void set_crnti(uint16_t rnti);
void set_crnti(uint16_t rnti) final;
/* Instructs the PHY to configure using the parameters written by set_param() */
void configure_prach_params();
void configure_prach_params() final;
/* Transmits PRACH in the next opportunity */
void prach_send(uint32_t preamble_idx, int allowed_subframe = -1, float target_power_dbm = 0.0);
prach_info_t prach_get_info();
void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm) final;
prach_info_t prach_get_info() final;
/* Indicates the transmission of a SR signal in the next opportunity */
void sr_send();
int sr_last_tx_tti();
void sr_send() final;
int sr_last_tx_tti() final;
// Time advance commands
void set_timeadv_rar(uint32_t ta_cmd);
void set_timeadv(uint32_t ta_cmd);
void set_timeadv_rar(uint32_t ta_cmd) final;
void set_timeadv(uint32_t ta_cmd) final;
/* Activate / Disactivate SCell*/
void set_activation_deactivation_scell(uint32_t ta_cmd);
void set_activation_deactivation_scell(uint32_t ta_cmd) final;
/* Sets RAR dci payload */
void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti);
void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) final;
/* Get/Set PHY parameters interface from RRC */
void set_config(phy_cfg_t *phy_cfg);
void set_config_scell(asn1::rrc::scell_to_add_mod_r10_s* scell_config);
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);
void set_config(phy_cfg_t* phy_cfg) final;
void set_config_scell(asn1::rrc::scell_to_add_mod_r10_s* scell_config) final;
void set_config_tdd(asn1::rrc::tdd_cfg_s* tdd) final;
void set_config_mbsfn_sib2(asn1::rrc::sib_type2_s* sib2) final;
void set_config_mbsfn_sib13(asn1::rrc::sib_type13_r9_s* sib13) final;
void set_config_mbsfn_mcch(asn1::rrc::mcch_msg_s* mcch) final;
/*Set MAC->PHY MCH period stopping point*/
void set_mch_period_stop(uint32_t stop);
void set_mch_period_stop(uint32_t stop) final;
float get_phr() final;
float get_pathloss_db() final;
float get_phr();
float get_pathloss_db();
uint32_t get_current_tti() final;
uint32_t get_current_tti();
void get_current_cell(srslte_cell_t* cell, uint32_t* current_earfcn) final;
uint32_t get_current_earfcn() final;
uint32_t get_current_pci() final;
void get_current_cell(srslte_cell_t *cell, uint32_t *current_earfcn = NULL);
uint32_t get_current_earfcn();
uint32_t get_current_pci();
void start_plot();
void start_plot() final;
const static int MAX_WORKERS = 4;
const static int DEFAULT_WORKERS = 4;
std::string get_type() { return "lte_soft"; }
std::string get_type() final { return "lte_soft"; }
private:
void run_thread();
void run_thread() final;
bool initiated;
uint32_t nof_workers;
bool initiated = false;
uint32_t nof_workers = 0;
const static int SF_RECV_THREAD_PRIO = 1;
const static int WORKERS_THREAD_PRIO = 2;
radio_interface_phy* radio;
radio_interface_phy* radio = nullptr;
std::vector<srslte::log_filter*> log_vec;
srslte::logger* logger;
srslte::logger* logger = nullptr;
srslte::log* log_h;
srslte::log *log_phy_lib_h;
srsue::stack_interface_phy_lte* stack;
srslte::log* log_h = nullptr;
srslte::log* log_phy_lib_h = nullptr;
srsue::stack_interface_phy_lte* stack = nullptr;
srslte::thread_pool workers_pool;
std::vector<sf_worker*> workers;
std::vector<std::unique_ptr<sf_worker> > workers;
phy_common common;
sync sfsync;
scell::async_recv_vector scell_sync;
uint32_t scell_earfcn[SRSLTE_MAX_CARRIERS - 1];
uint32_t scell_earfcn[SRSLTE_MAX_CARRIERS - 1] = {};
prach prach_buffer;
srslte_prach_cfg_t prach_cfg;
srslte_tdd_config_t tdd_config;
srslte_prach_cfg_t prach_cfg = {};
srslte_tdd_config_t tdd_config = {};
phy_interface_rrc_lte::phy_cfg_t config;
phy_args_t args;
phy_interface_rrc_lte::phy_cfg_t config = {};
phy_args_t args = {};
/* Current time advance */
uint32_t n_ta;
uint32_t n_ta = 0;
void set_default_args(phy_args_t *args);
bool check_args(const phy_args_t& args);

@ -42,15 +42,6 @@ using namespace asn1::rrc;
namespace srsue {
phy::phy() : workers_pool(MAX_WORKERS), workers(0), common(MAX_WORKERS), scell_sync(), thread("PHY")
{
tdd_config = {};
prach_cfg = {};
args = {};
ZERO_OBJECT(scell_earfcn);
n_ta = 0;
initiated = false;
}
static void srslte_phy_handler(phy_logger_level_t log_level, void *ctx, char *str) {
phy *r = (phy *) ctx;
@ -140,7 +131,7 @@ int phy::init(const phy_args_t& args_, srslte::logger* logger_)
// Create array of pointers to phy_logs
for (int i = 0; i < args.nof_phy_threads; i++) {
srslte::log_filter* mylog = new srslte::log_filter;
auto* mylog = new srslte::log_filter;
char tmp[16];
sprintf(tmp, "PHY%d", i);
mylog->init(tmp, logger, true);
@ -151,7 +142,7 @@ int phy::init(const phy_args_t& args_, srslte::logger* logger_)
// Add PHY lib log
if (log_vec.at(0)->get_level_from_string(args.log.phy_lib_level) != srslte::LOG_LEVEL_NONE) {
srslte::log_filter* lib_log = new srslte::log_filter;
auto* lib_log = new srslte::log_filter;
char tmp[16];
sprintf(tmp, "PHY_LIB");
lib_log->init(tmp, logger, true);
@ -159,7 +150,7 @@ int phy::init(const phy_args_t& args_, srslte::logger* logger_)
lib_log->set_hex_limit(args.log.phy_hex_limit);
log_vec.push_back(lib_log);
} else {
log_vec.push_back(NULL);
log_vec.push_back(nullptr);
}
// set default logger
@ -174,7 +165,7 @@ int phy::init(const phy_args_t& args_, srslte::logger* logger_)
this->log_phy_lib_h = (srslte::log*)log_vec[0];
srslte_phy_log_register_handler(this, srslte_phy_handler);
} else {
this->log_phy_lib_h = NULL;
this->log_phy_lib_h = nullptr;
}
initiated = false;
@ -190,10 +181,10 @@ void phy::run_thread()
// Add workers to workers pool and start threads
for (uint32_t i=0;i<nof_workers;i++) {
sf_worker* w =
new sf_worker(SRSLTE_MAX_PRB, &common, (srslte::log*)log_vec[i], (srslte::log*)log_vec[nof_workers], &sfsync);
workers.push_back(w);
workers_pool.init_worker(i, w, WORKERS_THREAD_PRIO, args.worker_cpu_mask);
auto w = std::unique_ptr<sf_worker>(
new sf_worker(SRSLTE_MAX_PRB, &common, (srslte::log*)log_vec[i], (srslte::log*)log_vec[nof_workers], &sfsync));
workers.push_back(std::move(w));
workers_pool.init_worker(i, w.get(), WORKERS_THREAD_PRIO, args.worker_cpu_mask);
}
// Load Asynchronous SCell objects
@ -240,9 +231,6 @@ void phy::stop()
workers_pool.stop();
prach_buffer.stop();
for (uint32_t i = 0; i < nof_workers; i++) {
delete ((sf_worker*)workers[i]);
}
initiated = false;
}
@ -350,7 +338,7 @@ uint32_t phy::get_current_pci() {
uint32_t phy::get_current_earfcn() {
uint32_t earfcn;
sfsync.get_current_cell(NULL, &earfcn);
sfsync.get_current_cell(nullptr, &earfcn);
return earfcn;
}

Loading…
Cancel
Save