mac,nr: create sched_nr object only at mac::init()

master
Francisco Paisana 3 years ago
parent 8a38a89652
commit a035ad144b

@ -28,16 +28,17 @@
namespace srsenb {
struct mac_nr_args_t {
srsran::phy_cfg_nr_t phy_base_cfg = {};
int fixed_dl_mcs = -1;
int fixed_ul_mcs = -1;
srsenb::pcap_args_t pcap;
srsran::phy_cfg_nr_t phy_base_cfg = {};
int fixed_dl_mcs = -1;
int fixed_ul_mcs = -1;
sched_nr_interface::sched_cfg_t sched_cfg = {};
srsenb::pcap_args_t pcap;
};
class mac_nr final : public mac_interface_phy_nr, public mac_interface_rrc_nr, public mac_interface_rlc_nr
{
public:
mac_nr(srsran::task_sched_handle task_sched_, const srsenb::sched_nr_interface::sched_cfg_t& sched_cfg = {});
explicit mac_nr(srsran::task_sched_handle task_sched_);
~mac_nr();
int init(const mac_nr_args_t& args_,
@ -83,7 +84,7 @@ private:
int handle_pdu(srsran::unique_byte_buffer_t pdu);
// Encoding
srsran::byte_buffer_t* assemble_rar(srsran::const_span<sched_nr_interface::sched_rar_grant_t> grants);
srsran::byte_buffer_t* assemble_rar(srsran::const_span<sched_nr_interface::sched_rar_grant_t> grants);
srsran::unique_byte_buffer_t rar_pdu_buffer = nullptr;
// Interaction with other components
@ -102,10 +103,10 @@ private:
std::atomic<bool> started = {false};
const static uint32_t NUMEROLOGY_IDX = 0; /// only 15kHz supported at this stage
srsran::slot_point pdsch_slot, pusch_slot;
srsenb::sched_nr sched;
std::vector<sched_nr_interface::cell_cfg_t> cell_config;
const static uint32_t NUMEROLOGY_IDX = 0; /// only 15kHz supported at this stage
srsran::slot_point pdsch_slot, pusch_slot;
std::unique_ptr<srsenb::sched_nr> sched;
std::vector<sched_nr_interface::cell_cfg_t> cell_config;
// Map of active UEs
pthread_rwlock_t rwlock = {};

@ -26,10 +26,9 @@
namespace srsenb {
mac_nr::mac_nr(srsran::task_sched_handle task_sched_, const sched_nr_interface::sched_cfg_t& sched_cfg) :
mac_nr::mac_nr(srsran::task_sched_handle task_sched_) :
logger(srslog::fetch_basic_logger("MAC-NR")),
task_sched(task_sched_),
sched(sched_cfg),
bcch_bch_payload(srsran::make_byte_buffer()),
rar_pdu_buffer(srsran::make_byte_buffer())
{
@ -49,6 +48,7 @@ int mac_nr::init(const mac_nr_args_t& args_,
{
args = args_;
sched.reset(new sched_nr{args.sched_cfg});
phy = phy_;
stack = stack_;
rlc = rlc_;
@ -82,7 +82,7 @@ void mac_nr::get_metrics(srsenb::mac_metrics_t& metrics)
srsran::rwlock_read_guard lock(rwlock);
metrics.ues.reserve(ue_db.size());
for (auto& u : ue_db) {
if (not sched.ue_exists(u.first)) {
if (not sched->ue_exists(u.first)) {
continue;
}
metrics.ues.emplace_back();
@ -98,7 +98,7 @@ void mac_nr::get_metrics(srsenb::mac_metrics_t& metrics)
int mac_nr::cell_cfg(const std::vector<srsenb::sched_nr_interface::cell_cfg_t>& nr_cells)
{
cell_config = nr_cells;
sched.cell_cfg(nr_cells);
sched->cell_cfg(nr_cells);
detected_rachs.resize(nr_cells.size());
// read SIBs from RRC (SIB1 for now only)
@ -127,7 +127,7 @@ int mac_nr::cell_cfg(const std::vector<srsenb::sched_nr_interface::cell_cfg_t>&
int mac_nr::ue_cfg(uint16_t rnti, const sched_nr_interface::ue_cfg_t& ue_cfg)
{
sched.ue_cfg(rnti, ue_cfg);
sched->ue_cfg(rnti, ue_cfg);
return SRSRAN_SUCCESS;
}
@ -148,7 +148,7 @@ uint16_t mac_nr::reserve_rnti(uint32_t enb_cc_idx)
srsenb::sched_nr_interface::ue_cfg_t ue_cfg = srsenb::get_default_ue_cfg(1);
ue_cfg.fixed_dl_mcs = args.fixed_dl_mcs;
ue_cfg.fixed_ul_mcs = args.fixed_ul_mcs;
sched.ue_cfg(rnti, ue_cfg);
sched->ue_cfg(rnti, ue_cfg);
return rnti;
}
@ -174,7 +174,7 @@ void mac_nr::rach_detected(const rach_info_t& rach_info)
rar_info.ta_cmd = rach_info.time_adv;
rar_info.prach_slot = slot_point{NUMEROLOGY_IDX, rach_info.slot_index};
// TODO: fill remaining fields as required
sched.dl_rach_info(enb_cc_idx, rar_info);
sched->dl_rach_info(enb_cc_idx, rar_info);
rrc->add_user(rnti);
logger.info("RACH: slot=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x",
@ -210,7 +210,8 @@ uint16_t mac_nr::alloc_ue(uint32_t enb_cc_idx)
}
// Allocate and initialize UE object
std::unique_ptr<ue_nr> ue_ptr = std::unique_ptr<ue_nr>(new ue_nr(rnti, enb_cc_idx, &sched, rrc, rlc, phy, logger));
std::unique_ptr<ue_nr> ue_ptr =
std::unique_ptr<ue_nr>(new ue_nr(rnti, enb_cc_idx, sched.get(), rrc, rlc, phy, logger));
// Add UE to rnti map
srsran::rwlock_write_guard rw_lock(rwlock);
@ -284,7 +285,7 @@ int mac_nr::get_dl_sched(const srsran_slot_cfg_t& slot_cfg, dl_sched_t& dl_sched
}
sched_nr_interface::dl_sched_res_t dl_res;
int ret = sched.get_dl_sched(pdsch_slot, 0, dl_res);
int ret = sched->get_dl_sched(pdsch_slot, 0, dl_res);
if (ret != SRSRAN_SUCCESS) {
return ret;
}
@ -312,7 +313,7 @@ int mac_nr::get_dl_sched(const srsran_slot_cfg_t& slot_cfg, dl_sched_t& dl_sched
} else if (pdsch.sch.grant.rnti_type == srsran_rnti_type_ra) {
sched_nr_interface::sched_rar_t& rar = dl_res.rar[rar_count++];
// for RARs we could actually move the byte_buffer to the PHY, as there are no retx
pdsch.data[0] = assemble_rar(rar.grants);
pdsch.data[0] = assemble_rar(rar.grants);
}
}
return SRSRAN_SUCCESS;
@ -326,7 +327,7 @@ int mac_nr::get_ul_sched(const srsran_slot_cfg_t& slot_cfg, ul_sched_t& ul_sched
pusch_slot++;
}
return sched.get_ul_sched(pusch_slot, 0, ul_sched);
return sched->get_ul_sched(pusch_slot, 0, ul_sched);
}
int mac_nr::pucch_info(const srsran_slot_cfg_t& slot_cfg, const mac_interface_phy_nr::pucch_info_t& pucch_info)
@ -344,7 +345,7 @@ bool mac_nr::handle_uci_data(const uint16_t rnti, const srsran_uci_cfg_nr_t& cfg
for (uint32_t i = 0; i < cfg_.ack.count; i++) {
const srsran_harq_ack_bit_t* ack_bit = &cfg_.ack.bits[i];
bool is_ok = (value.ack[i] == 1) and value.valid;
sched.dl_ack_info(rnti, 0, ack_bit->pid, 0, is_ok);
sched->dl_ack_info(rnti, 0, ack_bit->pid, 0, is_ok);
}
// Process SR
@ -364,7 +365,7 @@ int mac_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, mac_interface_phy_nr::
return SRSRAN_ERROR;
}
sched.ul_crc_info(rnti, 0, pusch_info.pid, pusch_info.pusch_data.tb[0].crc);
sched->ul_crc_info(rnti, 0, pusch_info.pid, pusch_info.pusch_data.tb[0].crc);
// process only PDUs with CRC=OK
if (pusch_info.pusch_data.tb[0].crc) {
@ -418,7 +419,8 @@ srsran::byte_buffer_t* mac_nr::assemble_rar(srsran::const_span<sched_nr_interfac
// copy only the required bits
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant = {};
std::copy(std::begin(dci_msg.payload), std::begin(dci_msg.payload)+SRSRAN_RAR_UL_GRANT_NBITS, packed_ul_grant.begin());
std::copy(
std::begin(dci_msg.payload), std::begin(dci_msg.payload) + SRSRAN_RAR_UL_GRANT_NBITS, packed_ul_grant.begin());
rar_subpdu.set_ul_grant(packed_ul_grant);
}

@ -338,11 +338,11 @@ public:
srslog::fetch_basic_logger("MAC-NR").set_level(srslog::str_to_basic_level(args.log_level));
// create sched object
srsenb::sched_nr_interface::sched_cfg_t sched_cfg{};
sched_cfg.pdsch_enabled = args.pdsch.slots != "" and args.pdsch.slots != "none";
sched_cfg.pusch_enabled = args.pusch.slots != "" and args.pusch.slots != "none";
mac.reset(new srsenb::mac_nr{&task_sched, sched_cfg});
mac->init(srsenb::mac_nr_args_t{}, nullptr, nullptr, &rlc_obj, &rrc_obj);
mac.reset(new srsenb::mac_nr{&task_sched});
srsenb::mac_nr_args_t mac_args{};
mac_args.sched_cfg.pdsch_enabled = args.pdsch.slots != "" and args.pdsch.slots != "none";
mac_args.sched_cfg.pusch_enabled = args.pusch.slots != "" and args.pusch.slots != "none";
mac->init(mac_args, nullptr, nullptr, &rlc_obj, &rrc_obj);
std::vector<srsenb::sched_nr_interface::cell_cfg_t> cells_cfg = srsenb::get_default_cells_cfg(1, phy_cfg);
mac->cell_cfg(cells_cfg);

Loading…
Cancel
Save