srsLTE/srsenb/hdr/enb.h

239 lines
6.1 KiB
C
Raw Normal View History

2017-06-02 03:46:06 -07:00
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2017 Software Radio Systems Limited
*
* \section LICENSE
*
* This file is part of srsLTE.
*
* srsUE 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.
*
* srsUE 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/.
*
*/
2017-06-01 03:25:57 -07:00
/******************************************************************************
* File: enb.h
* Description: Top-level eNodeB class. Creates and links all
* layers and helpers.
*****************************************************************************/
2018-03-31 10:04:04 -07:00
#ifndef SRSENB_ENB_H
#define SRSENB_ENB_H
2017-06-01 03:25:57 -07:00
#include <stdarg.h>
#include <string>
#include <pthread.h>
#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 "srslte/radio/radio.h"
#include "srslte/common/bcd_helpers.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/interfaces/ue_interfaces.h"
2017-06-23 07:29:46 -07:00
#include "srslte/common/logger_file.h"
2017-06-01 03:25:57 -07:00
#include "srslte/common/log_filter.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/interfaces/enb_metrics_interface.h"
namespace srsenb {
/*******************************************************************************
eNodeB Parameters
*******************************************************************************/
typedef struct {
s1ap_args_t s1ap;
uint32_t n_prb;
uint32_t pci;
uint32_t nof_ports;
uint32_t transmission_mode;
float p_a;
2017-06-01 03:25:57 -07:00
}enb_args_t;
typedef struct {
std::string sib_config;
std::string rr_config;
std::string drb_config;
} enb_files_t;
typedef struct {
uint32_t dl_earfcn;
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;
}rf_args_t;
typedef struct {
bool enable;
std::string filename;
}pcap_args_t;
typedef struct {
std::string phy_level;
std::string phy_lib_level;
2017-06-01 03:25:57 -07:00
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;
2018-01-16 03:44:22 -08:00
int file_max_size;
2017-06-01 03:25:57 -07:00
std::string filename;
}log_args_t;
typedef struct {
bool enable;
}gui_args_t;
typedef struct {
2018-11-20 02:59:04 -08:00
phy_args_t phy;
mac_args_t mac;
uint32_t rrc_inactivity_timer;
float metrics_period_secs;
bool metrics_csv_enable;
std::string metrics_csv_filename;
bool enable_mbsfn;
bool print_buffer_state;
2018-06-15 04:42:17 -07:00
std::string m1u_multiaddr;
std::string m1u_if_addr;
2017-06-01 03:25:57 -07:00
}expert_args_t;
typedef struct {
enb_args_t enb;
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
2017-06-01 03:25:57 -07:00
*******************************************************************************/
class enb
2017-09-05 07:51:44 -07:00
:public enb_metrics_interface {
2017-06-01 03:25:57 -07:00
public:
2017-09-05 07:51:44 -07:00
static enb *get_instance(void);
2017-06-01 03:25:57 -07:00
static void cleanup(void);
bool init(all_args_t *args_);
2017-09-05 07:51:44 -07:00
2017-06-01 03:25:57 -07:00
void stop();
2017-09-05 07:51:44 -07:00
2017-06-01 03:25:57 -07:00
void start_plot();
2017-09-05 07:51:44 -07:00
2018-05-10 07:40:37 -07:00
void print_pool();
2017-06-01 03:25:57 -07:00
static void rf_msg(srslte_rf_error_t error);
2017-09-05 07:51:44 -07:00
2017-06-01 03:25:57 -07:00
void handle_rf_msg(srslte_rf_error_t error);
// eNodeB metrics interface
bool get_metrics(enb_metrics_t &m);
void pregenerate_signals(bool enable);
2017-09-05 07:51:44 -07:00
2017-06-01 03:25:57 -07:00
private:
static enb *instance;
2017-09-05 07:51:44 -07:00
2018-07-06 06:30:51 -07:00
const static int ENB_POOL_SIZE = 1024*10;
2017-06-01 03:25:57 -07:00
enb();
2017-09-05 07:51:44 -07:00
2017-06-01 03:25:57 -07:00
virtual ~enb();
2017-09-05 07:51:44 -07:00
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;
srslte::logger *logger;
2017-06-23 07:29:46 -07:00
srslte::log_filter rf_log;
2018-03-28 07:46:40 -07:00
std::vector<srslte::log_filter*> phy_log;
2017-06-23 07:29:46 -07:00
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;
2018-07-12 07:57:22 -07:00
srslte::log_filter pool_log;
2017-06-01 03:25:57 -07:00
srslte::byte_buffer_pool *pool;
all_args_t *args;
bool started;
rf_metrics_t rf_metrics;
srslte::LOG_LEVEL_ENUM level(std::string l);
2019-01-17 03:42:01 -08:00
// bool check_srslte_version();
int parse_sib1(std::string filename, asn1::rrc::sib_type1_s* data);
int parse_sib2(std::string filename, asn1::rrc::sib_type2_s* data);
int parse_sib3(std::string filename, asn1::rrc::sib_type3_s* data);
int parse_sib4(std::string filename, asn1::rrc::sib_type4_s* data);
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);
2017-06-01 03:25:57 -07:00
int parse_rr(all_args_t *args, rrc_cfg_t *rrc_cfg);
2019-01-17 03:42:01 -08:00
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);
2018-10-01 12:43:42 -07:00
std::string get_build_mode();
std::string get_build_info();
std::string get_build_string();
2017-06-01 03:25:57 -07:00
};
} // namespace srsenb
2018-03-31 10:04:04 -07:00
#endif // SRSENB_ENB_H
2017-06-01 03:25:57 -07:00