From c03623863bdab59138f84320c974bbf27a84c37d Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 4 Aug 2021 18:51:47 +0200 Subject: [PATCH] enb,nsa: fix UL PDU processing * remove const from pusch_info() MAC/PHY interface to allow moving unique byte buffer --- lib/include/srsran/interfaces/gnb_interfaces.h | 2 +- srsenb/hdr/stack/enb_stack_lte.h | 2 +- srsenb/hdr/stack/gnb_stack_nr.h | 2 +- srsenb/hdr/stack/mac/mac_nr.h | 2 +- srsenb/src/phy/nr/slot_worker.cc | 2 ++ srsenb/src/stack/gnb_stack_nr.cc | 2 +- srsenb/src/stack/mac/nr/mac_nr.cc | 13 ++++++++----- test/phy/dummy_gnb_stack.h | 2 +- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/include/srsran/interfaces/gnb_interfaces.h b/lib/include/srsran/interfaces/gnb_interfaces.h index 9de1488a2..461377521 100644 --- a/lib/include/srsran/interfaces/gnb_interfaces.h +++ b/lib/include/srsran/interfaces/gnb_interfaces.h @@ -296,7 +296,7 @@ public: virtual int get_dl_sched(const srsran_slot_cfg_t& slot_cfg, dl_sched_t& dl_sched) = 0; virtual int get_ul_sched(const srsran_slot_cfg_t& slot_cfg, ul_sched_t& ul_sched) = 0; virtual int pucch_info(const srsran_slot_cfg_t& slot_cfg, const pucch_info_t& pucch_info) = 0; - virtual int pusch_info(const srsran_slot_cfg_t& slot_cfg, const pusch_info_t& pusch_info) = 0; + virtual int pusch_info(const srsran_slot_cfg_t& slot_cfg, pusch_info_t& pusch_info) = 0; virtual void rach_detected(const rach_info_t& rach_info) = 0; }; diff --git a/srsenb/hdr/stack/enb_stack_lte.h b/srsenb/hdr/stack/enb_stack_lte.h index b6b1a97f9..925c64f5e 100644 --- a/srsenb/hdr/stack/enb_stack_lte.h +++ b/srsenb/hdr/stack/enb_stack_lte.h @@ -126,7 +126,7 @@ public: { return mac_nr.pucch_info(slot_cfg, pucch_info); } - int pusch_info(const srsran_slot_cfg_t& slot_cfg, const pusch_info_t& pusch_info) override + int pusch_info(const srsran_slot_cfg_t& slot_cfg, pusch_info_t& pusch_info) override { return mac_nr.pusch_info(slot_cfg, pusch_info); } diff --git a/srsenb/hdr/stack/gnb_stack_nr.h b/srsenb/hdr/stack/gnb_stack_nr.h index acfc4ec16..0fcdc8534 100644 --- a/srsenb/hdr/stack/gnb_stack_nr.h +++ b/srsenb/hdr/stack/gnb_stack_nr.h @@ -73,7 +73,7 @@ public: 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; int pucch_info(const srsran_slot_cfg_t& slot_cfg, const pucch_info_t& pucch_info) override; - int pusch_info(const srsran_slot_cfg_t& slot_cfg, const pusch_info_t& pusch_info) override; + int pusch_info(const srsran_slot_cfg_t& slot_cfg, pusch_info_t& pusch_info) override; void rach_detected(const rach_info_t& rach_info) override; private: diff --git a/srsenb/hdr/stack/mac/mac_nr.h b/srsenb/hdr/stack/mac/mac_nr.h index cb9ff73da..006545dec 100644 --- a/srsenb/hdr/stack/mac/mac_nr.h +++ b/srsenb/hdr/stack/mac/mac_nr.h @@ -64,7 +64,7 @@ public: 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; int pucch_info(const srsran_slot_cfg_t& slot_cfg, const pucch_info_t& pucch_info) override; - int pusch_info(const srsran_slot_cfg_t& slot_cfg, const pusch_info_t& pusch_info) override; + int pusch_info(const srsran_slot_cfg_t& slot_cfg, pusch_info_t& pusch_info) override; void rach_detected(const rach_info_t& rach_info) override; private: diff --git a/srsenb/src/phy/nr/slot_worker.cc b/srsenb/src/phy/nr/slot_worker.cc index 04f1dcf88..5b47b306c 100644 --- a/srsenb/src/phy/nr/slot_worker.cc +++ b/srsenb/src/phy/nr/slot_worker.cc @@ -206,11 +206,13 @@ bool slot_worker::work_ul() stack_interface_phy_nr::pusch_info_t pusch_info = {}; pusch_info.uci_cfg = pusch.sch.uci; pusch_info.pid = pusch.pid; + pusch_info.rnti = pusch.sch.grant.rnti; pusch_info.pdu = srsran::make_byte_buffer(); if (pusch_info.pdu == nullptr) { logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return false; } + pusch_info.pdu->N_bytes = pusch.sch.grant.tb[0].tbs; pusch_info.pusch_data.tb[0].payload = pusch_info.pdu->data(); // Decode PUSCH diff --git a/srsenb/src/stack/gnb_stack_nr.cc b/srsenb/src/stack/gnb_stack_nr.cc index 679330057..205aed2a4 100644 --- a/srsenb/src/stack/gnb_stack_nr.cc +++ b/srsenb/src/stack/gnb_stack_nr.cc @@ -175,7 +175,7 @@ int gnb_stack_nr::pucch_info(const srsran_slot_cfg_t& slot_cfg, const mac_interf { return m_mac->pucch_info(slot_cfg, pucch_info); } -int gnb_stack_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, const mac_interface_phy_nr::pusch_info_t& pusch_info) +int gnb_stack_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, mac_interface_phy_nr::pusch_info_t& pusch_info) { return m_mac->pusch_info(slot_cfg, pusch_info); } diff --git a/srsenb/src/stack/mac/nr/mac_nr.cc b/srsenb/src/stack/mac/nr/mac_nr.cc index 843f63250..371118dad 100644 --- a/srsenb/src/stack/mac/nr/mac_nr.cc +++ b/srsenb/src/stack/mac/nr/mac_nr.cc @@ -320,7 +320,7 @@ bool mac_nr::handle_uci_data(const uint16_t rnti, const srsran_uci_cfg_nr_t& cfg return true; } -int mac_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, const mac_interface_phy_nr::pusch_info_t& pusch_info) +int mac_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, mac_interface_phy_nr::pusch_info_t& pusch_info) { uint16_t rnti = pusch_info.rnti; @@ -332,9 +332,12 @@ int mac_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, const mac_interface_ph sched.ul_crc_info(rnti, 0, pusch_info.pid, pusch_info.pusch_data.tb[0].crc); - // FIXME: move PDU from PHY - srsran::unique_byte_buffer_t rx_pdu; - auto process_pdu_task = [this, rnti](srsran::unique_byte_buffer_t& pdu) { + if (pusch_info.pusch_data.tb[0].crc && pcap) { + pcap->write_ul_crnti_nr( + pusch_info.pdu->msg, pusch_info.pdu->N_bytes, pusch_info.rnti, pusch_info.pid, slot_cfg.idx); + } + + auto process_pdu_task = [this, rnti](srsran::unique_byte_buffer_t& pdu) { srsran::rwlock_read_guard lock(rwlock); if (is_rnti_active_unsafe(rnti)) { ue_db[rnti]->process_pdu(std::move(pdu)); @@ -342,7 +345,7 @@ int mac_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, const mac_interface_ph logger.debug("Discarding PDU rnti=0x%x", rnti); } }; - stack_task_queue.try_push(std::bind(process_pdu_task, std::move(rx_pdu))); + stack_task_queue.try_push(std::bind(process_pdu_task, std::move(pusch_info.pdu))); return SRSRAN_SUCCESS; } diff --git a/test/phy/dummy_gnb_stack.h b/test/phy/dummy_gnb_stack.h index 46abca3ce..75a7ed21a 100644 --- a/test/phy/dummy_gnb_stack.h +++ b/test/phy/dummy_gnb_stack.h @@ -584,7 +584,7 @@ public: return SRSRAN_SUCCESS; } - int pusch_info(const srsran_slot_cfg_t& slot_cfg, const pusch_info_t& pusch_info) override + int pusch_info(const srsran_slot_cfg_t& slot_cfg, pusch_info_t& pusch_info) override { // Handle UCI data if (not handle_uci_data(pusch_info.uci_cfg, pusch_info.pusch_data.uci)) {