mirror of https://github.com/pvnis/srsRAN_4G.git
Fix NR srsue/srsenb. Initial PHY NR in SRSENB.
parent
2b2db90933
commit
a908fb6c5b
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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 SRSENB_NR_CC_WORKER_H
|
||||
#define SRSENB_NR_CC_WORKER_H
|
||||
|
||||
#include "srslte/common/log.h"
|
||||
#include "srslte/phy/enb/enb_dl_nr.h"
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
namespace srsenb {
|
||||
namespace nr {
|
||||
|
||||
typedef struct {
|
||||
uint32_t nof_carriers;
|
||||
uint32_t max_prb;
|
||||
srslte_enb_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_tx_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_tx_buffer(uint32_t antenna_idx);
|
||||
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> tx_buffer = {};
|
||||
std::array<std::vector<cf_t>, SRSLTE_MAX_PORTS> rx_buffer = {};
|
||||
phy_nr_state* phy_state;
|
||||
srslte_enb_dl_nr_t enb_dl = {};
|
||||
|
||||
// Temporal attributes
|
||||
srslte_softbuffer_tx_t softbuffer_tx = {};
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
|
||||
} // namespace nr
|
||||
} // namespace srsenb
|
||||
|
||||
#endif // SRSENB_NR_CC_WORKER_H
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 "cc_worker.h"
|
||||
#include "srsenb/hdr/phy/phy_common.h"
|
||||
#include "srslte/common/thread_pool.h"
|
||||
|
||||
namespace srsenb {
|
||||
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_rx(uint32_t cc_idx, uint32_t antenna_idx);
|
||||
cf_t* get_buffer_tx(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 srsenb
|
||||
|
||||
#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 srsenb {
|
||||
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(const phy_args_t& args, 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 srsenb
|
||||
|
||||
#endif // SRSUE_NR_WORKER_POOL_H
|
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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 "srsenb/hdr/phy/nr/cc_worker.h"
|
||||
#include "srslte/phy/enb/enb_dl_nr.h"
|
||||
#include "srslte/phy/phch/ra_nr.h"
|
||||
#include "srslte/phy/ue/ue_dl_nr_data.h"
|
||||
|
||||
namespace srsenb {
|
||||
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_tx_antennas; i++) {
|
||||
tx_buffer[i].resize(SRSLTE_SF_LEN_PRB(phy_state->args.max_prb));
|
||||
rx_buffer[i].resize(SRSLTE_SF_LEN_PRB(phy_state->args.max_prb));
|
||||
buffer_c[i] = tx_buffer[i].data();
|
||||
}
|
||||
|
||||
if (srslte_enb_dl_nr_init(&enb_dl, buffer_c, &phy_state_->args.dl)) {
|
||||
ERROR("Error initiating UE DL NR\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (srslte_softbuffer_tx_init_guru(&softbuffer_tx, 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);
|
||||
srslte_random_t r = srslte_random_init(1234);
|
||||
for (uint32_t i = 0; i < SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB; i++) {
|
||||
data[i] = srslte_random_uniform_int_dist(r, 0, UINT8_MAX);
|
||||
}
|
||||
srslte_random_free(r);
|
||||
}
|
||||
|
||||
cc_worker::~cc_worker()
|
||||
{
|
||||
srslte_enb_dl_nr_free(&enb_dl);
|
||||
srslte_softbuffer_tx_free(&softbuffer_tx);
|
||||
}
|
||||
|
||||
bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier)
|
||||
{
|
||||
if (srslte_enb_dl_nr_set_carrier(&enb_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_tx_buffer(uint32_t antenna_idx)
|
||||
{
|
||||
if (antenna_idx >= phy_state->args.dl.nof_tx_antennas) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return tx_buffer.at(antenna_idx).data();
|
||||
}
|
||||
|
||||
cf_t* cc_worker::get_rx_buffer(uint32_t antenna_idx)
|
||||
{
|
||||
if (antenna_idx >= phy_state->args.dl.nof_tx_antennas) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return rx_buffer.at(antenna_idx).data();
|
||||
}
|
||||
|
||||
uint32_t cc_worker::get_buffer_len()
|
||||
{
|
||||
return tx_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;
|
||||
|
||||
// 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 = enb_dl.carrier.max_mimo_layers;
|
||||
pdsch_grant.dci_format = srslte_dci_format_nr_1_0;
|
||||
|
||||
for (uint32_t i = 0; i < enb_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;
|
||||
}
|
||||
|
||||
uint8_t* data2[SRSLTE_MAX_TB] = {data.data(), data.data()};
|
||||
pdsch_grant.tb[0].softbuffer.tx = &softbuffer_tx;
|
||||
srslte_softbuffer_tx_reset(pdsch_grant.tb[0].softbuffer.tx);
|
||||
|
||||
if (srslte_enb_dl_nr_pdsch_put(&enb_dl, &dl_slot_cfg, &pdsch_cfg, &pdsch_grant, data2) < SRSLTE_SUCCESS) {
|
||||
ERROR("Error decoding PDSCH\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
srslte_enb_dl_nr_gen_signal(&enb_dl);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace nr
|
||||
} // namespace srsenb
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 "srsenb/hdr/phy/nr/sf_worker.h"
|
||||
|
||||
namespace srsenb {
|
||||
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_rx(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);
|
||||
}
|
||||
|
||||
cf_t* sf_worker::get_buffer_tx(uint32_t cc_idx, uint32_t antenna_idx)
|
||||
{
|
||||
if (cc_idx >= cc_workers.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return cc_workers.at(cc_idx)->get_tx_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 srsenb
|
@ -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 "srsenb/hdr/phy/nr/worker_pool.h"
|
||||
|
||||
namespace srsenb {
|
||||
namespace nr {
|
||||
|
||||
worker_pool::worker_pool(uint32_t max_workers) : pool(max_workers) {}
|
||||
|
||||
bool worker_pool::init(const phy_args_t& args, phy_common* common, srslte::logger* logger, int prio)
|
||||
{
|
||||
// Create logs
|
||||
// Create array of pointers to phy_logs
|
||||
for (uint32_t i = 0; i < 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(args.log.phy_level);
|
||||
mylog->set_hex_limit(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 < 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);
|
||||
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 srsenb
|
Loading…
Reference in New Issue