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/asn1/liblte_mme.h"
#include "srslte/common/common.h" #include "srslte/common/common.h"
#include "srslte/common/interfaces_common.h" #include "srslte/common/interfaces_common.h"
#include "srslte/common/multiqueue.h"
#include "srslte/common/security.h" #include "srslte/common/security.h"
#include "srslte/common/stack_procedure.h" #include "srslte/common/stack_procedure.h"
#include "srslte/common/tti_point.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. /* 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. */ * 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(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_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; 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 read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
int get_increment_sequence_num(); int get_increment_sequence_num();
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);
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_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); void write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
// RRC interface // 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 // 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."); rlc_log->info_hex(pdu->msg, pdu->N_bytes, "BCCH BCH message received.");
unique_byte_buffer_t buf = allocate_unique_buffer(*pool); pdcp->write_pdu_bcch_bch(std::move(pdu));
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");
}
} }
// Pass directly to PDCP, no DL througput counting done // 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 // 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."); rlc_log->info_hex(pdu->msg, pdu->N_bytes, "PCCH message received.");
unique_byte_buffer_t buf = allocate_unique_buffer(*pool); pdcp->write_pdu_pcch(std::move(pdu));
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");
}
} }
void rlc::write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) void rlc::write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)

@ -171,6 +171,9 @@ private:
void timer_alignment_expire(); void timer_alignment_expire();
srslte::timer_handler* timers = nullptr; srslte::timer_handler* timers = nullptr;
/* Queue to dispatch stack tasks */
srslte::byte_buffer_pool* pool = nullptr;
// pointer to MAC PCAP object // pointer to MAC PCAP object
srslte::mac_pcap* pcap = nullptr; srslte::mac_pcap* pcap = nullptr;
bool is_first_ul_grant = false; 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(&pch_softbuffer, 100);
srslte_softbuffer_rx_init(&mch_softbuffer, 100); srslte_softbuffer_rx_init(&mch_softbuffer, 100);
pool = srslte::byte_buffer_pool::get_instance();
// Keep initialising members // Keep initialising members
bzero(&metrics, sizeof(mac_metrics_t)); bzero(&metrics, sizeof(mac_metrics_t));
clear_rntis(); 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) void mac::bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len)
{ {
// Send MIB to RLC // 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) { if (pcap) {
pcap->write_dl_bch(payload, len, true, phy_h->get_current_tti(), cc_idx); 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) { } else if (grant.rnti == SRSLTE_PRNTI) {
// Send PCH payload to RLC // 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) { if (pcap) {
pcap->write_dl_pch(pch_payload_buffer, grant.tb[0].tbs, true, grant.tti, cc_idx); pcap->write_dl_pch(pch_payload_buffer, grant.tb[0].tbs, true, grant.tti, cc_idx);

@ -26,7 +26,7 @@
namespace srsue { namespace srsue {
class stack_dummy : public stack_interface_rrc class stack_dummy_interface : public stack_interface_rrc
{ {
public: public:
srslte::timer_handler::unique_timer get_unique_timer() override { return timers.get_unique_timer(); } 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::tti_point get_current_tti() override { return srslte::tti_point{timers.get_cur_time() % 10240}; }
srslte::timer_handler timers{100}; 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 } // namespace srsue

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

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

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

Loading…
Cancel
Save