Fix NR srsue/srsenb. Initial PHY NR in SRSENB.

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

@ -17,6 +17,10 @@
#include "srslte/phy/dft/ofdm.h" #include "srslte/phy/dft/ofdm.h"
#include "srslte/phy/phch/pdsch_nr.h" #include "srslte/phy/phch/pdsch_nr.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_pdsch_args_t pdsch; srslte_pdsch_args_t pdsch;
uint32_t nof_tx_antennas; uint32_t nof_tx_antennas;
@ -49,4 +53,8 @@ SRSLTE_API int srslte_enb_dl_nr_pdsch_put(srslte_enb_dl_nr_t* q,
const srslte_pdsch_grant_nr_t* grant, const srslte_pdsch_grant_nr_t* grant,
uint8_t* data[SRSLTE_MAX_TB]); uint8_t* data[SRSLTE_MAX_TB]);
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_ENB_DL_NR_H #endif // SRSLTE_ENB_DL_NR_H

@ -24,6 +24,10 @@
#include "srslte/config.h" #include "srslte/config.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t max_cb; uint32_t max_cb;
uint32_t max_cb_size; uint32_t max_cb_size;
@ -79,4 +83,8 @@ SRSLTE_API void srslte_softbuffer_tx_reset_cb(srslte_softbuffer_tx_t* q, uint32_
SRSLTE_API void srslte_softbuffer_tx_free(srslte_softbuffer_tx_t* p); SRSLTE_API void srslte_softbuffer_tx_free(srslte_softbuffer_tx_t* p);
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_SOFTBUFFER_H #endif // SRSLTE_SOFTBUFFER_H

@ -24,6 +24,10 @@
#include "srslte/phy/common/phy_common_nr.h" #include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/phch/sch_cfg_nr.h" #include "srslte/phy/phch/sch_cfg_nr.h"
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief PDSCH DMRS type * @brief PDSCH DMRS type
*/ */
@ -146,4 +150,8 @@ typedef struct SRSLTE_API {
srslte_sch_cfg_t sch_cfg; ///< Common shared channel parameters srslte_sch_cfg_t sch_cfg; ///< Common shared channel parameters
} srslte_pdsch_cfg_nr_t; } srslte_pdsch_cfg_nr_t;
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_PDSCH_CFG_NR_H #endif // SRSLTE_PDSCH_CFG_NR_H

@ -28,6 +28,10 @@
#include "srslte/phy/common/phy_common_nr.h" #include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/phch/pdsch_cfg_nr.h" #include "srslte/phy/phch/pdsch_cfg_nr.h"
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Determines the number of resource elements available for a given PDSCH transmission * @brief Determines the number of resource elements available for a given PDSCH transmission
* @param pdsch_cfg PDSCH configuration provided by higher layers * @param pdsch_cfg PDSCH configuration provided by higher layers
@ -52,4 +56,9 @@ SRSLTE_API int srslte_ra_nr_fill_tb(const srslte_pdsch_cfg_nr_t* pdsch_cfg,
const srslte_pdsch_grant_nr_t* grant, const srslte_pdsch_grant_nr_t* grant,
uint32_t mcs_idx, uint32_t mcs_idx,
srslte_sch_tb_t* tb); srslte_sch_tb_t* tb);
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_RA_NR_H #endif // SRSLTE_RA_NR_H

@ -26,6 +26,10 @@
#include "srslte/phy/common/phy_common_nr.h" #include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/phch/pdsch_cfg_nr.h" #include "srslte/phy/phch/pdsch_cfg_nr.h"
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Calculates the PDSCH time resource provided by higher layers and stores it in the provided PDSCH NR grant. * @brief Calculates the PDSCH time resource provided by higher layers and stores it in the provided PDSCH NR grant.
* *
@ -55,4 +59,8 @@ SRSLTE_API int srslte_ue_dl_nr_pdsch_time_resource_default_A(uint32_t
srslte_dmrs_pdsch_typeA_pos_t dmrs_typeA_pos, srslte_dmrs_pdsch_typeA_pos_t dmrs_typeA_pos,
srslte_pdsch_grant_nr_t* grant); srslte_pdsch_grant_nr_t* grant);
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_UE_DL_NR_DATA_H #endif // SRSLTE_UE_DL_NR_DATA_H

@ -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

@ -36,8 +36,10 @@ class phy_common
public: public:
phy_common() = default; phy_common() = default;
bool bool init(const phy_cell_cfg_list_t& cell_list_,
init(const phy_cell_cfg_list_t& cell_list_, srslte::radio_interface_phy* radio_handler, stack_interface_phy_lte* mac); const phy_cell_cfg_list_nr_t& cell_list_nr_,
srslte::radio_interface_phy* radio_handler,
stack_interface_phy_lte* mac);
void reset(); void reset();
void stop(); void stop();
@ -58,13 +60,15 @@ public:
// Common objects // Common objects
phy_args_t params = {}; phy_args_t params = {};
uint32_t get_nof_carriers() { return static_cast<uint32_t>(cell_list.size()); }; uint32_t get_nof_carriers_lte() { return static_cast<uint32_t>(cell_list_lte.size()); };
uint32_t get_nof_carriers_nr() { return static_cast<uint32_t>(cell_list_nr.size()); };
uint32_t get_nof_carriers() { return static_cast<uint32_t>(cell_list_lte.size() + cell_list_nr.size()); };
uint32_t get_nof_prb(uint32_t cc_idx) uint32_t get_nof_prb(uint32_t cc_idx)
{ {
uint32_t ret = 0; uint32_t ret = 0;
if (cc_idx < cell_list.size()) { if (cc_idx < cell_list_lte.size()) {
ret = cell_list[cc_idx].cell.nof_prb; ret = cell_list_lte[cc_idx].cell.nof_prb;
} }
return ret; return ret;
@ -73,8 +77,8 @@ public:
{ {
uint32_t ret = 0; uint32_t ret = 0;
if (cc_idx < cell_list.size()) { if (cc_idx < cell_list_lte.size()) {
ret = cell_list[cc_idx].cell.nof_ports; ret = cell_list_lte[cc_idx].cell.nof_ports;
} }
return ret; return ret;
@ -83,18 +87,27 @@ public:
{ {
uint32_t count = 0; uint32_t count = 0;
for (auto& cell : cell_list) { for (auto& cell : cell_list_lte) {
count += cell.cell.nof_ports; count += cell.cell.nof_ports;
} }
for (auto& cell : cell_list_nr) {
count += cell.cell.max_mimo_layers;
}
return count; return count;
} }
double get_ul_freq_hz(uint32_t cc_idx) double get_ul_freq_hz(uint32_t cc_idx)
{ {
double ret = 0.0; double ret = 0.0;
if (cc_idx < cell_list.size()) { if (cc_idx < cell_list_lte.size()) {
ret = cell_list[cc_idx].ul_freq_hz; ret = cell_list_lte[cc_idx].ul_freq_hz;
}
cc_idx -= cell_list_lte.size();
if (cc_idx < cell_list_nr.size()) {
ret = cell_list_nr[cc_idx].ul_freq_hz;
} }
return ret; return ret;
@ -103,8 +116,13 @@ public:
{ {
double ret = 0.0; double ret = 0.0;
if (cc_idx < cell_list.size()) { if (cc_idx < cell_list_lte.size()) {
ret = cell_list[cc_idx].dl_freq_hz; ret = cell_list_lte[cc_idx].dl_freq_hz;
}
cc_idx -= cell_list_lte.size();
if (cc_idx < cell_list_nr.size()) {
ret = cell_list_nr[cc_idx].dl_freq_hz;
} }
return ret; return ret;
@ -113,8 +131,13 @@ public:
{ {
uint32_t ret = 0; uint32_t ret = 0;
if (cc_idx < cell_list.size()) { if (cc_idx < cell_list_lte.size()) {
ret = cell_list[cc_idx].rf_port; ret = cell_list_lte[cc_idx].rf_port;
}
cc_idx -= cell_list_lte.size();
if (cc_idx < cell_list_nr.size()) {
ret = cell_list_nr[cc_idx].rf_port;
} }
return ret; return ret;
@ -122,31 +145,62 @@ public:
srslte_cell_t get_cell(uint32_t cc_idx) srslte_cell_t get_cell(uint32_t cc_idx)
{ {
srslte_cell_t c = {}; srslte_cell_t c = {};
if (cc_idx < cell_list.size()) { if (cc_idx < cell_list_lte.size()) {
c = cell_list[cc_idx].cell; c = cell_list_lte[cc_idx].cell;
}
return c;
};
srslte_carrier_nr_t get_cell_nr(uint32_t cc_idx)
{
srslte_carrier_nr_t c = {};
if (cc_idx < cell_list_lte.size()) {
return c;
}
cc_idx -= cell_list_lte.size();
if (cc_idx < cell_list_nr.size()) {
c = cell_list_nr[cc_idx].cell;
} }
return c; return c;
}; };
void set_cell_gain(uint32_t cell_id, float gain_db) void set_cell_gain(uint32_t cell_id, float gain_db)
{ {
auto it = // Find LTE cell
std::find_if(cell_list.begin(), cell_list.end(), [cell_id](phy_cell_cfg_t& x) { return x.cell_id == cell_id; }); auto it_lte = std::find_if(
cell_list_lte.begin(), cell_list_lte.end(), [cell_id](phy_cell_cfg_t& x) { return x.cell_id == cell_id; });
// Check if the cell was found; // Check if the lte cell was found;
if (it == cell_list.end()) { if (it_lte != cell_list_lte.end()) {
srslte::console("cell ID %d not found\n", cell_id); it_lte->gain_db = gain_db;
return; return;
} }
it->gain_db = gain_db; // Find NR cell
auto it_nr = std::find_if(
cell_list_nr.begin(), cell_list_nr.end(), [cell_id](phy_cell_cfg_nr_t& x) { return x.cell_id == cell_id; });
// Check if the nr cell was found;
if (it_nr != cell_list_nr.end()) {
it_nr->gain_db = gain_db;
return;
}
srslte::console("cell ID %d not found\n", cell_id);
} }
float get_cell_gain(uint32_t cc_idx) float get_cell_gain(uint32_t cc_idx)
{ {
if (cc_idx < cell_list.size()) { if (cc_idx < cell_list_lte.size()) {
return cell_list.at(cc_idx).gain_db; return cell_list_lte.at(cc_idx).gain_db;
} }
cc_idx -= cell_list_lte.size();
if (cc_idx < cell_list_nr.size()) {
return cell_list_nr.at(cc_idx).gain_db;
}
return 0.0f; return 0.0f;
} }
@ -178,7 +232,8 @@ private:
srslte::circular_array<stack_interface_phy_lte::ul_sched_list_t, TTIMOD_SZ> ul_grants = {}; srslte::circular_array<stack_interface_phy_lte::ul_sched_list_t, TTIMOD_SZ> ul_grants = {};
std::mutex grant_mutex = {}; std::mutex grant_mutex = {};
phy_cell_cfg_list_t cell_list; phy_cell_cfg_list_t cell_list_lte;
phy_cell_cfg_list_nr_t cell_list_nr;
bool have_mtch_stop = false; bool have_mtch_stop = false;
pthread_mutex_t mtch_mutex = {}; pthread_mutex_t mtch_mutex = {};

@ -14,9 +14,10 @@
#define SRSENB_PHY_INTERFACES_H_ #define SRSENB_PHY_INTERFACES_H_
#include "srslte/asn1/rrc/rr_common.h" #include "srslte/asn1/rrc/rr_common.h"
#include "srslte/common/interfaces_common.h"
#include "srslte/phy/channel/channel.h"
#include "srslte/phy/common/phy_common_nr.h"
#include <inttypes.h> #include <inttypes.h>
#include <srslte/common/interfaces_common.h>
#include <srslte/phy/channel/channel.h>
#include <vector> #include <vector>
namespace srsenb { namespace srsenb {
@ -32,7 +33,19 @@ struct phy_cell_cfg_t {
float gain_db; float gain_db;
}; };
struct phy_cell_cfg_nr_t {
srslte_carrier_nr_t cell;
uint32_t rf_port;
uint32_t cell_id;
double dl_freq_hz;
double ul_freq_hz;
uint32_t root_seq_idx;
uint32_t num_ra_preambles;
float gain_db;
};
typedef std::vector<phy_cell_cfg_t> phy_cell_cfg_list_t; typedef std::vector<phy_cell_cfg_t> phy_cell_cfg_list_t;
typedef std::vector<phy_cell_cfg_nr_t> phy_cell_cfg_list_nr_t;
struct phy_args_t { struct phy_args_t {
std::string type; std::string type;
@ -59,6 +72,7 @@ struct phy_args_t {
struct phy_cfg_t { struct phy_cfg_t {
// Individual cell/sector configuration list // Individual cell/sector configuration list
phy_cell_cfg_list_t phy_cell_cfg; phy_cell_cfg_list_t phy_cell_cfg;
phy_cell_cfg_list_nr_t phy_cell_cfg_nr;
// Common configuration for all cells // Common configuration for all cells
asn1::rrc::prach_cfg_sib_s prach_cnfg; asn1::rrc::prach_cfg_sib_s prach_cnfg;

@ -16,6 +16,7 @@
#include "phy_common.h" #include "phy_common.h"
#include "prach_worker.h" #include "prach_worker.h"
#include "srsenb/hdr/phy/lte/worker_pool.h" #include "srsenb/hdr/phy/lte/worker_pool.h"
#include "srsenb/hdr/phy/nr/worker_pool.h"
#include "srslte/common/log.h" #include "srslte/common/log.h"
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/phy/channel/channel.h" #include "srslte/phy/channel/channel.h"
@ -39,13 +40,14 @@ public:
private: private:
void run_thread() override; void run_thread() override;
stack_interface_phy_lte* stack = nullptr; stack_interface_phy_lte* stack = nullptr;
srslte::radio_interface_phy* radio_h = nullptr; srslte::radio_interface_phy* radio_h = nullptr;
srslte::log* log_h = nullptr; srslte::log* log_h = nullptr;
lte::worker_pool* workers_pool = nullptr; lte::worker_pool* lte_workers = nullptr;
prach_worker_pool* prach = nullptr; nr::worker_pool* nr_workers = nullptr;
phy_common* worker_com = nullptr; prach_worker_pool* prach = nullptr;
srslte::channel_ptr ul_channel = nullptr; phy_common* worker_com = nullptr;
srslte::channel_ptr ul_channel = nullptr;
// Main system TTI counter // Main system TTI counter
uint32_t tti = 0; uint32_t tti = 0;

@ -6,7 +6,18 @@
# the distribution. # the distribution.
# #
set(SOURCES lte/cc_worker.cc lte/sf_worker.cc lte/worker_pool.cc phy.cc phy_common.cc phy_ue_db.cc prach_worker.cc txrx.cc) set(SOURCES
lte/cc_worker.cc
lte/sf_worker.cc
lte/worker_pool.cc
nr/cc_worker.cc
nr/sf_worker.cc
nr/worker_pool.cc
phy.cc
phy_common.cc
phy_ue_db.cc
prach_worker.cc
txrx.cc)
add_library(srsenb_phy STATIC ${SOURCES}) add_library(srsenb_phy STATIC ${SOURCES})
if(ENABLE_GUI AND SRSGUI_FOUND) if(ENABLE_GUI AND SRSGUI_FOUND)

@ -1,24 +1,3 @@
/*
* 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/.
*
*/
/* /*
* Copyright 2013-2020 Software Radio Systems Limited * Copyright 2013-2020 Software Radio Systems Limited
* *

@ -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

@ -119,7 +119,7 @@ int phy::init(const phy_args_t& args,
workers_common.params = args; workers_common.params = args;
workers_common.init(cfg.phy_cell_cfg, radio, stack_); workers_common.init(cfg.phy_cell_cfg, cfg.phy_cell_cfg_nr, radio, stack_);
parse_common_config(cfg); parse_common_config(cfg);

@ -44,13 +44,15 @@ void phy_common::reset()
} }
} }
bool phy_common::init(const phy_cell_cfg_list_t& cell_list_, bool phy_common::init(const phy_cell_cfg_list_t& cell_list_,
srslte::radio_interface_phy* radio_h_, const phy_cell_cfg_list_nr_t& cell_list_nr_,
stack_interface_phy_lte* stack_) srslte::radio_interface_phy* radio_h_,
stack_interface_phy_lte* stack_)
{ {
radio = radio_h_; radio = radio_h_;
stack = stack_; stack = stack_;
cell_list = cell_list_; cell_list_lte = cell_list_;
cell_list_nr = cell_list_nr_;
pthread_mutex_init(&mtch_mutex, nullptr); pthread_mutex_init(&mtch_mutex, nullptr);
pthread_cond_init(&mtch_cvar, nullptr); pthread_cond_init(&mtch_cvar, nullptr);
@ -58,17 +60,17 @@ bool phy_common::init(const phy_cell_cfg_list_t& cell_list_,
// Instantiate DL channel emulator // Instantiate DL channel emulator
if (params.dl_channel_args.enable) { if (params.dl_channel_args.enable) {
dl_channel = srslte::channel_ptr(new srslte::channel(params.dl_channel_args, get_nof_rf_channels())); dl_channel = srslte::channel_ptr(new srslte::channel(params.dl_channel_args, get_nof_rf_channels()));
dl_channel->set_srate((uint32_t)srslte_sampling_freq_hz(cell_list[0].cell.nof_prb)); dl_channel->set_srate((uint32_t)srslte_sampling_freq_hz(cell_list_lte[0].cell.nof_prb));
dl_channel->set_signal_power_dBfs(srslte_enb_dl_get_maximum_signal_power_dBfs(cell_list[0].cell.nof_prb)); dl_channel->set_signal_power_dBfs(srslte_enb_dl_get_maximum_signal_power_dBfs(cell_list_lte[0].cell.nof_prb));
} }
// Create grants // Create grants
for (auto& q : ul_grants) { for (auto& q : ul_grants) {
q.resize(cell_list.size()); q.resize(cell_list_lte.size());
} }
// Set UE PHY data-base stack and configuration // Set UE PHY data-base stack and configuration
ue_db.init(stack, params, cell_list); ue_db.init(stack, params, cell_list_lte);
reset(); reset();
return true; return true;

@ -16,7 +16,6 @@
#include "srslte/common/threads.h" #include "srslte/common/threads.h"
#include "srslte/srslte.h" #include "srslte/srslte.h"
#include "srsenb/hdr/phy/lte/sf_worker.h"
#include "srsenb/hdr/phy/txrx.h" #include "srsenb/hdr/phy/txrx.h"
#define Error(fmt, ...) \ #define Error(fmt, ...) \
@ -52,13 +51,13 @@ bool txrx::init(stack_interface_phy_lte* stack_,
stack = stack_; stack = stack_;
radio_h = radio_h_; radio_h = radio_h_;
log_h = log_h_; log_h = log_h_;
workers_pool = workers_pool_; lte_workers = workers_pool_;
worker_com = worker_com_; worker_com = worker_com_;
prach = prach_; prach = prach_;
tx_worker_cnt = 0; tx_worker_cnt = 0;
running = true; running = true;
nof_workers = workers_pool->get_nof_workers(); nof_workers = lte_workers->get_nof_workers();
// Instantiate UL channel emulator // Instantiate UL channel emulator
if (worker_com->params.ul_channel_args.enable) { if (worker_com->params.ul_channel_args.enable) {
@ -80,7 +79,6 @@ void txrx::stop()
void txrx::run_thread() void txrx::run_thread()
{ {
lte::sf_worker* worker = nullptr;
srslte::rf_buffer_t buffer = {}; srslte::rf_buffer_t buffer = {};
srslte::rf_timestamp_t timestamp = {}; srslte::rf_timestamp_t timestamp = {};
uint32_t sf_len = SRSLTE_SF_LEN_PRB(worker_com->get_nof_prb(0)); uint32_t sf_len = SRSLTE_SF_LEN_PRB(worker_com->get_nof_prb(0));
@ -117,59 +115,83 @@ void txrx::run_thread()
// Main loop // Main loop
while (running) { while (running) {
tti = TTI_ADD(tti, 1); tti = TTI_ADD(tti, 1);
if (log_h) { if (log_h) {
log_h->step(tti); log_h->step(tti);
} }
worker = workers_pool->wait_worker(tti); lte::sf_worker* lte_worker = nullptr;
if (worker) { if (worker_com->get_nof_carriers_lte() > 0) {
// Multiple cell buffer mapping lte_worker = lte_workers->wait_worker(tti);
for (uint32_t cc = 0; cc < worker_com->get_nof_carriers(); cc++) { if (lte_worker == nullptr) {
// wait_worker() only returns NULL if it's being closed. Quit now to avoid unnecessary loops here
running = false;
continue;
}
}
nr::sf_worker* nr_worker = nullptr;
if (worker_com->get_nof_carriers_nr() > 0) {
nr_worker = nr_workers->wait_worker(tti);
if (nr_worker == nullptr) {
running = false;
continue;
}
}
// Multiple cell buffer mapping
{
uint32_t cc = 0;
for (uint32_t cc_lte = 0; cc_lte < worker_com->get_nof_carriers_lte(); cc_lte++, cc++) {
uint32_t rf_port = worker_com->get_rf_port(cc); uint32_t rf_port = worker_com->get_rf_port(cc);
for (uint32_t p = 0; p < worker_com->get_nof_ports(cc); p++) { for (uint32_t p = 0; p < worker_com->get_nof_ports(cc); p++) {
// WARNING: The number of ports for all cells must be the same // WARNING: The number of ports for all cells must be the same
buffer.set(rf_port, p, worker_com->get_nof_ports(0), worker->get_buffer_rx(cc, p)); buffer.set(rf_port, p, worker_com->get_nof_ports(0), lte_worker->get_buffer_rx(cc_lte, p));
} }
} }
for (uint32_t cc_nr = 0; cc_nr < worker_com->get_nof_carriers_lte(); cc_nr++, cc++) {
uint32_t rf_port = worker_com->get_rf_port(cc);
buffer.set_nof_samples(sf_len); for (uint32_t p = 0; p < worker_com->get_nof_ports(cc); p++) {
radio_h->rx_now(buffer, timestamp); // WARNING: The number of ports for all cells must be the same
buffer.set(rf_port, p, worker_com->get_nof_ports(0), nr_worker->get_buffer_rx(cc_nr, p));
if (ul_channel) { }
ul_channel->run(buffer.to_cf_t(), buffer.to_cf_t(), sf_len, timestamp.get(0));
} }
}
// Compute TX time: Any transmission happens in TTI+4 thus advance 4 ms the reception time buffer.set_nof_samples(sf_len);
timestamp.add(FDD_HARQ_DELAY_UL_MS * 1e-3); radio_h->rx_now(buffer, timestamp);
Debug("Setting TTI=%d, tx_mutex=%d, tx_time=%ld:%f to worker %d\n", if (ul_channel) {
tti, ul_channel->run(buffer.to_cf_t(), buffer.to_cf_t(), sf_len, timestamp.get(0));
tx_worker_cnt, }
timestamp.get(0).full_secs,
timestamp.get(0).frac_secs,
worker->get_id());
worker->set_time(tti, tx_worker_cnt, timestamp); // Compute TX time: Any transmission happens in TTI+4 thus advance 4 ms the reception time
tx_worker_cnt = (tx_worker_cnt + 1) % nof_workers; timestamp.add(FDD_HARQ_DELAY_UL_MS * 1e-3);
// Trigger phy worker execution Debug("Setting TTI=%d, tx_mutex=%d, tx_time=%ld:%f to worker %d\n",
worker_com->semaphore.push(worker); tti,
workers_pool->start_worker(worker); tx_worker_cnt,
timestamp.get(0).full_secs,
timestamp.get(0).frac_secs,
lte_worker->get_id());
// Trigger prach worker execution lte_worker->set_time(tti, tx_worker_cnt, timestamp);
for (uint32_t cc = 0; cc < worker_com->get_nof_carriers(); cc++) { tx_worker_cnt = (tx_worker_cnt + 1) % nof_workers;
prach->new_tti(cc, tti, buffer.get(worker_com->get_rf_port(cc), 0, worker_com->get_nof_ports(0)));
}
// Advance stack in time // Trigger phy worker execution
stack->tti_clock(); worker_com->semaphore.push(lte_worker);
lte_workers->start_worker(lte_worker);
} else { // Trigger prach worker execution
// wait_worker() only returns NULL if it's being closed. Quit now to avoid unnecessary loops here for (uint32_t cc = 0; cc < worker_com->get_nof_carriers_lte(); cc++) {
running = false; prach->new_tti(cc, tti, buffer.get(worker_com->get_rf_port(cc), 0, worker_com->get_nof_ports(0)));
} }
// Advance stack in time
stack->tti_clock();
} }
} }

@ -75,6 +75,7 @@ private:
srslte_dl_slot_cfg_t dl_slot_cfg = {}; srslte_dl_slot_cfg_t dl_slot_cfg = {};
uint32_t cc_idx = 0; uint32_t cc_idx = 0;
std::array<std::vector<cf_t>, SRSLTE_MAX_PORTS> rx_buffer = {}; std::array<std::vector<cf_t>, SRSLTE_MAX_PORTS> rx_buffer = {};
std::array<std::vector<cf_t>, SRSLTE_MAX_PORTS> tx_buffer = {};
phy_nr_state* phy_state; phy_nr_state* phy_state;
srslte_ue_dl_nr_t ue_dl = {}; srslte_ue_dl_nr_t ue_dl = {};

@ -111,6 +111,8 @@ bool cc_worker::work_dl()
pdsch_grant.tb[0].softbuffer.rx = &softbuffer_rx; pdsch_grant.tb[0].softbuffer.rx = &softbuffer_rx;
srslte_softbuffer_rx_reset(pdsch_grant.tb[0].softbuffer.rx); srslte_softbuffer_rx_reset(pdsch_grant.tb[0].softbuffer.rx);
srslte_ue_dl_nr_estimate_fft(&ue_dl);
if (srslte_ue_dl_nr_pdsch_get(&ue_dl, &dl_slot_cfg, &pdsch_cfg, &pdsch_grant, &pdsch_res) < SRSLTE_SUCCESS) { 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"); ERROR("Error decoding PDSCH\n");
return false; return false;

Loading…
Cancel
Save