SRSUE: initial NR workers

master
Xavier Arteaga 4 years ago committed by Andre Puschmann
parent 85afdf8ce3
commit 2b2db90933

@ -0,0 +1,89 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE 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.
*
* srsLTE 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/.
*
*/
#ifndef SRSLTE_NR_CC_WORKER_H
#define SRSLTE_NR_CC_WORKER_H
#include "srslte/common/log.h"
#include "srslte/phy/ue/ue_dl_nr.h"
#include "srsue/hdr/phy/phy_common.h"
#include <array>
#include <vector>
namespace srsue {
namespace nr {
typedef struct {
uint32_t nof_carriers;
uint32_t max_prb;
srslte_ue_dl_nr_args_t dl;
} phy_nr_args_t;
typedef struct {
srslte_pdsch_cfg_nr_t pdsch;
} phy_nr_cfg_t;
class phy_nr_state
{
public:
phy_nr_args_t args = {};
phy_nr_cfg_t cfg = {};
phy_nr_state()
{
args.nof_carriers = 1;
args.max_prb = SRSLTE_MAX_PRB;
args.dl.nof_rx_antennas = 1;
args.dl.pdsch.measure_evm = true;
args.dl.pdsch.sch.disable_simd = true;
}
};
class cc_worker
{
public:
cc_worker(uint32_t cc_idx, srslte::log* log, phy_nr_state* phy_state_);
~cc_worker();
bool set_carrier(const srslte_carrier_nr_t* carrier);
void set_tti(uint32_t tti);
cf_t* get_rx_buffer(uint32_t antenna_idx);
uint32_t get_buffer_len();
bool work_dl();
private:
srslte_dl_slot_cfg_t dl_slot_cfg = {};
uint32_t cc_idx = 0;
std::array<std::vector<cf_t>, SRSLTE_MAX_PORTS> rx_buffer = {};
phy_nr_state* phy_state;
srslte_ue_dl_nr_t ue_dl = {};
// Temporal attributes
srslte_softbuffer_rx_t softbuffer_rx = {};
std::vector<uint8_t> data;
};
} // namespace nr
} // namespace srsue
#endif // SRSLTE_NR_CC_WORKER_H

@ -0,0 +1,67 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE 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.
*
* srsLTE 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/.
*
*/
#ifndef SRSUE_NR_PHCH_WORKER_H
#define SRSUE_NR_PHCH_WORKER_H
#include "../phy_common.h"
#include "cc_worker.h"
#include "srslte/common/thread_pool.h"
namespace srsue {
namespace nr {
/**
* The sf_worker class handles the PHY processing, UL and DL procedures associated with 1 subframe.
* It contains multiple cc_worker objects, one for each component carrier which may be executed in
* one or multiple threads.
*
* A sf_worker object is executed by a thread within the thread_pool.
*/
class sf_worker final : public srslte::thread_pool::worker
{
public:
sf_worker(phy_common* phy_, phy_nr_state* phy_state_, srslte::log* log);
~sf_worker() = default;
bool set_carrier_unlocked(uint32_t cc_idx, const srslte_carrier_nr_t* carrier_);
/* Functions used by main PHY thread */
cf_t* get_buffer(uint32_t cc_idx, uint32_t antenna_idx);
uint32_t get_buffer_len();
void set_tti(uint32_t tti);
private:
/* Inherited from thread_pool::worker. Function called every subframe to run the DL/UL processing */
void work_imp() override;
std::vector<std::unique_ptr<cc_worker> > cc_workers;
phy_common* phy = nullptr;
phy_nr_state* phy_state = nullptr;
srslte::log* log_h = nullptr;
};
} // namespace nr
} // namespace srsue
#endif // SRSUE_NR_PHCH_WORKER_H

@ -0,0 +1,55 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE 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.
*
* srsLTE 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/.
*
*/
#ifndef SRSUE_NR_WORKER_POOL_H
#define SRSUE_NR_WORKER_POOL_H
#include "sf_worker.h"
#include "srslte/common/thread_pool.h"
namespace srsue {
namespace nr {
class worker_pool
{
private:
std::vector<std::unique_ptr<srslte::log_filter> > log_vec;
srslte::thread_pool pool;
std::vector<std::unique_ptr<sf_worker> > workers;
phy_nr_state phy_state;
public:
sf_worker* operator[](std::size_t pos) { return workers.at(pos).get(); }
worker_pool(uint32_t max_workers);
bool init(phy_common* common, srslte::logger* logger, int prio);
sf_worker* wait_worker(uint32_t tti);
sf_worker* wait_worker_id(uint32_t id);
void start_worker(sf_worker* w);
void stop();
};
} // namespace nr
} // namespace srsue
#endif // SRSUE_NR_WORKER_POOL_H

@ -0,0 +1,123 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE 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.
*
* srsLTE 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/.
*
*/
#include "srsue/hdr/phy/nr/cc_worker.h"
#include "srslte/phy/phch/ra_nr.h"
#include "srslte/phy/ue/ue_dl_nr_data.h"
namespace srsue {
namespace nr {
cc_worker::cc_worker(uint32_t cc_idx_, srslte::log* log, phy_nr_state* phy_state_) :
cc_idx(cc_idx_), phy_state(phy_state_)
{
cf_t* buffer_c[SRSLTE_MAX_PORTS] = {};
// Allocate buffers
for (uint32_t i = 0; phy_state_->args.dl.nof_rx_antennas; i++) {
rx_buffer[i].resize(SRSLTE_SF_LEN_PRB(phy_state->args.max_prb));
buffer_c[i] = rx_buffer[i].data();
}
if (srslte_ue_dl_nr_init(&ue_dl, buffer_c, &phy_state_->args.dl)) {
ERROR("Error initiating UE DL NR\n");
return;
}
if (srslte_softbuffer_rx_init_guru(&softbuffer_rx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) <
SRSLTE_SUCCESS) {
ERROR("Error init soft-buffer\n");
return;
}
data.resize(SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB);
}
cc_worker::~cc_worker()
{
srslte_ue_dl_nr_free(&ue_dl);
srslte_softbuffer_rx_free(&softbuffer_rx);
}
bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier)
{
if (srslte_ue_dl_nr_set_carrier(&ue_dl, carrier) < SRSLTE_SUCCESS) {
return false;
}
return true;
}
void cc_worker::set_tti(uint32_t tti)
{
dl_slot_cfg.idx = tti;
}
cf_t* cc_worker::get_rx_buffer(uint32_t antenna_idx)
{
if (antenna_idx >= phy_state->args.dl.nof_rx_antennas) {
return nullptr;
}
return rx_buffer.at(antenna_idx).data();
}
uint32_t cc_worker::get_buffer_len()
{
return rx_buffer.size();
}
bool cc_worker::work_dl()
{
srslte_pdsch_grant_nr_t pdsch_grant = {};
srslte_pdsch_cfg_nr_t pdsch_cfg = phy_state->cfg.pdsch;
srslte_pdsch_res_nr_t pdsch_res = {};
// Use grant default A time resources with m=0
if (srslte_ue_dl_nr_pdsch_time_resource_default_A(0, pdsch_cfg.dmrs_cfg_typeA.typeA_pos, &pdsch_grant) <
SRSLTE_SUCCESS) {
ERROR("Error loading default grant\n");
return false;
}
pdsch_grant.nof_layers = ue_dl.carrier.max_mimo_layers;
pdsch_grant.dci_format = srslte_dci_format_nr_1_0;
for (uint32_t i = 0; i < ue_dl.carrier.nof_prb; i++) {
pdsch_grant.prb_idx[i] = true;
}
if (srslte_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, 20, &pdsch_grant.tb[0]) < SRSLTE_SUCCESS) {
ERROR("Error filing tb\n");
return false;
}
pdsch_res.payload = data.data();
pdsch_grant.tb[0].softbuffer.rx = &softbuffer_rx;
srslte_softbuffer_rx_reset(pdsch_grant.tb[0].softbuffer.rx);
if (srslte_ue_dl_nr_pdsch_get(&ue_dl, &dl_slot_cfg, &pdsch_cfg, &pdsch_grant, &pdsch_res) < SRSLTE_SUCCESS) {
ERROR("Error decoding PDSCH\n");
return false;
}
return true;
}
} // namespace nr
} // namespace srsue

@ -0,0 +1,73 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE 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.
*
* srsLTE 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/.
*
*/
#include "srsue/hdr/phy/nr/sf_worker.h"
namespace srsue {
namespace nr {
sf_worker::sf_worker(phy_common* phy_, phy_nr_state* phy_state_, srslte::log* log) :
phy(phy_), phy_state(phy_state_), log_h(log)
{
for (uint32_t i = 0; i < phy_state->args.nof_carriers; i++) {
cc_worker* w = new cc_worker(i, log, phy_state);
cc_workers.push_back(std::unique_ptr<cc_worker>(w));
}
}
bool sf_worker::set_carrier_unlocked(uint32_t cc_idx, const srslte_carrier_nr_t* carrier_)
{
if (cc_idx >= cc_workers.size()) {
return false;
}
return cc_workers.at(cc_idx)->set_carrier(carrier_);
}
cf_t* sf_worker::get_buffer(uint32_t cc_idx, uint32_t antenna_idx)
{
if (cc_idx >= cc_workers.size()) {
return nullptr;
}
return cc_workers.at(cc_idx)->get_rx_buffer(antenna_idx);
}
uint32_t sf_worker::get_buffer_len()
{
return cc_workers.at(0)->get_buffer_len();
}
void sf_worker::set_tti(uint32_t tti)
{
for (auto& w : cc_workers) {
w->set_tti(tti);
}
}
void sf_worker::work_imp()
{
for (auto& w : cc_workers) {
w->work_dl();
}
}
}; // namespace nr
}; // namespace srsue

@ -0,0 +1,73 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE 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.
*
* srsLTE 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/.
*
*/
#include "srsue/hdr/phy/nr/worker_pool.h"
namespace srsue {
namespace nr {
worker_pool::worker_pool(uint32_t max_workers) : pool(max_workers) {}
bool worker_pool::init(phy_common* common, srslte::logger* logger, int prio)
{
// Create logs
// Create array of pointers to phy_logs
for (uint32_t i = 0; i < common->args->nof_phy_threads; i++) {
auto* mylog = new srslte::log_filter;
char tmp[16];
sprintf(tmp, "PHY%d", i);
mylog->init(tmp, logger, true);
mylog->set_level(common->args->log.phy_level);
mylog->set_hex_limit(common->args->log.phy_hex_limit);
log_vec.push_back(std::unique_ptr<srslte::log_filter>(mylog));
}
// Add workers to workers pool and start threads
for (uint32_t i = 0; i < common->args->nof_phy_threads; i++) {
auto w = std::unique_ptr<sf_worker>(new sf_worker(common, &phy_state, (srslte::log*)log_vec[i].get()));
pool.init_worker(i, w.get(), prio, common->args->worker_cpu_mask);
workers.push_back(std::move(w));
}
return true;
}
void worker_pool::start_worker(sf_worker* w)
{
pool.start_worker(w);
}
sf_worker* worker_pool::wait_worker(uint32_t tti)
{
return (sf_worker*)pool.wait_worker(tti);
}
sf_worker* worker_pool::wait_worker_id(uint32_t id)
{
return (sf_worker*)pool.wait_worker_id(id);
}
void worker_pool::stop()
{
pool.stop();
}
}; // namespace nr
}; // namespace srsue
Loading…
Cancel
Save