From 27e5d98ef9288772342d3a0963b27422755cd5ef Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Tue, 9 Jun 2020 19:58:04 +0100 Subject: [PATCH] added vnf phy nr --- lib/include/srslte/interfaces/ue_interfaces.h | 2 + lib/test/common/CMakeLists.txt | 6 +- srsenb/hdr/phy/phy_interfaces.h | 2 + srsenb/hdr/phy/vnf_phy_nr.h | 71 ++++++++++++++ srsenb/src/phy/CMakeLists.txt | 8 +- srsenb/src/phy/vnf_phy_nr.cc | 98 +++++++++++++++++++ srsue/hdr/phy/ue_nr_phy_base.h | 59 +++++++++++ srsue/hdr/phy/vnf_phy_nr.h | 73 ++++++++++++++ srsue/src/phy/CMakeLists.txt | 7 +- srsue/src/phy/vnf_phy_nr.cc | 96 ++++++++++++++++++ 10 files changed, 417 insertions(+), 5 deletions(-) create mode 100644 srsenb/hdr/phy/vnf_phy_nr.h create mode 100644 srsenb/src/phy/vnf_phy_nr.cc create mode 100644 srsue/hdr/phy/ue_nr_phy_base.h create mode 100644 srsue/hdr/phy/vnf_phy_nr.h create mode 100644 srsue/src/phy/vnf_phy_nr.cc diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index 6f9720584..169d587f9 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -518,6 +518,8 @@ typedef struct { srslte::channel::args_t dl_channel_args; srslte::channel::args_t ul_channel_args; + + srslte::vnf_args_t vnf_args; } phy_args_t; /* RAT agnostic Interface MAC -> PHY */ diff --git a/lib/test/common/CMakeLists.txt b/lib/test/common/CMakeLists.txt index 0c15e7d48..8b73dee43 100644 --- a/lib/test/common/CMakeLists.txt +++ b/lib/test/common/CMakeLists.txt @@ -98,6 +98,8 @@ add_executable(expected_test expected_test.cc) target_link_libraries(expected_test srslte_common) add_test(expected_test expected_test) -add_executable(pnf_dummy pnf_dummy.cc) -target_link_libraries(pnf_dummy ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +if(ENABLE_5GNR) + add_executable(pnf_dummy pnf_dummy.cc) + target_link_libraries(pnf_dummy ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +endif() diff --git a/srsenb/hdr/phy/phy_interfaces.h b/srsenb/hdr/phy/phy_interfaces.h index 43ea3149c..83a230bee 100644 --- a/srsenb/hdr/phy/phy_interfaces.h +++ b/srsenb/hdr/phy/phy_interfaces.h @@ -59,6 +59,8 @@ struct phy_args_t { srslte::channel::args_t dl_channel_args; srslte::channel::args_t ul_channel_args; + + srslte::vnf_args_t vnf_args; }; struct phy_cfg_t { diff --git a/srsenb/hdr/phy/vnf_phy_nr.h b/srsenb/hdr/phy/vnf_phy_nr.h new file mode 100644 index 000000000..efdb30798 --- /dev/null +++ b/srsenb/hdr/phy/vnf_phy_nr.h @@ -0,0 +1,71 @@ +/* + * 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 SRSGNB_NR_VNF_PHY_H +#define SRSGNB_NR_VNF_PHY_H + +#include "srsenb/hdr/phy/enb_phy_base.h" +#include "srsenb/hdr/phy/phy_common.h" +#include "srslte/common/basic_vnf.h" +#include "srslte/common/log.h" +#include "srslte/common/log_filter.h" +#include "srslte/interfaces/enb_metrics_interface.h" +#include "srslte/interfaces/gnb_interfaces.h" +#include "srslte/interfaces/radio_interfaces.h" + +namespace srsenb { + +struct nr_phy_cfg_t { + // TODO: add cell and RRC configs +}; + +class vnf_phy_nr : public srsenb::enb_phy_base, public srsenb::phy_interface_stack_nr +{ +public: + vnf_phy_nr(srslte::logger* logger_); + ~vnf_phy_nr(); + + int init(const srsenb::phy_args_t& args, const nr_phy_cfg_t& cfg, srsenb::stack_interface_phy_nr* stack_); + void stop(); + + std::string get_type() { return "vnf"; }; + + void start_plot(); + + void get_metrics(srsenb::phy_metrics_t metrics[ENB_METRICS_MAX_USERS]); + + // MAC interface + int dl_config_request(const dl_config_request_t& request); + int tx_request(const tx_request_t& request); + +private: + srslte::logger* logger = nullptr; + + std::unique_ptr vnf = nullptr; + + bool initialized = false; + + void parse_config(const nr_phy_cfg_t& cfg); +}; + +} // namespace srsenb + +#endif // SRSGNB_NR_VNF_PHY_H \ No newline at end of file diff --git a/srsenb/src/phy/CMakeLists.txt b/srsenb/src/phy/CMakeLists.txt index 83f96eb18..e4ae84e9c 100644 --- a/srsenb/src/phy/CMakeLists.txt +++ b/srsenb/src/phy/CMakeLists.txt @@ -18,9 +18,13 @@ # and at http://www.gnu.org/licenses/. # -file(GLOB SOURCES "*.cc") +set(SOURCES cc_worker.cc phy.cc phy_common.cc phy_ue_db.cc prach_worker.cc sf_worker.cc txrx.cc) add_library(srsenb_phy STATIC ${SOURCES}) if(ENABLE_GUI AND SRSGUI_FOUND) target_link_libraries(srsenb_phy ${SRSGUI_LIBRARIES}) -endif(ENABLE_GUI AND SRSGUI_FOUND) \ No newline at end of file +endif(ENABLE_GUI AND SRSGUI_FOUND) + +if(ENABLE_5GNR) + add_library(srsgnb_phy STATIC vnf_phy_nr.cc) +endif() \ No newline at end of file diff --git a/srsenb/src/phy/vnf_phy_nr.cc b/srsenb/src/phy/vnf_phy_nr.cc new file mode 100644 index 000000000..880b4c1ab --- /dev/null +++ b/srsenb/src/phy/vnf_phy_nr.cc @@ -0,0 +1,98 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include "srsenb/hdr/phy/vnf_phy_nr.h" +#include "srslte/common/basic_vnf_api.h" +#include "srslte/common/log.h" +#include "srslte/common/threads.h" + +#define Error(fmt, ...) \ + if (SRSLTE_DEBUG_ENABLED) \ + log_h->error(fmt, ##__VA_ARGS__) +#define Warning(fmt, ...) \ + if (SRSLTE_DEBUG_ENABLED) \ + log_h->warning(fmt, ##__VA_ARGS__) +#define Info(fmt, ...) \ + if (SRSLTE_DEBUG_ENABLED) \ + log_h->info(fmt, ##__VA_ARGS__) +#define Debug(fmt, ...) \ + if (SRSLTE_DEBUG_ENABLED) \ + log_h->debug(fmt, ##__VA_ARGS__) + +using namespace std; + +namespace srsenb { + +vnf_phy_nr::vnf_phy_nr(srslte::logger* logger_) : logger(logger_) {} + +vnf_phy_nr::~vnf_phy_nr() +{ + stop(); +} + +void vnf_phy_nr::parse_config(const nr_phy_cfg_t& cfg) {} + +int vnf_phy_nr::init(const srsenb::phy_args_t& args, const nr_phy_cfg_t& cfg, srsenb::stack_interface_phy_nr* stack_) +{ + mlockall(MCL_CURRENT | MCL_FUTURE); + + // create VNF + vnf = std::unique_ptr(new srslte::srslte_basic_vnf(args.vnf_args, logger, stack_)); + + initialized = true; + + return SRSLTE_SUCCESS; +} + +void vnf_phy_nr::stop() +{ + if (initialized) { + vnf->stop(); + initialized = false; + } +} + +// Start GUI +void vnf_phy_nr::start_plot() {} + +void vnf_phy_nr::get_metrics(srsenb::phy_metrics_t metrics[ENB_METRICS_MAX_USERS]) {} + +int vnf_phy_nr::dl_config_request(const dl_config_request_t& request) +{ + // prepare DL config request over basic API and send + return vnf->dl_config_request(request); +} + +int vnf_phy_nr::tx_request(const tx_request_t& request) +{ + // send Tx request over basic API + return vnf->tx_request(request); +} + +} // namespace srsenb \ No newline at end of file diff --git a/srsue/hdr/phy/ue_nr_phy_base.h b/srsue/hdr/phy/ue_nr_phy_base.h new file mode 100644 index 000000000..081c77296 --- /dev/null +++ b/srsue/hdr/phy/ue_nr_phy_base.h @@ -0,0 +1,59 @@ +/* + * 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/. + * + */ + +/****************************************************************************** + * File: ue_nr_phy_base.h + * Description: Base class for UE NR PHYs. + *****************************************************************************/ + +#ifndef SRSUE_UE_NR_PHY_BASE_H +#define SRSUE_UE_NR_PHY_BASE_H + +#include "srslte/common/log_filter.h" +#include "srslte/interfaces/radio_interfaces.h" +#include "srslte/interfaces/ue_nr_interfaces.h" +#include "srsue/hdr/phy/ue_phy_base.h" + +namespace srsue { + +class ue_nr_phy_base : public ue_phy_base, public phy_interface_stack_nr, public srslte::phy_interface_radio +{ +public: + ue_nr_phy_base(){}; + virtual ~ue_nr_phy_base() {} + + virtual std::string get_type() = 0; + + virtual int init(const phy_args_t& args_) = 0; + virtual int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) = 0; + virtual void stop() = 0; + + virtual void set_earfcn(std::vector earfcns) = 0; + + virtual void wait_initialize() = 0; + virtual void start_plot() = 0; + + virtual void get_metrics(phy_metrics_t* m) = 0; +}; + +} // namespace srsue + +#endif // SRSUE_UE_NR_PHY_BASE_H \ No newline at end of file diff --git a/srsue/hdr/phy/vnf_phy_nr.h b/srsue/hdr/phy/vnf_phy_nr.h new file mode 100644 index 000000000..24cd99d55 --- /dev/null +++ b/srsue/hdr/phy/vnf_phy_nr.h @@ -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/. + * + */ + +#ifndef SRSUE_VNF_PHY_NR_H +#define SRSUE_VNF_PHY_NR_H + +#include "srsenb/hdr/phy/phy_common.h" +#include "srslte/common/basic_vnf.h" +#include "srslte/common/log.h" +#include "srslte/common/log_filter.h" +#include "srslte/interfaces/enb_metrics_interface.h" +#include "srslte/interfaces/radio_interfaces.h" +#include "srslte/interfaces/ue_interfaces.h" +#include "srslte/interfaces/ue_nr_interfaces.h" +#include "srsue/hdr/phy/ue_nr_phy_base.h" + +namespace srsue { + +class vnf_phy_nr : public srsue::ue_phy_base, public srsue::phy_interface_stack_nr +{ +public: + vnf_phy_nr(srslte::logger* logger_); + ~vnf_phy_nr(); + + int init(const srsue::phy_args_t& args, srsue::stack_interface_phy_nr* stack_); + + int init(const srsue::phy_args_t& args_); + + void set_earfcn(std::vector earfcns); + + void stop(); + + void wait_initialize(); + void get_metrics(phy_metrics_t* m); + + std::string get_type() { return "vnf_nr"; }; + + void start_plot(); + + // MAC interface + int tx_request(const tx_request_t& request); + +private: + srslte::logger* logger = nullptr; + + std::unique_ptr vnf; + + srsue::stack_interface_phy_nr* stack = nullptr; + + bool initialized = false; +}; + +} // namespace srsue + +#endif // SRSUE_VNF_PHY_NR_H \ No newline at end of file diff --git a/srsue/src/phy/CMakeLists.txt b/srsue/src/phy/CMakeLists.txt index 1c7dfa03d..b42e6aa1b 100644 --- a/srsue/src/phy/CMakeLists.txt +++ b/srsue/src/phy/CMakeLists.txt @@ -23,4 +23,9 @@ add_library(srsue_phy STATIC ${SOURCES}) if(ENABLE_GUI AND SRSGUI_FOUND) target_link_libraries(srsue_phy ${SRSGUI_LIBRARIES}) -endif(ENABLE_GUI AND SRSGUI_FOUND) \ No newline at end of file +endif(ENABLE_GUI AND SRSGUI_FOUND) + +if(ENABLE_5GNR) +set(SOURCES_NR "../phy/vnf_phy_nr.cc") +add_library(srsue_phy_nr STATIC ${SOURCES_NR}) +endif() \ No newline at end of file diff --git a/srsue/src/phy/vnf_phy_nr.cc b/srsue/src/phy/vnf_phy_nr.cc new file mode 100644 index 000000000..251ee84cf --- /dev/null +++ b/srsue/src/phy/vnf_phy_nr.cc @@ -0,0 +1,96 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include "srslte/common/basic_vnf_api.h" +#include "srslte/common/log.h" +#include "srslte/common/threads.h" +#include "srsue/hdr/phy/vnf_phy_nr.h" + +#define Error(fmt, ...) \ + if (SRSLTE_DEBUG_ENABLED) \ + log_h->error(fmt, ##__VA_ARGS__) +#define Warning(fmt, ...) \ + if (SRSLTE_DEBUG_ENABLED) \ + log_h->warning(fmt, ##__VA_ARGS__) +#define Info(fmt, ...) \ + if (SRSLTE_DEBUG_ENABLED) \ + log_h->info(fmt, ##__VA_ARGS__) +#define Debug(fmt, ...) \ + if (SRSLTE_DEBUG_ENABLED) \ + log_h->debug(fmt, ##__VA_ARGS__) + +using namespace std; + +namespace srsue { + +vnf_phy_nr::vnf_phy_nr(srslte::logger* logger_) : logger(logger_) {} + +vnf_phy_nr::~vnf_phy_nr() +{ + stop(); +} + +int vnf_phy_nr::init(const srsue::phy_args_t& args_, srsue::stack_interface_phy_nr* stack_) +{ + stack = stack_; + return init(args_); +} + +int vnf_phy_nr::init(const srsue::phy_args_t& args_) +{ + // create VNF + vnf = std::unique_ptr(new srslte::srslte_basic_vnf(args_.vnf_args, logger, stack)); + initialized = true; + return SRSLTE_SUCCESS; +} + +void vnf_phy_nr::set_earfcn(std::vector earfcns) {} + +void vnf_phy_nr::stop() +{ + if (initialized) { + vnf->stop(); + initialized = false; + } +} + +// Start GUI +void vnf_phy_nr::start_plot() {} + +void vnf_phy_nr::wait_initialize() {} + +void vnf_phy_nr::get_metrics(phy_metrics_t* m) {} + +int vnf_phy_nr::tx_request(const tx_request_t& request) +{ + // send Tx request over basic API + return vnf->tx_request(request); +} + +} // namespace srsue \ No newline at end of file