SRSUE: add NR stack to PHY and initial decoded PDU push

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent e65c145704
commit a2d9b436d9

@ -581,6 +581,14 @@ typedef struct {
srslte::vnf_args_t vnf_args;
} phy_args_t;
typedef struct {
uint32_t nof_prb;
uint32_t nof_carriers;
uint32_t nof_phy_threads;
uint32_t worker_cpu_mask;
srslte::phy_log_args_t log;
} phy_args_nr_t;
/* RAT agnostic Interface MAC -> PHY */
class phy_interface_mac_common
{

@ -173,7 +173,7 @@ int srslte_ra_ul_nr_time(const srslte_sch_hl_cfg_nr_t* cfg,
// subcarrier spacing μ PUSCH is applied in addition to the K 2 value.
if (ss_type == srslte_search_space_rar) {
uint32_t delta[4] = {2, 3, 4, 6};
if (cfg->scs_cfg <= 4) {
if (cfg->scs_cfg >= 4) {
ERROR("Invalid numerology");
return SRSLTE_ERROR;
}

@ -48,7 +48,6 @@ private:
// Temporal attributes
srslte_softbuffer_rx_t softbuffer_rx = {};
std::vector<uint8_t> data;
};
} // namespace nr

@ -15,6 +15,7 @@
#include "srslte/adt/circular_array.h"
#include "srslte/common/common.h"
#include "srslte/interfaces/ue_nr_interfaces.h"
#include "srslte/srslte.h"
#include <array>
#include <mutex>
@ -38,6 +39,7 @@ typedef struct {
class state
{
public:
mac_interface_phy_nr* stack = nullptr;
srslte_carrier_nr_t carrier = {};
phy_nr_args_t args = {};
phy_nr_cfg_t cfg = {};

@ -32,7 +32,11 @@ public:
sf_worker* operator[](std::size_t pos) { return workers.at(pos).get(); }
worker_pool(uint32_t max_workers);
bool init(phy_common* common, srslog::sink& log_sink, int prio);
bool init(const phy_args_nr_t& args_,
phy_common* common,
stack_interface_phy_nr* stack_,
srslog::sink& log_sink,
int prio);
sf_worker* wait_worker(uint32_t tti);
void start_worker(sf_worker* w);
void stop();

@ -86,6 +86,8 @@ public:
// Init for LTE PHYs
int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) final;
int init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srslte::radio_interface_phy* radio_);
void stop() final;
void wait_initialize() final;

@ -38,7 +38,6 @@ cc_worker::cc_worker(uint32_t cc_idx_, srslog::basic_logger& log, state* phy_sta
ERROR("Error init soft-buffer");
return;
}
data.resize(SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8);
}
cc_worker::~cc_worker()
@ -96,8 +95,6 @@ uint32_t cc_worker::get_buffer_len()
bool cc_worker::work_dl()
{
srslte_sch_hl_cfg_nr_t pdsch_hl_cfg = phy->cfg.pdsch;
// Run FFT
srslte_ue_dl_nr_estimate_fft(&ue_dl, &dl_slot_cfg);
@ -133,14 +130,15 @@ bool cc_worker::work_dl()
nof_found_dci += n_test;
}
// Notify MAC about PDCCH found grants
// ...
// Iterate over all received grants
for (uint32_t i = 0; i < nof_found_dci; i++) {
// Select Received DCI
const srslte_dci_dl_nr_t* dci_dl = &dci_dl_rx[i];
// Notify MAC about PDCCH found grant
// ... At the moment reset softbuffer locally
srslte_softbuffer_rx_reset(&softbuffer_rx);
// Log found DCI
if (logger.info.enabled()) {
std::array<char, 512> str;
@ -150,16 +148,19 @@ bool cc_worker::work_dl()
// Compute DL grant
srslte_sch_cfg_nr_t pdsch_cfg = {};
if (srslte_ra_dl_dci_to_grant_nr(&ue_dl.carrier, &pdsch_hl_cfg, dci_dl, &pdsch_cfg, &pdsch_cfg.grant)) {
if (srslte_ra_dl_dci_to_grant_nr(&ue_dl.carrier, &phy->cfg.pdsch, dci_dl, &pdsch_cfg, &pdsch_cfg.grant)) {
ERROR("Computing DL grant");
return false;
}
// Get data buffer
srslte::unique_byte_buffer_t data = srslte::allocate_unique_buffer(*srslte::byte_buffer_pool::get_instance());
data->N_bytes = pdsch_cfg.grant.tb[0].tbs / 8U;
// Initialise PDSCH Result
std::array<srslte_pdsch_res_nr_t, SRSLTE_MAX_CODEWORDS> pdsch_res = {};
pdsch_res[0].payload = data.data();
pdsch_res[0].payload = data->buffer;
pdsch_cfg.grant.tb[0].softbuffer.rx = &softbuffer_rx;
srslte_softbuffer_rx_reset(pdsch_cfg.grant.tb[0].softbuffer.rx);
// Decode actual PDSCH transmission
if (srslte_ue_dl_nr_decode_pdsch(&ue_dl, &dl_slot_cfg, &pdsch_cfg, pdsch_res.data()) < SRSLTE_SUCCESS) {
@ -167,14 +168,24 @@ bool cc_worker::work_dl()
return false;
}
// Notify MAC about PDSCH decoding result
// ...
// Logging
if (logger.info.enabled()) {
std::array<char, 512> str;
srslte_ue_dl_nr_pdsch_info(&ue_dl, &pdsch_cfg, pdsch_res.data(), str.data(), str.size());
logger.info("PDSCH: cc=%d, %s", cc_idx, str.data());
logger.info(pdsch_res[0].payload, pdsch_cfg.grant.tb[0].tbs / 8, "PDSCH: cc=%d, %s", cc_idx, str.data());
}
// Notify MAC about PDSCH decoding result
if (pdsch_res[0].crc) {
// Prepare grant
mac_interface_phy_nr::mac_nr_grant_dl_t mac_nr_grant = {};
mac_nr_grant.tb[0] = std::move(data);
mac_nr_grant.pid = dci_dl->pid;
mac_nr_grant.rnti = dci_dl->rnti;
mac_nr_grant.tti = dl_slot_cfg.idx;
// Send data to MAC
phy->stack->tb_decoded(cc_idx, mac_nr_grant);
}
}

@ -16,15 +16,21 @@ namespace nr {
worker_pool::worker_pool(uint32_t max_workers) : pool(max_workers) {}
bool worker_pool::init(phy_common* common, srslog::sink& log_sink, int prio)
bool worker_pool::init(const phy_args_nr_t& args,
phy_common* common,
stack_interface_phy_nr* stack_,
srslog::sink& log_sink,
int prio)
{
phy_state.stack = stack_;
// Set carrier attributes
phy_state.carrier.id = 500;
phy_state.carrier.nof_prb = common->args->nr_nof_prb;
phy_state.carrier.nof_prb = args.nof_prb;
// Set NR arguments
phy_state.args.nof_carriers = common->args->nof_nr_carriers;
phy_state.args.dl.nof_max_prb = common->args->nr_nof_prb;
phy_state.args.nof_carriers = args.nof_carriers;
phy_state.args.dl.nof_max_prb = args.nof_prb;
// Skip init of workers if no NR carriers
if (phy_state.args.nof_carriers == 0) {
@ -32,13 +38,13 @@ bool worker_pool::init(phy_common* common, srslog::sink& log_sink, int prio)
}
// Add workers to workers pool and start threads
for (uint32_t i = 0; i < common->args->nof_phy_threads; i++) {
for (uint32_t i = 0; i < args.nof_phy_threads; i++) {
auto& log = srslog::fetch_basic_logger(fmt::format("PHY{}", i), log_sink);
log.set_level(srslog::str_to_basic_level(common->args->log.phy_level));
log.set_hex_dump_max_size(common->args->log.phy_hex_limit);
log.set_level(srslog::str_to_basic_level(args.log.phy_level));
log.set_hex_dump_max_size(args.log.phy_hex_limit);
auto w = new sf_worker(common, &phy_state, log);
pool.init_worker(i, w, prio, common->args->worker_cpu_mask);
pool.init_worker(i, w, prio, args.worker_cpu_mask);
workers.push_back(std::unique_ptr<sf_worker>(w));
if (not w->set_carrier_unlocked(0, &phy_state.carrier)) {

@ -106,6 +106,15 @@ int phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::
return SRSLTE_SUCCESS;
}
int phy::init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srslte::radio_interface_phy* radio_)
{
if (!nr_workers.init(args_, &common, stack_, log_sink, WORKERS_THREAD_PRIO)) {
return SRSLTE_ERROR;
}
return SRSLTE_SUCCESS;
}
int phy::init(const phy_args_t& args_)
{
std::unique_lock<std::mutex> lock(config_mutex);
@ -148,7 +157,6 @@ void phy::run_thread()
// Initialise workers
lte_workers.init(&common, log_sink, WORKERS_THREAD_PRIO);
nr_workers.init(&common, log_sink, WORKERS_THREAD_PRIO);
// Warning this must be initialized after all workers have been added to the pool
sfsync.init(

@ -97,6 +97,17 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_)
ret = SRSLTE_ERROR;
}
srsue::phy_args_nr_t phy_args_nr = {};
phy_args_nr.nof_prb = args.phy.nr_nof_prb;
phy_args_nr.nof_carriers = args.phy.nof_nr_carriers;
phy_args_nr.nof_phy_threads = args.phy.nof_phy_threads;
phy_args_nr.worker_cpu_mask = args.phy.worker_cpu_mask;
phy_args_nr.log = args.phy.log;
if (lte_phy->init(phy_args_nr, lte_stack.get(), lte_radio.get())) {
srslte::console("Error initializing NR PHY.\n");
ret = SRSLTE_ERROR;
}
if (lte_stack->init(args.stack, old_logger, lte_phy.get(), gw_ptr.get())) {
srslte::console("Error initializing stack.\n");
ret = SRSLTE_ERROR;

Loading…
Cancel
Save