From 7ab52500e91623af24a1602b36661e836f8c0a61 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 22 Jul 2021 22:52:44 +0200 Subject: [PATCH] enb,mac_nr: add NR sched class and add basic init calls --- srsenb/hdr/stack/mac/mac_nr.h | 7 +++++ srsenb/src/stack/mac/nr/mac_nr.cc | 50 +++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/srsenb/hdr/stack/mac/mac_nr.h b/srsenb/hdr/stack/mac/mac_nr.h index 1585f19b4..f98a69261 100644 --- a/srsenb/hdr/stack/mac/mac_nr.h +++ b/srsenb/hdr/stack/mac/mac_nr.h @@ -18,6 +18,7 @@ #include "srsenb/hdr/common/rnti_pool.h" #include "srsenb/hdr/stack/enb_stack_base.h" +#include "srsenb/hdr/stack/mac/nr/sched_nr.h" #include "srsenb/hdr/stack/mac/nr/ue_nr.h" #include "srsran/common/task_scheduler.h" #include "srsran/interfaces/enb_metrics_interface.h" @@ -27,6 +28,9 @@ 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; }; @@ -91,6 +95,9 @@ private: std::atomic 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; srsenb::sched_interface::cell_cfg_t cfg = {}; // Map of active UEs diff --git a/srsenb/src/stack/mac/nr/mac_nr.cc b/srsenb/src/stack/mac/nr/mac_nr.cc index 9a7d275cb..525bb7bfd 100644 --- a/srsenb/src/stack/mac/nr/mac_nr.cc +++ b/srsenb/src/stack/mac/nr/mac_nr.cc @@ -11,6 +11,7 @@ */ #include "srsenb/hdr/stack/mac/mac_nr.h" +#include "srsenb/test/mac/nr/sched_nr_cfg_generators.h" #include "srsran/common/buffer_pool.h" #include "srsran/common/log_helper.h" #include "srsran/common/rwlock_guard.h" @@ -24,7 +25,9 @@ namespace srsenb { mac_nr::mac_nr(srsran::task_sched_handle task_sched_) : - logger(srslog::fetch_basic_logger("MAC-NR")), task_sched(task_sched_) + logger(srslog::fetch_basic_logger("MAC-NR")), + task_sched(task_sched_), + sched(srsenb::sched_nr_interface::sched_cfg_t{}) { stack_task_queue = task_sched.make_task_queue(); } @@ -52,6 +55,10 @@ int mac_nr::init(const mac_nr_args_t& args_, pcap->open(args.pcap.filename); } + // configure scheduler for 1 carrier + std::vector cells_cfg = srsenb::get_default_cells_cfg(1); + sched.cell_cfg(cells_cfg); + bcch_bch_payload = srsran::make_byte_buffer(); if (bcch_bch_payload == nullptr) { return SRSRAN_ERROR; @@ -128,7 +135,10 @@ void mac_nr::rach_detected(const srsran_slot_cfg_t& slot_cfg, ++detected_rachs[enb_cc_idx]; // Add new user to the scheduler so that it can RX/TX SRB0 - // .. + 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); // Register new user in RRC if (rrc->add_user(rnti) == SRSRAN_ERROR) { @@ -251,15 +261,45 @@ int mac_nr::slot_indication(const srsran_slot_cfg_t& slot_cfg) int mac_nr::get_dl_sched(const srsran_slot_cfg_t& slot_cfg, dl_sched_t& dl_sched) { - return 0; + if (not pdsch_slot.valid()) { + pdsch_slot = srsran::slot_point{NUMEROLOGY_IDX, slot_cfg.idx}; + } else { + pdsch_slot++; + } + + int ret = sched.get_dl_sched(pdsch_slot, 0, dl_sched); + for (pdsch_t& pdsch : dl_sched.pdsch) { + // Set TBS + // Select grant and set data + pdsch.data[0] = nullptr; // FIXME: add ptr to PDU + pdsch.data[1] = nullptr; + } + + return SRSRAN_SUCCESS; } + int mac_nr::get_ul_sched(const srsran_slot_cfg_t& slot_cfg, ul_sched_t& ul_sched) { - return 0; + if (not pusch_slot.valid()) { + pusch_slot = srsran::slot_point{NUMEROLOGY_IDX, slot_cfg.idx}; + } else { + pusch_slot++; + } + + int ret = sched.get_ul_sched(pusch_slot, 0, ul_sched); + for (pusch_t& pusch : ul_sched.pusch) { + pusch.data[0] = nullptr; // FIXME: add ptr to data to be filled + pusch.data[1] = nullptr; + } + + return SRSRAN_SUCCESS; } int mac_nr::pucch_info(const srsran_slot_cfg_t& slot_cfg, const mac_interface_phy_nr::pucch_info_t& pucch_info) { - return 0; + // FIXME: provide CRC/ACK feedback + // sched.dl_ack_info(rnti_, cc, pid, tb_idx, ack); + // sched.ul_crc_info(rnti_, cc, pid, crc); + return SRSRAN_SUCCESS; } int mac_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, const mac_interface_phy_nr::pusch_info_t& pusch_info) {