updated mac-rlc interface to use unique_byte_buffer

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent 7d7ac01fb4
commit 46a1be3e76

@ -35,6 +35,7 @@
#include "srslte/asn1/liblte_mme.h"
#include "srslte/common/common.h"
#include "srslte/common/interfaces_common.h"
#include "srslte/common/multiqueue.h"
#include "srslte/common/security.h"
#include "srslte/common/stack_procedure.h"
#include "srslte/common/tti_point.h"
@ -296,9 +297,9 @@ public:
/* 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. */
virtual void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) = 0;
virtual void write_pdu_bcch_bch(uint8_t* payload, uint32_t nof_bytes) = 0;
virtual void write_pdu_bcch_bch(srslte::unique_byte_buffer_t payload) = 0;
virtual void write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes) = 0;
virtual void write_pdu_pcch(uint8_t* payload, uint32_t nof_bytes) = 0;
virtual void write_pdu_pcch(srslte::unique_byte_buffer_t payload) = 0;
virtual void write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) = 0;
};

@ -65,9 +65,9 @@ public:
int 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(uint8_t* payload, uint32_t nof_bytes);
void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu);
void write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes);
void write_pdu_pcch(uint8_t* payload, uint32_t nof_bytes);
void write_pdu_pcch(srslte::unique_byte_buffer_t pdu);
void write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
// RRC interface

@ -346,18 +346,10 @@ void rlc::write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
}
// Pass directly to PDCP, no DL througput counting done
void rlc::write_pdu_bcch_bch(uint8_t* payload, uint32_t nof_bytes)
void rlc::write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu)
{
rlc_log->info_hex(payload, nof_bytes, "BCCH BCH message received.");
unique_byte_buffer_t buf = allocate_unique_buffer(*pool);
if (buf != NULL) {
memcpy(buf->msg, payload, nof_bytes);
buf->N_bytes = nof_bytes;
buf->set_timestamp();
pdcp->write_pdu_bcch_bch(std::move(buf));
} else {
rlc_log->error("Fatal error: Out of buffers from the pool in write_pdu_bcch_bch()\n");
}
rlc_log->info_hex(pdu->msg, pdu->N_bytes, "BCCH BCH message received.");
pdcp->write_pdu_bcch_bch(std::move(pdu));
}
// Pass directly to PDCP, no DL througput counting done
@ -376,18 +368,10 @@ void rlc::write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes)
}
// Pass directly to PDCP, no DL througput counting done
void rlc::write_pdu_pcch(uint8_t* payload, uint32_t nof_bytes)
void rlc::write_pdu_pcch(srslte::unique_byte_buffer_t pdu)
{
rlc_log->info_hex(payload, nof_bytes, "PCCH message received.");
unique_byte_buffer_t buf = allocate_unique_buffer(*pool);
if (buf != NULL) {
memcpy(buf->msg, payload, nof_bytes);
buf->N_bytes = nof_bytes;
buf->set_timestamp();
pdcp->write_pdu_pcch(std::move(buf));
} else {
rlc_log->error("Fatal error: Out of buffers from the pool in write_pdu_pcch()\n");
}
rlc_log->info_hex(pdu->msg, pdu->N_bytes, "PCCH message received.");
pdcp->write_pdu_pcch(std::move(pdu));
}
void rlc::write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)

@ -171,6 +171,9 @@ private:
void timer_alignment_expire();
srslte::timer_handler* timers = nullptr;
/* Queue to dispatch stack tasks */
srslte::byte_buffer_pool* pool = nullptr;
// pointer to MAC PCAP object
srslte::mac_pcap* pcap = nullptr;
bool is_first_ul_grant = false;

@ -57,6 +57,8 @@ mac::mac(const char* logname) :
srslte_softbuffer_rx_init(&pch_softbuffer, 100);
srslte_softbuffer_rx_init(&mch_softbuffer, 100);
pool = srslte::byte_buffer_pool::get_instance();
// Keep initialising members
bzero(&metrics, sizeof(mac_metrics_t));
clear_rntis();
@ -370,7 +372,15 @@ uint16_t mac::get_dl_sched_rnti(uint32_t tti)
void mac::bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len)
{
// Send MIB to RLC
rlc_h->write_pdu_bcch_bch(payload, len);
unique_byte_buffer_t buf = allocate_unique_buffer(*pool);
if (buf != nullptr) {
memcpy(buf->msg, payload, len);
buf->N_bytes = len;
buf->set_timestamp();
rlc_h->write_pdu_bcch_bch(std::move(buf));
} else {
log_h->error("Fatal error: Out of buffers from the pool in write_pdu_bcch_bch()\n");
}
if (pcap) {
pcap->write_dl_bch(payload, len, true, phy_h->get_current_tti(), cc_idx);
@ -416,7 +426,15 @@ void mac::tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_
}
} else if (grant.rnti == SRSLTE_PRNTI) {
// Send PCH payload to RLC
rlc_h->write_pdu_pcch(pch_payload_buffer, grant.tb[0].tbs);
unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool);
if (pdu != nullptr) {
memcpy(pdu->msg, pch_payload_buffer, grant.tb[0].tbs);
pdu->N_bytes = grant.tb[0].tbs;
pdu->set_timestamp();
rlc_h->write_pdu_pcch(std::move(pdu));
} else {
log_h->error("Fatal error: Out of buffers from the pool in write_pdu_pcch()\n");
}
if (pcap) {
pcap->write_dl_pch(pch_payload_buffer, grant.tb[0].tbs, true, grant.tti, cc_idx);

@ -26,7 +26,7 @@
namespace srsue {
class stack_dummy : public stack_interface_rrc
class stack_dummy_interface : public stack_interface_rrc
{
public:
srslte::timer_handler::unique_timer get_unique_timer() override { return timers.get_unique_timer(); }
@ -35,6 +35,20 @@ public:
srslte::tti_point get_current_tti() override { return srslte::tti_point{timers.get_cur_time() % 10240}; }
srslte::timer_handler timers{100};
srslte::task_multiqueue pending_tasks;
};
class rlc_dummy_interface : public rlc_interface_mac
{
public:
bool has_data(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; }
void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) override {}
void write_pdu_bcch_bch(srslte::unique_byte_buffer_t payload) override {}
void write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes) override {}
void write_pdu_pcch(srslte::unique_byte_buffer_t payload) override {}
void write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) override {}
};
} // namespace srsue

@ -26,6 +26,7 @@
#include "srslte/interfaces/ue_interfaces.h"
#include "srsue/hdr/stack/mac/mac.h"
#include "srsue/hdr/stack/mac/mux.h"
#include "srsue/test/common/dummy_classes.h"
#include <assert.h>
#include <iostream>
#include <string.h>
@ -50,13 +51,13 @@ srslte::log_ref mac_log{"MAC"};
namespace srslte {
// fake classes
class rlc_dummy : public srsue::rlc_interface_mac
class rlc_dummy : public srsue::rlc_dummy_interface
{
public:
rlc_dummy(srslte::log_filter* log_) : received_bytes(0), log(log_) {}
bool has_data(const uint32_t lcid) { return ul_queues[lcid] > 0; }
uint32_t get_buffer_state(const uint32_t lcid) { return ul_queues[lcid]; }
int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
bool has_data(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
{
if (!read_enable) {
return 0;
@ -71,17 +72,13 @@ public:
return len;
};
void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) final
{
log->debug_hex(payload, nof_bytes, "Received %d B on LCID %d\n", nof_bytes, lcid);
received_bytes += nof_bytes;
};
}
void write_sdu(uint32_t lcid, uint32_t nof_bytes) { ul_queues[lcid] += nof_bytes; }
void write_pdu_bcch_bch(uint8_t* payload, uint32_t nof_bytes){};
void write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes){};
void write_pdu_pcch(uint8_t* payload, uint32_t nof_bytes){};
void write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes){};
uint32_t get_received_bytes() { return received_bytes; }
void disable_read() { read_enable = false; }
@ -99,7 +96,7 @@ class phy_dummy : public phy_interface_mac_lte
public:
phy_dummy() : scell_cmd(0){};
void set_log(srslte::log* log_h) { this->log_h = log_h; }
void set_log(srslte::log* log_h_) { log_h = log_h_; }
void reset()
{
last_preamble_idx = 0;

@ -141,7 +141,7 @@ private:
bool is_connected_flag = false;
};
class test_stack_dummy : public srsue::stack_dummy, public stack_interface_gw, public thread
class test_stack_dummy : public srsue::stack_dummy_interface, public stack_interface_gw, public thread
{
public:
test_stack_dummy(pdcp_interface_gw* pdcp_) : pdcp(pdcp_), thread("DUMMY STACK") {}
@ -210,7 +210,7 @@ int security_command_test()
rrc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log.set_hex_limit(100000);
stack_dummy stack;
stack_dummy_interface stack;
rrc_dummy rrc_dummy;
gw_dummy gw;
@ -352,7 +352,7 @@ int esm_info_request_test()
rrc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log.set_hex_limit(100000);
srsue::stack_dummy stack{};
srsue::stack_dummy_interface stack{};
rrc_dummy rrc_dummy;
gw_dummy gw;
@ -406,7 +406,7 @@ int dedicated_eps_bearer_test()
rrc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log.set_hex_limit(100000);
srsue::stack_dummy stack;
srsue::stack_dummy_interface stack;
rrc_dummy rrc_dummy;
gw_dummy gw;

@ -167,10 +167,10 @@ private:
class rrc_test : public rrc
{
srsue::stack_dummy* stack = nullptr;
srsue::stack_dummy_interface* stack = nullptr;
public:
rrc_test(srslte::log* log_, stack_dummy* stack_) : rrc(stack_), stack(stack_)
rrc_test(srslte::log* log_, stack_dummy_interface* stack_) : rrc(stack_), stack(stack_)
{
pool = srslte::byte_buffer_pool::get_instance();
nastest = std::unique_ptr<nas_test>(new nas_test(stack));
@ -274,7 +274,7 @@ int cell_select_test()
printf("====== Cell Select Testing ===============\n");
printf("==========================================================\n");
stack_dummy stack;
stack_dummy_interface stack;
rrc_test rrctest(&log1, &stack);
rrctest.init();
rrctest.connect();
@ -304,7 +304,7 @@ int meas_obj_test()
printf("====== Object Configuration Testing ===============\n");
printf("==========================================================\n");
stack_dummy stack;
stack_dummy_interface stack;
rrc_test rrctest(&log1, &stack);
rrctest.init();
rrctest.connect();
@ -720,7 +720,7 @@ int a1event_report_test(uint32_t a1_rsrp_th,
printf("============ Report Testing A1 ===============\n");
printf("==========================================================\n");
stack_dummy stack;
stack_dummy_interface stack;
rrc_test rrctest(&log1, &stack);
rrctest.init();
rrctest.connect();
@ -854,7 +854,7 @@ int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave)
printf("============ Report Testing A3 ===============\n");
printf("==========================================================\n");
stack_dummy stack;
stack_dummy_interface stack;
rrc_test rrctest(&log1, &stack);
rrctest.init();
rrctest.connect();

Loading…
Cancel
Save