diff --git a/lib/include/srsran/common/interfaces_common.h b/lib/include/srsran/common/interfaces_common.h index 5997e63b1..ce7996205 100644 --- a/lib/include/srsran/common/interfaces_common.h +++ b/lib/include/srsran/common/interfaces_common.h @@ -77,7 +77,7 @@ public: class read_pdu_interface { public: - virtual int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) = 0; + virtual uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) = 0; }; class stack_interface_phy_nr diff --git a/lib/include/srsran/interfaces/ue_rlc_interfaces.h b/lib/include/srsran/interfaces/ue_rlc_interfaces.h index c7f05dd42..4c6452138 100644 --- a/lib/include/srsran/interfaces/ue_rlc_interfaces.h +++ b/lib/include/srsran/interfaces/ue_rlc_interfaces.h @@ -67,7 +67,7 @@ public: /* MAC calls RLC to get RLC segment of nof_bytes length. * Segmentation happens in this function. RLC PDU is stored in payload. */ - virtual int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) = 0; + virtual uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) = 0; /* MAC calls RLC to push an RLC PDU. This function is called from an independent MAC thread. * PDU gets placed into the buffer and higher layer thread gets notified. */ diff --git a/lib/include/srsran/test/ue_test_interfaces.h b/lib/include/srsran/test/ue_test_interfaces.h index 4263eb6b8..0b7ad541f 100644 --- a/lib/include/srsran/test/ue_test_interfaces.h +++ b/lib/include/srsran/test/ue_test_interfaces.h @@ -50,7 +50,7 @@ class rlc_dummy_interface : public rlc_interface_mac public: bool has_data_locked(const uint32_t lcid) override { return false; } uint32_t get_buffer_state(const uint32_t lcid) override { return 0; } - int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) override { return 0; } + uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) override { return 0; } void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) override {} void write_pdu_bcch_bch(srsran::unique_byte_buffer_t payload) override {} void write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes) override {} diff --git a/lib/include/srsran/upper/rlc.h b/lib/include/srsran/upper/rlc.h index 75fff9a98..cb393a26e 100644 --- a/lib/include/srsran/upper/rlc.h +++ b/lib/include/srsran/upper/rlc.h @@ -66,8 +66,8 @@ public: bool has_data_locked(const uint32_t lcid); uint32_t get_buffer_state(const uint32_t lcid); uint32_t get_total_mch_buffer_state(uint32_t lcid); - int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes); - int read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes); + uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes); + uint32_t read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes); int get_increment_sequence_num(); void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes); void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu); diff --git a/lib/include/srsran/upper/rlc_am_lte.h b/lib/include/srsran/upper/rlc_am_lte.h index d5afc0aa4..e3f316b07 100644 --- a/lib/include/srsran/upper/rlc_am_lte.h +++ b/lib/include/srsran/upper/rlc_am_lte.h @@ -345,7 +345,7 @@ public: // MAC interface bool has_data(); uint32_t get_buffer_state(); - int read_pdu(uint8_t* payload, uint32_t nof_bytes); + uint32_t read_pdu(uint8_t* payload, uint32_t nof_bytes); void write_pdu(uint8_t* payload, uint32_t nof_bytes); rlc_bearer_metrics_t get_metrics(); @@ -368,7 +368,7 @@ private: void stop(); int write_sdu(unique_byte_buffer_t sdu); - int read_pdu(uint8_t* payload, uint32_t nof_bytes); + uint32_t read_pdu(uint8_t* payload, uint32_t nof_bytes); void discard_sdu(uint32_t discard_sn); bool sdu_queue_is_full(); diff --git a/lib/include/srsran/upper/rlc_common.h b/lib/include/srsran/upper/rlc_common.h index 44568cec7..fcbbf33e1 100644 --- a/lib/include/srsran/upper/rlc_common.h +++ b/lib/include/srsran/upper/rlc_common.h @@ -274,7 +274,7 @@ public: virtual bool has_data() = 0; bool is_suspended() { return suspended; }; virtual uint32_t get_buffer_state() = 0; - virtual int read_pdu(uint8_t* payload, uint32_t nof_bytes) = 0; + virtual uint32_t read_pdu(uint8_t* payload, uint32_t nof_bytes) = 0; virtual void write_pdu(uint8_t* payload, uint32_t nof_bytes) = 0; virtual void set_bsr_callback(bsr_callback_t callback) = 0; @@ -320,4 +320,5 @@ private: }; } // namespace srsran + #endif // SRSRAN_RLC_COMMON_H diff --git a/lib/include/srsran/upper/rlc_tm.h b/lib/include/srsran/upper/rlc_tm.h index d4890db70..b5db8fd67 100644 --- a/lib/include/srsran/upper/rlc_tm.h +++ b/lib/include/srsran/upper/rlc_tm.h @@ -54,7 +54,7 @@ public: // MAC interface bool has_data() override; uint32_t get_buffer_state() override; - int read_pdu(uint8_t* payload, uint32_t nof_bytes) override; + uint32_t read_pdu(uint8_t* payload, uint32_t nof_bytes) override; void write_pdu(uint8_t* payload, uint32_t nof_bytes) override; void set_bsr_callback(bsr_callback_t callback) override {} diff --git a/lib/include/srsran/upper/rlc_um_base.h b/lib/include/srsran/upper/rlc_um_base.h index 1094b7cff..b17357a38 100644 --- a/lib/include/srsran/upper/rlc_um_base.h +++ b/lib/include/srsran/upper/rlc_um_base.h @@ -58,7 +58,7 @@ public: // MAC interface bool has_data(); uint32_t get_buffer_state(); - int read_pdu(uint8_t* payload, uint32_t nof_bytes); + uint32_t read_pdu(uint8_t* payload, uint32_t nof_bytes); void write_pdu(uint8_t* payload, uint32_t nof_bytes); int get_increment_sequence_num(); @@ -75,7 +75,7 @@ protected: rlc_um_base_tx(rlc_um_base* parent_); virtual ~rlc_um_base_tx(); virtual bool configure(const rlc_config_t& cfg, std::string rb_name) = 0; - int build_data_pdu(uint8_t* payload, uint32_t nof_bytes); + uint32_t build_data_pdu(uint8_t* payload, uint32_t nof_bytes); void stop(); void reestablish(); void empty_queue(); @@ -107,7 +107,7 @@ protected: srsran::rolling_average mean_pdu_latency_us; #endif - virtual int build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes) = 0; + virtual uint32_t build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes) = 0; // helper functions virtual void debug_state() = 0; diff --git a/lib/include/srsran/upper/rlc_um_lte.h b/lib/include/srsran/upper/rlc_um_lte.h index f544c582e..17bf8ccb9 100644 --- a/lib/include/srsran/upper/rlc_um_lte.h +++ b/lib/include/srsran/upper/rlc_um_lte.h @@ -48,7 +48,7 @@ private: rlc_um_lte_tx(rlc_um_base* parent_); bool configure(const rlc_config_t& cfg, std::string rb_name); - int build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes); + uint32_t build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes); uint32_t get_buffer_state(); bool sdu_queue_is_full(); diff --git a/lib/include/srsran/upper/rlc_um_nr.h b/lib/include/srsran/upper/rlc_um_nr.h index 5d01b40d4..6c5e4936e 100644 --- a/lib/include/srsran/upper/rlc_um_nr.h +++ b/lib/include/srsran/upper/rlc_um_nr.h @@ -49,7 +49,7 @@ private: rlc_um_nr_tx(rlc_um_base* parent_); bool configure(const rlc_config_t& cfg, std::string rb_name); - int build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes); + uint32_t build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes); uint32_t get_buffer_state(); private: diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index 76836800e..d24dae789 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -292,7 +292,7 @@ uint32_t rlc::get_total_mch_buffer_state(uint32_t lcid) return ret; } -int rlc::read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) +uint32_t rlc::read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) { uint32_t ret = 0; @@ -309,7 +309,7 @@ int rlc::read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) return ret; } -int rlc::read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) +uint32_t rlc::read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) { uint32_t ret = 0; diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index 8590d0b91..45079e826 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -248,9 +248,9 @@ uint32_t rlc_am_lte::get_buffer_state() return tx.get_buffer_state(); } -int rlc_am_lte::read_pdu(uint8_t* payload, uint32_t nof_bytes) +uint32_t rlc_am_lte::read_pdu(uint8_t* payload, uint32_t nof_bytes) { - int read_bytes = tx.read_pdu(payload, nof_bytes); + uint32_t read_bytes = tx.read_pdu(payload, nof_bytes); metrics.num_tx_pdus++; metrics.num_tx_pdu_bytes += read_bytes; return read_bytes; @@ -533,7 +533,7 @@ bool rlc_am_lte::rlc_am_lte_tx::sdu_queue_is_full() return tx_sdu_queue.is_full(); } -int rlc_am_lte::rlc_am_lte_tx::read_pdu(uint8_t* payload, uint32_t nof_bytes) +uint32_t rlc_am_lte::rlc_am_lte_tx::read_pdu(uint8_t* payload, uint32_t nof_bytes) { std::lock_guard lock(mutex); diff --git a/lib/src/upper/rlc_tm.cc b/lib/src/upper/rlc_tm.cc index e1da8b802..776d2b3cf 100644 --- a/lib/src/upper/rlc_tm.cc +++ b/lib/src/upper/rlc_tm.cc @@ -134,12 +134,12 @@ void rlc_tm::reset_metrics() metrics = {}; } -int rlc_tm::read_pdu(uint8_t* payload, uint32_t nof_bytes) +uint32_t rlc_tm::read_pdu(uint8_t* payload, uint32_t nof_bytes) { uint32_t pdu_size = ul_queue.size_tail_bytes(); if (pdu_size > nof_bytes) { logger.info("%s Tx PDU size larger than MAC opportunity (%d > %d)", rrc->get_rb_name(lcid), pdu_size, nof_bytes); - return -1; + return 0; } unique_byte_buffer_t buf; if (ul_queue.try_read(&buf)) { @@ -171,7 +171,7 @@ int rlc_tm::read_pdu(uint8_t* payload, uint32_t nof_bytes) void rlc_tm::write_pdu(uint8_t* payload, uint32_t nof_bytes) { unique_byte_buffer_t buf = make_byte_buffer(); - if (buf) { + if (buf != nullptr) { memcpy(buf->msg, payload, nof_bytes); buf->N_bytes = nof_bytes; buf->set_timestamp(); diff --git a/lib/src/upper/rlc_um_base.cc b/lib/src/upper/rlc_um_base.cc index 5155ca31e..1ac0d183b 100644 --- a/lib/src/upper/rlc_um_base.cc +++ b/lib/src/upper/rlc_um_base.cc @@ -130,7 +130,7 @@ uint32_t rlc_um_base::get_buffer_state() return 0; } -int rlc_um_base::read_pdu(uint8_t* payload, uint32_t nof_bytes) +uint32_t rlc_um_base::read_pdu(uint8_t* payload, uint32_t nof_bytes) { if (tx && tx_enabled) { uint32_t len = tx->build_data_pdu(payload, nof_bytes); @@ -283,7 +283,7 @@ bool rlc_um_base::rlc_um_base_tx::sdu_queue_is_full() return tx_sdu_queue.is_full(); } -int rlc_um_base::rlc_um_base_tx::build_data_pdu(uint8_t* payload, uint32_t nof_bytes) +uint32_t rlc_um_base::rlc_um_base_tx::build_data_pdu(uint8_t* payload, uint32_t nof_bytes) { unique_byte_buffer_t pdu; { diff --git a/lib/src/upper/rlc_um_lte.cc b/lib/src/upper/rlc_um_lte.cc index 004787c12..cbfe56e4c 100644 --- a/lib/src/upper/rlc_um_lte.cc +++ b/lib/src/upper/rlc_um_lte.cc @@ -109,7 +109,7 @@ bool rlc_um_lte::rlc_um_lte_tx::configure(const rlc_config_t& cnfg_, std::string return true; } -int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes) +uint32_t rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes) { std::lock_guard lock(mutex); rlc_umd_pdu_header_t header; diff --git a/lib/src/upper/rlc_um_nr.cc b/lib/src/upper/rlc_um_nr.cc index 1c88f3aaa..1cf1aa4af 100644 --- a/lib/src/upper/rlc_um_nr.cc +++ b/lib/src/upper/rlc_um_nr.cc @@ -115,7 +115,7 @@ bool rlc_um_nr::rlc_um_nr_tx::configure(const rlc_config_t& cnfg_, std::string r return true; } -int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes) +uint32_t rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes) { // Sanity check (we need at least 2B for a SDU) if (nof_bytes < 2) { diff --git a/lib/test/mac/pdu_test.cc b/lib/test/mac/pdu_test.cc index 13296205b..4f10332f5 100644 --- a/lib/test/mac/pdu_test.cc +++ b/lib/test/mac/pdu_test.cc @@ -169,7 +169,7 @@ int mac_rar_pdu_pack_test2() class rlc_dummy : public srsran::read_pdu_interface { public: - int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) + uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) { uint32_t len = std::min(ul_queues[lcid], nof_bytes); diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index abd30bee2..7e7a945d1 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -175,7 +175,7 @@ public: void metrics_dl_cqi(uint32_t dl_cqi); void metrics_cnt(); - int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) final; + uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) final; private: void allocate_sdu(srsran::sch_pdu* pdu, uint32_t lcid, uint32_t sdu_len); diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 20435213a..0bc539178 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -503,7 +503,7 @@ bool ue::process_ce(srsran::sch_subh* subh, int grant_nof_prbs) return is_bsr; } -int ue::read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) +uint32_t ue::read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) { return rlc->read_pdu(rnti, lcid, payload, requested_bytes); } diff --git a/srsue/src/stack/mac_nr/test/mac_nr_test.cc b/srsue/src/stack/mac_nr/test/mac_nr_test.cc index ad685e63e..315581f92 100644 --- a/srsue/src/stack/mac_nr/test/mac_nr_test.cc +++ b/srsue/src/stack/mac_nr/test/mac_nr_test.cc @@ -92,7 +92,7 @@ public: rlc_dummy() : received_bytes(0) {} bool has_data_locked(const uint32_t lcid) final { return ul_queues[lcid] > 0; } uint32_t get_buffer_state(const uint32_t lcid) final { return ul_queues[lcid]; } - int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) final + uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) final { if (!read_enable || nof_bytes < read_min) { return 0; diff --git a/srsue/test/mac_test.cc b/srsue/test/mac_test.cc index 9d2b65b13..ba81533fe 100644 --- a/srsue/test/mac_test.cc +++ b/srsue/test/mac_test.cc @@ -37,7 +37,7 @@ public: rlc_dummy() : received_bytes(0) {} bool has_data_locked(const uint32_t lcid) final { return ul_queues[lcid] > 0; } uint32_t get_buffer_state(const uint32_t lcid) final { return ul_queues[lcid]; } - int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) final + uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) final { if (!read_enable || nof_bytes < read_min) { return 0;