Fix gNb PHY-Stack UL-DL time paradox (#3365)

* Fix gNb PHY-Stack UL-DL time paradox

* Fix clang compilation
master
Xavier Arteaga 3 years ago committed by GitHub
parent 6bdeb2d6b6
commit b6ea78dfd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -31,6 +31,24 @@ namespace nr {
class slot_worker final : public srsran::thread_pool::worker class slot_worker final : public srsran::thread_pool::worker
{ {
public: public:
/**
* @brief Slot worker synchronization interface
*/
class sync_interface
{
public:
/**
* @brief Wait for the worker to start DL scheduler
* @param w Worker pointer
*/
virtual void wait(slot_worker* w) = 0;
/**
* @brief Releases the current worker
*/
virtual void release() = 0;
};
struct args_t { struct args_t {
uint32_t cell_index = 0; uint32_t cell_index = 0;
uint32_t nof_max_prb = SRSRAN_MAX_PRB_NR; uint32_t nof_max_prb = SRSRAN_MAX_PRB_NR;
@ -42,7 +60,10 @@ public:
double srate_hz = 0.0; double srate_hz = 0.0;
}; };
slot_worker(srsran::phy_common_interface& common_, stack_interface_phy_nr& stack_, srslog::basic_logger& logger); slot_worker(srsran::phy_common_interface& common_,
stack_interface_phy_nr& stack_,
sync_interface& sync_,
srslog::basic_logger& logger);
~slot_worker(); ~slot_worker();
bool init(const args_t& args); bool init(const args_t& args);
@ -78,6 +99,7 @@ private:
srsran::phy_common_interface& common; srsran::phy_common_interface& common;
stack_interface_phy_nr& stack; stack_interface_phy_nr& stack;
srslog::basic_logger& logger; srslog::basic_logger& logger;
sync_interface& sync;
uint32_t sf_len = 0; uint32_t sf_len = 0;
uint32_t cell_index = 0; uint32_t cell_index = 0;

@ -17,15 +17,20 @@
#include "srsenb/hdr/phy/phy_interfaces.h" #include "srsenb/hdr/phy/phy_interfaces.h"
#include "srsenb/hdr/phy/prach_worker.h" #include "srsenb/hdr/phy/prach_worker.h"
#include "srsran/common/thread_pool.h" #include "srsran/common/thread_pool.h"
#include "srsran/common/tti_sempahore.h"
#include "srsran/interfaces/enb_mac_interfaces.h" #include "srsran/interfaces/enb_mac_interfaces.h"
#include "srsran/interfaces/gnb_interfaces.h" #include "srsran/interfaces/gnb_interfaces.h"
namespace srsenb { namespace srsenb {
namespace nr { namespace nr {
class worker_pool class worker_pool final : private slot_worker::sync_interface
{ {
private: private:
srsran::tti_semaphore<slot_worker*> slot_sync; ///< Slot synchronization semaphore
void wait(slot_worker* w) override { slot_sync.wait(w); }
void release() override { slot_sync.release(); }
class prach_stack_adaptor_t : public stack_interface_phy_lte class prach_stack_adaptor_t : public stack_interface_phy_lte
{ {
private: private:

@ -18,8 +18,9 @@ namespace srsenb {
namespace nr { namespace nr {
slot_worker::slot_worker(srsran::phy_common_interface& common_, slot_worker::slot_worker(srsran::phy_common_interface& common_,
stack_interface_phy_nr& stack_, stack_interface_phy_nr& stack_,
sync_interface& sync_,
srslog::basic_logger& logger_) : srslog::basic_logger& logger_) :
common(common_), stack(stack_), logger(logger_) common(common_), stack(stack_), sync(sync_), logger(logger_)
{ {
// Do nothing // Do nothing
} }
@ -243,9 +244,18 @@ bool slot_worker::work_ul()
bool slot_worker::work_dl() bool slot_worker::work_dl()
{ {
// The Scheduler interface needs to be called synchronously, wait for the sync to be available
sync.wait(this);
// Retrieve Scheduling for the current processing DL slot // Retrieve Scheduling for the current processing DL slot
stack_interface_phy_nr::dl_sched_t dl_sched = {}; stack_interface_phy_nr::dl_sched_t dl_sched = {};
if (stack.get_dl_sched(dl_slot_cfg, dl_sched) < SRSRAN_SUCCESS) { bool dl_sched_fail = stack.get_dl_sched(dl_slot_cfg, dl_sched) < SRSRAN_SUCCESS;
// Releases synchronization lock and allow next worker to retrieve scheduling results
sync.release();
// Abort if the scheduling failed
if (dl_sched_fail) {
logger.error("Error retrieving DL scheduling"); logger.error("Error retrieving DL scheduling");
return false; return false;
} }
@ -367,6 +377,9 @@ void slot_worker::work_imp()
// Process uplink // Process uplink
if (not work_ul()) { if (not work_ul()) {
// Wait and release synchronization
sync.wait(this);
sync.release();
common.worker_end(context, false, tx_rf_buffer); common.worker_end(context, false, tx_rf_buffer);
return; return;
} }

@ -50,7 +50,7 @@ bool worker_pool::init(const args_t& args, const phy_cell_cfg_list_nr_t& cell_li
log.set_level(log_level); log.set_level(log_level);
log.set_hex_dump_max_size(args.log.phy_hex_limit); log.set_hex_dump_max_size(args.log.phy_hex_limit);
auto w = new slot_worker(common, stack, log); auto w = new slot_worker(common, stack, *this, log);
pool.init_worker(i, w, args.prio); pool.init_worker(i, w, args.prio);
workers.push_back(std::unique_ptr<slot_worker>(w)); workers.push_back(std::unique_ptr<slot_worker>(w));
@ -74,6 +74,9 @@ bool worker_pool::init(const args_t& args, const phy_cell_cfg_list_nr_t& cell_li
void worker_pool::start_worker(slot_worker* w) void worker_pool::start_worker(slot_worker* w)
{ {
// Push worker into synchronization queue
slot_sync.push(w);
// Feed PRACH detection before start processing // Feed PRACH detection before start processing
prach.new_tti(0, current_tti, w->get_buffer_rx(0)); prach.new_tti(0, current_tti, w->get_buffer_rx(0));

@ -80,7 +80,6 @@ private:
srsenb::rrc_nr_dummy rrc_obj; srsenb::rrc_nr_dummy rrc_obj;
srsenb::rlc_dummy rlc_obj; srsenb::rlc_dummy rlc_obj;
std::unique_ptr<srsenb::mac_nr> mac; std::unique_ptr<srsenb::mac_nr> mac;
srsran::slot_point pdsch_slot, pusch_slot;
srslog::basic_logger& sched_logger; srslog::basic_logger& sched_logger;
bool autofill_pdsch_bsr = false; bool autofill_pdsch_bsr = false;
@ -441,11 +440,6 @@ public:
{ {
logger.set_context(slot_cfg.idx); logger.set_context(slot_cfg.idx);
sched_logger.set_context(slot_cfg.idx); sched_logger.set_context(slot_cfg.idx);
if (not pdsch_slot.valid()) {
pdsch_slot = srsran::slot_point{NUMEROLOGY_IDX, slot_cfg.idx};
} else {
pdsch_slot++;
}
if (not use_dummy_sched) { if (not use_dummy_sched) {
if (autofill_pdsch_bsr) { if (autofill_pdsch_bsr) {
@ -514,11 +508,6 @@ public:
{ {
logger.set_context(slot_cfg.idx); logger.set_context(slot_cfg.idx);
sched_logger.set_context(slot_cfg.idx); sched_logger.set_context(slot_cfg.idx);
if (not pusch_slot.valid()) {
pusch_slot = srsran::slot_point{NUMEROLOGY_IDX, slot_cfg.idx};
} else {
pusch_slot++;
}
if (not use_dummy_sched) { if (not use_dummy_sched) {
int ret = mac->get_ul_sched(slot_cfg, ul_sched); int ret = mac->get_ul_sched(slot_cfg, ul_sched);
@ -601,6 +590,7 @@ public:
{ {
if (not use_dummy_sched) { if (not use_dummy_sched) {
mac->pucch_info(slot_cfg, pucch_info); mac->pucch_info(slot_cfg, pucch_info);
return SRSRAN_SUCCESS;
} }
// Handle UCI data // Handle UCI data
@ -615,6 +605,7 @@ public:
} }
// Handle PHY metrics // Handle PHY metrics
std::unique_lock<std::mutex> lock(metrics_mutex);
metrics.pucch.epre_db_avg = SRSRAN_VEC_CMA(pucch_info.csi.epre_dB, metrics.pucch.epre_db_avg, metrics.pucch.count); metrics.pucch.epre_db_avg = SRSRAN_VEC_CMA(pucch_info.csi.epre_dB, metrics.pucch.epre_db_avg, metrics.pucch.count);
metrics.pucch.epre_db_min = SRSRAN_MIN(metrics.pucch.epre_db_min, pucch_info.csi.epre_dB); metrics.pucch.epre_db_min = SRSRAN_MIN(metrics.pucch.epre_db_min, pucch_info.csi.epre_dB);
metrics.pucch.epre_db_max = SRSRAN_MAX(metrics.pucch.epre_db_max, pucch_info.csi.epre_dB); metrics.pucch.epre_db_max = SRSRAN_MAX(metrics.pucch.epre_db_max, pucch_info.csi.epre_dB);

@ -25,7 +25,7 @@ class dummy_rx_harq_proc
private: private:
srsran::byte_buffer_t data; srsran::byte_buffer_t data;
srsran_softbuffer_rx_t softbuffer = {}; srsran_softbuffer_rx_t softbuffer = {};
uint32_t tbs = {0}; std::atomic<uint32_t> tbs = {0};
bool first = true; bool first = true;
uint32_t ndi = 0; uint32_t ndi = 0;

@ -28,6 +28,7 @@ public:
}; };
private: private:
std::mutex rnti_mutex;
srsran_rnti_type_t dl_rnti_type = srsran_rnti_type_c; srsran_rnti_type_t dl_rnti_type = srsran_rnti_type_c;
uint16_t rnti = 0; uint16_t rnti = 0;
bool valid = false; bool valid = false;
@ -73,9 +74,17 @@ public:
} }
} }
int sf_indication(const uint32_t tti) override { return 0; } int sf_indication(const uint32_t tti) override { return 0; }
sched_rnti_t get_dl_sched_rnti_nr(const uint32_t tti) override { return {rnti, dl_rnti_type}; } sched_rnti_t get_dl_sched_rnti_nr(const uint32_t tti) override
sched_rnti_t get_ul_sched_rnti_nr(const uint32_t tti) override { return {rnti, srsran_rnti_type_c}; } {
void new_grant_dl(const uint32_t cc_idx, const mac_nr_grant_dl_t& grant, tb_action_dl_t* action) override std::unique_lock<std::mutex> lock(rnti_mutex);
return {rnti, dl_rnti_type};
}
sched_rnti_t get_ul_sched_rnti_nr(const uint32_t tti) override
{
std::unique_lock<std::mutex> lock(rnti_mutex);
return {rnti, srsran_rnti_type_c};
}
void new_grant_dl(const uint32_t cc_idx, const mac_nr_grant_dl_t& grant, tb_action_dl_t* action) override
{ {
action->tb.enabled = true; action->tb.enabled = true;
action->tb.softbuffer = &rx_harq_proc[grant.pid].get_softbuffer(grant.ndi, grant.tbs); action->tb.softbuffer = &rx_harq_proc[grant.pid].get_softbuffer(grant.ndi, grant.tbs);
@ -92,6 +101,7 @@ public:
} }
void prach_sent(uint32_t tti, uint32_t s_id, uint32_t t_id, uint32_t f_id, uint32_t ul_carrier_id) override void prach_sent(uint32_t tti, uint32_t s_id, uint32_t t_id, uint32_t f_id, uint32_t ul_carrier_id) override
{ {
std::unique_lock<std::mutex> lock(rnti_mutex);
dl_rnti_type = srsran_rnti_type_ra; dl_rnti_type = srsran_rnti_type_ra;
rnti = 1 + s_id + 14 * t_id + 14 * 80 * f_id + 14 * 80 * 8 * ul_carrier_id; rnti = 1 + s_id + 14 * t_id + 14 * 80 * f_id + 14 * 80 * 8 * ul_carrier_id;
} }

@ -30,7 +30,7 @@ test_bench::args_t::args_t(int argc, char** argv)
bpo::options_description options_ue_stack("UE stack options"); bpo::options_description options_ue_stack("UE stack options");
bpo::options_description options_ue_phy("UE stack options"); bpo::options_description options_ue_phy("UE stack options");
uint16_t rnti = 0x1234; uint16_t rnti = 17921;
gnb_stack.pdsch.slots = "0,1,2,3,4,5"; gnb_stack.pdsch.slots = "0,1,2,3,4,5";
gnb_stack.pusch.slots = "6,7,8,9"; gnb_stack.pusch.slots = "6,7,8,9";

Loading…
Cancel
Save