rlc interface: convert entire read_pdu() interface to return uint32_t

we had it returning int but had a bug in using the return value properly,
i.e. handling when -1 was returned in RLC TM.

Thinking about it more, it doesn't make sense to have a negative return
value here anyway. Either the RLC can return a PDU or not. If it can't the
returned lenght is zero.
master
Andre Puschmann 3 years ago
parent 539ca47fe2
commit c0be8187c8

@ -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

@ -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. */

@ -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 {}

@ -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);

@ -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();

@ -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

@ -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 {}

@ -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<double> 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;

@ -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();

@ -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:

@ -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;

@ -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<std::mutex> lock(mutex);

@ -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();

@ -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;
{

@ -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<std::mutex> lock(mutex);
rlc_umd_pdu_header_t header;

@ -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) {

@ -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);

@ -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);

@ -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);
}

@ -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;

@ -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;

Loading…
Cancel
Save