Refactor PHY interfaces to remove difference between SA and NSA PHY

master
Ismael Gomez 3 years ago
parent 58ab8086ff
commit fb897d2998

@ -29,11 +29,7 @@ public:
virtual void out_of_sync() = 0; virtual void out_of_sync() = 0;
virtual void run_tti(const uint32_t tti) = 0; virtual void run_tti(const uint32_t tti) = 0;
virtual void set_phy_config_complete(bool status) = 0; virtual void set_phy_config_complete(bool status) = 0;
};
class rrc_interface_phy_sa_nr
{
public:
/** /**
* @brief Describes a cell search result * @brief Describes a cell search result
*/ */
@ -228,21 +224,13 @@ struct phy_args_nr_t {
class phy_interface_mac_nr class phy_interface_mac_nr
{ {
public: public:
typedef struct {
uint32_t tti;
uint32_t tb_len;
uint8_t* data; // always a pointer in our case
} tx_request_t;
// MAC informs PHY about UL grant included in RAR PDU // MAC informs PHY about UL grant included in RAR PDU
virtual int set_ul_grant(uint32_t rar_slot_idx, virtual int set_rar_grant(uint32_t rar_slot_idx,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant, std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant,
uint16_t rnti, uint16_t rnti,
srsran_rnti_type_t rnti_type) = 0; srsran_rnti_type_t rnti_type) = 0;
// MAC instructs PHY to transmit MAC TB at the given TTI
virtual int tx_request(const tx_request_t& request) = 0;
/// Instruct PHY to send PRACH in the next occasion. /// Instruct PHY to send PRACH in the next occasion.
virtual void send_prach(const uint32_t prach_occasion, virtual void send_prach(const uint32_t prach_occasion,
const int preamble_index, const int preamble_index,
@ -266,30 +254,26 @@ class phy_interface_rrc_nr
{ {
public: public:
virtual bool set_config(const srsran::phy_cfg_nr_t& cfg) = 0; virtual bool set_config(const srsran::phy_cfg_nr_t& cfg) = 0;
};
class phy_interface_rrc_sa_nr
{
public:
/** /**
* @brief Describe the possible NR standalone physical layer possible states * @brief Describe the possible NR standalone physical layer possible states
*/ */
typedef enum { typedef enum {
PHY_NR_SA_STATE_IDLE = 0, ///< There is no process going on PHY_NR_STATE_IDLE = 0, ///< There is no process going on
PHY_NR_SA_STATE_CELL_SEARCH, ///< Cell search is currently in progress PHY_NR_STATE_CELL_SEARCH, ///< Cell search is currently in progress
PHY_NR_SA_STATE_CELL_SELECT, ///< Cell selection is in progress or it is camped on a cell PHY_NR_STATE_CELL_SELECT, ///< Cell selection is in progress or it is camped on a cell
} phy_nr_sa_state_t; } phy_nr_state_t;
/** /**
* @brief Retrieves the physical layer state * @brief Retrieves the physical layer state
* @return * @return
*/ */
virtual phy_nr_sa_state_t get_state() const = 0; virtual phy_nr_state_t get_state() const = 0;
/** /**
* @brief Stops the ongoing process and transitions to IDLE * @brief Stops the ongoing process and transitions to IDLE
*/ */
virtual void reset() = 0; virtual void reset_nr() = 0;
/** /**
* @brief Describes cell search arguments * @brief Describes cell search arguments
@ -330,22 +314,10 @@ class stack_interface_phy_nr : public mac_interface_phy_nr,
public srsran::stack_interface_phy_nr public srsran::stack_interface_phy_nr
{}; {};
/**
* @brief Combines the stack interfaces for PHY to access stack (MAC and RRC) including the standalone interface
*/
class stack_interface_phy_sa_nr : public stack_interface_phy_nr, public rrc_interface_phy_sa_nr
{};
// Combined interface for stack (MAC and RRC) to access PHY // Combined interface for stack (MAC and RRC) to access PHY
class phy_interface_stack_nr : public phy_interface_mac_nr, public phy_interface_rrc_nr class phy_interface_stack_nr : public phy_interface_mac_nr, public phy_interface_rrc_nr
{}; {};
/**
* @brief Combines the PHY interfaces for stack (MAC and RRC) to access PHY for NSA including the standalone interfaces
*/
class phy_interface_stack_sa_nr : public phy_interface_stack_nr, public phy_interface_rrc_sa_nr
{};
} // namespace srsue } // namespace srsue
#endif // SRSRAN_UE_NR_INTERFACES_H #endif // SRSRAN_UE_NR_INTERFACES_H

@ -36,11 +36,10 @@ public:
srsran_duplex_mode_t duplex_mode; srsran_duplex_mode_t duplex_mode;
}; };
cell_search(stack_interface_phy_sa_nr& stack_, srsran::radio_interface_phy& radio_); cell_search(srslog::basic_logger& logger);
~cell_search(); ~cell_search();
bool init(const args_t& args); bool init(const args_t& args, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_);
bool start(const cfg_t& cfg); bool start(const cfg_t& cfg);
@ -50,8 +49,8 @@ public:
private: private:
srslog::basic_logger& logger; srslog::basic_logger& logger;
stack_interface_phy_sa_nr& stack; stack_interface_phy_nr* stack = nullptr;
srsran::radio_interface_phy& radio; srsran::radio_interface_phy* radio = nullptr;
srsran_ssb_t ssb = {}; srsran_ssb_t ssb = {};
uint32_t sf_sz = 0; ///< subframe size in samples (1 ms) uint32_t sf_sz = 0; ///< subframe size in samples (1 ms)
cf_t* buffer = nullptr; ///< Receive buffer cf_t* buffer = nullptr; ///< Receive buffer

@ -34,10 +34,10 @@ public:
int thread_priority = -1; int thread_priority = -1;
}; };
slot_sync(stack_interface_phy_sa_nr& stack_, srsran::radio_interface_phy& radio_); slot_sync(srslog::basic_logger& logger);
~slot_sync(); ~slot_sync();
bool init(const args_t& args); bool init(const args_t& args, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_);
int recv_callback(srsran::rf_buffer_t& rf_buffer, srsran_timestamp_t* timestamp); int recv_callback(srsran::rf_buffer_t& rf_buffer, srsran_timestamp_t* timestamp);
void run_stack_tti(); void run_stack_tti();
@ -47,8 +47,8 @@ private:
const static int MAX_TTI_JUMP = 1000; ///< Maximum time gap tolerance in RF stream metadata const static int MAX_TTI_JUMP = 1000; ///< Maximum time gap tolerance in RF stream metadata
enum { SEARCHING = 0, CAMPING } state = SEARCHING; enum { SEARCHING = 0, CAMPING } state = SEARCHING;
srslog::basic_logger& logger; srslog::basic_logger& logger;
stack_interface_phy_sa_nr& stack; stack_interface_phy_nr* stack = nullptr;
srsran::radio_interface_phy& radio; srsran::radio_interface_phy* radio = nullptr;
srsran::rf_timestamp_t last_rx_time; srsran::rf_timestamp_t last_rx_time;
srsran_ue_sync_nr_t ue_sync_nr = {}; srsran_ue_sync_nr_t ue_sync_nr = {};
srsran_timestamp_t stack_tti_ts_new = {}; srsran_timestamp_t stack_tti_ts_new = {};

@ -69,10 +69,10 @@ public:
STATE_CELL_SELECT STATE_CELL_SELECT
} state_t; } state_t;
sync_sa(stack_interface_phy_sa_nr& stack_, srsran::radio_interface_phy& radio_, worker_pool& workers_); sync_sa(srslog::basic_logger& logger, worker_pool& workers_);
~sync_sa(); ~sync_sa();
bool init(const args_t& args_); bool init(const args_t& args_, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_);
// The following methods control the SYNC state machine // The following methods control the SYNC state machine
bool start_cell_search(const cell_search::cfg_t& cfg); bool start_cell_search(const cell_search::cfg_t& cfg);
@ -86,8 +86,8 @@ public:
void worker_end(const worker_context_t& w_ctx, const bool& tx_enable, srsran::rf_buffer_t& buffer) override; void worker_end(const worker_context_t& w_ctx, const bool& tx_enable, srsran::rf_buffer_t& buffer) override;
private: private:
stack_interface_phy_sa_nr& stack; ///< Stand-Alone RRC interface stack_interface_phy_nr* stack = nullptr; ///< Stand-Alone RRC interface
srsran::radio_interface_phy& radio; ///< Radio object srsran::radio_interface_phy* radio = nullptr; ///< Radio object
srslog::basic_logger& logger; ///< General PHY logger srslog::basic_logger& logger; ///< General PHY logger
worker_pool& workers; worker_pool& workers;

@ -20,7 +20,7 @@
namespace srsue { namespace srsue {
namespace nr { namespace nr {
class worker_pool : public srsue::phy_interface_stack_nr class worker_pool
{ {
private: private:
srslog::basic_logger& logger; srslog::basic_logger& logger;
@ -40,7 +40,7 @@ private:
public: public:
sf_worker* operator[](std::size_t pos) { return workers.at(pos).get(); } sf_worker* operator[](std::size_t pos) { return workers.at(pos).get(); }
worker_pool(uint32_t max_workers); worker_pool(srslog::basic_logger& logger_, uint32_t max_workers);
bool init(const phy_args_nr_t& args_, srsran::phy_common_interface& common, stack_interface_phy_nr* stack_, int prio); bool init(const phy_args_nr_t& args_, srsran::phy_common_interface& common, stack_interface_phy_nr* stack_, int prio);
sf_worker* wait_worker(uint32_t tti); sf_worker* wait_worker(uint32_t tti);
void start_worker(sf_worker* w); void start_worker(sf_worker* w);
@ -48,16 +48,15 @@ public:
void send_prach(const uint32_t prach_occasion, void send_prach(const uint32_t prach_occasion,
const int preamble_index, const int preamble_index,
const float preamble_received_target_power, const float preamble_received_target_power,
const float ta_base_sec = 0.0f) override; const float ta_base_sec = 0.0f);
int set_ul_grant(uint32_t rx_tti, int set_rar_grant(uint32_t rx_tti,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> array, std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> array,
uint16_t rnti, uint16_t rnti,
srsran_rnti_type_t rnti_type) override; srsran_rnti_type_t rnti_type);
bool set_config(const srsran::phy_cfg_nr_t& cfg) override; bool set_config(const srsran::phy_cfg_nr_t& cfg);
bool has_valid_sr_resource(uint32_t sr_id) override; bool has_valid_sr_resource(uint32_t sr_id);
void clear_pending_grants() override; void clear_pending_grants();
void get_metrics(phy_metrics_t& m); void get_metrics(phy_metrics_t& m);
int tx_request(const tx_request_t& request) override;
/** /**
* @brief Sets external CFO to compensate UL signal frequency offset * @brief Sets external CFO to compensate UL signal frequency offset

@ -71,7 +71,7 @@ public:
logger_phy(srslog::fetch_basic_logger("PHY")), logger_phy(srslog::fetch_basic_logger("PHY")),
logger_phy_lib(srslog::fetch_basic_logger("PHY_LIB")), logger_phy_lib(srslog::fetch_basic_logger("PHY_LIB")),
lte_workers(MAX_WORKERS), lte_workers(MAX_WORKERS),
nr_workers(MAX_WORKERS), nr_workers(logger_phy, MAX_WORKERS),
common(logger_phy), common(logger_phy),
sfsync(logger_phy, logger_phy_lib), sfsync(logger_phy, logger_phy_lib),
prach_buffer(logger_phy), prach_buffer(logger_phy),
@ -163,20 +163,24 @@ public:
std::string get_type() final { return "lte_soft"; } std::string get_type() final { return "lte_soft"; }
/********** NR INTERFACE ********************/
int init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_) final; int init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_) final;
bool set_config(const srsran::phy_cfg_nr_t& cfg) final; bool set_config(const srsran::phy_cfg_nr_t& cfg) final;
int set_ul_grant(uint32_t rx_tti,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant,
uint16_t rnti,
srsran_rnti_type_t rnti_type) final;
void send_prach(const uint32_t prach_occasion, void send_prach(const uint32_t prach_occasion,
const int preamble_index, const int preamble_index,
const float preamble_received_target_power, const float preamble_received_target_power,
const float ta_base_sec = 0.0f) final; const float ta_base_sec = 0.0f) final;
int tx_request(const tx_request_t& request) final;
void set_earfcn(std::vector<uint32_t> earfcns) final; void set_earfcn(std::vector<uint32_t> earfcns) final;
bool has_valid_sr_resource(uint32_t sr_id) final; bool has_valid_sr_resource(uint32_t sr_id) final;
void clear_pending_grants() final; void clear_pending_grants() final;
int set_rar_grant(uint32_t rar_slot_idx,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant,
uint16_t rnti,
srsran_rnti_type_t rnti_type) final;
phy_nr_state_t get_state() const override { return PHY_NR_STATE_IDLE; };
void reset_nr() override{};
bool start_cell_search(const cell_search_args_t& req) override { return false; };
bool start_cell_select(const cell_search_args_t& req) override { return false; };
private: private:
void run_thread() final; void run_thread() final;

@ -15,53 +15,68 @@
#include "srsran/interfaces/ue_nr_interfaces.h" #include "srsran/interfaces/ue_nr_interfaces.h"
#include "srsue/hdr/phy/nr/sync_sa.h" #include "srsue/hdr/phy/nr/sync_sa.h"
#include "srsue/hdr/phy/ue_nr_phy_base.h"
namespace srsue { namespace srsue {
/** /**
* @brief NR Standalone PHY * @brief NR Standalone PHY
*/ */
class phy_nr_sa : public phy_interface_stack_sa_nr class phy_nr_sa final : public ue_nr_phy_base
{ {
public: public:
struct args_t { phy_nr_sa(const char* logname);
std::string log_level = "info"; ///< General PHY logging level
double srate_hz = 61.44e6; ///< Sampling rate in Hz
};
phy_nr_sa(stack_interface_phy_sa_nr& stack_, srsran::radio_interface_phy& radio_); int init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_) final;
bool init(const args_t& args_); std::string get_type() final { return "nr_soft"; }
int set_ul_grant(uint32_t rar_slot_idx, int set_rar_grant(uint32_t rar_slot_idx,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant, std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant,
uint16_t rnti, uint16_t rnti,
srsran_rnti_type_t rnti_type) override srsran_rnti_type_t rnti_type) final
{ {
return 0; return -1;
} }
int tx_request(const tx_request_t& request) override { return 0; }
void send_prach(const uint32_t prach_occasion, void send_prach(const uint32_t prach_occasion,
const int preamble_index, const int preamble_index,
const float preamble_received_target_power, const float preamble_received_target_power,
const float ta_base_sec) override const float ta_base_sec) final
{} {}
bool has_valid_sr_resource(uint32_t sr_id) override { return false; } void set_earfcn(std::vector<uint32_t> earfcns) final{};
void clear_pending_grants() override {} bool has_valid_sr_resource(uint32_t sr_id) final { return false; }
bool set_config(const srsran::phy_cfg_nr_t& cfg) override { return false; } void clear_pending_grants() final {}
bool set_config(const srsran::phy_cfg_nr_t& cfg) final { return false; }
phy_nr_state_t get_state() const final;
void reset_nr() final;
bool start_cell_search(const cell_search_args_t& req) final;
bool start_cell_select(const cell_search_args_t& req) final { return false; }
phy_nr_sa_state_t get_state() const override; void stop() final { sync.stop(); }
void reset() override;
bool start_cell_search(const cell_search_args_t& req) override;
bool start_cell_select(const cell_search_args_t& req) override { return false; }
void stop() { sync.stop(); } void get_metrics(const srsran::srsran_rat_t& rat, phy_metrics_t* m) final{};
private: private:
srslog::basic_logger& logger;
nr::worker_pool workers; nr::worker_pool workers;
phy_common common;
prach prach_buffer;
nr::sync_sa sync; nr::sync_sa sync;
srslog::basic_logger& logger;
args_t args; srsran::phy_cfg_nr_t config_nr = {};
phy_args_nr_t args = {};
srsran::radio_interface_phy* radio = nullptr;
std::mutex config_mutex;
std::condition_variable config_cond;
std::atomic<bool> is_configured = {false};
const static int SF_RECV_THREAD_PRIO = 0;
const static int WORKERS_THREAD_PRIO = 2;
}; };
} // namespace srsue } // namespace srsue

@ -32,7 +32,6 @@ public:
virtual std::string get_type() = 0; virtual std::string get_type() = 0;
virtual int init(const phy_args_t& args_) = 0;
virtual int init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_) = 0; virtual int init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_) = 0;
virtual void stop() = 0; virtual void stop() = 0;

@ -84,6 +84,7 @@ public:
// PHY interface // PHY interface
void in_sync() final; void in_sync() final;
void out_of_sync() final; void out_of_sync() final;
void cell_search_found_cell(const cell_search_result_t& result) final{};
// RLC interface // RLC interface
void max_retx_attempted() final; void max_retx_attempted() final;

@ -123,6 +123,9 @@ public:
void run_tti(uint32_t tti, uint32_t tti_jump) final; void run_tti(uint32_t tti, uint32_t tti_jump) final;
// RRC interface for NR PHY
void cell_search_found_cell(const cell_search_result_t& result) final {}
// MAC Interface for NR PHY // MAC Interface for NR PHY
int sf_indication(const uint32_t tti) final { return SRSRAN_SUCCESS; } int sf_indication(const uint32_t tti) final { return SRSRAN_SUCCESS; }
void tb_decoded(const uint32_t cc_idx, void tb_decoded(const uint32_t cc_idx,

@ -18,9 +18,7 @@
namespace srsue { namespace srsue {
namespace nr { namespace nr {
cell_search::cell_search(stack_interface_phy_sa_nr& stack_, srsran::radio_interface_phy& radio_) : cell_search::cell_search(srslog::basic_logger& logger_) : logger(logger_) {}
logger(srslog::fetch_basic_logger("PHY")), stack(stack_), radio(radio_)
{}
cell_search::~cell_search() cell_search::~cell_search()
{ {
@ -30,8 +28,11 @@ cell_search::~cell_search()
} }
} }
bool cell_search::init(const args_t& args) bool cell_search::init(const args_t& args, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_)
{ {
stack = stack_;
radio = radio_;
// Compute subframe size // Compute subframe size
sf_sz = (uint32_t)(args.max_srate_hz / 1000.0f); sf_sz = (uint32_t)(args.max_srate_hz / 1000.0f);
@ -81,7 +82,7 @@ bool cell_search::start(const cfg_t& cfg)
srsran_subcarrier_spacing_to_str(cfg.ssb_scs)); srsran_subcarrier_spacing_to_str(cfg.ssb_scs));
// Set RX frequency // Set RX frequency
radio.set_rx_freq(0, cfg.center_freq_hz); radio->set_rx_freq(0, cfg.center_freq_hz);
// Zero receive buffer // Zero receive buffer
srsran_vec_zero(buffer, sf_sz); srsran_vec_zero(buffer, sf_sz);
@ -98,7 +99,7 @@ bool cell_search::run()
// Receive // Receive
srsran::rf_timestamp_t rf_timestamp = {}; srsran::rf_timestamp_t rf_timestamp = {};
if (not radio.rx_now(rf_buffer, rf_timestamp)) { if (not radio->rx_now(rf_buffer, rf_timestamp)) {
return false; return false;
} }
@ -111,15 +112,15 @@ bool cell_search::run()
// Consider the SSB is found and decoded if the PBCH CRC matched // Consider the SSB is found and decoded if the PBCH CRC matched
if (res.measurements.snr_dB >= -10.0f and res.pbch_msg.crc) { if (res.measurements.snr_dB >= -10.0f and res.pbch_msg.crc) {
rrc_interface_phy_sa_nr::cell_search_result_t cs_res = {}; rrc_interface_phy_nr::cell_search_result_t cs_res = {};
cs_res.pci = res.N_id; cs_res.pci = res.N_id;
cs_res.pbch_msg = res.pbch_msg; cs_res.pbch_msg = res.pbch_msg;
cs_res.measurements = res.measurements; cs_res.measurements = res.measurements;
stack.cell_search_found_cell(cs_res); stack->cell_search_found_cell(cs_res);
} }
// Advance stack TTI // Advance stack TTI
stack.run_tti(0); stack->run_tti(0);
return true; return true;
} }

@ -15,11 +15,7 @@
namespace srsue { namespace srsue {
namespace nr { namespace nr {
slot_sync::slot_sync(stack_interface_phy_sa_nr& stack_, srsran::radio_interface_phy& radio_) : slot_sync::slot_sync(srslog::basic_logger& logger_) : logger(logger_) {}
logger(srslog::fetch_basic_logger("PHY")),
stack(stack_),
radio(radio_)
{}
slot_sync::~slot_sync() slot_sync::~slot_sync()
{ {
@ -37,8 +33,11 @@ int sync_sa_recv_callback(void* ptr, cf_t** buffer, uint32_t nsamples, srsran_ti
return sync->recv_callback(rf_buffer, ts); return sync->recv_callback(rf_buffer, ts);
} }
bool slot_sync::init(const args_t& args) bool slot_sync::init(const args_t& args, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_)
{ {
stack = stack_;
radio = radio_;
srsran_ue_sync_nr_args_t ue_sync_nr_args = {}; srsran_ue_sync_nr_args_t ue_sync_nr_args = {};
ue_sync_nr_args.max_srate_hz = args.max_srate_hz; ue_sync_nr_args.max_srate_hz = args.max_srate_hz;
ue_sync_nr_args.min_scs = args.ssb_min_scs; ue_sync_nr_args.min_scs = args.ssb_min_scs;
@ -63,7 +62,7 @@ int slot_sync::recv_callback(srsran::rf_buffer_t& data, srsran_timestamp_t* rx_t
srsran::rf_timestamp_t& rf_timestamp = (rx_time == nullptr) ? dummy_ts : last_rx_time; srsran::rf_timestamp_t& rf_timestamp = (rx_time == nullptr) ? dummy_ts : last_rx_time;
// Receive // Receive
if (not radio.rx_now(data, rf_timestamp)) { if (not radio->rx_now(data, rf_timestamp)) {
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
@ -120,7 +119,7 @@ void slot_sync::run_stack_tti()
// Run stack // Run stack
logger.debug("run_stack_tti: calling stack tti=%d, tti_jump=%d", tti, tti_jump); logger.debug("run_stack_tti: calling stack tti=%d, tti_jump=%d", tti, tti_jump);
stack.run_tti(tti); stack->run_tti(tti);
logger.debug("run_stack_tti: stack called"); logger.debug("run_stack_tti: stack called");
} }

@ -15,7 +15,7 @@
namespace srsue { namespace srsue {
namespace nr { namespace nr {
worker_pool::worker_pool(uint32_t max_workers) : pool(max_workers), logger(srslog::fetch_basic_logger("PHY-NR")) {} worker_pool::worker_pool(srslog::basic_logger& logger_, uint32_t max_workers) : pool(max_workers), logger(logger_) {}
bool worker_pool::init(const phy_args_nr_t& args, bool worker_pool::init(const phy_args_nr_t& args,
srsran::phy_common_interface& common, srsran::phy_common_interface& common,
@ -158,7 +158,7 @@ void worker_pool::send_prach(const uint32_t prach_occasion,
} }
// called from Stack thread when processing RAR PDU // called from Stack thread when processing RAR PDU
int worker_pool::set_ul_grant(uint32_t rar_slot_idx, int worker_pool::set_rar_grant(uint32_t rar_slot_idx,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant, std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant,
uint16_t rnti, uint16_t rnti,
srsran_rnti_type_t rnti_type) srsran_rnti_type_t rnti_type)
@ -294,10 +294,5 @@ void worker_pool::get_metrics(phy_metrics_t& m)
phy_state.get_metrics(m); phy_state.get_metrics(m);
} }
int worker_pool::tx_request(const phy_interface_mac_nr::tx_request_t& request)
{
return 0;
}
} // namespace nr } // namespace nr
} // namespace srsue } // namespace srsue

@ -631,12 +631,12 @@ int phy::init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srsran
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }
int phy::set_ul_grant(uint32_t rar_slot_idx, int phy::set_rar_grant(uint32_t rar_slot_idx,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant, std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant,
uint16_t rnti, uint16_t rnti,
srsran_rnti_type_t rnti_type) srsran_rnti_type_t rnti_type)
{ {
return nr_workers.set_ul_grant(rar_slot_idx, packed_ul_grant, rnti, rnti_type); return nr_workers.set_rar_grant(rar_slot_idx, packed_ul_grant, rnti, rnti_type);
} }
void phy::send_prach(const uint32_t prach_occasion, void phy::send_prach(const uint32_t prach_occasion,
@ -647,11 +647,6 @@ void phy::send_prach(const uint32_t prach_occasion,
nr_workers.send_prach(prach_occasion, preamble_index, preamble_received_target_power); nr_workers.send_prach(prach_occasion, preamble_index, preamble_received_target_power);
} }
int phy::tx_request(const phy_interface_mac_nr::tx_request_t& request)
{
return 0;
}
void phy::set_earfcn(std::vector<uint32_t> earfcns) void phy::set_earfcn(std::vector<uint32_t> earfcns)
{ {
// Do nothing // Do nothing

@ -13,17 +13,22 @@
namespace srsue { namespace srsue {
phy_nr_sa::phy_nr_sa(stack_interface_phy_sa_nr& stack_, srsran::radio_interface_phy& radio_) : phy_nr_sa::phy_nr_sa(const char* logname) :
logger(srslog::fetch_basic_logger("PHY-NR")), sync(stack_, radio_, workers), workers(4) logger(srslog::fetch_basic_logger(logname)),
sync(logger, workers),
workers(logger, 4),
common(logger),
prach_buffer(logger)
{} {}
bool phy_nr_sa::init(const args_t& args_) int phy_nr_sa::init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_)
{ {
args = args_; args = args_;
prach_buffer.init(SRSRAN_MAX_PRB);
nr::sync_sa::args_t sync_args = {}; nr::sync_sa::args_t sync_args = {};
sync_args.srate_hz = args.srate_hz; if (not sync.init(sync_args, stack_, radio_)) {
if (not sync.init(sync_args)) {
logger.error("Error initialising SYNC"); logger.error("Error initialising SYNC");
return false; return false;
} }
@ -31,22 +36,22 @@ bool phy_nr_sa::init(const args_t& args_)
return true; return true;
} }
phy_interface_rrc_sa_nr::phy_nr_sa_state_t phy_nr_sa::get_state() const phy_interface_rrc_nr::phy_nr_state_t phy_nr_sa::get_state() const
{ {
{ {
switch (sync.get_state()) { switch (sync.get_state()) {
case nr::sync_sa::STATE_IDLE: case nr::sync_sa::STATE_IDLE:
break; break;
case nr::sync_sa::STATE_CELL_SEARCH: case nr::sync_sa::STATE_CELL_SEARCH:
return phy_interface_rrc_sa_nr::PHY_NR_SA_STATE_CELL_SEARCH; return phy_interface_rrc_nr::PHY_NR_STATE_CELL_SEARCH;
case nr::sync_sa::STATE_CELL_SELECT: case nr::sync_sa::STATE_CELL_SELECT:
return phy_interface_rrc_sa_nr::PHY_NR_SA_STATE_CELL_SELECT; return phy_interface_rrc_nr::PHY_NR_STATE_CELL_SELECT;
} }
} }
return phy_interface_rrc_sa_nr::PHY_NR_SA_STATE_IDLE; return phy_interface_rrc_nr::PHY_NR_STATE_IDLE;
} }
void phy_nr_sa::reset() void phy_nr_sa::reset_nr()
{ {
sync.go_idle(); sync.go_idle();
} }
@ -55,7 +60,7 @@ bool phy_nr_sa::start_cell_search(const cell_search_args_t& req)
{ {
// Prepare cell search configuration from the request // Prepare cell search configuration from the request
nr::cell_search::cfg_t cfg = {}; nr::cell_search::cfg_t cfg = {};
cfg.srate_hz = args.srate_hz; cfg.srate_hz = 0; // args.srate_hz;
cfg.center_freq_hz = req.center_freq_hz; cfg.center_freq_hz = req.center_freq_hz;
cfg.ssb_freq_hz = req.ssb_freq_hz; cfg.ssb_freq_hz = req.ssb_freq_hz;
cfg.ssb_scs = req.ssb_scs; cfg.ssb_scs = req.ssb_scs;

@ -14,30 +14,26 @@
namespace srsue { namespace srsue {
namespace nr { namespace nr {
sync_sa::sync_sa(stack_interface_phy_sa_nr& stack_, srsran::radio_interface_phy& radio_, worker_pool& workers_) : sync_sa::sync_sa(srslog::basic_logger& logger_, worker_pool& workers_) :
logger(srslog::fetch_basic_logger("PHY-NR")), logger(logger_), workers(workers_), slot_synchronizer(logger_), searcher(logger_), srsran::thread("SYNC")
stack(stack_),
radio(radio_),
workers(workers_),
srsran::thread("SYNC"),
searcher(stack_, radio_),
slot_synchronizer(stack_, radio_)
{} {}
sync_sa::~sync_sa() {} sync_sa::~sync_sa() {}
bool sync_sa::init(const args_t& args) bool sync_sa::init(const args_t& args, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_)
{ {
stack = stack_;
radio = radio_;
sf_sz = (uint32_t)(args.srate_hz / 1000.0f); sf_sz = (uint32_t)(args.srate_hz / 1000.0f);
// Initialise cell search internal object // Initialise cell search internal object
if (not searcher.init(args.get_cell_search())) { if (not searcher.init(args.get_cell_search(), stack, radio)) {
logger.error("Error initialising cell searcher"); logger.error("Error initialising cell searcher");
return false; return false;
} }
// Initialise slot synchronizer object // Initialise slot synchronizer object
if (not slot_synchronizer.init(args.get_slot_sync())) { if (not slot_synchronizer.init(args.get_slot_sync(), stack, radio)) {
logger.error("Error initialising slot synchronizer"); logger.error("Error initialising slot synchronizer");
return false; return false;
} }
@ -114,9 +110,9 @@ void sync_sa::run_state_idle()
srsran::rf_timestamp_t ts = {}; srsran::rf_timestamp_t ts = {};
// Receives from radio 1 slot // Receives from radio 1 slot
radio.rx_now(rf_buffer, ts); radio->rx_now(rf_buffer, ts);
stack.run_tti(slot_cfg.idx); stack->run_tti(slot_cfg.idx);
} }
void sync_sa::run_state_cell_search() void sync_sa::run_state_cell_search()

@ -213,15 +213,15 @@ private:
public: public:
struct args_t { struct args_t {
srsue::phy_nr_sa::args_t phy; srsue::phy_args_nr_t phy;
ue_dummy_stack::args_t stack; ue_dummy_stack::args_t stack;
}; };
dummy_ue(const args_t& args, srsran::radio_interface_phy& radio) : stack(args.stack, phy), phy(stack, radio) dummy_ue(const args_t& args, srsran::radio_interface_phy* radio) : stack(args.stack, phy), phy("PHY")
{ {
srsran_assert(phy.init(args.phy), "Failed to initialise PHY"); srsran_assert(phy.init(args.phy, &stack, radio), "Failed to initialise PHY");
} }
bool start_cell_search(const srsue::phy_interface_stack_sa_nr::cell_search_args_t& args) bool start_cell_search(const srsue::phy_interface_stack_nr::cell_search_args_t& args)
{ {
return phy.start_cell_search(args); return phy.start_cell_search(args);
} }
@ -230,7 +230,7 @@ public:
void stop() void stop()
{ {
// First transition PHY to IDLE // First transition PHY to IDLE
phy.reset(); phy.reset_nr();
// Make sure PHY transitioned to IDLE // Make sure PHY transitioned to IDLE
// ... // ...
@ -303,9 +303,7 @@ int main(int argc, char** argv)
// Create dummy UE // Create dummy UE
dummy_ue::args_t ue_args = {}; dummy_ue::args_t ue_args = {};
ue_args.stack.log_level = args.stack_log_level; ue_args.stack.log_level = args.stack_log_level;
ue_args.phy.log_level = args.phy_log_level; dummy_ue ue(ue_args, radio.get());
ue_args.phy.srate_hz = args.srate_hz;
dummy_ue ue(ue_args, *radio);
// Transition PHY to cell search // Transition PHY to cell search
srsue::phy_nr_sa::cell_search_args_t cell_search_req = {}; srsue::phy_nr_sa::cell_search_args_t cell_search_req = {};

@ -213,7 +213,7 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::tb_action_dl_
temp_crnti = subpdu.get_temp_crnti(); temp_crnti = subpdu.get_temp_crnti();
// Set Temporary-C-RNTI if provided, otherwise C-RNTI is ok // Set Temporary-C-RNTI if provided, otherwise C-RNTI is ok
phy->set_ul_grant(tb.rx_slot_idx, subpdu.get_ul_grant(), temp_crnti, srsran_rnti_type_ra); phy->set_rar_grant(tb.rx_slot_idx, subpdu.get_ul_grant(), temp_crnti, srsran_rnti_type_ra);
// reset all parameters that are used before rar // reset all parameters that are used before rar
rar_rnti = SRSRAN_INVALID_RNTI; rar_rnti = SRSRAN_INVALID_RNTI;

@ -35,8 +35,7 @@ public:
preamble_index = preamble_index_; preamble_index = preamble_index_;
preamble_received_target_power = preamble_received_target_power_; preamble_received_target_power = preamble_received_target_power_;
} }
int tx_request(const tx_request_t& request) override { return 0; } int set_rar_grant(uint32_t rar_slot_idx,
int set_ul_grant(uint32_t rar_slot_idx,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS>, std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS>,
uint16_t rnti, uint16_t rnti,
srsran_rnti_type_t rnti_type) override srsran_rnti_type_t rnti_type) override

@ -29,14 +29,6 @@ public:
preamble_index = preamble_index_; preamble_index = preamble_index_;
preamble_received_target_power = preamble_received_target_power_; preamble_received_target_power = preamble_received_target_power_;
} }
int tx_request(const tx_request_t& request) override { return 0; }
int set_ul_grant(uint32_t rar_slot_idx,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS>,
uint16_t rnti,
srsran_rnti_type_t rnti_type) override
{
return 0;
}
void get_last_send_prach(uint32_t* prach_occasion_, uint32_t* preamble_index_, int* preamble_received_target_power_) void get_last_send_prach(uint32_t* prach_occasion_, uint32_t* preamble_index_, int* preamble_received_target_power_)
{ {
@ -47,6 +39,14 @@ public:
bool has_valid_sr_resource(uint32_t sr_id) override { return false; } bool has_valid_sr_resource(uint32_t sr_id) override { return false; }
void clear_pending_grants() override {} void clear_pending_grants() override {}
int set_rar_grant(uint32_t rar_slot_idx,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant,
uint16_t rnti,
srsran_rnti_type_t rnti_type) override
{
return -1;
}
private: private:
uint32_t prach_occasion = 0; uint32_t prach_occasion = 0;
uint32_t preamble_index = 0; uint32_t preamble_index = 0;

@ -30,8 +30,7 @@ public:
preamble_index = preamble_index_; preamble_index = preamble_index_;
preamble_received_target_power = preamble_received_target_power_; preamble_received_target_power = preamble_received_target_power_;
} }
int tx_request(const tx_request_t& request) override { return 0; } int set_rar_grant(uint32_t rar_slot_idx,
int set_ul_grant(uint32_t rar_slot_idx,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS>, std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS>,
uint16_t rnti, uint16_t rnti,
srsran_rnti_type_t rnti_type) override srsran_rnti_type_t rnti_type) override

@ -22,7 +22,11 @@ using namespace srsue;
class dummy_phy : public phy_interface_rrc_nr class dummy_phy : public phy_interface_rrc_nr
{ {
bool set_config(const srsran::phy_cfg_nr_t& cfg) { return true; } bool set_config(const srsran::phy_cfg_nr_t& cfg) override { return true; }
phy_nr_state_t get_state() const override { return PHY_NR_STATE_IDLE; };
void reset_nr() override{};
bool start_cell_search(const cell_search_args_t& req) override { return false; };
bool start_cell_select(const cell_search_args_t& req) override { return false; };
}; };
class dummy_mac : public mac_interface_rrc_nr class dummy_mac : public mac_interface_rrc_nr

@ -18,7 +18,7 @@
#include "srsran/asn1/rrc_nr.h" #include "srsran/asn1/rrc_nr.h"
#include "srsran/interfaces/ue_nr_interfaces.h" #include "srsran/interfaces/ue_nr_interfaces.h"
class ue_dummy_stack : public srsue::stack_interface_phy_sa_nr class ue_dummy_stack : public srsue::stack_interface_phy_nr
{ {
public: public:
struct prach_metrics_t { struct prach_metrics_t {
@ -141,6 +141,7 @@ public:
void cell_search_found_cell(const cell_search_result_t& result) override void cell_search_found_cell(const cell_search_result_t& result) override
{ {
#if 0
// Unpack MIB with ASN1 // Unpack MIB with ASN1
asn1::rrc_nr::mib_s mib_asn1; asn1::rrc_nr::mib_s mib_asn1;
asn1::cbit_ref cbit(result.pbch_msg.payload, SRSRAN_PBCH_MSG_NR_SZ); asn1::cbit_ref cbit(result.pbch_msg.payload, SRSRAN_PBCH_MSG_NR_SZ);
@ -164,6 +165,7 @@ public:
logger.info( logger.info(
"Cell found pci=%d %s %s ASN1: %s", result.pci, mib_info.data(), csi_info.data(), json.to_string().c_str()); "Cell found pci=%d %s %s ASN1: %s", result.pci, mib_info.data(), csi_info.data(), json.to_string().c_str());
#endif
} }
}; };

@ -14,6 +14,7 @@
#define SRSRAN_TEST_BENCH_H #define SRSRAN_TEST_BENCH_H
#include "dummy_phy_common.h" #include "dummy_phy_common.h"
#include "dummy_ue_phy.h"
#include "srsenb/hdr/phy/nr/worker_pool.h" #include "srsenb/hdr/phy/nr/worker_pool.h"
#include "srsue/hdr/phy/nr/worker_pool.h" #include "srsue/hdr/phy/nr/worker_pool.h"
@ -30,7 +31,7 @@ private:
srsenb::nr::worker_pool gnb_phy; srsenb::nr::worker_pool gnb_phy;
phy_common gnb_phy_com; phy_common gnb_phy_com;
ue_dummy_stack ue_stack; ue_dummy_stack ue_stack;
srsue::nr::worker_pool ue_phy; ue_dummy_phy ue_phy;
phy_common ue_phy_com; phy_common ue_phy_com;
bool initialised = false; bool initialised = false;
uint32_t sf_sz = 0; uint32_t sf_sz = 0;
@ -70,7 +71,7 @@ public:
gnb_stack(args.gnb_stack), gnb_stack(args.gnb_stack),
gnb_phy(gnb_phy_com, gnb_stack, srslog::get_default_sink(), args.gnb_phy.nof_phy_threads), gnb_phy(gnb_phy_com, gnb_stack, srslog::get_default_sink(), args.gnb_phy.nof_phy_threads),
ue_stack(args.ue_stack, ue_phy), ue_stack(args.ue_stack, ue_phy),
ue_phy(args.ue_phy.nof_phy_threads), ue_phy("PHY", args.ue_phy.nof_phy_threads),
ue_phy_com(phy_common::args_t(args.srate_hz, args.buffer_sz_ms, args.nof_channels), ue_phy_com(phy_common::args_t(args.srate_hz, args.buffer_sz_ms, args.nof_channels),
srslog::fetch_basic_logger(UE_PHY_COM_LOG_NAME, srslog::get_default_sink(), false)), srslog::fetch_basic_logger(UE_PHY_COM_LOG_NAME, srslog::get_default_sink(), false)),

Loading…
Cancel
Save