From 19918d9a678f3e0c6457e0f316fd0d30dee8198b Mon Sep 17 00:00:00 2001 From: yagoda Date: Thu, 8 Sep 2022 13:07:57 +0200 Subject: [PATCH] phy,mac,mbms: moving payload buffer from MAC to PHY to avoid thread clashes --- .../srsran/interfaces/ue_mac_interfaces.h | 5 +---- srsue/hdr/phy/lte/cc_worker.h | 15 +++++++++------ srsue/hdr/stack/mac/mac.h | 3 +-- srsue/hdr/stack/ue_stack_lte.h | 7 +------ srsue/src/phy/lte/cc_worker.cc | 15 +++++++++++++-- srsue/src/phy/test/ue_phy_test.cc | 3 +-- srsue/src/stack/mac/mac.cc | 18 ++++-------------- 7 files changed, 30 insertions(+), 36 deletions(-) diff --git a/lib/include/srsran/interfaces/ue_mac_interfaces.h b/lib/include/srsran/interfaces/ue_mac_interfaces.h index 972e31eaa..e0ff9995c 100644 --- a/lib/include/srsran/interfaces/ue_mac_interfaces.h +++ b/lib/include/srsran/interfaces/ue_mac_interfaces.h @@ -94,10 +94,7 @@ public: virtual void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) = 0; /* Indicate successful decoding of MCH TB through PMCH */ - virtual void mch_decoded(uint32_t len, bool crc) = 0; - - /* Obtain action for a new MCH subframe. */ - virtual void new_mch_dl(const srsran_pdsch_grant_t& phy_grant, tb_action_dl_t* action) = 0; + virtual void mch_decoded(uint32_t len, bool crc, uint8_t* payload) = 0; /* Communicate the number of mbsfn services available */ virtual void set_mbsfn_config(uint32_t nof_mbsfn_services) = 0; diff --git a/srsue/hdr/phy/lte/cc_worker.h b/srsue/hdr/phy/lte/cc_worker.h index de43e534f..4500ccfce 100644 --- a/srsue/hdr/phy/lte/cc_worker.h +++ b/srsue/hdr/phy/lte/cc_worker.h @@ -75,7 +75,7 @@ private: mac_interface_phy_lte::tb_action_dl_t* action, bool acks[SRSRAN_MAX_CODEWORDS]); int decode_pmch(mac_interface_phy_lte::tb_action_dl_t* action, srsran_mbsfn_cfg_t* mbsfn_cfg); - + void new_mch_dl(mac_interface_phy_lte::tb_action_dl_t*); /* Methods for UL */ bool encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srsran_uci_data_t* uci_data); void set_uci_sr(srsran_uci_data_t* uci_data); @@ -91,11 +91,14 @@ private: srsran_dl_sf_cfg_t sf_cfg_dl = {}; srsran_ul_sf_cfg_t sf_cfg_ul = {}; - uint32_t cc_idx = 0; - bool cell_initiated = false; - cf_t* signal_buffer_rx[SRSRAN_MAX_PORTS] = {}; - cf_t* signal_buffer_tx[SRSRAN_MAX_PORTS] = {}; - uint32_t signal_buffer_max_samples = 0; + uint32_t cc_idx = 0; + bool cell_initiated = false; + cf_t* signal_buffer_rx[SRSRAN_MAX_PORTS] = {}; + cf_t* signal_buffer_tx[SRSRAN_MAX_PORTS] = {}; + uint32_t signal_buffer_max_samples = 0; + const static uint32_t mch_payload_buffer_sz = SRSRAN_MAX_BUFFER_SIZE_BYTES; + uint8_t mch_payload_buffer[mch_payload_buffer_sz]; + srsran_softbuffer_rx_t mch_softbuffer; /* Objects for DL */ srsran_ue_dl_t ue_dl = {}; diff --git a/srsue/hdr/stack/mac/mac.h b/srsue/hdr/stack/mac/mac.h index 554958702..c38f66d05 100644 --- a/srsue/hdr/stack/mac/mac.h +++ b/srsue/hdr/stack/mac/mac.h @@ -50,13 +50,12 @@ public: /* see mac_interface.h for comments */ void new_grant_ul(uint32_t cc_idx, mac_grant_ul_t grant, tb_action_ul_t* action); void new_grant_dl(uint32_t cc_idx, mac_grant_dl_t grant, tb_action_dl_t* action); - void new_mch_dl(const srsran_pdsch_grant_t& phy_grant, tb_action_dl_t* action); void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSRAN_MAX_CODEWORDS]); void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len); uint16_t get_dl_sched_rnti(uint32_t tti); uint16_t get_ul_sched_rnti(uint32_t tti); - void mch_decoded(uint32_t len, bool crc); + void mch_decoded(uint32_t len, bool crc, uint8_t* payload); void process_mch_pdu(uint32_t len); void set_mbsfn_config(uint32_t nof_mbsfn_services); diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index 199de428d..24bc6d00a 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -136,12 +136,7 @@ public: mac.bch_decoded_ok(cc_idx, payload, len); } - void mch_decoded(uint32_t len, bool crc) final { mac.mch_decoded(len, crc); } - - void new_mch_dl(const srsran_pdsch_grant_t& phy_grant, mac_interface_phy_lte::tb_action_dl_t* action) final - { - mac.new_mch_dl(phy_grant, action); - } + void mch_decoded(uint32_t len, bool crc, uint8_t* payload) final { mac.mch_decoded(len, crc, payload); } void set_mbsfn_config(uint32_t nof_mbsfn_services) final { mac.set_mbsfn_config(nof_mbsfn_services); } diff --git a/srsue/src/phy/lte/cc_worker.cc b/srsue/src/phy/lte/cc_worker.cc index f7087c00d..5526a0e08 100644 --- a/srsue/src/phy/lte/cc_worker.cc +++ b/srsue/src/phy/lte/cc_worker.cc @@ -92,6 +92,7 @@ cc_worker::cc_worker(uint32_t cc_idx_, uint32_t max_prb, srsue::phy_common* phy_ chest_default_cfg = ue_dl_cfg.chest_cfg; + srsran_softbuffer_rx_init(&mch_softbuffer, 100); // Set default PHY params reset(); @@ -111,6 +112,7 @@ cc_worker::~cc_worker() free(signal_buffer_rx[i]); } } + srsran_softbuffer_rx_free(&mch_softbuffer); srsran_ue_dl_free(&ue_dl); srsran_ue_ul_free(&ue_ul); } @@ -344,12 +346,12 @@ bool cc_worker::work_dl_mbsfn(srsran_mbsfn_cfg_t mbsfn_cfg) srsran_ra_dl_compute_nof_re(&cell, &sf_cfg_dl, &pmch_cfg.pdsch_cfg.grant); // Send grant to MAC and get action for this TB, then call tb_decoded to unlock MAC - phy->stack->new_mch_dl(pmch_cfg.pdsch_cfg.grant, &dl_action); + new_mch_dl(&dl_action); bool mch_decoded = true; if (!decode_pmch(&dl_action, &mbsfn_cfg)) { mch_decoded = false; } - phy->stack->mch_decoded((uint32_t)pmch_cfg.pdsch_cfg.grant.tb[0].tbs / 8, mch_decoded); + phy->stack->mch_decoded((uint32_t)pmch_cfg.pdsch_cfg.grant.tb[0].tbs / 8, mch_decoded, mch_payload_buffer); } else if (mbsfn_cfg.is_mcch) { // release lock in phy_common phy->set_mch_period_stop(0); @@ -920,5 +922,14 @@ int cc_worker::read_pdsch_d(cf_t* pdsch_d) return ue_dl_cfg.cfg.pdsch.grant.nof_re; } +void cc_worker::new_mch_dl(mac_interface_phy_lte::tb_action_dl_t* action) +{ + action->generate_ack = false; + action->tb[0].enabled = true; + action->tb[0].payload = mch_payload_buffer; + action->tb[0].softbuffer.rx = &mch_softbuffer; + srsran_softbuffer_rx_reset_cb(&mch_softbuffer, 1); +} + } // namespace lte } // namespace srsue diff --git a/srsue/src/phy/test/ue_phy_test.cc b/srsue/src/phy/test/ue_phy_test.cc index 6bcc6b790..7ed584f78 100644 --- a/srsue/src/phy/test/ue_phy_test.cc +++ b/srsue/src/phy/test/ue_phy_test.cc @@ -102,8 +102,7 @@ private: } void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool* ack) override {} void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) override {} - void mch_decoded(uint32_t len, bool crc) override {} - void new_mch_dl(const srsran_pdsch_grant_t& phy_grant, tb_action_dl_t* action) override {} + void mch_decoded(uint32_t len, bool crc, uint8_t* payload) override {} void set_mbsfn_config(uint32_t nof_mbsfn_services) override {} void run_tti(const uint32_t tti, const uint32_t tti_jump) override { diff --git a/srsue/src/stack/mac/mac.cc b/srsue/src/stack/mac/mac.cc index 4f2edcd7f..4c0e03f09 100644 --- a/srsue/src/stack/mac/mac.cc +++ b/srsue/src/stack/mac/mac.cc @@ -41,7 +41,6 @@ mac::mac(const char* logname, ext_task_sched_handle task_sched_) : dl_harq.at(PCELL_CC_IDX) = dl_harq_entity_ptr(new dl_harq_entity(PCELL_CC_IDX)); srsran_softbuffer_rx_init(&pch_softbuffer, 100); - srsran_softbuffer_rx_init(&mch_softbuffer, 100); // Keep initialising members bzero(&metrics, sizeof(mac_metrics_t)); @@ -53,7 +52,6 @@ mac::~mac() stop(); srsran_softbuffer_rx_free(&pch_softbuffer); - srsran_softbuffer_rx_free(&mch_softbuffer); } bool mac::init(phy_interface_mac_lte* phy, rlc_interface_mac* rlc, rrc_interface_mac* rrc) @@ -324,12 +322,12 @@ void mac::bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) } } -void mac::mch_decoded(uint32_t len, bool crc) +void mac::mch_decoded(uint32_t len, bool crc, uint8_t* payload) { // Parse MAC header if (crc) { mch_msg.init_rx(len); - mch_msg.parse_packet(mch_payload_buffer); + mch_msg.parse_packet(payload); while (mch_msg.next()) { for (uint32_t i = 0; i < phy_mbsfn_cfg.nof_mbsfn_services; i++) { if (srsran::mch_lcid::MCH_SCHED_INFO == mch_msg.get()->mch_ce_type()) { @@ -343,11 +341,11 @@ void mac::mch_decoded(uint32_t len, bool crc) } } - demux_unit.push_pdu_mch(mch_payload_buffer, len); + demux_unit.push_pdu_mch(payload, len); process_pdus(); if (pcap) { - pcap->write_dl_mch(mch_payload_buffer, len, true, phy_h->get_current_tti(), 0); + pcap->write_dl_mch(payload, len, true, phy_h->get_current_tti(), 0); } std::lock_guard lock(metrics_mutex); @@ -521,14 +519,6 @@ void mac::new_grant_ul(uint32_t cc_idx, } // end of holding metrics mutex } -void mac::new_mch_dl(const srsran_pdsch_grant_t& phy_grant, tb_action_dl_t* action) -{ - action->generate_ack = false; - action->tb[0].enabled = true; - action->tb[0].payload = mch_payload_buffer; - action->tb[0].softbuffer.rx = &mch_softbuffer; - srsran_softbuffer_rx_reset_cb(&mch_softbuffer, 1); -} void mac::setup_timers(int time_alignment_timer) {