enb: prepare split of EUTRA and NR stack classes

this allows for a slimmer base station if only EUTRA or NR cells are used.
also it seperates entities in a cleaner way
master
Andre Puschmann 3 years ago
parent 8a2231251a
commit 8d49e58078

@ -155,7 +155,8 @@ private:
rrc_cfg_t rrc_cfg = {}; rrc_cfg_t rrc_cfg = {};
// eNB components // eNB components
std::unique_ptr<enb_stack_base> stack = nullptr; std::unique_ptr<enb_stack_base> eutra_stack = nullptr;
std::unique_ptr<enb_stack_base> nr_stack = nullptr;
std::unique_ptr<srsran::radio_base> radio = nullptr; std::unique_ptr<srsran::radio_base> radio = nullptr;
std::unique_ptr<enb_phy_base> phy = nullptr; std::unique_ptr<enb_phy_base> phy = nullptr;

@ -30,7 +30,8 @@ enb::enb(srslog::sink& log_sink) :
enb::~enb() enb::~enb()
{ {
stack.reset(); eutra_stack.reset();
nr_stack.reset();
} }
int enb::init(const all_args_t& args_) int enb::init(const all_args_t& args_)
@ -50,54 +51,68 @@ int enb::init(const all_args_t& args_)
srsran::byte_buffer_pool::get_instance()->enable_logger(true); srsran::byte_buffer_pool::get_instance()->enable_logger(true);
// Create layers // Create layers
if (args.stack.type == "lte") { std::unique_ptr<enb_stack_lte> tmp_eutra_stack;
std::unique_ptr<enb_stack_lte> lte_stack(new enb_stack_lte(log_sink)); if (not rrc_cfg.cell_list.empty()) {
if (!lte_stack) { // add EUTRA stack
srsran::console("Error creating eNB stack.\n"); tmp_eutra_stack.reset(new enb_stack_lte(log_sink));
if (tmp_eutra_stack == nullptr) {
srsran::console("Error creating EUTRA stack.\n");
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
}
std::unique_ptr<srsran::radio> lte_radio = std::unique_ptr<srsran::radio>(new srsran::radio); std::unique_ptr<gnb_stack_nr> tmp_nr_stack;
if (!lte_radio) { if (not rrc_cfg.cell_list_nr.empty()) {
// add NR stack
tmp_nr_stack.reset(new gnb_stack_nr());
if (tmp_nr_stack == nullptr) {
srsran::console("Error creating NR stack.\n");
return SRSRAN_ERROR;
}
}
// Radio is RAT agnostic
std::unique_ptr<srsran::radio> tmp_radio = std::unique_ptr<srsran::radio>(new srsran::radio);
if (tmp_radio == nullptr) {
srsran::console("Error creating radio multi instance.\n"); srsran::console("Error creating radio multi instance.\n");
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
std::unique_ptr<srsenb::phy> lte_phy = std::unique_ptr<srsenb::phy>(new srsenb::phy(log_sink)); // PHY is RAT agnostic too
if (!lte_phy) { std::unique_ptr<srsenb::phy> tmp_phy = std::unique_ptr<srsenb::phy>(new srsenb::phy(log_sink));
srsran::console("Error creating LTE PHY instance.\n"); if (tmp_phy == nullptr) {
srsran::console("Error creating PHY instance.\n");
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
if (ret == SRSRAN_SUCCESS) { // initialize layers
if (lte_stack->init(args.stack, rrc_cfg, lte_phy.get(), lte_phy.get()) != SRSRAN_SUCCESS) { if (tmp_eutra_stack->init(args.stack, rrc_cfg, tmp_phy.get(), tmp_phy.get()) != SRSRAN_SUCCESS) {
srsran::console("Error initializing stack.\n"); srsran::console("Error initializing stack.\n");
ret = SRSRAN_ERROR; ret = SRSRAN_ERROR;
} }
}
// Init Radio // Init Radio
if (lte_radio->init(args.rf, lte_phy.get())) { if (tmp_radio->init(args.rf, tmp_phy.get())) {
srsran::console("Error initializing radio.\n"); srsran::console("Error initializing radio.\n");
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
// Only Init PHY if radio could be initialized // Only Init PHY if radio could be initialized
if (ret == SRSRAN_SUCCESS) { if (ret == SRSRAN_SUCCESS) {
if (lte_phy->init(args.phy, phy_cfg, lte_radio.get(), lte_stack.get(), *lte_stack)) { if (tmp_phy->init(args.phy, phy_cfg, tmp_radio.get(), tmp_eutra_stack.get(), *tmp_eutra_stack)) {
srsran::console("Error initializing PHY.\n"); srsran::console("Error initializing PHY.\n");
ret = SRSRAN_ERROR; ret = SRSRAN_ERROR;
} }
} }
stack = std::move(lte_stack); if (tmp_eutra_stack) {
phy = std::move(lte_phy); eutra_stack = std::move(tmp_eutra_stack);
radio = std::move(lte_radio); }
if (tmp_nr_stack) {
} else { nr_stack = std::move(tmp_nr_stack);
srsran::console("Stack type %s not supported.\n", args.stack.type.c_str());
return SRSRAN_ERROR;
} }
phy = std::move(tmp_phy);
radio = std::move(tmp_radio);
started = true; // set to true in any case to allow stopping the eNB if an error happened started = true; // set to true in any case to allow stopping the eNB if an error happened
@ -127,8 +142,12 @@ void enb::stop()
phy->stop(); phy->stop();
} }
if (stack) { if (eutra_stack) {
stack->stop(); eutra_stack->stop();
}
if (nr_stack) {
nr_stack->stop();
} }
if (radio) { if (radio) {
@ -167,7 +186,9 @@ bool enb::get_metrics(enb_metrics_t* m)
{ {
radio->get_metrics(&m->rf); radio->get_metrics(&m->rf);
phy->get_metrics(m->phy); phy->get_metrics(m->phy);
stack->get_metrics(&m->stack); if (eutra_stack) {
eutra_stack->get_metrics(&m->stack);
}
m->running = started; m->running = started;
m->sys = sys_proc.get_metrics(); m->sys = sys_proc.get_metrics();
return true; return true;
@ -200,7 +221,7 @@ std::string enb::get_build_string()
void enb::toggle_padding() void enb::toggle_padding()
{ {
stack->toggle_padding(); eutra_stack->toggle_padding();
} }
} // namespace srsenb } // namespace srsenb

Loading…
Cancel
Save