From f7d313147a4683329127718cbefabdfae2083bcd Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Tue, 15 Dec 2020 11:04:42 +0100 Subject: [PATCH] Added infrastrukture for measurements Init rrc_nr as part of the LTE stack --- lib/include/srslte/interfaces/ue_interfaces.h | 3 +- srsue/hdr/stack/rrc/rrc.h | 2 +- srsue/hdr/stack/rrc/rrc_nr.h | 30 +++++++----- srsue/hdr/stack/ue_stack_base.h | 1 + srsue/src/stack/rrc/rrc_meas.cc | 8 +++- srsue/src/stack/rrc/rrc_nr.cc | 48 +++++++++++-------- srsue/src/stack/ue_stack_lte.cc | 3 +- srsue/src/stack/ue_stack_nr.cc | 4 +- srsue/test/upper/rrc_meas_test.cc | 23 +++++++-- srsue/test/upper/ue_rrc_nr_test.cc | 7 +-- 10 files changed, 83 insertions(+), 46 deletions(-) diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index a8fa39515..d7253d98a 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -151,7 +151,7 @@ typedef struct { } phy_meas_nr_t; // RRC interface for RRC NR -class rrc_interface_rrc_nr +class rrc_eutra_interface_rrc_nr { public: virtual void new_cell_meas_nr(const std::vector& meas) = 0; @@ -266,6 +266,7 @@ class rrc_nr_interface_rrc public: virtual void get_eutra_nr_capabilities(srslte::byte_buffer_t* eutra_nr_caps) = 0; virtual void get_nr_capabilities(srslte::byte_buffer_t* nr_cap) = 0; + virtual void phy_set_cells_to_meas(uint32_t carrier_freq_r15) = 0; }; // PDCP interface for RLC diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index 3be8eb19d..3cdd7b3a1 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -63,7 +63,7 @@ class rrc : public rrc_interface_nas, public rrc_interface_mac, public rrc_interface_pdcp, #ifdef HAVE_5GNR - public rrc_interface_rrc_nr, + public rrc_eutra_interface_rrc_nr, #endif public rrc_interface_rlc, public srslte::timer_callback diff --git a/srsue/hdr/stack/rrc/rrc_nr.h b/srsue/hdr/stack/rrc/rrc_nr.h index cb4548492..11102b12b 100644 --- a/srsue/hdr/stack/rrc/rrc_nr.h +++ b/srsue/hdr/stack/rrc/rrc_nr.h @@ -45,17 +45,18 @@ class rrc_nr final : public rrc_interface_phy_nr, public srslte::timer_callback { public: - rrc_nr(); + rrc_nr(srslte::task_sched_handle task_sched_); ~rrc_nr(); - void init(phy_interface_rrc_nr* phy_, - mac_interface_rrc_nr* mac_, - rlc_interface_rrc* rlc_, - pdcp_interface_rrc* pdcp_, - gw_interface_rrc* gw_, - srslte::timer_handler* timers_, - stack_interface_rrc* stack_, - const rrc_nr_args_t& args_); + void init(phy_interface_rrc_nr* phy_, + mac_interface_rrc_nr* mac_, + rlc_interface_rrc* rlc_, + pdcp_interface_rrc* pdcp_, + gw_interface_rrc* gw_, + rrc_eutra_interface_rrc_nr* rrc_eutra_, + srslte::timer_handler* timers_, + stack_interface_rrc* stack_, + const rrc_nr_args_t& args_); void stop(); @@ -93,11 +94,13 @@ public: // RRC (LTE) interface void get_eutra_nr_capabilities(srslte::byte_buffer_t* eutra_nr_caps); void get_nr_capabilities(srslte::byte_buffer_t* eutra_nr_caps); + void phy_set_cells_to_meas(uint32_t carrier_freq_r15); // STACK interface void cell_search_completed(const rrc_interface_phy_lte::cell_search_ret_t& cs_ret, const phy_cell_t& found_cell); private: + srslte::task_sched_handle task_sched; struct cmd_msg_t { enum { PDU, PCCH, PDU_MCH, RLF, PDU_BCCH_DLSCH, STOP } command; srslte::unique_byte_buffer_t pdu; @@ -109,10 +112,11 @@ private: phy_interface_rrc_nr* phy = nullptr; // mac_interface_rrc* mac = nullptr; - rlc_interface_rrc* rlc = nullptr; - pdcp_interface_rrc* pdcp = nullptr; - gw_interface_rrc* gw = nullptr; - stack_interface_rrc* stack = nullptr; + rlc_interface_rrc* rlc = nullptr; + pdcp_interface_rrc* pdcp = nullptr; + gw_interface_rrc* gw = nullptr; + rrc_eutra_interface_rrc_nr* rrc_eutra = nullptr; + stack_interface_rrc* stack = nullptr; srslte::log_ref log_h; diff --git a/srsue/hdr/stack/ue_stack_base.h b/srsue/hdr/stack/ue_stack_base.h index 9447b79d3..3e4a01dc5 100644 --- a/srsue/hdr/stack/ue_stack_base.h +++ b/srsue/hdr/stack/ue_stack_base.h @@ -58,6 +58,7 @@ typedef struct { stack_log_args_t log; usim_args_t usim; rrc_args_t rrc; + rrc_nr_args_t rrc_nr; std::string ue_category_str; nas_args_t nas; gw_args_t gw; diff --git a/srsue/src/stack/rrc/rrc_meas.cc b/srsue/src/stack/rrc/rrc_meas.cc index c99a688d2..b130a0850 100644 --- a/srsue/src/stack/rrc/rrc_meas.cc +++ b/srsue/src/stack/rrc/rrc_meas.cc @@ -84,8 +84,12 @@ void rrc::rrc_meas::update_phy() rrc_ptr->phy->set_cells_to_meas(obj.meas_obj.meas_obj_eutra().carrier_freq, neighbour_pcis); break; } - case meas_obj_to_add_mod_s::meas_obj_c_::types_opts::meas_obj_nr_r15: - // Todo NR +#ifdef HAVE_5GNR + case meas_obj_to_add_mod_s::meas_obj_c_::types_opts::meas_obj_nr_r15: { + rrc_ptr->rrc_nr->phy_set_cells_to_meas(obj.meas_obj.meas_obj_nr_r15().carrier_freq_r15); + break; + } +#endif default: log_h->error("Not supported\n"); break; diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index 9cad8a83f..74c85223b 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -18,30 +18,32 @@ namespace srsue { const char* rrc_nr::rrc_nr_state_text[] = {"IDLE", "CONNECTED", "CONNECTED-INACTIVE"}; -rrc_nr::rrc_nr() : log_h("RRC") {} +rrc_nr::rrc_nr(srslte::task_sched_handle task_sched_) : log_h("RRC"), task_sched(task_sched_) {} rrc_nr::~rrc_nr() = default; -void rrc_nr::init(phy_interface_rrc_nr* phy_, - mac_interface_rrc_nr* mac_, - rlc_interface_rrc* rlc_, - pdcp_interface_rrc* pdcp_, - gw_interface_rrc* gw_, - srslte::timer_handler* timers_, - stack_interface_rrc* stack_, - const rrc_nr_args_t& args_) +void rrc_nr::init(phy_interface_rrc_nr* phy_, + mac_interface_rrc_nr* mac_, + rlc_interface_rrc* rlc_, + pdcp_interface_rrc* pdcp_, + gw_interface_rrc* gw_, + rrc_eutra_interface_rrc_nr* rrc_eutra_, + srslte::timer_handler* timers_, + stack_interface_rrc* stack_, + const rrc_nr_args_t& args_) { - phy = phy_; - rlc = rlc_; - pdcp = pdcp_; - gw = gw_; - timers = timers_; - stack = stack_; - args = args_; + phy = phy_; + rlc = rlc_; + pdcp = pdcp_; + gw = gw_; + rrc_eutra = rrc_eutra_; + timers = timers_; + stack = stack_; + args = args_; log_h->info("Creating dummy DRB on LCID=%d\n", args.coreless.drb_lcid); srslte::rlc_config_t rlc_cnfg = srslte::rlc_config_t::default_rlc_um_nr_config(6); - rlc->add_bearer(args.coreless.drb_lcid, rlc_cnfg); + // rlc->add_bearer(args.coreless.drb_lcid, rlc_cnfg); srslte::pdcp_config_t pdcp_cnfg{args.coreless.drb_lcid, srslte::PDCP_RB_IS_DRB, @@ -51,7 +53,7 @@ void rrc_nr::init(phy_interface_rrc_nr* phy_, srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_discard_timer_t ::ms100}; - pdcp->add_bearer(args.coreless.drb_lcid, pdcp_cnfg); + // pdcp->add_bearer(args.coreless.drb_lcid, pdcp_cnfg); running = true; } @@ -64,7 +66,10 @@ void rrc_nr::stop() void rrc_nr::get_metrics(rrc_nr_metrics_t& m) {} // Timeout callback interface -void rrc_nr::timer_expired(uint32_t timeout_id) {} +void rrc_nr::timer_expired(uint32_t timeout_id) +{ + log_h->debug("[NR] Handling Timer Expired\n"); +} void rrc_nr::srslte_rrc_log(const char* str) {} @@ -234,6 +239,11 @@ void rrc_nr::get_nr_capabilities(srslte::byte_buffer_t* nr_caps_pdu) nr_caps_pdu->N_bytes = bref.distance_bytes(); log_h->debug_hex(nr_caps_pdu->msg, nr_caps_pdu->N_bytes, "NR capabilities (%u B)\n", nr_caps_pdu->N_bytes); return; +}; + +void rrc_nr::phy_set_cells_to_meas(uint32_t carrier_freq_r15) +{ + log_h->debug("[NR] Measuring phy cell %d \n", carrier_freq_r15); } // RLC interface diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 66a9bee8b..0df20c75e 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -32,7 +32,7 @@ ue_stack_lte::ue_stack_lte() : mac("MAC", &task_sched), rrc(this, &task_sched), #ifdef HAVE_5GNR - rrc_nr(), + rrc_nr(&task_sched), #endif pdcp(&task_sched, "PDCP"), nas(&task_sched), @@ -122,6 +122,7 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_) pdcp.init(&rlc, &rrc, gw); nas.init(usim.get(), &rrc, gw, args.nas); #ifdef HAVE_5GNR + rrc_nr.init(nullptr, nullptr, nullptr, nullptr, gw, &rrc, task_sched.get_timer_handler(), nullptr, args.rrc_nr); rrc.init(phy, &mac, &rlc, &pdcp, &nas, usim.get(), gw, &rrc_nr, args.rrc); #else rrc.init(phy, &mac, &rlc, &pdcp, &nas, usim.get(), gw, args.rrc); diff --git a/srsue/src/stack/ue_stack_nr.cc b/srsue/src/stack/ue_stack_nr.cc index d7db64599..0d8325ce7 100644 --- a/srsue/src/stack/ue_stack_nr.cc +++ b/srsue/src/stack/ue_stack_nr.cc @@ -28,7 +28,7 @@ ue_stack_nr::ue_stack_nr(srslte::logger* logger_) : mac.reset(new mac_nr(&task_sched)); pdcp.reset(new srslte::pdcp(&task_sched, "PDCP")); rlc.reset(new srslte::rlc("RLC")); - rrc.reset(new rrc_nr()); + rrc.reset(new rrc_nr(&task_sched)); // setup logging for pool, RLC and PDCP pool_log->set_level(srslte::LOG_LEVEL_ERROR); @@ -83,7 +83,7 @@ int ue_stack_nr::init(const stack_args_t& args_) rrc_args.log_hex_limit = args.log.rrc_hex_limit; rrc_args.coreless.drb_lcid = 4; rrc_args.coreless.ip_addr = "192.168.1.3"; - rrc->init(phy, mac.get(), rlc.get(), pdcp.get(), gw, task_sched.get_timer_handler(), this, rrc_args); + rrc->init(phy, mac.get(), rlc.get(), pdcp.get(), gw, nullptr, task_sched.get_timer_handler(), this, rrc_args); running = true; start(STACK_MAIN_THREAD_PRIO); diff --git a/srsue/test/upper/rrc_meas_test.cc b/srsue/test/upper/rrc_meas_test.cc index a43368783..180f1c4e3 100644 --- a/srsue/test/upper/rrc_meas_test.cc +++ b/srsue/test/upper/rrc_meas_test.cc @@ -18,6 +18,7 @@ #include "srslte/upper/pdcp.h" #include "srsue/hdr/stack/rrc/rrc.h" #include "srsue/hdr/stack/rrc/rrc_meas.h" +#include "srsue/hdr/stack/rrc/rrc_nr.h" #include "srsue/hdr/stack/upper/nas.h" #include @@ -161,6 +162,15 @@ public: void reset() override {} }; +class rrc_nr_test final : public srsue::rrc_nr_interface_rrc +{ +public: + ~rrc_nr_test() = default; + void get_eutra_nr_capabilities(srslte::byte_buffer_t* eutra_nr_caps) override{}; + void get_nr_capabilities(srslte::byte_buffer_t* nr_cap) override{}; + void phy_set_cells_to_meas(uint32_t carrier_freq_r15) override{}; +}; + class nas_test : public srsue::nas { public: @@ -229,12 +239,16 @@ public: rrc_test(srslte::log_ref log_, stack_test_dummy* stack_) : rrc(stack_, &stack_->task_sched), stack(stack_), mactest(this, &stack_->task_sched) { - pool = srslte::byte_buffer_pool::get_instance(); - nastest = std::unique_ptr(new nas_test(&stack->task_sched)); - pdcptest = std::unique_ptr(new pdcp_test(log_->get_service_name().c_str(), &stack->task_sched)); + pool = srslte::byte_buffer_pool::get_instance(); + nastest = std::unique_ptr(new nas_test(&stack->task_sched)); + pdcptest = std::unique_ptr(new pdcp_test(log_->get_service_name().c_str(), &stack->task_sched)); + rrcnrtest = std::unique_ptr(new rrc_nr_test()); } #ifdef HAVE_5GNR - void init() { rrc::init(&phytest, &mactest, nullptr, pdcptest.get(), nastest.get(), nullptr, nullptr, nullptr, {}); } + void init() + { + rrc::init(&phytest, &mactest, nullptr, pdcptest.get(), nastest.get(), nullptr, nullptr, rrcnrtest.get(), {}); + } #else void init() { rrc::init(&phytest, &mactest, nullptr, pdcptest.get(), nastest.get(), nullptr, nullptr, {}); } #endif @@ -347,6 +361,7 @@ public: private: std::unique_ptr pdcptest; std::unique_ptr nastest; + std::unique_ptr rrcnrtest; uint32_t tti = 0; srslte::byte_buffer_pool* pool = nullptr; }; diff --git a/srsue/test/upper/ue_rrc_nr_test.cc b/srsue/test/upper/ue_rrc_nr_test.cc index d5f00a135..4c035f766 100644 --- a/srsue/test/upper/ue_rrc_nr_test.cc +++ b/srsue/test/upper/ue_rrc_nr_test.cc @@ -21,9 +21,10 @@ int rrc_nr_cap_request_test() srslte::log_ref rrc_log("RRC"); rrc_log->set_level(srslte::LOG_LEVEL_DEBUG); rrc_log->set_hex_limit(-1); - - rrc_nr rrc_nr; - srslte::byte_buffer_t caps; + srslte::task_scheduler task_sched{512, 0, 100}; + srslte::task_sched_handle task_sched_handle(&task_sched); + rrc_nr rrc_nr(task_sched_handle); + srslte::byte_buffer_t caps; rrc_nr.get_eutra_nr_capabilities(&caps); rrc_nr.get_nr_capabilities(&caps); return SRSLTE_SUCCESS;