From 4867b16e3877c0e0fcc9c1ef5e48664db90e69b6 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 10 Dec 2018 10:39:42 +0100 Subject: [PATCH] move config file parsing in enb to beginning of init - this waits with initializing the radio until after the configs have been read - in case the config files contain any mistake, the enb shuts down gracefully --- srsenb/src/enb.cc | 101 +++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index a97382f3e..acd07177f 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -132,13 +132,63 @@ bool enb::init(all_args_t *args_) 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; + phy_cfg_t phy_cfg; + rrc_cfg_t rrc_cfg; + + if (parse_cell_cfg(args, &cell_cfg)) { + fprintf(stderr, "Error parsing Cell configuration\n"); + return false; + } + if (parse_sibs(args, &rrc_cfg, &phy_cfg)) { + fprintf(stderr, "Error parsing SIB configuration\n"); + return false; + } + if (parse_rr(args, &rrc_cfg)) { + fprintf(stderr, "Error parsing Radio Resources configuration\n"); + return false; + } + if (parse_drb(args, &rrc_cfg)) { + fprintf(stderr, "Error parsing DRB configuration\n"); + return false; + } + + uint32_t prach_freq_offset = rrc_cfg.sibs[1].sib.sib2.rr_config_common_sib.prach_cnfg.prach_cnfg_info.prach_freq_offset; + + if(cell_cfg.nof_prb>10) { + if (prach_freq_offset + 6 > cell_cfg.nof_prb - SRSLTE_MAX(rrc_cfg.cqi_cfg.nof_prb, rrc_cfg.sr_cfg.nof_prb)) { + fprintf(stderr, "Invalid PRACH configuration: frequency offset=%d outside bandwidth limits\n", prach_freq_offset); + return false; + } + + if (prach_freq_offset < SRSLTE_MAX(rrc_cfg.cqi_cfg.nof_prb, rrc_cfg.sr_cfg.nof_prb)) { + fprintf(stderr, "Invalid PRACH configuration: frequency offset=%d lower than CQI offset: %d or SR offset: %d\n", + prach_freq_offset, rrc_cfg.cqi_cfg.nof_prb, rrc_cfg.sr_cfg.nof_prb); + return false; + } + } else { // 6 PRB case + if (prach_freq_offset+6 > cell_cfg.nof_prb) { + fprintf(stderr, "Invalid PRACH configuration: frequency interval=(%d, %d) does not fit into the eNB PRBs=(0,%d)\n", + prach_freq_offset, prach_freq_offset+6, cell_cfg.nof_prb); + return false; + } + } + + rrc_cfg.inactivity_timeout_ms = args->expert.rrc_inactivity_timer; + rrc_cfg.enable_mbsfn = args->expert.enable_mbsfn; + + // Copy cell struct to rrc and phy + 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 */ @@ -194,55 +244,6 @@ bool enb::init(all_args_t *args_) radio.register_error_handler(rf_msg); - srslte_cell_t cell_cfg; - phy_cfg_t phy_cfg; - rrc_cfg_t rrc_cfg; - - if (parse_cell_cfg(args, &cell_cfg)) { - fprintf(stderr, "Error parsing Cell configuration\n"); - return false; - } - if (parse_sibs(args, &rrc_cfg, &phy_cfg)) { - fprintf(stderr, "Error parsing SIB configuration\n"); - return false; - } - if (parse_rr(args, &rrc_cfg)) { - fprintf(stderr, "Error parsing Radio Resources configuration\n"); - return false; - } - if (parse_drb(args, &rrc_cfg)) { - fprintf(stderr, "Error parsing DRB configuration\n"); - return false; - } - - uint32_t prach_freq_offset = rrc_cfg.sibs[1].sib.sib2.rr_config_common_sib.prach_cnfg.prach_cnfg_info.prach_freq_offset; - - if(cell_cfg.nof_prb>10) { - if (prach_freq_offset + 6 > cell_cfg.nof_prb - SRSLTE_MAX(rrc_cfg.cqi_cfg.nof_prb, rrc_cfg.sr_cfg.nof_prb)) { - fprintf(stderr, "Invalid PRACH configuration: frequency offset=%d outside bandwidth limits\n", prach_freq_offset); - return false; - } - - if (prach_freq_offset < SRSLTE_MAX(rrc_cfg.cqi_cfg.nof_prb, rrc_cfg.sr_cfg.nof_prb)) { - fprintf(stderr, "Invalid PRACH configuration: frequency offset=%d lower than CQI offset: %d or SR offset: %d\n", - prach_freq_offset, rrc_cfg.cqi_cfg.nof_prb, rrc_cfg.sr_cfg.nof_prb); - return false; - } - } else { // 6 PRB case - if (prach_freq_offset+6 > cell_cfg.nof_prb) { - fprintf(stderr, "Invalid PRACH configuration: frequency interval=(%d, %d) does not fit into the eNB PRBs=(0,%d)\n", - prach_freq_offset, prach_freq_offset+6, cell_cfg.nof_prb); - return false; - } - } - - rrc_cfg.inactivity_timeout_ms = args->expert.rrc_inactivity_timer; - rrc_cfg.enable_mbsfn = args->expert.enable_mbsfn; - - // Copy cell struct to rrc and phy - memcpy(&rrc_cfg.cell, &cell_cfg, sizeof(srslte_cell_t)); - memcpy(&phy_cfg.cell, &cell_cfg, sizeof(srslte_cell_t)); - // 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);