From 2edecea33ed515c19877a8ae2bb2eb30bbfd8104 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 6 Mar 2020 17:58:26 +0100 Subject: [PATCH] fix SIB transmission for CA Avoid double buffering of SIBs in MAC as this would require one buffer for each CC. Instead, use byte_buffer managed by RRC that contains packed SIBs to avoid double memcpy for each SIB tx. Only use MAC provided buffer in error case. Also avoid MAC calling RLC for each SIB and call RRC directly. --- lib/include/srslte/interfaces/enb_interfaces.h | 5 +++-- srsenb/hdr/stack/mac/mac.h | 5 +++-- srsenb/hdr/stack/rrc/rrc.h | 2 +- srsenb/hdr/stack/upper/rlc.h | 1 - srsenb/src/stack/mac/mac.cc | 10 +++++++--- srsenb/src/stack/rrc/rrc.cc | 5 +++-- srsenb/src/stack/upper/rlc.cc | 6 ------ 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index 2c80229b4..09cf6fe5c 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -296,7 +296,6 @@ public: * Segmentation happens in this function. RLC PDU is stored in payload. */ virtual int read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) = 0; - virtual void read_pdu_bcch_dlsch(const uint8_t cc_idx, const uint32_t sib_index, uint8_t* payload) = 0; virtual void read_pdu_pcch(uint8_t* payload, uint32_t buffer_size) = 0; /* MAC calls RLC to push an RLC PDU. This function is called from an independent MAC thread. @@ -371,7 +370,6 @@ public: class rrc_interface_rlc { public: - virtual void read_pdu_bcch_dlsch(const uint8_t cc_idx, const uint32_t sib_index, uint8_t* payload) = 0; virtual void read_pdu_pcch(uint8_t* payload, uint32_t payload_size) = 0; virtual void max_retx_attempted(uint16_t rnti) = 0; virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; @@ -387,6 +385,9 @@ public: virtual void upd_user(uint16_t new_rnti, uint16_t old_rnti) = 0; virtual void set_activity_user(uint16_t rnti) = 0; virtual bool is_paging_opportunity(uint32_t tti, uint32_t* payload_len) = 0; + + ///< Provide packed SIB to MAC (buffer is managed by RRC) + virtual uint8_t* read_pdu_bcch_dlsch(const uint8_t cc_idx, const uint32_t sib_index) = 0; }; // SCell configuration diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index d84f0741e..617de5b95 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -143,8 +143,9 @@ private: std::vector rar_pdu_msg; srslte::byte_buffer_t rar_payload[sched_interface::MAX_RAR_LIST]; - const static int NOF_BCCH_DLSCH_MSG = sched_interface::MAX_SIBS; - uint8_t bcch_dlsch_payload[sched_interface::MAX_SIB_PAYLOAD_LEN] = {}; + const static int NOF_BCCH_DLSCH_MSG = sched_interface::MAX_SIBS; + ///< Backup buffer if RRC can't provide valid SIB + uint8_t bcch_dlsch_payload[sched_interface::MAX_SIB_PAYLOAD_LEN] = {}; const static int pcch_payload_buffer_len = 1024; uint8_t pcch_payload_buffer[pcch_payload_buffer_len] = {}; diff --git a/srsenb/hdr/stack/rrc/rrc.h b/srsenb/hdr/stack/rrc/rrc.h index 245a4b355..223030135 100644 --- a/srsenb/hdr/stack/rrc/rrc.h +++ b/srsenb/hdr/stack/rrc/rrc.h @@ -146,9 +146,9 @@ public: void upd_user(uint16_t new_rnti, uint16_t old_rnti) override; void set_activity_user(uint16_t rnti) override; bool is_paging_opportunity(uint32_t tti, uint32_t* payload_len) override; + uint8_t* read_pdu_bcch_dlsch(const uint8_t cc_idx, const uint32_t sib_index) override; // rrc_interface_rlc - void read_pdu_bcch_dlsch(const uint8_t cc_idx, const uint32_t sib_index, uint8_t* payload) override; void read_pdu_pcch(uint8_t* payload, uint32_t buffer_size) override; void max_retx_attempted(uint16_t rnti) override; diff --git a/srsenb/hdr/stack/upper/rlc.h b/srsenb/hdr/stack/upper/rlc.h index 6d22b887b..c0c11ef28 100644 --- a/srsenb/hdr/stack/upper/rlc.h +++ b/srsenb/hdr/stack/upper/rlc.h @@ -64,7 +64,6 @@ public: // rlc_interface_mac int read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes); - void read_pdu_bcch_dlsch(const uint8_t cc_idx, const uint32_t sib_index, uint8_t* payload); void write_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes); void read_pdu_pcch(uint8_t* payload, uint32_t buffer_size); diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 6d150ec81..6e07cdf45 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -739,10 +739,14 @@ uint8_t* mac::assemble_rar(sched_interface::dl_sched_rar_grant_t* grants, } } -uint8_t* mac::assemble_si(const uint8_t cc_idx, const uint32_t index) +uint8_t* mac::assemble_si(const uint8_t cc_idx, const uint32_t sib_index) { - rlc_h->read_pdu_bcch_dlsch(cc_idx, index, bcch_dlsch_payload); - return bcch_dlsch_payload; + uint8_t* sib_payload = rrc_h->read_pdu_bcch_dlsch(cc_idx, sib_index); + if (sib_payload == nullptr) { + // return MAC managed dummy buffer in this case + sib_payload = bcch_dlsch_payload; + } + return sib_payload; } int mac::get_ul_sched(uint32_t tti, ul_sched_list_t& ul_sched_res_list) diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 440c64cbe..d0d6fa451 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -126,11 +126,12 @@ void rrc::get_metrics(rrc_metrics_t& m) to the queue and process later *******************************************************************************/ -void rrc::read_pdu_bcch_dlsch(const uint8_t cc_idx, const uint32_t sib_index, uint8_t* payload) +uint8_t* rrc::read_pdu_bcch_dlsch(const uint8_t cc_idx, const uint32_t sib_index) { if (sib_index < ASN1_RRC_MAX_SIB && cc_idx < sib_buffer.size()) { - memcpy(payload, sib_buffer.at(cc_idx).at(sib_index)->msg, sib_buffer.at(cc_idx).at(sib_index)->N_bytes); + return sib_buffer.at(cc_idx).at(sib_index)->msg; } + return nullptr; } void rrc::rl_failure(uint16_t rnti) diff --git a/srsenb/src/stack/upper/rlc.cc b/srsenb/src/stack/upper/rlc.cc index 13d131011..a998fb9ab 100644 --- a/srsenb/src/stack/upper/rlc.cc +++ b/srsenb/src/stack/upper/rlc.cc @@ -193,12 +193,6 @@ void rlc::write_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof pthread_rwlock_unlock(&rwlock); } -void rlc::read_pdu_bcch_dlsch(const uint8_t cc_idx, const uint32_t sib_index, uint8_t* payload) -{ - // RLC is transparent for BCCH - rrc->read_pdu_bcch_dlsch(cc_idx, sib_index, payload); -} - void rlc::write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) { uint32_t tx_queue;