mirror of https://github.com/pvnis/srsRAN_4G.git
rrc,nr: create DU configuration manager in RRC NR class to handle the generation of SIBs and other cell-specific parameters
parent
12cc7cb4d7
commit
ab9fe90d3a
@ -0,0 +1,62 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2021 Software Radio Systems Limited
|
||||
*
|
||||
* By using this file, you agree to the terms and conditions set
|
||||
* forth in the LICENSE file which can be found at the top level of
|
||||
* the distribution.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SRSRAN_RRC_NR_DU_MANAGER_H
|
||||
#define SRSRAN_RRC_NR_DU_MANAGER_H
|
||||
|
||||
#include "rrc_nr_config.h"
|
||||
#include "srsgnb/hdr/stack/mac/sched_nr_interface.h"
|
||||
#include "srsran/asn1/rrc_nr.h"
|
||||
|
||||
namespace srsenb {
|
||||
|
||||
class du_cell_config
|
||||
{
|
||||
public:
|
||||
uint32_t cc;
|
||||
uint32_t pci;
|
||||
|
||||
asn1::rrc_nr::mib_s mib;
|
||||
srsran::unique_byte_buffer_t packed_mib;
|
||||
|
||||
asn1::rrc_nr::sib1_s sib1;
|
||||
srsran::unique_byte_buffer_t packed_sib1;
|
||||
|
||||
/// SI messages (index=0 for SIB1)
|
||||
srsran::const_byte_span packed_si_msg(uint32_t idx) { return srsran::make_span(packed_sib1); }
|
||||
size_t nof_si_msgs() const { return 1; }
|
||||
};
|
||||
|
||||
class du_config_manager
|
||||
{
|
||||
public:
|
||||
du_config_manager(const rrc_nr_cfg_t& cfg);
|
||||
~du_config_manager();
|
||||
|
||||
int add_cell();
|
||||
|
||||
const du_cell_config& cell(uint32_t cc) const
|
||||
{
|
||||
srsran_assert(cc < cells.size(), "Unknown DU Cell Index=%d", cc);
|
||||
return *cells[cc];
|
||||
}
|
||||
|
||||
private:
|
||||
const rrc_nr_cfg_t& cfg;
|
||||
srslog::basic_logger& logger;
|
||||
|
||||
std::vector<std::unique_ptr<du_cell_config> > cells;
|
||||
};
|
||||
|
||||
} // namespace srsenb
|
||||
|
||||
#endif // SRSRAN_RRC_NR_DU_MANAGER_H
|
@ -0,0 +1,96 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2021 Software Radio Systems Limited
|
||||
*
|
||||
* By using this file, you agree to the terms and conditions set
|
||||
* forth in the LICENSE file which can be found at the top level of
|
||||
* the distribution.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "srsgnb/hdr/stack/rrc/rrc_nr_du_manager.h"
|
||||
#include "srsgnb/hdr/stack/rrc/cell_asn1_config.h"
|
||||
#include "srsran/common/string_helpers.h"
|
||||
|
||||
using namespace asn1::rrc_nr;
|
||||
|
||||
namespace srsenb {
|
||||
|
||||
du_config_manager::du_config_manager(const rrc_nr_cfg_t& cfg_) : cfg(cfg_), logger(srslog::fetch_basic_logger("RRC-NR"))
|
||||
{}
|
||||
|
||||
du_config_manager::~du_config_manager() {}
|
||||
|
||||
int du_config_manager::add_cell()
|
||||
{
|
||||
// add cell
|
||||
std::unique_ptr<du_cell_config> obj = std::make_unique<du_cell_config>();
|
||||
du_cell_config& cell = *obj;
|
||||
cell.cc = cells.size();
|
||||
|
||||
// Fill general cell params
|
||||
cell.pci = cfg.cell_list[cell.cc].phy_cell.carrier.pci;
|
||||
|
||||
// fill MIB ASN.1
|
||||
if (fill_mib_from_enb_cfg(cfg.cell_list[cell.cc], cell.mib) != SRSRAN_SUCCESS) {
|
||||
return SRSRAN_ERROR;
|
||||
}
|
||||
|
||||
// Pack MIB
|
||||
cell.packed_mib = srsran::make_byte_buffer();
|
||||
if (cell.packed_mib == nullptr) {
|
||||
logger.error("Couldn't allocate PDU in %s().", __FUNCTION__);
|
||||
return SRSRAN_ERROR;
|
||||
}
|
||||
{
|
||||
asn1::bit_ref bref(cell.packed_mib->msg, cell.packed_mib->get_tailroom());
|
||||
bcch_bch_msg_s bch_msg;
|
||||
bch_msg.msg.set_mib() = cell.mib;
|
||||
if (bch_msg.pack(bref) != asn1::SRSASN_SUCCESS) {
|
||||
logger.error("Couldn't pack mib msg");
|
||||
return SRSRAN_ERROR;
|
||||
}
|
||||
cell.packed_mib->N_bytes = bref.distance_bytes();
|
||||
}
|
||||
logger.info(
|
||||
cell.packed_mib->data(), cell.packed_mib->size(), "BCCH-BCH Message (with MIB) (%d B)", cell.packed_mib->size());
|
||||
asn1::json_writer js;
|
||||
cell.mib.to_json(js);
|
||||
logger.info("MIB content: %s", js.to_string().c_str());
|
||||
|
||||
// fill SIB1 ASN.1
|
||||
if (fill_sib1_from_enb_cfg(cfg, cell.cc, cell.sib1) != SRSRAN_SUCCESS) {
|
||||
logger.error("Couldn't generate SIB1");
|
||||
return SRSRAN_ERROR;
|
||||
}
|
||||
|
||||
// Pack SIB1
|
||||
cell.packed_sib1 = srsran::make_byte_buffer();
|
||||
if (cell.packed_sib1 == nullptr) {
|
||||
logger.error("Couldn't allocate PDU in %s().", __FUNCTION__);
|
||||
return SRSRAN_ERROR;
|
||||
}
|
||||
{
|
||||
asn1::bit_ref bref(cell.packed_sib1->msg, cell.packed_sib1->get_tailroom());
|
||||
bcch_dl_sch_msg_s bcch_msg;
|
||||
bcch_msg.msg.set_c1().set_sib_type1() = cell.sib1;
|
||||
if (bcch_msg.pack(bref) != asn1::SRSASN_SUCCESS) {
|
||||
logger.error("Couldn't pack SIB1 msg");
|
||||
return SRSRAN_ERROR;
|
||||
}
|
||||
cell.packed_sib1->N_bytes = bref.distance_bytes();
|
||||
}
|
||||
logger.info(cell.packed_sib1->data(),
|
||||
cell.packed_sib1->size(),
|
||||
"BCCH-DL-SCH-Message (with SIB1) (%d B)",
|
||||
cell.packed_sib1->size());
|
||||
cell.sib1.to_json(js);
|
||||
logger.info("SIB1 content: %s", js.to_string().c_str());
|
||||
|
||||
cells.push_back(std::move(obj));
|
||||
return SRSRAN_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace srsenb
|
Loading…
Reference in New Issue