diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index 82cec98e4..7fc1bb3d4 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -37,7 +37,7 @@ namespace srsenb { /* Interface PHY -> MAC */ -class mac_interface_phy +class mac_interface_phy_lte { public: const static int MAX_GRANTS = 64; @@ -98,7 +98,7 @@ public: }; /* Interface MAC -> PHY */ -class phy_interface_mac +class phy_interface_mac_lte { public: @@ -109,7 +109,7 @@ public: }; /* Interface RRC -> PHY */ -class phy_interface_rrc +class phy_interface_rrc_lte { public: struct phy_cfg_mbsfn_t { @@ -305,6 +305,32 @@ public: virtual bool is_mme_connected() = 0; }; +// Combined interface for PHY to access stack (MAC and RRC) +class stack_interface_phy_lte : public mac_interface_phy_lte +{ +}; + +// Combined interface for stack (MAC and RRC) to access PHY +class phy_interface_stack_lte : public phy_interface_mac_lte, public phy_interface_rrc_lte +{ +}; + +typedef struct { + uint32_t enb_id; // 20-bit id (lsb bits) + uint8_t cell_id; // 8-bit cell id + uint16_t tac; // 16-bit tac + uint16_t mcc; // BCD-coded with 0xF filler + uint16_t mnc; // BCD-coded with 0xF filler + std::string mme_addr; + std::string gtp_bind_addr; + std::string s1c_bind_addr; + std::string enb_name; +} s1ap_args_t; + +typedef struct { + sched_interface::sched_args_t sched; + int link_failure_nof_err; +} mac_args_t; } #endif // SRSLTE_ENB_INTERFACES_H diff --git a/lib/include/srslte/interfaces/enb_metrics_interface.h b/lib/include/srslte/interfaces/enb_metrics_interface.h index 651a43808..651b2d444 100644 --- a/lib/include/srslte/interfaces/enb_metrics_interface.h +++ b/lib/include/srslte/interfaces/enb_metrics_interface.h @@ -24,11 +24,11 @@ #include -#include "srsenb/hdr/mac/mac_metrics.h" #include "srsenb/hdr/phy/phy_metrics.h" -#include "srsenb/hdr/upper/common_enb.h" -#include "srsenb/hdr/upper/rrc_metrics.h" -#include "srsenb/hdr/upper/s1ap_metrics.h" +#include "srsenb/hdr/stack/mac/mac_metrics.h" +#include "srsenb/hdr/stack/rrc/rrc_metrics.h" +#include "srsenb/hdr/stack/upper/common_enb.h" +#include "srsenb/hdr/stack/upper/s1ap_metrics.h" #include "srslte/common/metrics_hub.h" #include "srslte/upper/rlc_metrics.h" #include "srsue/hdr/stack/upper/gw_metrics.h" @@ -42,12 +42,16 @@ typedef struct { bool rf_error; }rf_metrics_t; +struct stack_metrics_t { + mac_metrics_t mac[ENB_METRICS_MAX_USERS]; + rrc_metrics_t rrc; + s1ap_metrics_t s1ap; +}; + typedef struct { rf_metrics_t rf; phy_metrics_t phy[ENB_METRICS_MAX_USERS]; - mac_metrics_t mac[ENB_METRICS_MAX_USERS]; - rrc_metrics_t rrc; - s1ap_metrics_t s1ap; + stack_metrics_t stack; bool running; }enb_metrics_t; diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index b9a1a48f7..40bbf7e17 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -47,11 +47,6 @@ typedef enum { AUTH_SYNCH_FAILURE } auth_result_t; -// UE interface -class ue_interface -{ -}; - // USIM interface for NAS class usim_interface_nas { diff --git a/lib/include/srslte/upper/rlc.h b/lib/include/srslte/upper/rlc.h index 20f100cd0..cc86ba37f 100644 --- a/lib/include/srslte/upper/rlc.h +++ b/lib/include/srslte/upper/rlc.h @@ -47,8 +47,7 @@ public: virtual ~rlc(); void init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srsue::ue_interface* ue_, - srslte::log* log_, + log* rlc_log_, mac_interface_timers* mac_timers_, uint32_t lcid_); void stop(); @@ -95,7 +94,6 @@ private: srsue::pdcp_interface_rlc *pdcp; srsue::rrc_interface_rlc *rrc; srslte::mac_interface_timers *mac_timers; - srsue::ue_interface *ue; typedef std::map rlc_map_t; typedef std::pair rlc_map_pair_t; diff --git a/lib/src/common/logger_file.cc b/lib/src/common/logger_file.cc index ec248231b..b0f082062 100644 --- a/lib/src/common/logger_file.cc +++ b/lib/src/common/logger_file.cc @@ -80,7 +80,10 @@ void logger_file::run_thread() { pthread_mutex_lock(&mutex); while(buffer.empty()) { pthread_cond_wait(¬_empty, &mutex); - if(!is_running) return; // Thread done. Messages in buffer will be handled in flush. + if (!is_running) { + pthread_mutex_unlock(&mutex); + return; // Thread done. Messages in buffer will be handled in flush. + } } str_ptr s = buffer.front(); int n = 0; diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index ca363a0e7..81dddc0b5 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -35,7 +35,6 @@ rlc::rlc() pdcp = NULL; rrc = NULL; mac_timers = NULL; - ue = NULL; bzero(metrics_time, sizeof(metrics_time)); pthread_rwlock_init(&rwlock, NULL); } @@ -60,14 +59,12 @@ rlc::~rlc() void rlc::init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srsue::ue_interface* ue_, log* rlc_log_, mac_interface_timers* mac_timers_, uint32_t lcid_) { pdcp = pdcp_; rrc = rrc_; - ue = ue_; rlc_log = rlc_log_; mac_timers = mac_timers_; default_lcid = lcid_; diff --git a/lib/test/upper/rlc_stress_test.cc b/lib/test/upper/rlc_stress_test.cc index 08c9f22c9..990a6da8c 100644 --- a/lib/test/upper/rlc_stress_test.cc +++ b/lib/test/upper/rlc_stress_test.cc @@ -343,10 +343,9 @@ void stress_test(stress_test_args_t args) rlc_tester tester1(&rlc1, "tester1", args, lcid); rlc_tester tester2(&rlc2, "tester2", args, lcid); mac_dummy mac(&rlc1, &rlc2, args, lcid, &stack, &pcap); - ue_interface ue; - rlc1.init(&tester1, &tester1, &ue, &log1, &stack, 0); - rlc2.init(&tester2, &tester2, &ue, &log2, &stack, 0); + rlc1.init(&tester1, &tester1, &log1, &stack, 0); + rlc2.init(&tester2, &tester2, &log2, &stack, 0); // only add AM and UM bearers if (args.mode != "TM") { diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index e8dbab5a5..374bb70fe 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -33,24 +33,20 @@ #include #include "phy/phy.h" -#include "mac/mac.h" -#include "upper/rrc.h" -#include "upper/gtpu.h" -#include "upper/s1ap.h" -#include "upper/rlc.h" -#include "upper/pdcp.h" +#include "srsenb/hdr/stack/rrc/rrc.h" #include "srslte/radio/radio.h" -#include "srslte/common/security.h" +#include "srsenb/hdr/stack/enb_stack_base.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/buffer_pool.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/common/logger_file.h" #include "srslte/common/log_filter.h" +#include "srslte/common/logger_file.h" #include "srslte/common/mac_pcap.h" -#include "srslte/interfaces/sched_interface.h" +#include "srslte/common/security.h" #include "srslte/interfaces/enb_metrics_interface.h" +#include "srslte/interfaces/sched_interface.h" +#include "srslte/interfaces/ue_interfaces.h" namespace srsenb { @@ -58,32 +54,32 @@ namespace srsenb { eNodeB Parameters *******************************************************************************/ -typedef struct { - s1ap_args_t s1ap; - uint32_t n_prb; - uint32_t pci; +struct enb_args_t { + s1ap_args_t s1ap; + uint32_t n_prb; + uint32_t pci; uint32_t nof_ports; uint32_t transmission_mode; float p_a; -}enb_args_t; +}; -typedef struct { +struct enb_files_t { std::string sib_config; - std::string rr_config; - std::string drb_config; -} enb_files_t; + std::string rr_config; + std::string drb_config; +}; typedef struct { uint32_t dl_earfcn; - uint32_t ul_earfcn; - float dl_freq; - float ul_freq; + uint32_t ul_earfcn; + float dl_freq; + float ul_freq; float rx_gain; float tx_gain; - std::string device_name; - std::string device_args; - std::string time_adv_nsamples; - std::string burst_preamble; + std::string device_name; + std::string device_args; + std::string time_adv_nsamples; + std::string burst_preamble; }rf_args_t; typedef struct { @@ -92,32 +88,32 @@ typedef struct { }pcap_args_t; typedef struct { - std::string phy_level; - std::string phy_lib_level; - std::string mac_level; - std::string rlc_level; - std::string pdcp_level; - std::string rrc_level; - std::string gtpu_level; - std::string s1ap_level; - std::string all_level; - int phy_hex_limit; - int mac_hex_limit; - int rlc_hex_limit; - int pdcp_hex_limit; - int rrc_hex_limit; - int gtpu_hex_limit; - int s1ap_hex_limit; - int all_hex_limit; - int file_max_size; - std::string filename; + std::string phy_level; + std::string phy_lib_level; + std::string mac_level; + std::string rlc_level; + std::string pdcp_level; + std::string rrc_level; + std::string gtpu_level; + std::string s1ap_level; + std::string all_level; + int phy_hex_limit; + int mac_hex_limit; + int rlc_hex_limit; + int pdcp_hex_limit; + int rrc_hex_limit; + int gtpu_hex_limit; + int s1ap_hex_limit; + int all_hex_limit; + int file_max_size; + std::string filename; }log_args_t; -typedef struct { - bool enable; -}gui_args_t; +struct gui_args_t { + bool enable; +}; -typedef struct { +struct expert_args_t { phy_args_t phy; mac_args_t mac; uint32_t rrc_inactivity_timer; @@ -130,24 +126,24 @@ typedef struct { std::string m1u_if_addr; std::string eia_pref_list; std::string eea_pref_list; -}expert_args_t; +}; -typedef struct { +struct all_args_t { enb_args_t enb; - enb_files_t enb_files; + enb_files_t enb_files; rf_args_t rf; pcap_args_t pcap; log_args_t log; gui_args_t gui; expert_args_t expert; -}all_args_t; +}; /******************************************************************************* Main eNB class *******************************************************************************/ -class enb - :public enb_metrics_interface { +class enb : public enb_metrics_interface +{ public: static enb *get_instance(void); @@ -178,15 +174,9 @@ private: virtual ~enb(); + std::unique_ptr stack; srslte::radio radio; srsenb::phy phy; - srsenb::mac mac; - srslte::mac_pcap mac_pcap; - srsenb::rlc rlc; - srsenb::pdcp pdcp; - srsenb::rrc rrc; - srsenb::gtpu gtpu; - srsenb::s1ap s1ap; srslte::logger_stdout logger_stdout; srslte::logger_file logger_file; @@ -194,12 +184,6 @@ private: srslte::log_filter rf_log; std::vector phy_log; - srslte::log_filter mac_log; - srslte::log_filter rlc_log; - srslte::log_filter pdcp_log; - srslte::log_filter rrc_log; - srslte::log_filter gtpu_log; - srslte::log_filter s1ap_log; srslte::log_filter pool_log; srslte::byte_buffer_pool *pool; @@ -218,8 +202,8 @@ private: int parse_sib9(std::string filename, asn1::rrc::sib_type9_s* data); int parse_sib13(std::string filename, asn1::rrc::sib_type13_r9_s* data); int parse_sibs(all_args_t* args, rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_config_common); - int parse_rr(all_args_t *args, rrc_cfg_t *rrc_cfg); - int parse_drb(all_args_t *args, rrc_cfg_t *rrc_cfg); + int parse_rr(all_args_t* args, rrc_cfg_t* rrc_cfg); + int parse_drb(all_args_t* args, rrc_cfg_t* rrc_cfg); bool sib_is_present(const asn1::rrc::sched_info_list_l& l, asn1::rrc::sib_type_e sib_num); int parse_cell_cfg(all_args_t* args, srslte_cell_t* cell); diff --git a/srsenb/hdr/phy/phy.h b/srsenb/hdr/phy/phy.h index 70b93dbe0..2e472332c 100644 --- a/srsenb/hdr/phy/phy.h +++ b/srsenb/hdr/phy/phy.h @@ -43,14 +43,21 @@ typedef struct { asn1::rrc::srs_ul_cfg_common_c srs_ul_cnfg; } phy_cfg_t; -class phy : public phy_interface_mac, - public phy_interface_rrc +class phy : public phy_interface_stack_lte { public: phy(); - bool init(phy_args_t *args, phy_cfg_t *common_cfg, srslte::radio *radio_handler, mac_interface_phy *mac, srslte::log_filter* log_h); - bool init(phy_args_t *args, phy_cfg_t *common_cfg, srslte::radio *radio_handler, mac_interface_phy *mac, std::vector log_vec); + bool init(phy_args_t* args, + phy_cfg_t* common_cfg, + srslte::radio* radio_handler, + stack_interface_phy_lte* stack, + srslte::log_filter* log_h); + bool init(phy_args_t* args, + phy_cfg_t* common_cfg, + srslte::radio* radio_handler, + stack_interface_phy_lte* stack, + std::vector log_vec); void stop(); /* MAC->PHY interface */ diff --git a/srsenb/hdr/phy/phy_common.h b/srsenb/hdr/phy/phy_common.h index af3c0fcec..9506d7090 100644 --- a/srsenb/hdr/phy/phy_common.h +++ b/srsenb/hdr/phy/phy_common.h @@ -54,7 +54,7 @@ public: void set_nof_workers(uint32_t nof_workers); - bool init(srslte_cell_t *cell, srslte::radio *radio_handler, mac_interface_phy *mac); + bool init(srslte_cell_t* cell, srslte::radio* radio_handler, stack_interface_phy_lte* mac); void reset(); void stop(); @@ -71,12 +71,12 @@ public: srslte_dl_cfg_t dl_cfg_com; srslte::radio *radio; - mac_interface_phy *mac; - - // Common objects for schedulign grants - mac_interface_phy::ul_sched_t ul_grants[TTIMOD_SZ]; - mac_interface_phy::dl_sched_t dl_grants[TTIMOD_SZ]; - + stack_interface_phy_lte* stack; + + // Common objects for schedulign grants + stack_interface_phy_lte::ul_sched_t ul_grants[TTIMOD_SZ]; + stack_interface_phy_lte::dl_sched_t dl_grants[TTIMOD_SZ]; + // Map of pending ACKs for each user typedef struct { bool is_pending[TTIMOD_SZ][SRSLTE_MAX_TB]; @@ -103,7 +103,7 @@ public: void ue_db_set_last_ul_tb(uint16_t rnti, uint32_t pid, srslte_ra_tb_t tb); srslte_ra_tb_t ue_db_get_last_ul_tb(uint16_t rnti, uint32_t pid); - void configure_mbsfn(phy_interface_rrc::phy_cfg_mbsfn_t *cfg); + void configure_mbsfn(phy_interface_stack_lte::phy_cfg_mbsfn_t* cfg); void build_mch_table(); void build_mcch_table(); bool is_mbsfn_sf(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti); @@ -122,7 +122,7 @@ private: bool have_mtch_stop; pthread_mutex_t mtch_mutex; pthread_cond_t mtch_cvar; - phy_interface_rrc::phy_cfg_mbsfn_t mbsfn; + phy_interface_stack_lte::phy_cfg_mbsfn_t mbsfn; bool sib13_configured; bool mcch_configured; uint8_t mch_table[40]; diff --git a/srsenb/hdr/phy/prach_worker.h b/srsenb/hdr/phy/prach_worker.h index 8388a98c1..a0bee4382 100644 --- a/srsenb/hdr/phy/prach_worker.h +++ b/srsenb/hdr/phy/prach_worker.h @@ -44,7 +44,7 @@ public: thread("PRACH_WORKER") { log_h = NULL; - mac = NULL; + stack = NULL; bzero(&prach, sizeof(srslte_prach_t)); bzero(&prach_indices, sizeof(prach_indices)); bzero(&prach_offsets, sizeof(prach_offsets)); @@ -52,8 +52,12 @@ public: bzero(&cell, sizeof(cell)); bzero(&prach_cfg, sizeof(prach_cfg)); } - - int init(srslte_cell_t *cell, srslte_prach_cfg_t *prach_cfg, mac_interface_phy *mac, srslte::log *log_h, int priority); + + int init(srslte_cell_t* cell, + srslte_prach_cfg_t* prach_cfg, + stack_interface_phy_lte* mac, + srslte::log* log_h, + int priority); int new_tti(uint32_t tti, cf_t *buffer); void set_max_prach_offset_us(float delay_us); void stop(); @@ -93,7 +97,7 @@ private: sf_buffer* current_buffer; srslte::log* log_h; - mac_interface_phy *mac; + stack_interface_phy_lte* stack; float max_prach_offset_us; bool initiated; bool running; diff --git a/srsenb/hdr/phy/sf_worker.h b/srsenb/hdr/phy/sf_worker.h index f1dda2720..2d7276457 100644 --- a/srsenb/hdr/phy/sf_worker.h +++ b/srsenb/hdr/phy/sf_worker.h @@ -63,12 +63,12 @@ private: void work_imp(); - int encode_pdsch(mac_interface_phy::dl_sched_grant_t* grants, uint32_t nof_grants); - int encode_pmch(mac_interface_phy::dl_sched_grant_t* grant, srslte_mbsfn_cfg_t* mbsfn_cfg); - int decode_pusch(mac_interface_phy::ul_sched_grant_t* grants, uint32_t nof_pusch); - int encode_phich(mac_interface_phy::ul_sched_ack_t* acks, uint32_t nof_acks); - int encode_pdcch_dl(mac_interface_phy::dl_sched_grant_t* grants, uint32_t nof_grants); - int encode_pdcch_ul(mac_interface_phy::ul_sched_grant_t* grants, uint32_t nof_grants); + int encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, uint32_t nof_grants); + int encode_pmch(stack_interface_phy_lte::dl_sched_grant_t* grant, srslte_mbsfn_cfg_t* mbsfn_cfg); + int decode_pusch(stack_interface_phy_lte::ul_sched_grant_t* grants, uint32_t nof_pusch); + int encode_phich(stack_interface_phy_lte::ul_sched_ack_t* acks, uint32_t nof_acks); + int encode_pdcch_dl(stack_interface_phy_lte::dl_sched_grant_t* grants, uint32_t nof_grants); + int encode_pdcch_ul(stack_interface_phy_lte::ul_sched_grant_t* grants, uint32_t nof_grants); int decode_pucch(); void send_uci_data(uint16_t rnti, srslte_uci_cfg_t* uci_cfg, srslte_uci_value_t* uci_value); diff --git a/srsenb/hdr/stack/enb_stack_base.h b/srsenb/hdr/stack/enb_stack_base.h new file mode 100644 index 000000000..6b0a8cc02 --- /dev/null +++ b/srsenb/hdr/stack/enb_stack_base.h @@ -0,0 +1,46 @@ +/* + * Copyright 2013-2019 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_ENB_STACK_BASE_H +#define SRSLTE_ENB_STACK_BASE_H + +#include + +namespace srsenb { + +struct stack_metrics_t; + +class enb_stack_base +{ +public: + virtual ~enb_stack_base() = default; + + virtual std::string get_type() = 0; + + virtual void stop() = 0; + + // eNB metrics interface + virtual bool get_metrics(stack_metrics_t* metrics) = 0; +}; + +} // namespace srsenb + +#endif // SRSLTE_ENB_STACK_BASE_H diff --git a/srsenb/hdr/stack/enb_stack_lte.h b/srsenb/hdr/stack/enb_stack_lte.h new file mode 100644 index 000000000..602c2a93b --- /dev/null +++ b/srsenb/hdr/stack/enb_stack_lte.h @@ -0,0 +1,130 @@ +/* + * Copyright 2013-2019 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: enb_stack_lte.h + * Description: L2/L3 LTE eNB stack class. + *****************************************************************************/ + +#ifndef SRSLTE_ENB_STACK_LTE_H +#define SRSLTE_ENB_STACK_LTE_H + +#include "mac/mac.h" +#include "rrc/rrc.h" +#include "upper/gtpu.h" +#include "upper/pdcp.h" +#include "upper/rlc.h" +#include "upper/s1ap.h" + +#include "srslte/common/log_filter.h" + +#include "enb_stack_base.h" +#include "srsenb/hdr/enb.h" +#include "srslte/interfaces/enb_interfaces.h" + +namespace srsenb { + +class enb_stack_lte final : public enb_stack_base, public stack_interface_phy_lte +{ +public: + struct args_t { + struct stack_expert_args_t { + mac_args_t mac; + bool enable_mbsfn; + std::string m1u_multiaddr; + std::string m1u_if_addr; + }; + + enb_args_t enb; + pcap_args_t pcap; + log_args_t log; + stack_expert_args_t expert; + }; + + enb_stack_lte(); + ~enb_stack_lte() final; + + // eNB stack base interface + int init(const args_t& args_, const rrc_cfg_t& rrc_cfg_, srslte::logger* logger_, phy_interface_stack_lte* phy_); + int init(const args_t& args_, const rrc_cfg_t& rrc_cfg_, srslte::logger* logger_); + void stop() final; + std::string get_type() final; + bool get_metrics(stack_metrics_t* metrics) final; + + /* PHY-MAC interface */ + int sr_detected(uint32_t tti, uint16_t rnti) final { return mac.sr_detected(tti, rnti); } + int rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv) final + { + return mac.rach_detected(tti, preamble_idx, time_adv); + } + int ri_info(uint32_t tti, uint16_t rnti, uint32_t ri_value) final { return mac.ri_info(tti, rnti, ri_value); } + int pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value) final { return mac.pmi_info(tti, rnti, pmi_value); } + int cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi_value) final { return mac.cqi_info(tti, rnti, cqi_value); } + int snr_info(uint32_t tti, uint16_t rnti, float snr_db) final { return mac.snr_info(tti, rnti, snr_db); } + int ack_info(uint32_t tti, uint16_t rnti, uint32_t tb_idx, bool ack) final + { + return mac.ack_info(tti, rnti, tb_idx, ack); + } + int crc_info(uint32_t tti, uint16_t rnti, uint32_t nof_bytes, bool crc_res) final + { + return mac.crc_info(tti, rnti, nof_bytes, crc_res); + } + int get_dl_sched(uint32_t tti, dl_sched_t* dl_sched_res) final { return mac.get_dl_sched(tti, dl_sched_res); } + int get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_t* dl_sched_res) final + { + return mac.get_mch_sched(tti, is_mcch, dl_sched_res); + } + int get_ul_sched(uint32_t tti, ul_sched_t* ul_sched_res) final { return mac.get_ul_sched(tti, ul_sched_res); } + // Radio-Link status + void rl_failure(uint16_t rnti) final { mac.rl_failure(rnti); } + void rl_ok(uint16_t rnti) final { mac.rl_ok(rnti); } + void tti_clock() final { mac.tti_clock(); } + +private: + args_t args; + rrc_cfg_t rrc_cfg; + bool started; + + srsenb::mac mac; + srslte::mac_pcap mac_pcap; + srsenb::rlc rlc; + srsenb::pdcp pdcp; + srsenb::rrc rrc; + srsenb::gtpu gtpu; + srsenb::s1ap s1ap; + + srslte::logger* logger; + + // Radio and PHY log are in enb.cc + srslte::log_filter mac_log; + srslte::log_filter rlc_log; + srslte::log_filter pdcp_log; + srslte::log_filter rrc_log; + srslte::log_filter s1ap_log; + srslte::log_filter gtpu_log; + + // RAT-specific interfaces + phy_interface_stack_lte* phy; +}; + +} // namespace srsenb + +#endif // SRSLTE_ENB_STACK_LTE_H diff --git a/srsenb/hdr/mac/mac.h b/srsenb/hdr/stack/mac/mac.h similarity index 89% rename from srsenb/hdr/mac/mac.h rename to srsenb/hdr/stack/mac/mac.h index a00453e0a..45f2da24a 100644 --- a/srsenb/hdr/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -44,29 +44,28 @@ public: virtual bool process_pdus() = 0; }; -typedef struct { - sched_interface::sched_args_t sched; - int link_failure_nof_err; -} mac_args_t; - -class mac - :public mac_interface_phy, - public mac_interface_rlc, - public mac_interface_rrc, - public srslte::mac_interface_timers, - public pdu_process_handler +class mac : public mac_interface_phy_lte, + public mac_interface_rlc, + public mac_interface_rrc, + public srslte::mac_interface_timers, + public pdu_process_handler { public: mac(); ~mac(); - bool init(mac_args_t *args, srslte_cell_t *cell, phy_interface_mac *phy, rlc_interface_mac *rlc, rrc_interface_mac *rrc, srslte::log *log_h); + bool init(const mac_args_t& args_, + srslte_cell_t* cell, + phy_interface_stack_lte* phy, + rlc_interface_mac* rlc, + rrc_interface_mac* rrc, + srslte::log* log_h); void stop(); void start_pcap(srslte::mac_pcap* pcap_); - /******** Interface from PHY (PHY -> MAC) ****************/ - int sr_detected(uint32_t tti, uint16_t rnti); - int rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv); + /******** Interface from PHY (PHY -> MAC) ****************/ + int sr_detected(uint32_t tti, uint16_t rnti) final; + int rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv) final; int set_dl_ant_info(uint16_t rnti, asn1::rrc::phys_cfg_ded_s::ant_info_c_* dl_ant_info); @@ -124,12 +123,12 @@ private: // We use a rwlock in MAC to allow multiple workers to access MAC simultaneously. No conflicts will happen since access for different TTIs pthread_rwlock_t rwlock; - // Interaction with PHY - phy_interface_mac *phy_h; - rlc_interface_mac *rlc_h; - rrc_interface_mac *rrc_h; - srslte::log *log_h; - + // Interaction with PHY + phy_interface_stack_lte* phy_h; + rlc_interface_mac* rlc_h; + rrc_interface_mac* rrc_h; + srslte::log* log_h; + srslte_cell_t cell; mac_args_t args; diff --git a/srsenb/hdr/mac/mac_metrics.h b/srsenb/hdr/stack/mac/mac_metrics.h similarity index 100% rename from srsenb/hdr/mac/mac_metrics.h rename to srsenb/hdr/stack/mac/mac_metrics.h diff --git a/srsenb/hdr/mac/scheduler.h b/srsenb/hdr/stack/mac/scheduler.h similarity index 99% rename from srsenb/hdr/mac/scheduler.h rename to srsenb/hdr/stack/mac/scheduler.h index 4bc61e1bd..de0d111a9 100644 --- a/srsenb/hdr/mac/scheduler.h +++ b/srsenb/hdr/stack/mac/scheduler.h @@ -22,9 +22,9 @@ #ifndef SRSENB_SCHEDULER_H #define SRSENB_SCHEDULER_H +#include "scheduler_grid.h" #include "scheduler_harq.h" #include "scheduler_ue.h" -#include "srsenb/hdr/mac/scheduler_grid.h" #include "srslte/common/log.h" #include "srslte/interfaces/enb_interfaces.h" #include "srslte/interfaces/sched_interface.h" diff --git a/srsenb/hdr/mac/scheduler_grid.h b/srsenb/hdr/stack/mac/scheduler_grid.h similarity index 99% rename from srsenb/hdr/mac/scheduler_grid.h rename to srsenb/hdr/stack/mac/scheduler_grid.h index cbf3b5eb4..20d57c17a 100644 --- a/srsenb/hdr/mac/scheduler_grid.h +++ b/srsenb/hdr/stack/mac/scheduler_grid.h @@ -23,7 +23,7 @@ #define SRSLTE_SCHEDULER_GRID_H #include "lib/include/srslte/interfaces/sched_interface.h" -#include "srsenb/hdr/mac/scheduler_ue.h" +#include "scheduler_ue.h" #include "srslte/common/bounded_bitset.h" #include "srslte/common/log.h" #include diff --git a/srsenb/hdr/mac/scheduler_harq.h b/srsenb/hdr/stack/mac/scheduler_harq.h similarity index 100% rename from srsenb/hdr/mac/scheduler_harq.h rename to srsenb/hdr/stack/mac/scheduler_harq.h diff --git a/srsenb/hdr/mac/scheduler_metric.h b/srsenb/hdr/stack/mac/scheduler_metric.h similarity index 100% rename from srsenb/hdr/mac/scheduler_metric.h rename to srsenb/hdr/stack/mac/scheduler_metric.h diff --git a/srsenb/hdr/mac/scheduler_ue.h b/srsenb/hdr/stack/mac/scheduler_ue.h similarity index 100% rename from srsenb/hdr/mac/scheduler_ue.h rename to srsenb/hdr/stack/mac/scheduler_ue.h diff --git a/srsenb/hdr/mac/ue.h b/srsenb/hdr/stack/mac/ue.h similarity index 100% rename from srsenb/hdr/mac/ue.h rename to srsenb/hdr/stack/mac/ue.h diff --git a/srsenb/hdr/upper/rrc.h b/srsenb/hdr/stack/rrc/rrc.h similarity index 96% rename from srsenb/hdr/upper/rrc.h rename to srsenb/hdr/stack/rrc/rrc.h index 2a46f5c17..0dd4da54f 100644 --- a/srsenb/hdr/upper/rrc.h +++ b/srsenb/hdr/stack/rrc/rrc.h @@ -22,8 +22,8 @@ #ifndef SRSENB_RRC_H #define SRSENB_RRC_H -#include "common_enb.h" #include "rrc_metrics.h" +#include "srsenb/hdr/stack/upper/common_enb.h" #include "srslte/asn1/rrc_asn1.h" #include "srslte/common/block_queue.h" #include "srslte/common/buffer_pool.h" @@ -127,16 +127,16 @@ public: bzero(&cfg.qci_cfg, sizeof(cfg.qci_cfg)); bzero(&cfg.cell, sizeof(cfg.cell)); } - - void init(rrc_cfg_t *cfg, - phy_interface_rrc *phy, - mac_interface_rrc *mac, - rlc_interface_rrc *rlc, - pdcp_interface_rrc *pdcp, - s1ap_interface_rrc *s1ap, - gtpu_interface_rrc *gtpu, - srslte::log *log_rrc); - + + void init(rrc_cfg_t* cfg, + phy_interface_stack_lte* phy, + mac_interface_rrc* mac, + rlc_interface_rrc* rlc, + pdcp_interface_rrc* pdcp, + s1ap_interface_rrc* s1ap, + gtpu_interface_rrc* gtpu, + srslte::log* log_rrc); + void stop(); void get_metrics(rrc_metrics_t &m); @@ -343,7 +343,7 @@ private: srslte::byte_buffer_pool* pool; srslte::byte_buffer_t byte_buf_paging; - phy_interface_rrc* phy; + phy_interface_stack_lte* phy; mac_interface_rrc* mac; rlc_interface_rrc* rlc; pdcp_interface_rrc* pdcp; diff --git a/srsenb/hdr/upper/rrc_metrics.h b/srsenb/hdr/stack/rrc/rrc_metrics.h similarity index 96% rename from srsenb/hdr/upper/rrc_metrics.h rename to srsenb/hdr/stack/rrc/rrc_metrics.h index ea3060e24..90d625a74 100644 --- a/srsenb/hdr/upper/rrc_metrics.h +++ b/srsenb/hdr/stack/rrc/rrc_metrics.h @@ -22,7 +22,7 @@ #ifndef SRSENB_RRC_METRICS_H #define SRSENB_RRC_METRICS_H -#include "common_enb.h" +#include "srsenb/hdr/stack/upper/common_enb.h" namespace srsenb { diff --git a/srsenb/hdr/upper/common_enb.h b/srsenb/hdr/stack/upper/common_enb.h similarity index 100% rename from srsenb/hdr/upper/common_enb.h rename to srsenb/hdr/stack/upper/common_enb.h diff --git a/srsenb/hdr/upper/gtpu.h b/srsenb/hdr/stack/upper/gtpu.h similarity index 100% rename from srsenb/hdr/upper/gtpu.h rename to srsenb/hdr/stack/upper/gtpu.h diff --git a/srsenb/hdr/upper/pdcp.h b/srsenb/hdr/stack/upper/pdcp.h similarity index 100% rename from srsenb/hdr/upper/pdcp.h rename to srsenb/hdr/stack/upper/pdcp.h diff --git a/srsenb/hdr/upper/rlc.h b/srsenb/hdr/stack/upper/rlc.h similarity index 89% rename from srsenb/hdr/upper/rlc.h rename to srsenb/hdr/stack/upper/rlc.h index 95ba5aa3d..cbbe9b2a4 100644 --- a/srsenb/hdr/upper/rlc.h +++ b/srsenb/hdr/stack/upper/rlc.h @@ -65,11 +65,8 @@ public: void write_pdu(uint16_t rnti, uint32_t lcid, uint8_t *payload, uint32_t nof_bytes); void read_pdu_pcch(uint8_t *payload, uint32_t buffer_size); -private: - - class user_interface : public srsue::pdcp_interface_rlc, - public srsue::rrc_interface_rlc, - public srsue::ue_interface +private: + class user_interface : public srsue::pdcp_interface_rlc, public srsue::rrc_interface_rlc { public: void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu); @@ -81,14 +78,12 @@ private: std::string get_rb_name(uint32_t lcid); uint16_t rnti; - srsenb::pdcp_interface_rlc *pdcp; - srsenb::rrc_interface_rlc *rrc; - srslte::rlc *rlc; - srsenb::rlc *parent; + srsenb::pdcp_interface_rlc *pdcp; + srsenb::rrc_interface_rlc *rrc; + std::unique_ptr rlc; + srsenb::rlc *parent; }; - void clear_user(user_interface *ue); - pthread_rwlock_t rwlock; std::map users; diff --git a/srsenb/hdr/upper/s1ap.h b/srsenb/hdr/stack/upper/s1ap.h similarity index 93% rename from srsenb/hdr/upper/s1ap.h rename to srsenb/hdr/stack/upper/s1ap.h index 1abfdf03f..bdcfb016a 100644 --- a/srsenb/hdr/upper/s1ap.h +++ b/srsenb/hdr/stack/upper/s1ap.h @@ -36,18 +36,6 @@ namespace srsenb { -typedef struct { - uint32_t enb_id; // 20-bit id (lsb bits) - uint8_t cell_id; // 8-bit cell id - uint16_t tac; // 16-bit tac - uint16_t mcc; // BCD-coded with 0xF filler - uint16_t mnc; // BCD-coded with 0xF filler - std::string mme_addr; - std::string gtp_bind_addr; - std::string s1c_bind_addr; - std::string enb_name; -}s1ap_args_t; - typedef struct { uint32_t rnti; uint32_t eNB_UE_S1AP_ID; diff --git a/srsenb/hdr/upper/s1ap_metrics.h b/srsenb/hdr/stack/upper/s1ap_metrics.h similarity index 100% rename from srsenb/hdr/upper/s1ap_metrics.h rename to srsenb/hdr/stack/upper/s1ap_metrics.h diff --git a/srsenb/src/CMakeLists.txt b/srsenb/src/CMakeLists.txt index f1976ab50..fde7a33a2 100644 --- a/srsenb/src/CMakeLists.txt +++ b/srsenb/src/CMakeLists.txt @@ -19,8 +19,7 @@ # add_subdirectory(phy) -add_subdirectory(mac) -add_subdirectory(upper) +add_subdirectory(stack) # Link libstdc++ and libgcc @@ -35,9 +34,11 @@ endif (RPATH) add_executable(srsenb main.cc enb.cc parser.cc enb_cfg_parser.cc metrics_stdout.cc metrics_csv.cc) -target_link_libraries(srsenb srsenb_upper +target_link_libraries(srsenb srsenb_phy + srsenb_stack + srsenb_upper srsenb_mac - srsenb_phy + srsenb_rrc srslte_common srslte_phy srslte_upper @@ -53,8 +54,6 @@ if (RPATH) set_target_properties(srsenb PROPERTIES INSTALL_RPATH ".") endif (RPATH) -install(TARGETS srsenb DESTINATION ${RUNTIME_DIR}) - ######################################################################## # Option to run command after build (useful for remote builds) ######################################################################## diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index 9241666d2..3121fb642 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -19,9 +19,10 @@ * */ -#include #include "srsenb/hdr/enb.h" +#include "srsenb/hdr/stack/enb_stack_lte.h" #include "srslte/build_info.h" +#include #include #include @@ -94,12 +95,6 @@ bool enb::init(all_args_t *args_) mylog->init(tmp, logger, true); phy_log.push_back(mylog); } - mac_log.init("MAC ", logger, true); - rlc_log.init("RLC ", logger); - pdcp_log.init("PDCP", logger); - rrc_log.init("RRC ", logger); - gtpu_log.init("GTPU", logger); - s1ap_log.init("S1AP", logger); pool_log.init("POOL", logger); pool_log.set_level(srslte::LOG_LEVEL_ERROR); @@ -110,22 +105,10 @@ bool enb::init(all_args_t *args_) for (int i=0;iexpert.phy.nof_phy_threads;i++) { ((srslte::log_filter*) phy_log[i])->set_level(level(args->log.phy_level)); } - mac_log.set_level(level(args->log.mac_level)); - rlc_log.set_level(level(args->log.rlc_level)); - pdcp_log.set_level(level(args->log.pdcp_level)); - rrc_log.set_level(level(args->log.rrc_level)); - gtpu_log.set_level(level(args->log.gtpu_level)); - s1ap_log.set_level(level(args->log.s1ap_level)); for (int i=0;iexpert.phy.nof_phy_threads;i++) { ((srslte::log_filter*) phy_log[i])->set_hex_limit(args->log.phy_hex_limit); } - mac_log.set_hex_limit(args->log.mac_hex_limit); - rlc_log.set_hex_limit(args->log.rlc_hex_limit); - pdcp_log.set_hex_limit(args->log.pdcp_hex_limit); - rrc_log.set_hex_limit(args->log.rrc_hex_limit); - gtpu_log.set_hex_limit(args->log.gtpu_hex_limit); - s1ap_log.set_hex_limit(args->log.s1ap_hex_limit); // Parse config files srslte_cell_t cell_cfg; @@ -155,44 +138,16 @@ bool enb::init(all_args_t *args_) phy_cfg.pdsch_cnfg.p_b = 1; // Default TM2,3,4 } - uint32_t prach_freq_offset = rrc_cfg.sibs[1].sib2().rr_cfg_common.prach_cfg.prach_cfg_info.prach_freq_offset; - - if (cell_cfg.nof_prb > 10) { - uint32_t lower_bound = SRSLTE_MAX(rrc_cfg.sr_cfg.nof_prb, rrc_cfg.cqi_cfg.nof_prb); - uint32_t upper_bound = cell_cfg.nof_prb - lower_bound; - if (prach_freq_offset + 6 > upper_bound or prach_freq_offset < lower_bound) { - fprintf(stderr, - "ERROR: Invalid PRACH configuration - prach_freq_offset=%d collides with PUCCH.\n", - prach_freq_offset); - fprintf(stderr, - " Consider changing \"prach_freq_offset\" in sib.conf to a value between %d and %d.\n", - lower_bound, - upper_bound); - return false; - } - } else { // 6 PRB case - if (prach_freq_offset + 6 > cell_cfg.nof_prb) { - fprintf(stderr, - "ERROR: Invalid PRACH configuration - prach=(%d, %d) does not fit into the eNB PRBs=(0, %d).\n", - prach_freq_offset, - prach_freq_offset + 6, - cell_cfg.nof_prb); - fprintf( - stderr, - " Consider changing the \"prach_freq_offset\" value to 0 in the sib.conf file when using 6 PRBs.\n"); - return false; - } - } - rrc_cfg.inactivity_timeout_ms = args->expert.rrc_inactivity_timer; rrc_cfg.enable_mbsfn = args->expert.enable_mbsfn; // Check number of control symbols if (cell_cfg.nof_prb < 50 && args->expert.mac.sched.nof_ctrl_symbols != 3) { args->expert.mac.sched.nof_ctrl_symbols = 3; - mac_log.info("Setting number of control symbols to %d for %d PRB cell.\n", - args->expert.mac.sched.nof_ctrl_symbols, - cell_cfg.nof_prb); + fprintf(stdout, + "Setting number of control symbols to %d for %d PRB cell.\n", + args->expert.mac.sched.nof_ctrl_symbols, + cell_cfg.nof_prb); } // Parse EEA preference list @@ -245,13 +200,6 @@ bool enb::init(all_args_t *args_) memcpy(&rrc_cfg.cell, &cell_cfg, sizeof(srslte_cell_t)); memcpy(&phy_cfg.cell, &cell_cfg, sizeof(srslte_cell_t)); - // Set up pcap and trace - if(args->pcap.enable) - { - mac_pcap.open(args->pcap.filename.c_str()); - mac.start_pcap(&mac_pcap); - } - // Init layers /* Start Radio */ @@ -269,8 +217,8 @@ bool enb::init(all_args_t *args_) phy_log[0]->console( "Failed to find device %s with args %s\n", args->rf.device_name.c_str(), args->rf.device_args.c_str()); return false; - } - + } + // Set RF options if (args->rf.time_adv_nsamples != "auto") { radio.set_tx_adv((int)strtol(args->rf.time_adv_nsamples.c_str(), nullptr, 10)); @@ -288,14 +236,23 @@ bool enb::init(all_args_t *args_) radio.register_error_handler(rf_msg); - // Init all layers - phy.init(&args->expert.phy, &phy_cfg, &radio, &mac, phy_log); - mac.init(&args->expert.mac, &cell_cfg, &phy, &rlc, &rrc, &mac_log); - rlc.init(&pdcp, &rrc, &mac, &mac, &rlc_log); - pdcp.init(&rlc, &rrc, >pu, &pdcp_log); - rrc.init(&rrc_cfg, &phy, &mac, &rlc, &pdcp, &s1ap, >pu, &rrc_log); - s1ap.init(args->enb.s1ap, &rrc, &s1ap_log); - gtpu.init(args->enb.s1ap.gtp_bind_addr, args->enb.s1ap.mme_addr, args->expert.m1u_multiaddr, args->expert.m1u_if_addr, &pdcp, >pu_log, args->expert.enable_mbsfn); + // Setup Stack Args + enb_stack_lte::args_t stack_args; + stack_args.enb = args->enb; + stack_args.expert.mac = args->expert.mac; + stack_args.expert.enable_mbsfn = args->expert.enable_mbsfn; + stack_args.expert.m1u_if_addr = args->expert.m1u_if_addr; + stack_args.expert.m1u_multiaddr = args->expert.m1u_multiaddr; + stack_args.log = args->log; + stack_args.pcap = args->pcap; + + // Init all layers + std::unique_ptr lte_stack(new enb_stack_lte()); + phy.init(&args->expert.phy, &phy_cfg, &radio, lte_stack.get(), phy_log); + if (lte_stack->init(stack_args, rrc_cfg, logger, &phy) != SRSLTE_SUCCESS) { + return false; + } + stack = std::move(lte_stack); started = true; return true; @@ -305,21 +262,8 @@ void enb::stop() { if(started) { - s1ap.stop(); - gtpu.stop(); phy.stop(); - mac.stop(); - usleep(50000); - - rlc.stop(); - pdcp.stop(); - rrc.stop(); - - usleep(10000); - if(args->pcap.enable) - { - mac_pcap.close(); - } + stack->stop(); radio.stop(); started = false; } @@ -340,9 +284,7 @@ bool enb::get_metrics(enb_metrics_t* m) rf_metrics.rf_error = false; // Reset error flag phy.get_metrics(m->phy); - mac.get_metrics(m->mac); - rrc.get_metrics(m->rrc); - s1ap.get_metrics(m->s1ap); + stack->get_metrics(&m->stack); m->running = started; return true; diff --git a/srsenb/src/enb_cfg_parser.h b/srsenb/src/enb_cfg_parser.h index 724f84272..72b7ea5af 100644 --- a/srsenb/src/enb_cfg_parser.h +++ b/srsenb/src/enb_cfg_parser.h @@ -30,7 +30,7 @@ #include #include "srsenb/hdr/parser.h" -#include "srsenb/hdr/upper/rrc.h" +#include "srsenb/hdr/stack/rrc/rrc.h" #include "srslte/asn1/asn1_utils.h" namespace srsenb { diff --git a/srsenb/src/metrics_csv.cc b/srsenb/src/metrics_csv.cc index acf5cda8d..279291a0a 100644 --- a/srsenb/src/metrics_csv.cc +++ b/srsenb/src/metrics_csv.cc @@ -73,13 +73,13 @@ void metrics_csv::set_metrics(enb_metrics_t &metrics, const uint32_t period_usec file << (metrics_report_period*n_reports) << ";"; // UEs - file << (metrics.rrc.n_ues) << ";"; + file << (metrics.stack.rrc.n_ues) << ";"; // Sum up rates for all UEs float dl_rate_sum = 0.0, ul_rate_sum = 0.0; - for (int i = 0; i < metrics.rrc.n_ues; i++) { - dl_rate_sum += metrics.mac[i].tx_brate; - ul_rate_sum += metrics.mac[i].rx_brate; + for (int i = 0; i < metrics.stack.rrc.n_ues; i++) { + dl_rate_sum += metrics.stack.mac[i].tx_brate; + ul_rate_sum += metrics.stack.mac[i].rx_brate; } // DL rate diff --git a/srsenb/src/metrics_stdout.cc b/srsenb/src/metrics_stdout.cc index ffd0b2692..a0d4054e6 100644 --- a/srsenb/src/metrics_stdout.cc +++ b/srsenb/src/metrics_stdout.cc @@ -62,7 +62,7 @@ void metrics_stdout::toggle_print(bool b) void metrics_stdout::set_metrics(enb_metrics_t &metrics, const uint32_t period_usec) { - if (!do_print || enb == NULL || metrics.rrc.n_ues == 0) { + if (!do_print || enb == NULL || metrics.stack.rrc.n_ues == 0) { return; } @@ -75,29 +75,30 @@ void metrics_stdout::set_metrics(enb_metrics_t &metrics, const uint32_t period_u cout << "rnti cqi ri mcs brate bler snr phr mcs brate bler bsr" << endl; } - for (int i = 0; i < metrics.rrc.n_ues; i++) { - if (metrics.mac[i].tx_errors > metrics.mac[i].tx_pkts) { - printf("tx caution errors %d > %d\n", metrics.mac[i].tx_errors, metrics.mac[i].tx_pkts); + for (int i = 0; i < metrics.stack.rrc.n_ues; i++) { + if (metrics.stack.mac[i].tx_errors > metrics.stack.mac[i].tx_pkts) { + printf("tx caution errors %d > %d\n", metrics.stack.mac[i].tx_errors, metrics.stack.mac[i].tx_pkts); } - if (metrics.mac[i].rx_errors > metrics.mac[i].rx_pkts) { - printf("rx caution errors %d > %d\n", metrics.mac[i].rx_errors, metrics.mac[i].rx_pkts); + if (metrics.stack.mac[i].rx_errors > metrics.stack.mac[i].rx_pkts) { + printf("rx caution errors %d > %d\n", metrics.stack.mac[i].rx_errors, metrics.stack.mac[i].rx_pkts); } - cout << std::hex << metrics.mac[i].rnti << " "; - cout << float_to_string(SRSLTE_MAX(0.1, metrics.mac[i].dl_cqi), 2); - cout << float_to_string(metrics.mac[i].dl_ri, 1); + cout << std::hex << metrics.stack.mac[i].rnti << " "; + cout << float_to_string(SRSLTE_MAX(0.1, metrics.stack.mac[i].dl_cqi), 2); + cout << float_to_string(metrics.stack.mac[i].dl_ri, 1); if (not isnan(metrics.phy[i].dl.mcs)) { cout << float_to_string(SRSLTE_MAX(0.1, metrics.phy[i].dl.mcs), 2); } else { cout << float_to_string(0, 2); } - if (metrics.mac[i].tx_brate > 0) { - cout << float_to_eng_string(SRSLTE_MAX(0.1, (float)metrics.mac[i].tx_brate / period_usec * 1e6), 2); + if (metrics.stack.mac[i].tx_brate > 0) { + cout << float_to_eng_string(SRSLTE_MAX(0.1, (float)metrics.stack.mac[i].tx_brate / period_usec * 1e6), 2); } else { cout << float_to_string(0, 2) << ""; } - if (metrics.mac[i].tx_pkts > 0 && metrics.mac[i].tx_errors) { - cout << float_to_string(SRSLTE_MAX(0.1, (float)100 * metrics.mac[i].tx_errors / metrics.mac[i].tx_pkts), 1) + if (metrics.stack.mac[i].tx_pkts > 0 && metrics.stack.mac[i].tx_errors) { + cout << float_to_string( + SRSLTE_MAX(0.1, (float)100 * metrics.stack.mac[i].tx_errors / metrics.stack.mac[i].tx_pkts), 1) << "%"; } else { cout << float_to_string(0, 1) << "%"; @@ -107,24 +108,25 @@ void metrics_stdout::set_metrics(enb_metrics_t &metrics, const uint32_t period_u } else { cout << float_to_string(0, 2); } - cout << float_to_string(metrics.mac[i].phr, 2); + cout << float_to_string(metrics.stack.mac[i].phr, 2); if (not isnan(metrics.phy[i].ul.mcs)) { cout << float_to_string(SRSLTE_MAX(0.1, metrics.phy[i].ul.mcs), 2); } else { cout << float_to_string(0, 2); } - if (metrics.mac[i].rx_brate > 0) { - cout << float_to_eng_string(SRSLTE_MAX(0.1, (float)metrics.mac[i].rx_brate / period_usec * 1e6), 2); + if (metrics.stack.mac[i].rx_brate > 0) { + cout << float_to_eng_string(SRSLTE_MAX(0.1, (float)metrics.stack.mac[i].rx_brate / period_usec * 1e6), 2); } else { cout << float_to_string(0, 2) << ""; } - if (metrics.mac[i].rx_pkts > 0 && metrics.mac[i].rx_errors > 0) { - cout << float_to_string(SRSLTE_MAX(0.1, (float)100 * metrics.mac[i].rx_errors / metrics.mac[i].rx_pkts), 1) + if (metrics.stack.mac[i].rx_pkts > 0 && metrics.stack.mac[i].rx_errors > 0) { + cout << float_to_string( + SRSLTE_MAX(0.1, (float)100 * metrics.stack.mac[i].rx_errors / metrics.stack.mac[i].rx_pkts), 1) << "%"; } else { cout << float_to_string(0, 1) << "%"; } - cout << float_to_eng_string(metrics.mac[i].ul_buffer, 2); + cout << float_to_eng_string(metrics.stack.mac[i].ul_buffer, 2); cout << endl; } diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 7f15e0239..8e11b223d 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -98,11 +98,11 @@ void phy::parse_config(phy_cfg_t* cfg) workers_common.dl_cfg_com.pdsch.meas_time_en = true; } -bool phy::init(phy_args_t *args, - phy_cfg_t *cfg, - srslte::radio* radio_handler_, - mac_interface_phy *mac, - srslte::log_filter* log_h) +bool phy::init(phy_args_t* args, + phy_cfg_t* cfg, + srslte::radio* radio_handler_, + stack_interface_phy_lte* stack_, + srslte::log_filter* log_h) { std::vector log_vec; @@ -110,14 +110,14 @@ bool phy::init(phy_args_t *args, for (int i=0;inof_phy_threads;i++) { log_vec.push_back(log_h); } - init(args, cfg, radio_handler_, mac, log_vec); + init(args, cfg, radio_handler_, stack_, log_vec); return true; } -bool phy::init(phy_args_t *args, - phy_cfg_t *cfg, - srslte::radio* radio_handler_, - mac_interface_phy *mac, +bool phy::init(phy_args_t* args, + phy_cfg_t* cfg, + srslte::radio* radio_handler_, + stack_interface_phy_lte* stack_, std::vector log_vec) { @@ -126,10 +126,10 @@ bool phy::init(phy_args_t *args, radio_handler = radio_handler_; nof_workers = args->nof_phy_threads; this->log_h = (srslte::log*)log_vec[0]; - workers_common.params = *args; + workers_common.params = *args; + + workers_common.init(&cfg->cell, radio_handler, stack_); - workers_common.init(&cfg->cell, radio_handler, mac); - parse_config(cfg); // Add workers to workers pool and start threads @@ -137,8 +137,8 @@ bool phy::init(phy_args_t *args, workers[i].init(&workers_common, (srslte::log*) log_vec[i]); workers_pool.init_worker(i, &workers[i], WORKERS_THREAD_PRIO); } - - prach.init(&cfg->cell, &prach_cfg, mac, (srslte::log*) log_vec[0], PRACH_WORKER_THREAD_PRIO); + + prach.init(&cfg->cell, &prach_cfg, stack_, (srslte::log*)log_vec[0], PRACH_WORKER_THREAD_PRIO); prach.set_max_prach_offset_us(args->max_prach_offset_us); // Warning this must be initialized after all workers have been added to the pool diff --git a/srsenb/src/phy/phy_common.cc b/srsenb/src/phy/phy_common.cc index d0477974f..c71918848 100644 --- a/srsenb/src/phy/phy_common.cc +++ b/srsenb/src/phy/phy_common.cc @@ -42,7 +42,7 @@ phy_common::phy_common(uint32_t max_workers) : tx_sem(max_workers) this->nof_workers = nof_workers; params.max_prach_offset_us = 20; radio = NULL; - mac = NULL; + stack = NULL; is_first_tx = false; is_first_of_burst = false; have_mtch_stop = false; @@ -71,14 +71,14 @@ void phy_common::set_nof_workers(uint32_t nof_workers) void phy_common::reset() { - bzero(ul_grants, sizeof(mac_interface_phy::ul_sched_t)*TTIMOD_SZ); - bzero(dl_grants, sizeof(mac_interface_phy::dl_sched_t)*TTIMOD_SZ); + bzero(ul_grants, sizeof(stack_interface_phy_lte::ul_sched_t) * TTIMOD_SZ); + bzero(dl_grants, sizeof(stack_interface_phy_lte::dl_sched_t) * TTIMOD_SZ); } -bool phy_common::init(srslte_cell_t* cell_, srslte::radio* radio_h_, mac_interface_phy* mac_) +bool phy_common::init(srslte_cell_t* cell_, srslte::radio* radio_h_, stack_interface_phy_lte* stack_) { radio = radio_h_; - mac = mac_; + stack = stack_; memcpy(&cell, cell_, sizeof(srslte_cell_t)); pthread_mutex_init(&user_mutex, NULL); @@ -129,7 +129,7 @@ void phy_common::worker_end(uint32_t tti, sem_post(&tx_sem[(tti+1)%nof_workers]); // Trigger MAC clock - mac->tti_clock(); + stack->tti_clock(); } void phy_common::ue_db_clear(uint32_t tti) @@ -246,7 +246,7 @@ void phy_common::set_mch_period_stop(uint32_t stop) pthread_mutex_unlock(&mtch_mutex); } -void phy_common::configure_mbsfn(phy_interface_rrc::phy_cfg_mbsfn_t* cfg) +void phy_common::configure_mbsfn(phy_interface_stack_lte::phy_cfg_mbsfn_t* cfg) { mbsfn = *cfg; diff --git a/srsenb/src/phy/prach_worker.cc b/srsenb/src/phy/prach_worker.cc index ef0f7d77f..f9f3b774f 100644 --- a/srsenb/src/phy/prach_worker.cc +++ b/srsenb/src/phy/prach_worker.cc @@ -24,10 +24,14 @@ namespace srsenb { -int prach_worker::init(srslte_cell_t *cell_, srslte_prach_cfg_t *prach_cfg_, mac_interface_phy* mac_, srslte::log* log_h_, int priority) +int prach_worker::init(srslte_cell_t* cell_, + srslte_prach_cfg_t* prach_cfg_, + stack_interface_phy_lte* stack_, + srslte::log* log_h_, + int priority) { - log_h = log_h_; - mac = mac_; + log_h = log_h_; + stack = stack_; memcpy(&prach_cfg, prach_cfg_, sizeof(srslte_prach_cfg_t)); memcpy(&cell, cell_, sizeof(srslte_cell_t)); @@ -127,7 +131,7 @@ int prach_worker::run_tti(sf_buffer *b) i, prach_nof_det, prach_indices[i], prach_offsets[i]*1e6, prach_p2avg[i], max_prach_offset_us); if (prach_offsets[i]*1e6 < max_prach_offset_us) { - mac->rach_detected(b->tti, prach_indices[i], (uint32_t) (prach_offsets[i]*1e6)); + stack->rach_detected(b->tti, prach_indices[i], (uint32_t)(prach_offsets[i] * 1e6)); } } } diff --git a/srsenb/src/phy/sf_worker.cc b/srsenb/src/phy/sf_worker.cc index 9f004e2c0..cbe1f5e14 100644 --- a/srsenb/src/phy/sf_worker.cc +++ b/srsenb/src/phy/sf_worker.cc @@ -362,9 +362,9 @@ void sf_worker::work_imp() srslte_mbsfn_cfg_t mbsfn_cfg; srslte_sf_t sf_type = phy->is_mbsfn_sf(&mbsfn_cfg, tti_tx_dl) ? SRSLTE_SF_MBSFN : SRSLTE_SF_NORM; - mac_interface_phy::ul_sched_t* ul_grants = phy->ul_grants; - mac_interface_phy::dl_sched_t* dl_grants = phy->dl_grants; - mac_interface_phy* mac = phy->mac; + stack_interface_phy_lte::ul_sched_t* ul_grants = phy->ul_grants; + stack_interface_phy_lte::dl_sched_t* dl_grants = phy->dl_grants; + stack_interface_phy_lte* stack = phy->stack; log_h->step(tti_rx); @@ -391,13 +391,13 @@ void sf_worker::work_imp() // Get DL scheduling for the TX TTI from MAC if (sf_type == SRSLTE_SF_NORM) { - if (mac->get_dl_sched(tti_tx_dl, &dl_grants[t_tx_dl]) < 0) { + if (stack->get_dl_sched(tti_tx_dl, &dl_grants[t_tx_dl]) < 0) { Error("Getting DL scheduling from MAC\n"); goto unlock; } } else { dl_grants[t_tx_dl].cfi = mbsfn_cfg.non_mbsfn_region_length; - if (mac->get_mch_sched(tti_tx_dl, mbsfn_cfg.is_mcch, &dl_grants[t_tx_dl])) { + if (stack->get_mch_sched(tti_tx_dl, mbsfn_cfg.is_mcch, &dl_grants[t_tx_dl])) { Error("Getting MCH packets from MAC\n"); goto unlock; } @@ -409,7 +409,7 @@ void sf_worker::work_imp() } // Get UL scheduling for the TX TTI from MAC - if (mac->get_ul_sched(tti_tx_ul, &ul_grants[t_tx_ul]) < 0) { + if (stack->get_ul_sched(tti_tx_ul, &ul_grants[t_tx_ul]) < 0) { Error("Getting UL scheduling from MAC\n"); goto unlock; } @@ -513,7 +513,7 @@ void sf_worker::send_uci_data(uint16_t rnti, srslte_uci_cfg_t* uci_cfg, srslte_u { // Notify SR if (uci_cfg->is_scheduling_request_tti && uci_value->scheduling_request) { - phy->mac->sr_detected(tti_rx, rnti); + phy->stack->sr_detected(tti_rx, rnti); } /* If only one ACK is required, it can be for TB0 or TB1 */ @@ -522,7 +522,7 @@ void sf_worker::send_uci_data(uint16_t rnti, srslte_uci_cfg_t* uci_cfg, srslte_u if (uci_cfg->ack.pending_tb[tb]) { bool ack = uci_value->ack.ack_value[ack_idx]; bool valid = uci_value->ack.valid; - phy->mac->ack_info(tti_rx, rnti, tb, ack && valid); + phy->stack->ack_info(tti_rx, rnti, tb, ack && valid); ack_idx++; } } @@ -545,10 +545,10 @@ void sf_worker::send_uci_data(uint16_t rnti, srslte_uci_cfg_t* uci_cfg, srslte_u cqi_value = uci_value->cqi.subband_ue.wideband_cqi; break; } - phy->mac->cqi_info(tti_rx, rnti, cqi_value); + phy->stack->cqi_info(tti_rx, rnti, cqi_value); } if (uci_cfg->cqi.ri_len) { - phy->mac->ri_info(tti_rx, rnti, uci_value->ri); + phy->stack->ri_info(tti_rx, rnti, uci_value->ri); phy->ue_db_set_ri(rnti, uci_value->ri); } if (uci_cfg->cqi.pmi_present) { @@ -564,12 +564,12 @@ void sf_worker::send_uci_data(uint16_t rnti, srslte_uci_cfg_t* uci_cfg, srslte_u Error("CQI type=%d not implemented for PMI\n", uci_cfg->cqi.type); break; } - phy->mac->pmi_info(tti_rx, rnti, pmi_value); + phy->stack->pmi_info(tti_rx, rnti, pmi_value); } } } -int sf_worker::decode_pusch(mac_interface_phy::ul_sched_grant_t* grants, uint32_t nof_pusch) +int sf_worker::decode_pusch(stack_interface_phy_lte::ul_sched_grant_t* grants, uint32_t nof_pusch) { srslte_pusch_res_t pusch_res; @@ -614,20 +614,20 @@ int sf_worker::decode_pusch(mac_interface_phy::ul_sched_grant_t* grants, uint32_ // Notify MAC of RL status if (snr_db >= PUSCH_RL_SNR_DB_TH) { - phy->mac->snr_info(tti_rx, rnti, snr_db); + phy->stack->snr_info(tti_rx, rnti, snr_db); if (grants[i].dci.tb.rv == 0) { if (!pusch_res.crc) { Debug("PUSCH: Radio-Link failure snr=%.1f dB\n", snr_db); - phy->mac->rl_failure(rnti); + phy->stack->rl_failure(rnti); } else { - phy->mac->rl_ok(rnti); + phy->stack->rl_ok(rnti); } } } // Notify MAC new received data and HARQ Indication value - phy->mac->crc_info(tti_rx, rnti, grant->tb.tbs / 8, pusch_res.crc); + phy->stack->crc_info(tti_rx, rnti, grant->tb.tbs / 8, pusch_res.crc); // Send UCI data to MAC send_uci_data(rnti, &ue_db[rnti]->ul_cfg.pusch.uci_cfg, &pusch_res.uci); @@ -666,9 +666,9 @@ int sf_worker::decode_pucch() if (!ue_db[rnti]->ul_cfg.pucch.uci_cfg.is_scheduling_request_tti) { if (pucch_res.correlation < PUCCH_RL_CORR_TH) { Debug("PUCCH: Radio-Link failure corr=%.1f\n", pucch_res.correlation); - phy->mac->rl_failure(rnti); + phy->stack->rl_failure(rnti); } else { - phy->mac->rl_ok(rnti); + phy->stack->rl_ok(rnti); } } @@ -685,7 +685,7 @@ int sf_worker::decode_pucch() return 0; } -int sf_worker::encode_phich(mac_interface_phy::ul_sched_ack_t* acks, uint32_t nof_acks) +int sf_worker::encode_phich(stack_interface_phy_lte::ul_sched_ack_t* acks, uint32_t nof_acks) { for (uint32_t i = 0; i < nof_acks; i++) { if (acks[i].rnti && ue_db.count(acks[i].rnti)) { @@ -702,7 +702,7 @@ int sf_worker::encode_phich(mac_interface_phy::ul_sched_ack_t* acks, uint32_t no return SRSLTE_SUCCESS; } -int sf_worker::encode_pdcch_ul(mac_interface_phy::ul_sched_grant_t* grants, uint32_t nof_grants) +int sf_worker::encode_pdcch_ul(stack_interface_phy_lte::ul_sched_grant_t* grants, uint32_t nof_grants) { for (uint32_t i = 0; i < nof_grants; i++) { if (grants[i].needs_pdcch) { @@ -720,7 +720,7 @@ int sf_worker::encode_pdcch_ul(mac_interface_phy::ul_sched_grant_t* grants, uint return SRSLTE_SUCCESS; } -int sf_worker::encode_pdcch_dl(mac_interface_phy::dl_sched_grant_t* grants, uint32_t nof_grants) +int sf_worker::encode_pdcch_dl(stack_interface_phy_lte::dl_sched_grant_t* grants, uint32_t nof_grants) { for (uint32_t i = 0; i < nof_grants; i++) { uint16_t rnti = grants[i].dci.rnti; @@ -741,7 +741,7 @@ int sf_worker::encode_pdcch_dl(mac_interface_phy::dl_sched_grant_t* grants, uint return 0; } -int sf_worker::encode_pmch(mac_interface_phy::dl_sched_grant_t* grant, srslte_mbsfn_cfg_t* mbsfn_cfg) +int sf_worker::encode_pmch(stack_interface_phy_lte::dl_sched_grant_t* grant, srslte_mbsfn_cfg_t* mbsfn_cfg) { srslte_pmch_cfg_t pmch_cfg; ZERO_OBJECT(pmch_cfg); @@ -765,7 +765,7 @@ int sf_worker::encode_pmch(mac_interface_phy::dl_sched_grant_t* grant, srslte_mb return SRSLTE_SUCCESS; } -int sf_worker::encode_pdsch(mac_interface_phy::dl_sched_grant_t* grants, uint32_t nof_grants) +int sf_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, uint32_t nof_grants) { /* Scales the Resources Elements affected by the power allocation (p_b) */ diff --git a/srsenb/src/stack/CMakeLists.txt b/srsenb/src/stack/CMakeLists.txt new file mode 100644 index 000000000..b4a83094a --- /dev/null +++ b/srsenb/src/stack/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# Copyright 2013-2019 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/. +# + +add_subdirectory(mac) +add_subdirectory(rrc) +add_subdirectory(upper) + +set(SOURCES enb_stack_lte.cc) + +add_library(srsenb_stack STATIC ${SOURCES}) +target_link_libraries(srsenb_stack) + +install(TARGETS srsenb_stack DESTINATION ${LIBRARY_DIR}) + diff --git a/srsenb/src/stack/enb_stack_lte.cc b/srsenb/src/stack/enb_stack_lte.cc new file mode 100644 index 000000000..c84b7336f --- /dev/null +++ b/srsenb/src/stack/enb_stack_lte.cc @@ -0,0 +1,166 @@ +/* + * Copyright 2013-2019 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/stack/enb_stack_lte.h" +#include "srsenb/hdr/enb.h" +#include "srslte/srslte.h" +#include + +using namespace srslte; + +namespace srsenb { + +enb_stack_lte::enb_stack_lte() : args(), started(false), logger(nullptr), phy(nullptr) {} + +enb_stack_lte::~enb_stack_lte() +{ + stop(); +} + +std::string enb_stack_lte::get_type() +{ + return "lte"; +} + +int enb_stack_lte::init(const args_t& args_, + const rrc_cfg_t& rrc_cfg_, + srslte::logger* logger_, + phy_interface_stack_lte* phy_) +{ + phy = phy_; + if (init(args_, rrc_cfg_, logger_)) { + return SRSLTE_ERROR; + } + return SRSLTE_SUCCESS; +} + +int enb_stack_lte::init(const args_t& args_, const rrc_cfg_t& rrc_cfg_, srslte::logger* logger_) +{ + args = args_; + rrc_cfg = rrc_cfg_; + logger = logger_; + + // setup logging for each layer + mac_log.init("MAC ", logger, true); + rlc_log.init("RLC ", logger); + pdcp_log.init("PDCP", logger); + rrc_log.init("RRC ", logger); + gtpu_log.init("GTPU", logger); + s1ap_log.init("S1AP", logger); + + // Init logs + mac_log.set_level(args.log.mac_level); + rlc_log.set_level(args.log.rlc_level); + pdcp_log.set_level(args.log.pdcp_level); + rrc_log.set_level(args.log.rrc_level); + gtpu_log.set_level(args.log.gtpu_level); + s1ap_log.set_level(args.log.s1ap_level); + + mac_log.set_hex_limit(args.log.mac_hex_limit); + rlc_log.set_hex_limit(args.log.rlc_hex_limit); + pdcp_log.set_hex_limit(args.log.pdcp_hex_limit); + rrc_log.set_hex_limit(args.log.rrc_hex_limit); + gtpu_log.set_hex_limit(args.log.gtpu_hex_limit); + s1ap_log.set_hex_limit(args.log.s1ap_hex_limit); + + // Set up pcap and trace + if (args.pcap.enable) { + mac_pcap.open(args.pcap.filename.c_str()); + mac.start_pcap(&mac_pcap); + } + + // verify configuration correctness + uint32_t prach_freq_offset = rrc_cfg.sibs[1].sib2().rr_cfg_common.prach_cfg.prach_cfg_info.prach_freq_offset; + srslte_cell_t& cell_cfg = rrc_cfg.cell; + if (cell_cfg.nof_prb > 10) { + uint32_t lower_bound = SRSLTE_MAX(rrc_cfg.sr_cfg.nof_prb, rrc_cfg.cqi_cfg.nof_prb); + uint32_t upper_bound = cell_cfg.nof_prb - lower_bound; + if (prach_freq_offset + 6 > upper_bound or prach_freq_offset < lower_bound) { + fprintf(stderr, + "ERROR: Invalid PRACH configuration - prach_freq_offset=%d collides with PUCCH.\n", + prach_freq_offset); + fprintf(stderr, + " Consider changing \"prach_freq_offset\" in sib.conf to a value between %d and %d.\n", + lower_bound, + upper_bound); + return false; + } + } else { // 6 PRB case + if (prach_freq_offset + 6 > cell_cfg.nof_prb) { + fprintf(stderr, + "ERROR: Invalid PRACH configuration - prach=(%d, %d) does not fit into the eNB PRBs=(0, %d).\n", + prach_freq_offset, + prach_freq_offset + 6, + cell_cfg.nof_prb); + fprintf( + stderr, + " Consider changing the \"prach_freq_offset\" value to 0 in the sib.conf file when using 6 PRBs.\n"); + return false; + } + } + + // Init all layers + mac.init(args.expert.mac, &cell_cfg, phy, &rlc, &rrc, &mac_log); + rlc.init(&pdcp, &rrc, &mac, &mac, &rlc_log); + pdcp.init(&rlc, &rrc, >pu, &pdcp_log); + rrc.init(&rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, >pu, &rrc_log); + s1ap.init(args.enb.s1ap, &rrc, &s1ap_log); + gtpu.init(args.enb.s1ap.gtp_bind_addr, + args.enb.s1ap.mme_addr, + args.expert.m1u_multiaddr, + args.expert.m1u_if_addr, + &pdcp, + >pu_log, + args.expert.enable_mbsfn); + + started = true; + return SRSLTE_SUCCESS; +} + +void enb_stack_lte::stop() +{ + if (started) { + s1ap.stop(); + gtpu.stop(); + mac.stop(); + usleep(50000); + + rlc.stop(); + pdcp.stop(); + rrc.stop(); + + usleep(10000); + if (args.pcap.enable) { + mac_pcap.close(); + } + started = false; + } +} + +bool enb_stack_lte::get_metrics(stack_metrics_t* metrics) +{ + mac.get_metrics(metrics->mac); + rrc.get_metrics(metrics->rrc); + s1ap.get_metrics(metrics->s1ap); + return true; +} + +} // namespace srsenb diff --git a/srsenb/src/mac/CMakeLists.txt b/srsenb/src/stack/mac/CMakeLists.txt similarity index 100% rename from srsenb/src/mac/CMakeLists.txt rename to srsenb/src/stack/mac/CMakeLists.txt diff --git a/srsenb/src/mac/mac.cc b/srsenb/src/stack/mac/mac.cc similarity index 98% rename from srsenb/src/mac/mac.cc rename to srsenb/src/stack/mac/mac.cc index daed71f9e..e2075bf2d 100644 --- a/srsenb/src/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -30,8 +30,8 @@ #include #include +#include "srsenb/hdr/stack/mac/mac.h" #include "srslte/common/log.h" -#include "srsenb/hdr/mac/mac.h" //#define WRITE_SIB_PCAP using namespace asn1::rrc; @@ -66,20 +66,25 @@ mac::~mac() pthread_rwlock_unlock(&rwlock); pthread_rwlock_destroy(&rwlock); } - -bool mac::init(mac_args_t *args_, srslte_cell_t *cell_, phy_interface_mac *phy, rlc_interface_mac *rlc, rrc_interface_mac *rrc, srslte::log *log_h_) + +bool mac::init(const mac_args_t& args_, + srslte_cell_t* cell_, + phy_interface_stack_lte* phy, + rlc_interface_mac* rlc, + rrc_interface_mac* rrc, + srslte::log* log_h_) { - started = false; + started = false; - if (cell_ && phy && rlc && log_h_ && args_) { + if (cell_ && phy && rlc && log_h_) { phy_h = phy; rlc_h = rlc; rrc_h = rrc; - log_h = log_h_; - - memcpy(&args, args_, sizeof(mac_args_t)); - memcpy(&cell, cell_, sizeof(srslte_cell_t)); - + log_h = log_h_; + + args = args_; + cell = *cell_; + scheduler.init(rrc, log_h); // Set default scheduler (RR) scheduler.set_metric(&sched_metric_dl_rr, &sched_metric_ul_rr); diff --git a/srsenb/src/mac/scheduler.cc b/srsenb/src/stack/mac/scheduler.cc similarity index 99% rename from srsenb/src/mac/scheduler.cc rename to srsenb/src/stack/mac/scheduler.cc index 7d9197167..6aa4b4f70 100644 --- a/srsenb/src/mac/scheduler.cc +++ b/srsenb/src/stack/mac/scheduler.cc @@ -19,12 +19,12 @@ * */ -#include +#include #include -#include "srslte/srslte.h" +#include "srsenb/hdr/stack/mac/scheduler.h" #include "srslte/common/pdu.h" -#include "srsenb/hdr/mac/scheduler.h" +#include "srslte/srslte.h" #define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__) diff --git a/srsenb/src/mac/scheduler_grid.cc b/srsenb/src/stack/mac/scheduler_grid.cc similarity index 98% rename from srsenb/src/mac/scheduler_grid.cc rename to srsenb/src/stack/mac/scheduler_grid.cc index 2761e74ac..67c763f97 100644 --- a/srsenb/src/mac/scheduler_grid.cc +++ b/srsenb/src/stack/mac/scheduler_grid.cc @@ -19,8 +19,8 @@ * */ -#include "srsenb/hdr/mac/scheduler_grid.h" -#include "srsenb/hdr/mac/scheduler.h" +#include "srsenb/hdr/stack/mac/scheduler_grid.h" +#include "srsenb/hdr/stack/mac/scheduler.h" #include namespace srsenb { diff --git a/srsenb/src/mac/scheduler_harq.cc b/srsenb/src/stack/mac/scheduler_harq.cc similarity index 99% rename from srsenb/src/mac/scheduler_harq.cc rename to srsenb/src/stack/mac/scheduler_harq.cc index 4992acde3..5bbd4e81c 100644 --- a/srsenb/src/mac/scheduler_harq.cc +++ b/srsenb/src/stack/mac/scheduler_harq.cc @@ -21,9 +21,9 @@ #include -#include "srslte/srslte.h" +#include "srsenb/hdr/stack/mac/scheduler.h" #include "srslte/common/pdu.h" -#include "srsenb/hdr/mac/scheduler.h" +#include "srslte/srslte.h" #define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__) diff --git a/srsenb/src/mac/scheduler_metric.cc b/srsenb/src/stack/mac/scheduler_metric.cc similarity index 98% rename from srsenb/src/mac/scheduler_metric.cc rename to srsenb/src/stack/mac/scheduler_metric.cc index 401665a13..97fc6febd 100644 --- a/srsenb/src/mac/scheduler_metric.cc +++ b/srsenb/src/stack/mac/scheduler_metric.cc @@ -19,9 +19,9 @@ * */ +#include "srsenb/hdr/stack/mac/scheduler_metric.h" +#include "srsenb/hdr/stack/mac/scheduler_harq.h" #include -#include "srsenb/hdr/mac/scheduler_harq.h" -#include "srsenb/hdr/mac/scheduler_metric.h" #define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__) diff --git a/srsenb/src/mac/scheduler_ue.cc b/srsenb/src/stack/mac/scheduler_ue.cc similarity index 99% rename from srsenb/src/mac/scheduler_ue.cc rename to srsenb/src/stack/mac/scheduler_ue.cc index 6b5cd57a3..ed1543965 100644 --- a/srsenb/src/mac/scheduler_ue.cc +++ b/srsenb/src/stack/mac/scheduler_ue.cc @@ -21,10 +21,10 @@ #include -#include "srslte/srslte.h" +#include "srsenb/hdr/stack/mac/scheduler.h" +#include "srsenb/hdr/stack/mac/scheduler_ue.h" #include "srslte/common/pdu.h" -#include "srsenb/hdr/mac/scheduler_ue.h" -#include "srsenb/hdr/mac/scheduler.h" +#include "srslte/srslte.h" #define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__) diff --git a/srsenb/src/mac/ue.cc b/srsenb/src/stack/mac/ue.cc similarity index 99% rename from srsenb/src/mac/ue.cc rename to srsenb/src/stack/mac/ue.cc index f6fc35670..f1f3db92e 100644 --- a/srsenb/src/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -22,8 +22,8 @@ #include #include +#include "srsenb/hdr/stack/mac/ue.h" #include "srslte/interfaces/enb_interfaces.h" -#include "srsenb/hdr/mac/ue.h" #define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__) diff --git a/srsenb/src/stack/rrc/CMakeLists.txt b/srsenb/src/stack/rrc/CMakeLists.txt new file mode 100644 index 000000000..f5f225b8c --- /dev/null +++ b/srsenb/src/stack/rrc/CMakeLists.txt @@ -0,0 +1,25 @@ +# +# Copyright 2013-2019 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/. +# + +set(SOURCES rrc.cc) + +add_library(srsenb_rrc STATIC ${SOURCES}) + +install(TARGETS srsenb_rrc DESTINATION ${LIBRARY_DIR}) diff --git a/srsenb/src/upper/rrc.cc b/srsenb/src/stack/rrc/rrc.cc similarity index 99% rename from srsenb/src/upper/rrc.cc rename to srsenb/src/stack/rrc/rrc.cc index 1f038b8c7..a3ec07843 100644 --- a/srsenb/src/upper/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -19,7 +19,7 @@ * */ -#include "srsenb/hdr/upper/rrc.h" +#include "srsenb/hdr/stack/rrc/rrc.h" #include "srslte/asn1/asn1_utils.h" #include "srslte/asn1/liblte_mme.h" #include "srslte/common/bcd_helpers.h" @@ -35,15 +35,15 @@ using srslte::uint8_to_uint32; using namespace asn1::rrc; namespace srsenb { - -void rrc::init(rrc_cfg_t *cfg_, - phy_interface_rrc* phy_, - mac_interface_rrc* mac_, - rlc_interface_rrc* rlc_, - pdcp_interface_rrc* pdcp_, - s1ap_interface_rrc *s1ap_, - gtpu_interface_rrc* gtpu_, - srslte::log* log_rrc) + +void rrc::init(rrc_cfg_t* cfg_, + phy_interface_stack_lte* phy_, + mac_interface_rrc* mac_, + rlc_interface_rrc* rlc_, + pdcp_interface_rrc* pdcp_, + s1ap_interface_rrc* s1ap_, + gtpu_interface_rrc* gtpu_, + srslte::log* log_rrc) { phy = phy_; mac = mac_; diff --git a/srsenb/src/upper/CMakeLists.txt b/srsenb/src/stack/upper/CMakeLists.txt similarity index 100% rename from srsenb/src/upper/CMakeLists.txt rename to srsenb/src/stack/upper/CMakeLists.txt diff --git a/srsenb/src/upper/gtpu.cc b/srsenb/src/stack/upper/gtpu.cc similarity index 99% rename from srsenb/src/upper/gtpu.cc rename to srsenb/src/stack/upper/gtpu.cc index 3cc70d5c2..a04bfbd6b 100644 --- a/srsenb/src/upper/gtpu.cc +++ b/srsenb/src/stack/upper/gtpu.cc @@ -19,11 +19,11 @@ * */ #include "srslte/upper/gtpu.h" -#include "srsenb/hdr/upper/gtpu.h" -#include -#include -#include +#include "srsenb/hdr/stack/upper/gtpu.h" #include +#include +#include +#include using namespace srslte; namespace srsenb { diff --git a/srsenb/src/upper/pdcp.cc b/srsenb/src/stack/upper/pdcp.cc similarity index 98% rename from srsenb/src/upper/pdcp.cc rename to srsenb/src/stack/upper/pdcp.cc index d533ed6c5..846231cda 100644 --- a/srsenb/src/upper/pdcp.cc +++ b/srsenb/src/stack/upper/pdcp.cc @@ -19,8 +19,8 @@ * */ -#include "srsenb/hdr/upper/pdcp.h" -#include "srsenb/hdr/upper/common_enb.h" +#include "srsenb/hdr/stack/upper/pdcp.h" +#include "srsenb/hdr/stack/upper/common_enb.h" namespace srsenb { diff --git a/srsenb/src/upper/rlc.cc b/srsenb/src/stack/upper/rlc.cc similarity index 91% rename from srsenb/src/upper/rlc.cc rename to srsenb/src/stack/upper/rlc.cc index b4b251e88..e78b11559 100644 --- a/srsenb/src/upper/rlc.cc +++ b/srsenb/src/stack/upper/rlc.cc @@ -19,8 +19,8 @@ * */ -#include "srsenb/hdr/upper/rlc.h" -#include "srsenb/hdr/upper/common_enb.h" +#include "srsenb/hdr/stack/upper/rlc.h" +#include "srsenb/hdr/stack/upper/common_enb.h" namespace srsenb { @@ -41,8 +41,8 @@ void rlc::init(pdcp_interface_rlc* pdcp_, rrc_interface_rlc* rrc_, mac_interface void rlc::stop() { pthread_rwlock_wrlock(&rwlock); - for(std::map::iterator iter=users.begin(); iter!=users.end(); ++iter) { - clear_user(&iter->second); + for (auto& user : users) { + user.second.rlc->stop(); } users.clear(); pthread_rwlock_unlock(&rwlock); @@ -52,30 +52,23 @@ void rlc::stop() void rlc::add_user(uint16_t rnti) { pthread_rwlock_rdlock(&rwlock); - if (users.count(rnti) == 0) { - srslte::rlc *obj = new srslte::rlc; - obj->init(&users[rnti], &users[rnti], &users[rnti], log_h, mac_timers, RB_ID_SRB0); + if (users.count(rnti) == 0) { + std::unique_ptr obj(new srslte::rlc); + obj->init(&users[rnti], &users[rnti], log_h, mac_timers, RB_ID_SRB0); users[rnti].rnti = rnti; users[rnti].pdcp = pdcp; - users[rnti].rrc = rrc; - users[rnti].rlc = obj; + users[rnti].rrc = rrc; + users[rnti].rlc = std::move(obj); users[rnti].parent = this; } pthread_rwlock_unlock(&rwlock); } -// Private unlocked deallocation of user -void rlc::clear_user(user_interface *ue) -{ - ue->rlc->stop(); - delete ue->rlc; - ue->rlc = NULL; -} void rlc::rem_user(uint16_t rnti) { pthread_rwlock_wrlock(&rwlock); if (users.count(rnti)) { - clear_user(&users[rnti]); + users[rnti].rlc->stop(); users.erase(rnti); } else { log_h->error("Removing rnti=0x%x. Already removed\n", rnti); diff --git a/srsenb/src/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc similarity index 99% rename from srsenb/src/upper/s1ap.cc rename to srsenb/src/stack/upper/s1ap.cc index 4eaea0cc2..376c70d24 100644 --- a/srsenb/src/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -19,8 +19,8 @@ * */ -#include "srsenb/hdr/upper/s1ap.h" -#include "srsenb/hdr/upper/common_enb.h" +#include "srsenb/hdr/stack/upper/s1ap.h" +#include "srsenb/hdr/stack/upper/common_enb.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/int_helpers.h" diff --git a/srsenb/test/mac/scheduler_test.cc b/srsenb/test/mac/scheduler_test.cc index c3ae799b5..536bd44d9 100644 --- a/srsenb/test/mac/scheduler_test.cc +++ b/srsenb/test/mac/scheduler_test.cc @@ -21,8 +21,8 @@ #include -#include "srsenb/hdr/mac/mac.h" #include "srsenb/hdr/phy/phy.h" +#include "srsenb/hdr/stack/mac/mac.h" #include "srslte/interfaces/enb_interfaces.h" #include "srslte/interfaces/sched_interface.h" diff --git a/srsenb/test/mac/scheduler_test_rand.cc b/srsenb/test/mac/scheduler_test_rand.cc index ca9c86e1a..7a458ba7e 100644 --- a/srsenb/test/mac/scheduler_test_rand.cc +++ b/srsenb/test/mac/scheduler_test_rand.cc @@ -19,18 +19,17 @@ * */ +#include "srsenb/hdr/stack/mac/scheduler.h" +#include "srsenb/hdr/stack/mac/scheduler_ue.h" #include #include #include #include -#include -#include -#include #include #include -#include "srsenb/hdr/mac/mac.h" #include "srsenb/hdr/phy/phy.h" +#include "srsenb/hdr/stack/mac/mac.h" #include "srslte/common/log_filter.h" #include "srslte/interfaces/enb_interfaces.h" diff --git a/srsenb/test/upper/plmn_test.cc b/srsenb/test/upper/plmn_test.cc index 2cc013051..cefcecd32 100644 --- a/srsenb/test/upper/plmn_test.cc +++ b/srsenb/test/upper/plmn_test.cc @@ -19,7 +19,7 @@ * */ -#include "srsenb/hdr/upper/common_enb.h" +#include "srsenb/hdr/stack/upper/common_enb.h" #include "srslte/asn1/rrc_asn1.h" #include "srslte/common/bcd_helpers.h" #include diff --git a/srsue/hdr/stack/ue_stack_base.h b/srsue/hdr/stack/ue_stack_base.h index a2bc387ac..d866e2478 100644 --- a/srsue/hdr/stack/ue_stack_base.h +++ b/srsue/hdr/stack/ue_stack_base.h @@ -25,24 +25,61 @@ #include "srslte/common/logger.h" #include "srslte/interfaces/ue_interfaces.h" #include "srsue/hdr/ue_metrics_interface.h" -#include "srsue/hdr/ue_stack_interface.h" -#include + +#include "rrc/rrc.h" +#include "upper/gw.h" +#include "upper/usim.h" namespace srsue { -class ue_stack_base : public ue_interface +typedef struct { + bool enable; + std::string filename; + bool nas_enable; + std::string nas_filename; +} pcap_args_t; + +typedef struct { + std::string mac_level; + std::string rlc_level; + std::string pdcp_level; + std::string rrc_level; + std::string gw_level; + std::string nas_level; + std::string usim_level; + + int mac_hex_limit; + int rlc_hex_limit; + int pdcp_hex_limit; + int rrc_hex_limit; + int gw_hex_limit; + int nas_hex_limit; + int usim_hex_limit; +} stack_log_args_t; + +typedef struct { + std::string type; + pcap_args_t pcap; + stack_log_args_t log; + usim_args_t usim; + rrc_args_t rrc; + std::string ue_category_str; + nas_args_t nas; + gw_args_t gw; +} stack_args_t; + +class ue_stack_base { public: - ue_stack_base(){}; - virtual ~ue_stack_base(){}; + ue_stack_base() = default; + virtual ~ue_stack_base() = default; virtual std::string get_type() = 0; - virtual int init(const stack_args_t& args_, srslte::logger* logger_) = 0; - virtual void stop() = 0; - virtual bool switch_on() = 0; - virtual bool switch_off() = 0; - virtual bool is_rrc_connected() = 0; + virtual void stop() = 0; + virtual bool switch_on() = 0; + virtual bool switch_off() = 0; + virtual bool is_rrc_connected() = 0; // UE metrics interface virtual bool get_metrics(stack_metrics_t* metrics) = 0; diff --git a/srsue/hdr/ue.h b/srsue/hdr/ue.h index adcc738b4..2bd0f50f9 100644 --- a/srsue/hdr/ue.h +++ b/srsue/hdr/ue.h @@ -35,7 +35,6 @@ #include "phy/ue_phy_base.h" #include "radio/ue_radio_base.h" #include "stack/ue_stack_base.h" -#include "ue_stack_interface.h" #include "srslte/common/buffer_pool.h" #include "srslte/interfaces/ue_interfaces.h" #include "srslte/common/logger_file.h" @@ -88,7 +87,7 @@ typedef struct { Main UE class *******************************************************************************/ -class ue : public ue_interface, public ue_metrics_interface +class ue : public ue_metrics_interface { public: ue(); diff --git a/srsue/hdr/ue_stack_interface.h b/srsue/hdr/ue_stack_interface.h deleted file mode 100644 index 883188cad..000000000 --- a/srsue/hdr/ue_stack_interface.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2013-2019 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_stack_interface.h - * Description: Pure virtual interface to the UE stack. - *****************************************************************************/ - -#ifndef SRSUE_UE_STACK_INTERFACE_H -#define SRSUE_UE_STACK_INTERFACE_H - -#include "srslte/common/logger.h" -#include "stack/rrc/rrc.h" -#include "stack/upper/gw.h" -#include "stack/upper/nas.h" -#include "stack/upper/usim.h" -#include "ue_metrics_interface.h" - -namespace srsue { - -typedef struct { - bool enable; - std::string filename; - bool nas_enable; - std::string nas_filename; -} pcap_args_t; - -typedef struct { - std::string mac_level; - std::string rlc_level; - std::string pdcp_level; - std::string rrc_level; - std::string gw_level; - std::string nas_level; - std::string usim_level; - - int mac_hex_limit; - int rlc_hex_limit; - int pdcp_hex_limit; - int rrc_hex_limit; - int gw_hex_limit; - int nas_hex_limit; - int usim_hex_limit; -} stack_log_args_t; - -typedef struct { - std::string type; - pcap_args_t pcap; - stack_log_args_t log; - usim_args_t usim; - rrc_args_t rrc; - std::string ue_category_str; - nas_args_t nas; - gw_args_t gw; -} stack_args_t; - -class ue_stack_interface -{ -public: - virtual bool init(stack_args_t args_, srslte::logger* logger_) = 0; - virtual void stop() = 0; - virtual bool switch_on() = 0; - virtual bool switch_off() = 0; - - virtual bool get_metrics(ue_metrics_t* metrics) = 0; - - virtual bool is_rrc_connected() = 0; -}; - -} // namespace srsue - -#endif // SRSUE_UE_STACK_INTERFACE_H diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 880e7054f..b630275ec 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -101,7 +101,7 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_) } mac.init(phy, &rlc, &rrc, &mac_log); - rlc.init(&pdcp, &rrc, NULL, &rlc_log, &mac, 0 /* RB_ID_SRB0 */); + rlc.init(&pdcp, &rrc, &rlc_log, &mac, 0 /* RB_ID_SRB0 */); pdcp.init(&rlc, &rrc, &gw, &pdcp_log, 0 /* RB_ID_SRB0 */, SECURITY_DIRECTION_UPLINK); nas.init(usim.get(), &rrc, &gw, &nas_log, args.nas); gw.init(&pdcp, &nas, &gw_log, args.gw); diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index eddd385c4..9ed1bd0ae 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -73,7 +73,7 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_) // Instantiate layers and stack together our UE if (args.stack.type == "lte") { - std::unique_ptr lte_stack = std::unique_ptr(new ue_stack_lte()); + std::unique_ptr lte_stack(new ue_stack_lte()); if (!lte_stack) { log.console("Error creating LTE stack instance.\n"); return SRSLTE_ERROR;