mirror of https://github.com/pvnis/srsRAN_4G.git
reorganized enb to mirror ue director/class structure with a stack class
parent
d67d18cc6b
commit
415d3418b6
@ -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 <string>
|
||||
|
||||
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
|
@ -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
|
@ -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})
|
||||
|
@ -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 <srslte/interfaces/enb_metrics_interface.h>
|
||||
|
||||
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
|
@ -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})
|
@ -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
|
Loading…
Reference in New Issue