diff --git a/lib/include/srsran/interfaces/enb_mac_interfaces.h b/lib/include/srsran/interfaces/enb_mac_interfaces.h index 6ee722a1d..b3e2ef2fc 100644 --- a/lib/include/srsran/interfaces/enb_mac_interfaces.h +++ b/lib/include/srsran/interfaces/enb_mac_interfaces.h @@ -257,8 +257,7 @@ public: // Combined interface for PHY to access stack (MAC and RRC) class stack_interface_phy_lte : public mac_interface_phy_lte -{ -}; +{}; } // namespace srsenb diff --git a/lib/src/phy/phch/dci_nr.c b/lib/src/phy/phch/dci_nr.c index a37c06a4a..f18656c0e 100644 --- a/lib/src/phy/phch/dci_nr.c +++ b/lib/src/phy/phch/dci_nr.c @@ -1269,7 +1269,7 @@ static uint32_t dci_nr_format_1_0_to_str(const srsran_dci_dl_nr_t* dci, char* st // HARQ process number – 4 bits if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { - len = srsran_print_check(str, str_len, len, "harq_id=%d ", dci->harq_feedback); + len = srsran_print_check(str, str_len, len, "harq_id=%d ", dci->pid); } // System information indicator – 1 bit diff --git a/srsenb/hdr/stack/mac/nr/mac_nr.h b/srsenb/hdr/stack/mac/nr/mac_nr.h index fb7de2523..313f6cb69 100644 --- a/srsenb/hdr/stack/mac/nr/mac_nr.h +++ b/srsenb/hdr/stack/mac/nr/mac_nr.h @@ -61,7 +61,6 @@ public: int rlc_buffer_state(uint16_t rnti, uint32_t lcid, uint32_t tx_queue, uint32_t retx_queue) override; // Interface for PHY - void process_pdus(); int slot_indication(const srsran_slot_cfg_t& slot_cfg) override; int get_dl_sched(const srsran_slot_cfg_t& slot_cfg, dl_sched_t& dl_sched) override; int get_ul_sched(const srsran_slot_cfg_t& slot_cfg, ul_sched_t& ul_sched) override; diff --git a/srsenb/src/stack/mac/nr/mac_nr.cc b/srsenb/src/stack/mac/nr/mac_nr.cc index 65da81474..69aa970ff 100644 --- a/srsenb/src/stack/mac/nr/mac_nr.cc +++ b/srsenb/src/stack/mac/nr/mac_nr.cc @@ -267,6 +267,12 @@ bool mac_nr::is_rnti_active_unsafe(uint16_t rnti) return ue_db[rnti]->is_active(); } +int mac_nr::rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) +{ + sched.dl_buffer_state(rnti, lc_id, tx_queue, retx_queue); + return SRSRAN_SUCCESS; +} + int mac_nr::slot_indication(const srsran_slot_cfg_t& slot_cfg) { return 0; diff --git a/srsenb/src/stack/mac/nr/sched_nr_ue.cc b/srsenb/src/stack/mac/nr/sched_nr_ue.cc index 5f9156db3..8453ce395 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_ue.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_ue.cc @@ -86,6 +86,10 @@ ue::ue(uint16_t rnti_, const ue_cfg_t& cfg, const sched_params& sched_cfg_) : rnti(rnti_), sched_cfg(sched_cfg_), buffers(srslog::fetch_basic_logger(sched_cfg_.sched_cfg.logger_name)) { set_cfg(cfg); + + mac_lc_ch_cfg_t lch{}; + lch.direction = mac_lc_ch_cfg_t::BOTH; + buffers.config_lcid(0, lch); } void ue::set_cfg(const ue_cfg_t& cfg) diff --git a/srsenb/src/stack/mac/nr/sched_nr_worker.cc b/srsenb/src/stack/mac/nr/sched_nr_worker.cc index 2d560036a..6c843b245 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_worker.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_worker.cc @@ -152,49 +152,50 @@ void slot_cc_worker::postprocess_decisions() continue; } - if (ue.h_ul != nullptr and ue.h_ul->harq_slot_tx() == ue.pusch_slot) { - // PUSCH was allocated. Insert UCI in PUSCH - for (auto& pusch : bwp_slot.puschs) { - if (pusch.sch.grant.rnti == ue.rnti) { - // Put UCI configuration in PUSCH config - if (not ue.cfg->phy().get_pusch_uci_cfg(slot_cfg, uci_cfg, pusch.sch)) { - logger.error("Error setting UCI configuration in PUSCH"); - continue; - } - break; - } - } - } else { - // If any UCI information is triggered, schedule PUCCH - if (uci_cfg.ack.count > 0 || uci_cfg.nof_csi > 0 || uci_cfg.o_sr > 0) { - bwp_slot.pucch.emplace_back(); - mac_interface_phy_nr::pucch_t& pucch = bwp_slot.pucch.back(); + if (uci_cfg.ack.count == 0 and uci_cfg.nof_csi == 0 and uci_cfg.o_sr == 0) { + continue; + } - uci_cfg.pucch.rnti = ue.rnti; + bool has_pusch = false; + for (auto& pusch : bwp_slot.puschs) { + if (pusch.sch.grant.rnti == ue.rnti) { + // Put UCI configuration in PUSCH config + has_pusch = true; + if (not ue.cfg->phy().get_pusch_uci_cfg(slot_cfg, uci_cfg, pusch.sch)) { + logger.error("Error setting UCI configuration in PUSCH"); + continue; + } + break; + } + } + if (not has_pusch) { + // If any UCI information is triggered, schedule PUCCH + bwp_slot.pucch.emplace_back(); + mac_interface_phy_nr::pucch_t& pucch = bwp_slot.pucch.back(); + + uci_cfg.pucch.rnti = ue.rnti; + pucch.candidates.emplace_back(); + pucch.candidates.back().uci_cfg = uci_cfg; + if (not ue.cfg->phy().get_pucch_uci_cfg(slot_cfg, uci_cfg, pucch.pucch_cfg, pucch.candidates.back().resource)) { + logger.error("Error getting UCI CFG"); + continue; + } + + // If this slot has a SR opportunity and the selected PUCCH format is 1, consider positive SR. + if (uci_cfg.o_sr > 0 and uci_cfg.ack.count > 0 and + pucch.candidates.back().resource.format == SRSRAN_PUCCH_NR_FORMAT_1) { + // Set SR negative + if (uci_cfg.o_sr > 0) { + uci_cfg.sr_positive_present = false; + } + + // Append new resource pucch.candidates.emplace_back(); pucch.candidates.back().uci_cfg = uci_cfg; if (not ue.cfg->phy().get_pucch_uci_cfg(slot_cfg, uci_cfg, pucch.pucch_cfg, pucch.candidates.back().resource)) { logger.error("Error getting UCI CFG"); continue; } - - // If this slot has a SR opportunity and the selected PUCCH format is 1, consider positive SR. - if (uci_cfg.o_sr > 0 and uci_cfg.ack.count > 0 and - pucch.candidates.back().resource.format == SRSRAN_PUCCH_NR_FORMAT_1) { - // Set SR negative - if (uci_cfg.o_sr > 0) { - uci_cfg.sr_positive_present = false; - } - - // Append new resource - pucch.candidates.emplace_back(); - pucch.candidates.back().uci_cfg = uci_cfg; - if (not ue.cfg->phy().get_pucch_uci_cfg( - slot_cfg, uci_cfg, pucch.pucch_cfg, pucch.candidates.back().resource)) { - logger.error("Error getting UCI CFG"); - continue; - } - } } } } diff --git a/test/phy/dummy_gnb_stack.h b/test/phy/dummy_gnb_stack.h index f134e939e..25d64fa7d 100644 --- a/test/phy/dummy_gnb_stack.h +++ b/test/phy/dummy_gnb_stack.h @@ -82,6 +82,7 @@ private: std::unique_ptr mac; srsran::slot_point pdsch_slot, pusch_slot; srslog::basic_logger& sched_logger; + bool autofill_pdsch_bsr = false; std::mutex metrics_mutex; metrics_t metrics = {}; @@ -337,6 +338,8 @@ public: sched_logger.set_level(srslog::str_to_basic_level(args.log_level)); srslog::fetch_basic_logger("MAC-NR").set_level(srslog::str_to_basic_level(args.log_level)); + autofill_pdsch_bsr = args.pdsch.slots != "" and args.pdsch.slots != "none"; + // create sched object mac.reset(new srsenb::mac_nr{&task_sched}); srsenb::mac_nr_args_t mac_args{}; @@ -444,6 +447,10 @@ public: } if (not use_dummy_sched) { + if (autofill_pdsch_bsr) { + mac->rlc_buffer_state(rnti, 0, 10000, 0); + } + int ret = mac->get_dl_sched(slot_cfg, dl_sched); for (pdsch_t& pdsch : dl_sched.pdsch) {