Merge branch 'rlc_refactor' into next

master
Andre Puschmann 7 years ago
commit 74e38ee0a2

@ -228,8 +228,8 @@ public:
class pdcp_interface_gw class pdcp_interface_gw
{ {
public: public:
virtual void write_sdu(uint32_t lcid, srslte::byte_buffer_t *sdu) = 0; virtual void write_sdu(uint32_t lcid, srslte::byte_buffer_t *sdu, bool blocking) = 0;
virtual bool is_drb_enabled(uint32_t lcid) = 0; virtual bool is_lcid_enabled(uint32_t lcid) = 0;
}; };
// PDCP interface for RRC // PDCP interface for RRC
@ -238,7 +238,7 @@ class pdcp_interface_rrc
public: public:
virtual void reestablish() = 0; virtual void reestablish() = 0;
virtual void reset() = 0; virtual void reset() = 0;
virtual void write_sdu(uint32_t lcid, srslte::byte_buffer_t *sdu) = 0; virtual void write_sdu(uint32_t lcid, srslte::byte_buffer_t *sdu, bool blocking = true) = 0;
virtual void add_bearer(uint32_t lcid, srslte::srslte_pdcp_config_t cnfg = srslte::srslte_pdcp_config_t()) = 0; virtual void add_bearer(uint32_t lcid, srslte::srslte_pdcp_config_t cnfg = srslte::srslte_pdcp_config_t()) = 0;
virtual void config_security(uint32_t lcid, virtual void config_security(uint32_t lcid,
uint8_t *k_enc_, uint8_t *k_enc_,
@ -282,7 +282,7 @@ class rlc_interface_pdcp
public: public:
/* PDCP calls RLC to push an RLC SDU. SDU gets placed into the RLC buffer and MAC pulls /* PDCP calls RLC to push an RLC SDU. SDU gets placed into the RLC buffer and MAC pulls
* RLC PDUs according to TB size. */ * RLC PDUs according to TB size. */
virtual void write_sdu(uint32_t lcid, srslte::byte_buffer_t *sdu) = 0; virtual void write_sdu(uint32_t lcid, srslte::byte_buffer_t *sdu, bool blocking = true) = 0;
virtual bool rb_is_um(uint32_t lcid) = 0; virtual bool rb_is_um(uint32_t lcid) = 0;
}; };

@ -51,12 +51,12 @@ public:
void stop(); void stop();
// GW interface // GW interface
bool is_drb_enabled(uint32_t lcid); bool is_lcid_enabled(uint32_t lcid);
// RRC interface // RRC interface
void reestablish(); void reestablish();
void reset(); void reset();
void write_sdu(uint32_t lcid, byte_buffer_t *sdu); void write_sdu(uint32_t lcid, byte_buffer_t *sdu, bool blocking = true);
void write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu); void write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu);
void add_bearer(uint32_t lcid, srslte_pdcp_config_t cnfg = srslte_pdcp_config_t()); void add_bearer(uint32_t lcid, srslte_pdcp_config_t cnfg = srslte_pdcp_config_t());
void add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_t cnfg = srslte_pdcp_config_t()); void add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_t cnfg = srslte_pdcp_config_t());

@ -76,7 +76,7 @@ public:
bool is_active(); bool is_active();
// RRC interface // RRC interface
void write_sdu(byte_buffer_t *sdu); void write_sdu(byte_buffer_t *sdu, bool blocking);
void config_security(uint8_t *k_enc_, void config_security(uint8_t *k_enc_,
uint8_t *k_int_, uint8_t *k_int_,
CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,

@ -55,7 +55,7 @@ public:
virtual bool is_active() = 0; virtual bool is_active() = 0;
// RRC interface // RRC interface
virtual void write_sdu(byte_buffer_t *sdu) = 0; virtual void write_sdu(byte_buffer_t *sdu, bool blocking) = 0;
virtual void config_security(uint8_t *k_enc_, virtual void config_security(uint8_t *k_enc_,
uint8_t *k_int_, uint8_t *k_int_,
CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,

@ -31,7 +31,6 @@
#include "srslte/common/log.h" #include "srslte/common/log.h"
#include "srslte/common/common.h" #include "srslte/common/common.h"
#include "srslte/interfaces/ue_interfaces.h" #include "srslte/interfaces/ue_interfaces.h"
#include "srslte/upper/rlc_entity.h"
#include "srslte/upper/rlc_metrics.h" #include "srslte/upper/rlc_metrics.h"
#include "srslte/upper/rlc_common.h" #include "srslte/upper/rlc_common.h"
@ -50,7 +49,7 @@ class rlc
{ {
public: public:
rlc(); rlc();
virtual ~rlc() {} virtual ~rlc();
void init(srsue::pdcp_interface_rlc *pdcp_, void init(srsue::pdcp_interface_rlc *pdcp_,
srsue::rrc_interface_rlc *rrc_, srsue::rrc_interface_rlc *rrc_,
srsue::ue_interface *ue_, srsue::ue_interface *ue_,
@ -63,8 +62,7 @@ public:
void get_metrics(rlc_metrics_t &m); void get_metrics(rlc_metrics_t &m);
// PDCP interface // PDCP interface
void write_sdu(uint32_t lcid, byte_buffer_t *sdu); void write_sdu(uint32_t lcid, byte_buffer_t *sdu, bool blocking = true);
void write_sdu_nb(uint32_t lcid, byte_buffer_t *sdu);
void write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu); void write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu);
bool rb_is_um(uint32_t lcid); bool rb_is_um(uint32_t lcid);
@ -88,7 +86,7 @@ public:
void add_bearer(uint32_t lcid); void add_bearer(uint32_t lcid);
void add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg); void add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg);
void add_bearer_mrb(uint32_t lcid); void add_bearer_mrb(uint32_t lcid);
void add_bearer_mrb_enb(uint32_t lcid);
private: private:
void reset_metrics(); void reset_metrics();
@ -98,14 +96,17 @@ private:
srsue::rrc_interface_rlc *rrc; srsue::rrc_interface_rlc *rrc;
srslte::mac_interface_timers *mac_timers; srslte::mac_interface_timers *mac_timers;
srsue::ue_interface *ue; srsue::ue_interface *ue;
srslte::rlc_entity rlc_array[SRSLTE_N_RADIO_BEARERS];
srslte::rlc_um rlc_array_mrb[SRSLTE_N_MCH_LCIDS]; typedef std::map<uint16_t, rlc_common*> rlc_map_t;
typedef std::pair<uint16_t, rlc_common*> rlc_map_pair_t;
rlc_map_t rlc_array, rlc_array_mrb;
pthread_rwlock_t rwlock;
uint32_t default_lcid; uint32_t default_lcid;
int buffer_size; int buffer_size;
long ul_tput_bytes[SRSLTE_N_RADIO_BEARERS]; // Timer needed for metrics calculation
long dl_tput_bytes[SRSLTE_N_RADIO_BEARERS];
long dl_tput_bytes_mrb[SRSLTE_N_MCH_LCIDS];
struct timeval metrics_time[3]; struct timeval metrics_time[3];
bool valid_lcid(uint32_t lcid); bool valid_lcid(uint32_t lcid);

@ -66,8 +66,7 @@ struct rlc_amd_retx_t{
}; };
class rlc_am class rlc_am : public rlc_common
:public rlc_common
{ {
public: public:
rlc_am(uint32_t queue_len = 16); rlc_am(uint32_t queue_len = 16);
@ -77,7 +76,7 @@ public:
srsue::pdcp_interface_rlc *pdcp_, srsue::pdcp_interface_rlc *pdcp_,
srsue::rrc_interface_rlc *rrc_, srsue::rrc_interface_rlc *rrc_,
mac_interface_timers *mac_timers); mac_interface_timers *mac_timers);
void configure(srslte_rlc_config_t cnfg); bool configure(srslte_rlc_config_t cnfg);
void reestablish(); void reestablish();
void stop(); void stop();
@ -87,8 +86,7 @@ public:
uint32_t get_bearer(); uint32_t get_bearer();
// PDCP interface // PDCP interface
void write_sdu(byte_buffer_t *sdu); void write_sdu(byte_buffer_t *sdu, bool blocking = true);
void write_sdu_nb(byte_buffer_t *sdu);
// MAC interface // MAC interface
uint32_t get_buffer_state(); uint32_t get_buffer_state();
@ -96,6 +94,10 @@ public:
int read_pdu(uint8_t *payload, uint32_t nof_bytes); int read_pdu(uint8_t *payload, uint32_t nof_bytes);
void write_pdu(uint8_t *payload, uint32_t nof_bytes); void write_pdu(uint8_t *payload, uint32_t nof_bytes);
uint32_t get_num_tx_bytes();
uint32_t get_num_rx_bytes();
void reset_metrics();
private: private:
byte_buffer_pool *pool; byte_buffer_pool *pool;
@ -128,6 +130,10 @@ private:
bool do_status; bool do_status;
rlc_status_pdu_t status; rlc_status_pdu_t status;
// Metrics
uint32_t num_tx_bytes;
uint32_t num_rx_bytes;
/**************************************************************************** /****************************************************************************
* Configurable parameters * Configurable parameters
* Ref: 3GPP TS 36.322 v10.0.0 Section 7 * Ref: 3GPP TS 36.322 v10.0.0 Section 7

@ -38,15 +38,7 @@ namespace srslte {
#define RLC_AM_WINDOW_SIZE 512 #define RLC_AM_WINDOW_SIZE 512
typedef enum{
RLC_MODE_TM = 0,
RLC_MODE_UM,
RLC_MODE_AM,
RLC_MODE_N_ITEMS,
}rlc_mode_t;
static const char rlc_mode_text[RLC_MODE_N_ITEMS][20] = {"Transparent Mode",
"Unacknowledged Mode",
"Acknowledged Mode"};
typedef enum{ typedef enum{
RLC_FI_FIELD_START_AND_END_ALIGNED = 0, RLC_FI_FIELD_START_AND_END_ALIGNED = 0,
@ -161,7 +153,7 @@ public:
srsue::pdcp_interface_rlc *pdcp_, srsue::pdcp_interface_rlc *pdcp_,
srsue::rrc_interface_rlc *rrc_, srsue::rrc_interface_rlc *rrc_,
srslte::mac_interface_timers *mac_timers_) = 0; srslte::mac_interface_timers *mac_timers_) = 0;
virtual void configure(srslte_rlc_config_t cnfg) = 0; virtual bool configure(srslte_rlc_config_t cnfg) = 0;
virtual void stop() = 0; virtual void stop() = 0;
virtual void reestablish() = 0; virtual void reestablish() = 0;
virtual void empty_queue() = 0; virtual void empty_queue() = 0;
@ -169,9 +161,12 @@ public:
virtual rlc_mode_t get_mode() = 0; virtual rlc_mode_t get_mode() = 0;
virtual uint32_t get_bearer() = 0; virtual uint32_t get_bearer() = 0;
virtual uint32_t get_num_tx_bytes() = 0;
virtual uint32_t get_num_rx_bytes() = 0;
virtual void reset_metrics() = 0;
// PDCP interface // PDCP interface
virtual void write_sdu(byte_buffer_t *sdu) = 0; virtual void write_sdu(byte_buffer_t *sdu, bool blocking) = 0;
virtual void write_sdu_nb(byte_buffer_t *sdu) = 0;
// MAC interface // MAC interface
virtual uint32_t get_buffer_state() = 0; virtual uint32_t get_buffer_state() = 0;

@ -1,87 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 Software Radio Systems Limited
*
* \section LICENSE
*
* This file is part of the srsUE library.
*
* srsUE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsUE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SRSLTE_RLC_ENTITY_H
#define SRSLTE_RLC_ENTITY_H
#include "srslte/common/log.h"
#include "srslte/common/common.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/upper/rlc_common.h"
#include "srslte/upper/rlc_tm.h"
#include "srslte/upper/rlc_um.h"
#include "srslte/upper/rlc_am.h"
namespace srslte {
/****************************************************************************
* RLC Entity
* Common container for all RLC entities
***************************************************************************/
class rlc_entity
{
public:
rlc_entity();
void init(rlc_mode_t mode,
log *rlc_entity_log_,
uint32_t lcid_,
srsue::pdcp_interface_rlc *pdcp_,
srsue::rrc_interface_rlc *rrc_,
mac_interface_timers *mac_timers_,
int buffer_size = -1); // use -1 for default buffer sizes
void configure(srslte_rlc_config_t cnfg);
void reestablish();
void stop();
void empty_queue();
bool active();
rlc_mode_t get_mode();
uint32_t get_bearer();
// PDCP interface
void write_sdu(byte_buffer_t *sdu);
void write_sdu_nb(byte_buffer_t *sdu);
// MAC interface
uint32_t get_buffer_state();
uint32_t get_total_buffer_state();
int read_pdu(uint8_t *payload, uint32_t nof_bytes);
void write_pdu(uint8_t *payload, uint32_t nof_bytes);
private:
rlc_mode_t mode;
uint32_t lcid;
rlc_common *rlc;
};
} // namespace srslte
#endif // SRSLTE_RLC_ENTITY_H

@ -28,10 +28,19 @@
#define SRSLTE_RLC_INTERFACE_H #define SRSLTE_RLC_INTERFACE_H
// for custom constructors // for custom constructors
#include "srslte/asn1/liblte_rrc.h" #include <srslte/asn1/liblte_rrc.h>
namespace srslte { namespace srslte {
typedef enum{
RLC_MODE_TM = 0,
RLC_MODE_UM,
RLC_MODE_AM,
RLC_MODE_N_ITEMS,
}rlc_mode_t;
static const char rlc_mode_text[RLC_MODE_N_ITEMS][20] = {"Transparent Mode",
"Unacknowledged Mode",
"Acknowledged Mode"};
typedef enum{ typedef enum{
RLC_UMD_SN_SIZE_5_BITS = 0, RLC_UMD_SN_SIZE_5_BITS = 0,
@ -80,19 +89,22 @@ typedef struct {
class srslte_rlc_config_t class srslte_rlc_config_t
{ {
public: public:
LIBLTE_RRC_RLC_MODE_ENUM rlc_mode; rlc_mode_t rlc_mode;
srslte_rlc_am_config_t am; srslte_rlc_am_config_t am;
srslte_rlc_um_config_t um; srslte_rlc_um_config_t um;
// Default ctor // Default ctor
srslte_rlc_config_t(): rlc_mode(LIBLTE_RRC_RLC_MODE_AM), am(), um() {}; srslte_rlc_config_t(): rlc_mode(RLC_MODE_TM), am(), um() {};
// Constructor based on liblte's RLC config // Constructor based on liblte's RLC config
srslte_rlc_config_t(LIBLTE_RRC_RLC_CONFIG_STRUCT *cnfg) : rlc_mode(cnfg->rlc_mode), am(), um() srslte_rlc_config_t(LIBLTE_RRC_RLC_CONFIG_STRUCT *cnfg) : rlc_mode(RLC_MODE_AM), am(), um()
{ {
// update RLC mode to internal mode struct
rlc_mode = (cnfg->rlc_mode == LIBLTE_RRC_RLC_MODE_AM) ? RLC_MODE_AM : RLC_MODE_UM;
switch(rlc_mode) switch(rlc_mode)
{ {
case LIBLTE_RRC_RLC_MODE_AM: case RLC_MODE_AM:
am.t_poll_retx = liblte_rrc_t_poll_retransmit_num[cnfg->ul_am_rlc.t_poll_retx]; am.t_poll_retx = liblte_rrc_t_poll_retransmit_num[cnfg->ul_am_rlc.t_poll_retx];
am.poll_pdu = liblte_rrc_poll_pdu_num[cnfg->ul_am_rlc.poll_pdu]; am.poll_pdu = liblte_rrc_poll_pdu_num[cnfg->ul_am_rlc.poll_pdu];
am.poll_byte = liblte_rrc_poll_byte_num[cnfg->ul_am_rlc.poll_byte]*1000; // KB am.poll_byte = liblte_rrc_poll_byte_num[cnfg->ul_am_rlc.poll_byte]*1000; // KB
@ -100,7 +112,7 @@ public:
am.t_reordering = liblte_rrc_t_reordering_num[cnfg->dl_am_rlc.t_reordering]; am.t_reordering = liblte_rrc_t_reordering_num[cnfg->dl_am_rlc.t_reordering];
am.t_status_prohibit = liblte_rrc_t_status_prohibit_num[cnfg->dl_am_rlc.t_status_prohibit]; am.t_status_prohibit = liblte_rrc_t_status_prohibit_num[cnfg->dl_am_rlc.t_status_prohibit];
break; break;
case LIBLTE_RRC_RLC_MODE_UM_BI: case RLC_MODE_UM:
um.t_reordering = liblte_rrc_t_reordering_num[cnfg->dl_um_bi_rlc.t_reordering]; um.t_reordering = liblte_rrc_t_reordering_num[cnfg->dl_um_bi_rlc.t_reordering];
um.rx_sn_field_length = (rlc_umd_sn_size_t)cnfg->dl_um_bi_rlc.sn_field_len; um.rx_sn_field_length = (rlc_umd_sn_size_t)cnfg->dl_um_bi_rlc.sn_field_len;
um.rx_window_size = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 16 : 512; um.rx_window_size = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 16 : 512;
@ -108,16 +120,6 @@ public:
um.tx_sn_field_length = (rlc_umd_sn_size_t)cnfg->ul_um_bi_rlc.sn_field_len; um.tx_sn_field_length = (rlc_umd_sn_size_t)cnfg->ul_um_bi_rlc.sn_field_len;
um.tx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.tx_sn_field_length) ? 32 : 1024; um.tx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.tx_sn_field_length) ? 32 : 1024;
break; break;
case LIBLTE_RRC_RLC_MODE_UM_UNI_UL:
um.tx_sn_field_length = (rlc_umd_sn_size_t)cnfg->ul_um_uni_rlc.sn_field_len;
um.tx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.tx_sn_field_length) ? 32 : 1024;
break;
case LIBLTE_RRC_RLC_MODE_UM_UNI_DL:
um.t_reordering = liblte_rrc_t_reordering_num[cnfg->dl_um_uni_rlc.t_reordering];
um.rx_sn_field_length = (rlc_umd_sn_size_t)cnfg->dl_um_uni_rlc.sn_field_len;
um.rx_window_size = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 16 : 512;
um.rx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 32 : 1024;
break;
default: default:
// Handle default case // Handle default case
break; break;
@ -128,7 +130,7 @@ public:
static srslte_rlc_config_t mch_config() static srslte_rlc_config_t mch_config()
{ {
srslte_rlc_config_t cfg; srslte_rlc_config_t cfg;
cfg.rlc_mode = LIBLTE_RRC_RLC_MODE_UM_UNI_DL; cfg.rlc_mode = RLC_MODE_UM;
cfg.um.t_reordering = 0; cfg.um.t_reordering = 0;
cfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; cfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS;
cfg.um.rx_window_size = 0; cfg.um.rx_window_size = 0;

@ -36,8 +36,7 @@
namespace srslte { namespace srslte {
class rlc_tm class rlc_tm : public rlc_common
:public rlc_common
{ {
public: public:
rlc_tm(uint32_t queue_len = 16); rlc_tm(uint32_t queue_len = 16);
@ -47,7 +46,7 @@ public:
srsue::pdcp_interface_rlc *pdcp_, srsue::pdcp_interface_rlc *pdcp_,
srsue::rrc_interface_rlc *rrc_, srsue::rrc_interface_rlc *rrc_,
mac_interface_timers *mac_timers); mac_interface_timers *mac_timers);
void configure(srslte_rlc_config_t cnfg); bool configure(srslte_rlc_config_t cnfg);
void stop(); void stop();
void reestablish(); void reestablish();
void empty_queue(); void empty_queue();
@ -55,9 +54,12 @@ public:
rlc_mode_t get_mode(); rlc_mode_t get_mode();
uint32_t get_bearer(); uint32_t get_bearer();
uint32_t get_num_tx_bytes();
uint32_t get_num_rx_bytes();
void reset_metrics();
// PDCP interface // PDCP interface
void write_sdu(byte_buffer_t *sdu); void write_sdu(byte_buffer_t *sdu, bool blocking);
void write_sdu_nb(byte_buffer_t *sdu);
// MAC interface // MAC interface
uint32_t get_buffer_state(); uint32_t get_buffer_state();
@ -75,6 +77,9 @@ private:
bool tx_enabled; bool tx_enabled;
uint32_t num_tx_bytes;
uint32_t num_rx_bytes;
// Thread-safe queues for MAC messages // Thread-safe queues for MAC messages
rlc_tx_queue ul_queue; rlc_tx_queue ul_queue;
}; };

@ -55,7 +55,7 @@ public:
srsue::pdcp_interface_rlc *pdcp_, srsue::pdcp_interface_rlc *pdcp_,
srsue::rrc_interface_rlc *rrc_, srsue::rrc_interface_rlc *rrc_,
mac_interface_timers *mac_timers_); mac_interface_timers *mac_timers_);
void configure(srslte_rlc_config_t cnfg); bool configure(srslte_rlc_config_t cnfg);
void reestablish(); void reestablish();
void stop(); void stop();
void empty_queue(); void empty_queue();
@ -65,8 +65,7 @@ public:
uint32_t get_bearer(); uint32_t get_bearer();
// PDCP interface // PDCP interface
void write_sdu(byte_buffer_t *sdu); void write_sdu(byte_buffer_t *sdu, bool blocking = true);
void write_sdu_nb(byte_buffer_t *sdu);
// MAC interface // MAC interface
uint32_t get_buffer_state(); uint32_t get_buffer_state();
@ -75,6 +74,10 @@ public:
void write_pdu(uint8_t *payload, uint32_t nof_bytes); void write_pdu(uint8_t *payload, uint32_t nof_bytes);
int get_increment_sequence_num(); int get_increment_sequence_num();
uint32_t get_num_tx_bytes();
uint32_t get_num_rx_bytes();
void reset_metrics();
private: private:
// Transmitter sub-class // Transmitter sub-class
@ -84,13 +87,15 @@ private:
rlc_um_tx(uint32_t queue_len); rlc_um_tx(uint32_t queue_len);
~rlc_um_tx(); ~rlc_um_tx();
void init(srslte::log *log_); void init(srslte::log *log_);
void configure(srslte_rlc_config_t cfg, std::string rb_name); bool configure(srslte_rlc_config_t cfg, std::string rb_name);
int build_data_pdu(uint8_t *payload, uint32_t nof_bytes); int build_data_pdu(uint8_t *payload, uint32_t nof_bytes);
void stop(); void stop();
void reestablish(); void reestablish();
void empty_queue(); void empty_queue();
void write_sdu(byte_buffer_t *sdu); void write_sdu(byte_buffer_t *sdu);
void try_write_sdu(byte_buffer_t *sdu); void try_write_sdu(byte_buffer_t *sdu);
uint32_t get_num_tx_bytes();
void reset_metrics();
uint32_t get_buffer_size_bytes(); uint32_t get_buffer_size_bytes();
private: private:
@ -119,6 +124,8 @@ private:
bool tx_enabled; bool tx_enabled;
uint32_t num_tx_bytes;
// helper functions // helper functions
void debug_state(); void debug_state();
const char* get_rb_name(); const char* get_rb_name();
@ -136,10 +143,12 @@ private:
srslte::mac_interface_timers *mac_timers_); srslte::mac_interface_timers *mac_timers_);
void stop(); void stop();
void reestablish(); void reestablish();
void configure(srslte_rlc_config_t cfg, std::string rb_name); bool configure(srslte_rlc_config_t cfg, std::string rb_name);
void handle_data_pdu(uint8_t *payload, uint32_t nof_bytes); void handle_data_pdu(uint8_t *payload, uint32_t nof_bytes);
void reassemble_rx_sdus(); void reassemble_rx_sdus();
bool inside_reordering_window(uint16_t sn); bool inside_reordering_window(uint16_t sn);
uint32_t get_num_rx_bytes();
void reset_metrics();
// Timeout callback interface // Timeout callback interface
void timer_expired(uint32_t timeout_id); void timer_expired(uint32_t timeout_id);
@ -163,12 +172,14 @@ private:
byte_buffer_t *rx_sdu; byte_buffer_t *rx_sdu;
uint32_t vr_ur_in_rx_sdu; uint32_t vr_ur_in_rx_sdu;
// Rx state variables // Rx state variables and counter
uint32_t vr_ur; // Receive state. SN of earliest PDU still considered for reordering. uint32_t vr_ur; // Receive state. SN of earliest PDU still considered for reordering.
uint32_t vr_ux; // t_reordering state. SN following PDU which triggered t_reordering. uint32_t vr_ux; // t_reordering state. SN following PDU which triggered t_reordering.
uint32_t vr_uh; // Highest rx state. SN following PDU with highest SN among rxed PDUs. uint32_t vr_uh; // Highest rx state. SN following PDU with highest SN among rxed PDUs.
bool pdu_lost; bool pdu_lost;
uint32_t num_rx_bytes;
// Upper layer handles and variables // Upper layer handles and variables
srsue::pdcp_interface_rlc *pdcp; srsue::pdcp_interface_rlc *pdcp;
srsue::rrc_interface_rlc *rrc; srsue::rrc_interface_rlc *rrc;
@ -177,6 +188,8 @@ private:
// Mutexes // Mutexes
pthread_mutex_t mutex; pthread_mutex_t mutex;
bool rx_enabled;
/**************************************************************************** /****************************************************************************
* Timers * Timers
* Ref: 3GPP TS 36.322 v10.0.0 Section 7 * Ref: 3GPP TS 36.322 v10.0.0 Section 7
@ -196,6 +209,7 @@ private:
// Common variables needed by parent class // Common variables needed by parent class
srsue::rrc_interface_rlc *rrc; srsue::rrc_interface_rlc *rrc;
srslte::log *log;
uint32_t lcid; uint32_t lcid;
srslte_rlc_um_config_t cfg; srslte_rlc_um_config_t cfg;
std::string rb_name; std::string rb_name;

@ -91,20 +91,22 @@ void pdcp::reestablish() {
void pdcp::reset() void pdcp::reset()
{ {
pthread_rwlock_rdlock(&rwlock); // destroy all bearers
pthread_rwlock_wrlock(&rwlock);
for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); ++it) { for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); ++it) {
it->second->reset(); delete(it->second);
} pdcp_array.erase(it);
if (valid_lcid(0)) {
pdcp_array.at(0)->init(rlc, rrc, gw, pdcp_log, default_lcid, default_cnfg);
} }
pthread_rwlock_unlock(&rwlock); pthread_rwlock_unlock(&rwlock);
// add default SRB0 again
add_bearer(0, default_cnfg);
} }
/******************************************************************************* /*******************************************************************************
RRC/GW interface RRC/GW interface
*******************************************************************************/ *******************************************************************************/
bool pdcp::is_drb_enabled(uint32_t lcid) bool pdcp::is_lcid_enabled(uint32_t lcid)
{ {
pthread_rwlock_rdlock(&rwlock); pthread_rwlock_rdlock(&rwlock);
bool ret = false; bool ret = false;
@ -115,11 +117,11 @@ bool pdcp::is_drb_enabled(uint32_t lcid)
return ret; return ret;
} }
void pdcp::write_sdu(uint32_t lcid, byte_buffer_t *sdu) void pdcp::write_sdu(uint32_t lcid, byte_buffer_t *sdu, bool blocking)
{ {
pthread_rwlock_rdlock(&rwlock); pthread_rwlock_rdlock(&rwlock);
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
pdcp_array.at(lcid)->write_sdu(sdu); pdcp_array.at(lcid)->write_sdu(sdu, blocking);
} else { } else {
pdcp_log->warning("Writing sdu: lcid=%d. Deallocating sdu\n", lcid); pdcp_log->warning("Writing sdu: lcid=%d. Deallocating sdu\n", lcid);
byte_buffer_pool::get_instance()->deallocate(sdu); byte_buffer_pool::get_instance()->deallocate(sdu);
@ -131,40 +133,42 @@ void pdcp::write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu)
{ {
pthread_rwlock_rdlock(&rwlock); pthread_rwlock_rdlock(&rwlock);
if (valid_mch_lcid(lcid)){ if (valid_mch_lcid(lcid)){
pdcp_array_mrb.at(lcid)->write_sdu(sdu); pdcp_array_mrb.at(lcid)->write_sdu(sdu, true);
} }
pthread_rwlock_unlock(&rwlock); pthread_rwlock_unlock(&rwlock);
} }
void pdcp::add_bearer(uint32_t lcid, srslte_pdcp_config_t cfg) void pdcp::add_bearer(uint32_t lcid, srslte_pdcp_config_t cfg)
{ {
pthread_rwlock_rdlock(&rwlock); pthread_rwlock_wrlock(&rwlock);
if (not valid_lcid(lcid)) { if (not valid_lcid(lcid)) {
if (not pdcp_array.insert(pdcp_map_pair_t(lcid, new pdcp_entity())).second) { if (not pdcp_array.insert(pdcp_map_pair_t(lcid, new pdcp_entity())).second) {
pdcp_log->error("Error inserting PDCP entity in to array\n."); pdcp_log->error("Error inserting PDCP entity in to array\n.");
return; goto unlock_and_exit;
} }
pdcp_array.at(lcid)->init(rlc, rrc, gw, pdcp_log, lcid, cfg); pdcp_array.at(lcid)->init(rlc, rrc, gw, pdcp_log, lcid, cfg);
pdcp_log->info("Added bearer %s\n", rrc->get_rb_name(lcid).c_str()); pdcp_log->info("Added bearer %s\n", rrc->get_rb_name(lcid).c_str());
} else { } else {
pdcp_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str()); pdcp_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str());
} }
unlock_and_exit:
pthread_rwlock_unlock(&rwlock); pthread_rwlock_unlock(&rwlock);
} }
void pdcp::add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_t cfg) void pdcp::add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_t cfg)
{ {
pthread_rwlock_rdlock(&rwlock); pthread_rwlock_wrlock(&rwlock);
if (not valid_mch_lcid(lcid)) { if (not valid_mch_lcid(lcid)) {
if (not pdcp_array_mrb.insert(pdcp_map_pair_t(lcid, new pdcp_entity())).second) { if (not pdcp_array_mrb.insert(pdcp_map_pair_t(lcid, new pdcp_entity())).second) {
pdcp_log->error("Error inserting PDCP entity in to array\n."); pdcp_log->error("Error inserting PDCP entity in to array\n.");
return; goto unlock_and_exit;
} }
pdcp_array_mrb.at(lcid)->init(rlc, rrc, gw, pdcp_log, lcid, cfg); pdcp_array_mrb.at(lcid)->init(rlc, rrc, gw, pdcp_log, lcid, cfg);
pdcp_log->info("Added bearer %s\n", rrc->get_rb_name(lcid).c_str()); pdcp_log->info("Added bearer %s\n", rrc->get_rb_name(lcid).c_str());
} else { } else {
pdcp_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str()); pdcp_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str());
} }
unlock_and_exit:
pthread_rwlock_unlock(&rwlock); pthread_rwlock_unlock(&rwlock);
} }

@ -70,11 +70,11 @@ void pdcp_entity::init(srsue::rlc_interface_pdcp *rlc_,
cfg.sn_len = 0; cfg.sn_len = 0;
sn_len_bytes = 0; sn_len_bytes = 0;
if(cfg.is_control) { if (cfg.is_control) {
cfg.sn_len = 5; cfg.sn_len = 5;
sn_len_bytes = 1; sn_len_bytes = 1;
} }
if(cfg.is_data) { if (cfg.is_data) {
cfg.sn_len = 12; cfg.sn_len = 12;
sn_len_bytes = 2; sn_len_bytes = 2;
} }
@ -89,6 +89,7 @@ void pdcp_entity::reestablish() {
tx_count = 0; tx_count = 0;
rx_count = 0; rx_count = 0;
} else { } else {
// Only reset counter in RLC-UM
if (rlc->rb_is_um(lcid)) { if (rlc->rb_is_um(lcid)) {
tx_count = 0; tx_count = 0;
rx_count = 0; rx_count = 0;
@ -96,11 +97,13 @@ void pdcp_entity::reestablish() {
} }
} }
// Used to stop/pause the entity (called on RRC conn release)
void pdcp_entity::reset() void pdcp_entity::reset()
{ {
active = false; active = false;
if(log) if (log) {
log->debug("Reset %s\n", rrc->get_rb_name(lcid).c_str()); log->debug("Reset %s\n", rrc->get_rb_name(lcid).c_str());
}
} }
bool pdcp_entity::is_active() bool pdcp_entity::is_active()
@ -108,8 +111,8 @@ bool pdcp_entity::is_active()
return active; return active;
} }
// RRC interface // GW/RRC interface
void pdcp_entity::write_sdu(byte_buffer_t *sdu) void pdcp_entity::write_sdu(byte_buffer_t *sdu, bool blocking)
{ {
log->info_hex(sdu->msg, sdu->N_bytes, log->info_hex(sdu->msg, sdu->N_bytes,
"TX %s SDU, SN: %d, do_integrity = %s, do_encryption = %s", "TX %s SDU, SN: %d, do_integrity = %s, do_encryption = %s",
@ -141,7 +144,7 @@ void pdcp_entity::write_sdu(byte_buffer_t *sdu)
} }
tx_count++; tx_count++;
rlc->write_sdu(lcid, sdu); rlc->write_sdu(lcid, sdu, blocking);
} }
void pdcp_entity::config_security(uint8_t *k_enc_, void pdcp_entity::config_security(uint8_t *k_enc_,

@ -25,6 +25,7 @@
*/ */
#include <srslte/asn1/liblte_rrc.h>
#include "srslte/upper/rlc.h" #include "srslte/upper/rlc.h"
#include "srslte/upper/rlc_tm.h" #include "srslte/upper/rlc_tm.h"
#include "srslte/upper/rlc_um.h" #include "srslte/upper/rlc_um.h"
@ -42,8 +43,25 @@ rlc::rlc()
ue = NULL; ue = NULL;
default_lcid = 0; default_lcid = 0;
bzero(metrics_time, sizeof(metrics_time)); bzero(metrics_time, sizeof(metrics_time));
bzero(ul_tput_bytes, sizeof(ul_tput_bytes)); pthread_rwlock_init(&rwlock, NULL);
bzero(dl_tput_bytes, sizeof(dl_tput_bytes)); }
rlc::~rlc()
{
// destroy all remaining entities
pthread_rwlock_wrlock(&rwlock);
for (rlc_map_t::iterator it = rlc_array.begin(); it != rlc_array.end(); ++it) {
delete(it->second);
}
rlc_array.clear();
for (rlc_map_t::iterator it = rlc_array_mrb.begin(); it != rlc_array_mrb.end(); ++it) {
delete(it->second);
}
rlc_array_mrb.clear();
pthread_rwlock_unlock(&rwlock);
pthread_rwlock_destroy(&rwlock);
} }
void rlc::init(srsue::pdcp_interface_rlc *pdcp_, void rlc::init(srsue::pdcp_interface_rlc *pdcp_,
@ -65,26 +83,36 @@ void rlc::init(srsue::pdcp_interface_rlc *pdcp_,
gettimeofday(&metrics_time[1], NULL); gettimeofday(&metrics_time[1], NULL);
reset_metrics(); reset_metrics();
rlc_array[0].init(RLC_MODE_TM, rlc_log, default_lcid, pdcp, rrc, mac_timers, buffer_size); // SRB0 // create default RLC_TM bearer for SRB0
add_bearer(default_lcid, srslte_rlc_config_t());
} }
void rlc::reset_metrics() void rlc::reset_metrics()
{ {
bzero(dl_tput_bytes, sizeof(long)*SRSLTE_N_RADIO_BEARERS); for (rlc_map_t::iterator it = rlc_array.begin(); it != rlc_array.end(); ++it) {
bzero(ul_tput_bytes, sizeof(long)*SRSLTE_N_RADIO_BEARERS); it->second->reset_metrics();
}
for (rlc_map_t::iterator it = rlc_array_mrb.begin(); it != rlc_array_mrb.end(); ++it) {
it->second->reset_metrics();
}
} }
void rlc::stop() void rlc::stop()
{ {
for(uint32_t i=0; i<SRSLTE_N_RADIO_BEARERS; i++) { pthread_rwlock_rdlock(&rwlock);
if(rlc_array[i].active()) { for (rlc_map_t::iterator it = rlc_array.begin(); it != rlc_array.end(); ++it) {
rlc_array[i].stop(); it->second->stop();
} }
for (rlc_map_t::iterator it = rlc_array_mrb.begin(); it != rlc_array_mrb.end(); ++it) {
it->second->stop();
} }
pthread_rwlock_unlock(&rwlock);
} }
void rlc::get_metrics(rlc_metrics_t &m) void rlc::get_metrics(rlc_metrics_t &m)
{ {
pthread_rwlock_rdlock(&rwlock);
gettimeofday(&metrics_time[2], NULL); gettimeofday(&metrics_time[2], NULL);
get_time_interval(metrics_time); get_time_interval(metrics_time);
@ -92,80 +120,120 @@ void rlc::get_metrics(rlc_metrics_t &m)
m.dl_tput_mbps = 0; m.dl_tput_mbps = 0;
m.ul_tput_mbps = 0; m.ul_tput_mbps = 0;
for (int i=0;i<SRSLTE_N_RADIO_BEARERS;i++) {
m.dl_tput_mbps += (dl_tput_bytes[i]*8/(double)1e6)/secs; for (rlc_map_t::iterator it = rlc_array.begin(); it != rlc_array.end(); ++it) {
m.ul_tput_mbps += (ul_tput_bytes[i]*8/(double)1e6)/secs; m.dl_tput_mbps += (it->second->get_num_rx_bytes()*8/(double)1e6)/secs;
if(rlc_array[i].active()) { m.ul_tput_mbps += (it->second->get_num_tx_bytes()*8/(double)1e6)/secs;
rlc_log->info("LCID=%d, RX throughput: %4.6f Mbps. TX throughput: %4.6f Mbps.\n", rlc_log->info("LCID=%d, RX throughput: %4.6f Mbps. TX throughput: %4.6f Mbps.\n",
i, it->first,
(dl_tput_bytes[i]*8/(double)1e6)/secs, (it->second->get_num_rx_bytes()*8/(double)1e6)/secs,
(ul_tput_bytes[i]*8/(double)1e6)/secs); (it->second->get_num_tx_bytes()*8/(double)1e6)/secs);
}
} }
// Add multicast metrics // Add multicast metrics
for (int i=0;i<SRSLTE_N_MCH_LCIDS;i++) { for (rlc_map_t::iterator it = rlc_array_mrb.begin(); it != rlc_array_mrb.end(); ++it) {
m.dl_tput_mbps += (dl_tput_bytes_mrb[i]*8/(double)1e6)/secs; m.dl_tput_mbps += (it->second->get_num_rx_bytes()*8/(double)1e6)/secs;
if(rlc_array_mrb[i].is_mrb()) { rlc_log->info("MCH_LCID=%d, RX throughput: %4.6f Mbps\n",
rlc_log->info("MCH_LCID=%d, RX throughput: %4.6f Mbps.\n", it->first,
i, (it->second->get_num_rx_bytes()*8/(double)1e6)/secs);
(dl_tput_bytes_mrb[i]*8/(double)1e6)/secs);
}
} }
memcpy(&metrics_time[1], &metrics_time[2], sizeof(struct timeval)); memcpy(&metrics_time[1], &metrics_time[2], sizeof(struct timeval));
reset_metrics(); reset_metrics();
pthread_rwlock_unlock(&rwlock);
} }
// A call to reestablish stops all lcids but does not delete the instances. The mapping lcid to rlc mode can not change // A call to reestablish stops all lcids but does not delete the instances. The mapping lcid to rlc mode can not change
void rlc::reestablish() { void rlc::reestablish()
for(uint32_t i=0; i<SRSLTE_N_RADIO_BEARERS; i++) { {
if(rlc_array[i].active()) { pthread_rwlock_rdlock(&rwlock);
rlc_array[i].reestablish();
for (rlc_map_t::iterator it = rlc_array.begin(); it != rlc_array.end(); ++it) {
it->second->reestablish();
} }
for (rlc_map_t::iterator it = rlc_array_mrb.begin(); it != rlc_array_mrb.end(); ++it) {
it->second->reestablish();
} }
pthread_rwlock_unlock(&rwlock);
} }
// Resetting the RLC layer returns the object to the state after the call to init(): All lcids are stopped and // Resetting the RLC layer returns the object to the state after the call to init():
// defaul lcid=0 is created // All LCIDs are removed, except SRB0
void rlc::reset() void rlc::reset()
{ {
stop(); pthread_rwlock_wrlock(&rwlock);
rlc_array[0].init(RLC_MODE_TM, rlc_log, default_lcid, pdcp, rrc, mac_timers, buffer_size); // SRB0
for (rlc_map_t::iterator it = rlc_array.begin(); it != rlc_array.end(); ++it) {
it->second->stop();
delete(it->second);
}
rlc_array.clear();
for (rlc_map_t::iterator it = rlc_array_mrb.begin(); it != rlc_array_mrb.end(); ++it) {
it->second->stop();
delete(it->second);
}
rlc_array_mrb.clear();
pthread_rwlock_unlock(&rwlock);
// Add SRB0 again
add_bearer(default_lcid, srslte_rlc_config_t());
} }
void rlc::empty_queue() void rlc::empty_queue()
{ {
for(uint32_t i=0; i<SRSLTE_N_RADIO_BEARERS; i++) { // Empty Tx queue, not needed for MCH bearers
if(rlc_array[i].active()) pthread_rwlock_rdlock(&rwlock);
rlc_array[i].empty_queue(); for (rlc_map_t::iterator it = rlc_array.begin(); it != rlc_array.end(); ++it) {
it->second->empty_queue();
} }
pthread_rwlock_unlock(&rwlock);
} }
/******************************************************************************* /*******************************************************************************
PDCP interface PDCP interface
*******************************************************************************/ *******************************************************************************/
void rlc::write_sdu(uint32_t lcid, byte_buffer_t *sdu)
void rlc::write_sdu(uint32_t lcid, byte_buffer_t *sdu, bool blocking)
{ {
if(valid_lcid(lcid)) { pthread_rwlock_rdlock(&rwlock);
rlc_array[lcid].write_sdu(sdu); if (valid_lcid(lcid)) {
rlc_array.at(lcid)->write_sdu(sdu, blocking);
} else {
rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid);
byte_buffer_pool::get_instance()->deallocate(sdu);
} }
pthread_rwlock_unlock(&rwlock);
} }
void rlc::write_sdu_nb(uint32_t lcid, byte_buffer_t *sdu)
void rlc::write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu)
{ {
if(valid_lcid(lcid)) { pthread_rwlock_rdlock(&rwlock);
rlc_array[lcid].write_sdu_nb(sdu); if (valid_lcid_mrb(lcid)) {
rlc_array_mrb.at(lcid)->write_sdu(sdu, false); // write in non-blocking mode by default
} else {
rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid);
byte_buffer_pool::get_instance()->deallocate(sdu);
} }
pthread_rwlock_unlock(&rwlock);
} }
void rlc::write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu)
bool rlc::rb_is_um(uint32_t lcid)
{ {
if(valid_lcid_mrb(lcid)) { bool ret = false;
rlc_array_mrb[lcid].write_sdu(sdu);
pthread_rwlock_rdlock(&rwlock);
if (valid_lcid(lcid)) {
ret = rlc_array.at(lcid)->get_mode() == RLC_MODE_UM;
} }
} pthread_rwlock_unlock(&rwlock);
bool rlc::rb_is_um(uint32_t lcid) { return ret;
return rlc_array[lcid].get_mode()==RLC_MODE_UM;
} }
/******************************************************************************* /*******************************************************************************
@ -173,61 +241,82 @@ bool rlc::rb_is_um(uint32_t lcid) {
*******************************************************************************/ *******************************************************************************/
uint32_t rlc::get_buffer_state(uint32_t lcid) uint32_t rlc::get_buffer_state(uint32_t lcid)
{ {
if(valid_lcid(lcid)) { uint32_t ret = 0;
return rlc_array[lcid].get_buffer_state();
} else { pthread_rwlock_rdlock(&rwlock);
return 0; if (valid_lcid(lcid)) {
ret = rlc_array.at(lcid)->get_buffer_state();
} }
pthread_rwlock_unlock(&rwlock);
return ret;
} }
uint32_t rlc::get_total_buffer_state(uint32_t lcid) uint32_t rlc::get_total_buffer_state(uint32_t lcid)
{ {
if(valid_lcid(lcid)) { uint32_t ret = 0;
return rlc_array[lcid].get_total_buffer_state();
} else { pthread_rwlock_rdlock(&rwlock);
return 0; if (valid_lcid(lcid)) {
ret = rlc_array.at(lcid)->get_total_buffer_state();
} }
pthread_rwlock_unlock(&rwlock);
return ret;
} }
uint32_t rlc::get_total_mch_buffer_state(uint32_t lcid) uint32_t rlc::get_total_mch_buffer_state(uint32_t lcid)
{ {
if(valid_lcid_mrb(lcid)) { uint32_t ret = 0;
return rlc_array_mrb[lcid].get_total_buffer_state();
} else { pthread_rwlock_rdlock(&rwlock);
return 0; if (valid_lcid(lcid)) {
ret = rlc_array_mrb.at(lcid)->get_total_buffer_state();
} }
pthread_rwlock_unlock(&rwlock);
return ret;
} }
int rlc::read_pdu(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes) int rlc::read_pdu(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes)
{ {
if(valid_lcid(lcid)) { uint32_t ret = 0;
ul_tput_bytes[lcid] += nof_bytes;
return rlc_array[lcid].read_pdu(payload, nof_bytes); pthread_rwlock_rdlock(&rwlock);
if (valid_lcid(lcid)) {
ret = rlc_array.at(lcid)->read_pdu(payload, nof_bytes);
} }
return 0; pthread_rwlock_unlock(&rwlock);
return ret;
} }
int rlc::read_pdu_mch(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes) int rlc::read_pdu_mch(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes)
{ {
if(valid_lcid_mrb(lcid)) { uint32_t ret = 0;
ul_tput_bytes[lcid] += nof_bytes;
return rlc_array_mrb[lcid].read_pdu(payload, nof_bytes); pthread_rwlock_rdlock(&rwlock);
if (valid_lcid(lcid)) {
ret = rlc_array_mrb.at(lcid)->read_pdu(payload, nof_bytes);
} }
return 0; pthread_rwlock_unlock(&rwlock);
return ret;
} }
void rlc::write_pdu(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes) void rlc::write_pdu(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes)
{ {
if(valid_lcid(lcid)) { pthread_rwlock_rdlock(&rwlock);
dl_tput_bytes[lcid] += nof_bytes; if (valid_lcid(lcid)) {
rlc_array[lcid].write_pdu(payload, nof_bytes); rlc_array.at(lcid)->write_pdu(payload, nof_bytes);
} }
pthread_rwlock_unlock(&rwlock);
} }
// 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(uint8_t *payload, uint32_t nof_bytes)
{ {
rlc_log->info_hex(payload, nof_bytes, "BCCH BCH message received."); rlc_log->info_hex(payload, nof_bytes, "BCCH BCH message received.");
dl_tput_bytes[0] += nof_bytes;
byte_buffer_t *buf = pool_allocate; byte_buffer_t *buf = pool_allocate;
if (buf) { if (buf) {
memcpy(buf->msg, payload, nof_bytes); memcpy(buf->msg, payload, nof_bytes);
@ -239,10 +328,10 @@ void rlc::write_pdu_bcch_bch(uint8_t *payload, uint32_t nof_bytes)
} }
} }
// Pass directly to PDCP, no DL througput counting done
void rlc::write_pdu_bcch_dlsch(uint8_t *payload, uint32_t nof_bytes) void rlc::write_pdu_bcch_dlsch(uint8_t *payload, uint32_t nof_bytes)
{ {
rlc_log->info_hex(payload, nof_bytes, "BCCH TXSCH message received."); rlc_log->info_hex(payload, nof_bytes, "BCCH TXSCH message received.");
dl_tput_bytes[0] += nof_bytes;
byte_buffer_t *buf = pool_allocate; byte_buffer_t *buf = pool_allocate;
if (buf) { if (buf) {
memcpy(buf->msg, payload, nof_bytes); memcpy(buf->msg, payload, nof_bytes);
@ -254,10 +343,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(uint8_t *payload, uint32_t nof_bytes)
{ {
rlc_log->info_hex(payload, nof_bytes, "PCCH message received."); rlc_log->info_hex(payload, nof_bytes, "PCCH message received.");
dl_tput_bytes[0] += nof_bytes;
byte_buffer_t *buf = pool_allocate; byte_buffer_t *buf = pool_allocate;
if (buf) { if (buf) {
memcpy(buf->msg, payload, nof_bytes); memcpy(buf->msg, payload, nof_bytes);
@ -271,20 +360,31 @@ void rlc::write_pdu_pcch(uint8_t *payload, uint32_t nof_bytes)
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)
{ {
if(valid_lcid_mrb(lcid)) { pthread_rwlock_rdlock(&rwlock);
dl_tput_bytes_mrb[lcid] += nof_bytes; if (valid_lcid_mrb(lcid)) {
rlc_array_mrb[lcid].write_pdu(payload, nof_bytes); rlc_array_mrb.at(lcid)->write_pdu(payload, nof_bytes);
} }
pthread_rwlock_unlock(&rwlock);
} }
/******************************************************************************* /*******************************************************************************
RRC interface RRC interface
*******************************************************************************/ *******************************************************************************/
// FIXME: Remove function to forbid implicit configuration
void rlc::add_bearer(uint32_t lcid) void rlc::add_bearer(uint32_t lcid)
{ {
// No config provided - use defaults for SRB1 and SRB2 if (lcid > 2) {
if(lcid < 3) { rlc_log->error("Radio bearer %s does not support default RLC configuration.\n", rrc->get_rb_name(lcid).c_str());
if (!rlc_array[lcid].active()) { return;
}
// No config provided - use defaults for SRB0, SRB1, and SRB2
if (lcid == 0) {
// SRB0 is TM
add_bearer(lcid, srslte_rlc_config_t());
} else {
// SRB1 and SRB2 are AM
LIBLTE_RRC_RLC_CONFIG_STRUCT cnfg; LIBLTE_RRC_RLC_CONFIG_STRUCT cnfg;
cnfg.rlc_mode = LIBLTE_RRC_RLC_MODE_AM; cnfg.rlc_mode = LIBLTE_RRC_RLC_MODE_AM;
cnfg.ul_am_rlc.t_poll_retx = LIBLTE_RRC_T_POLL_RETRANSMIT_MS45; cnfg.ul_am_rlc.t_poll_retx = LIBLTE_RRC_T_POLL_RETRANSMIT_MS45;
@ -294,94 +394,136 @@ void rlc::add_bearer(uint32_t lcid)
cnfg.dl_am_rlc.t_reordering = LIBLTE_RRC_T_REORDERING_MS35; cnfg.dl_am_rlc.t_reordering = LIBLTE_RRC_T_REORDERING_MS35;
cnfg.dl_am_rlc.t_status_prohibit = LIBLTE_RRC_T_STATUS_PROHIBIT_MS0; cnfg.dl_am_rlc.t_status_prohibit = LIBLTE_RRC_T_STATUS_PROHIBIT_MS0;
add_bearer(lcid, srslte_rlc_config_t(&cnfg)); add_bearer(lcid, srslte_rlc_config_t(&cnfg));
} else {
rlc_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str());
}
}else{
rlc_log->error("Radio bearer %s does not support default RLC configuration.\n", rrc->get_rb_name(lcid).c_str());
} }
} }
void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg) void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg)
{ {
if(lcid >= SRSLTE_N_RADIO_BEARERS) { pthread_rwlock_wrlock(&rwlock);
rlc_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
return; rlc_common *rlc_entity = NULL;
}
if (!rlc_array[lcid].active()) { if (not valid_lcid(lcid)) {
rlc_log->warning("Adding radio bearer %s with mode %s\n",
rrc->get_rb_name(lcid).c_str(), liblte_rrc_rlc_mode_text[cnfg.rlc_mode]);
switch(cnfg.rlc_mode) switch(cnfg.rlc_mode)
{ {
case LIBLTE_RRC_RLC_MODE_AM: case RLC_MODE_TM:
rlc_array[lcid].init(RLC_MODE_AM, rlc_log, lcid, pdcp, rrc, mac_timers, buffer_size); rlc_entity = new rlc_tm();
break;
case LIBLTE_RRC_RLC_MODE_UM_BI:
rlc_array[lcid].init(RLC_MODE_UM, rlc_log, lcid, pdcp, rrc, mac_timers, buffer_size);
break; break;
case LIBLTE_RRC_RLC_MODE_UM_UNI_DL: case RLC_MODE_AM:
rlc_array[lcid].init(RLC_MODE_UM, rlc_log, lcid, pdcp, rrc, mac_timers, buffer_size); rlc_entity = new rlc_am();
break; break;
case LIBLTE_RRC_RLC_MODE_UM_UNI_UL: case RLC_MODE_UM:
rlc_array[lcid].init(RLC_MODE_UM, rlc_log, lcid, pdcp, rrc, mac_timers, buffer_size); rlc_entity = new rlc_um();
break; break;
default: default:
rlc_log->error("Cannot add RLC entity - invalid mode\n"); rlc_log->error("Cannot add RLC entity - invalid mode\n");
return; goto unlock_and_exit;
}
if (rlc_entity) {
// configure and add to array
rlc_entity->init(rlc_log, lcid, pdcp, rrc, mac_timers);
if (cnfg.rlc_mode != RLC_MODE_TM) {
if (rlc_entity->configure(cnfg) == false) {
rlc_log->error("Error configuring RLC entity\n.");
goto delete_and_exit;
}
}
if (not rlc_array.insert(rlc_map_pair_t(lcid, rlc_entity)).second) {
rlc_log->error("Error inserting RLC entity in to array\n.");
goto delete_and_exit;
} }
} else {
rlc_log->error("Error instantiating RLC\n");
goto delete_and_exit;
}
rlc_log->warning("Added radio bearer %s with mode %s\n", rrc->get_rb_name(lcid).c_str(), liblte_rrc_rlc_mode_text[cnfg.rlc_mode]);
goto unlock_and_exit;
} else { } else {
rlc_log->warning("Bearer %s already created.\n", rrc->get_rb_name(lcid).c_str()); rlc_log->warning("Bearer %s already created.\n", rrc->get_rb_name(lcid).c_str());
} }
rlc_array[lcid].configure(cnfg);
delete_and_exit:
if (rlc_entity) {
delete(rlc_entity);
}
unlock_and_exit:
pthread_rwlock_unlock(&rwlock);
} }
void rlc::add_bearer_mrb(uint32_t lcid) void rlc::add_bearer_mrb(uint32_t lcid)
{ {
// 36.321 Table 6.2.1-4 pthread_rwlock_wrlock(&rwlock);
if(lcid >= SRSLTE_N_MCH_LCIDS) { rlc_common *rlc_entity = NULL;
rlc_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_MCH_LCIDS, lcid);
return; if (not valid_lcid_mrb(lcid)) {
rlc_entity = new rlc_um();
if (rlc_entity) {
// configure and add to array
rlc_entity->init(rlc_log, lcid, pdcp, rrc, mac_timers);
if (rlc_entity->configure(srslte_rlc_config_t::mch_config()) == false) {
rlc_log->error("Error configuring RLC entity\n.");
goto delete_and_exit;
}
if (not rlc_array_mrb.insert(rlc_map_pair_t(lcid, rlc_entity)).second) {
rlc_log->error("Error inserting RLC entity in to array\n.");
goto delete_and_exit;
}
} else {
rlc_log->error("Error instantiating RLC\n");
goto delete_and_exit;
}
rlc_log->warning("Added radio bearer %s with mode RLC_UM\n", rrc->get_rb_name(lcid).c_str());
goto unlock_and_exit;
} else {
rlc_log->warning("Bearer %s already created.\n", rrc->get_rb_name(lcid).c_str());
} }
rlc_array_mrb[lcid].init(rlc_log, lcid, pdcp, rrc, mac_timers);
rlc_array_mrb[lcid].configure(srslte_rlc_config_t::mch_config());
}
void rlc::add_bearer_mrb_enb(uint32_t lcid) delete_and_exit:
{ if (rlc_entity) {
if(lcid >= SRSLTE_N_MCH_LCIDS) { delete(rlc_entity);
rlc_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_MCH_LCIDS, lcid);
return;
} }
rlc_array_mrb[lcid].init(rlc_log,lcid,pdcp,rrc,mac_timers);
rlc_array_mrb[lcid].configure(srslte_rlc_config_t::mch_config()); unlock_and_exit:
pthread_rwlock_unlock(&rwlock);
} }
/******************************************************************************* /*******************************************************************************
Helpers Helpers (Lock must be hold when calling those)
*******************************************************************************/ *******************************************************************************/
bool rlc::valid_lcid(uint32_t lcid) bool rlc::valid_lcid(uint32_t lcid)
{ {
if(lcid >= SRSLTE_N_RADIO_BEARERS) { if (lcid >= SRSLTE_N_RADIO_BEARERS) {
rlc_log->warning("Invalid LCID=%d\n", lcid); rlc_log->error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid);
return false; return false;
} else if(!rlc_array[lcid].active()) { }
if (rlc_array.find(lcid) == rlc_array.end()) {
return false; return false;
} }
return true; return true;
} }
bool rlc::valid_lcid_mrb(uint32_t lcid) bool rlc::valid_lcid_mrb(uint32_t lcid)
{ {
if(lcid >= SRSLTE_N_MCH_LCIDS) { if (lcid >= SRSLTE_N_MCH_LCIDS) {
rlc_log->error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid);
return false; return false;
} }
if(!rlc_array_mrb[lcid].is_mrb()) {
if (rlc_array_mrb.find(lcid) == rlc_array_mrb.end()) {
return false; return false;
} }
return true; return true;
} }
} // namespace srsue } // namespace srsue

@ -61,6 +61,9 @@ rlc_am::rlc_am(uint32_t queue_len) : tx_sdu_queue(queue_len)
vr_ms = 0; vr_ms = 0;
vr_h = 0; vr_h = 0;
num_tx_bytes = 0;
num_rx_bytes = 0;
pdu_without_poll = 0; pdu_without_poll = 0;
byte_without_poll = 0; byte_without_poll = 0;
@ -88,23 +91,27 @@ void rlc_am::init(srslte::log *log_,
tx_enabled = true; tx_enabled = true;
} }
void rlc_am::configure(srslte_rlc_config_t cfg_) bool rlc_am::configure(srslte_rlc_config_t cfg_)
{ {
cfg = cfg_.am; cfg = cfg_.am;
log->warning("%s configured: t_poll_retx=%d, poll_pdu=%d, poll_byte=%d, max_retx_thresh=%d, " log->warning("%s configured: t_poll_retx=%d, poll_pdu=%d, poll_byte=%d, max_retx_thresh=%d, "
"t_reordering=%d, t_status_prohibit=%d\n", "t_reordering=%d, t_status_prohibit=%d\n",
rrc->get_rb_name(lcid).c_str(), cfg.t_poll_retx, cfg.poll_pdu, cfg.poll_byte, cfg.max_retx_thresh, rrc->get_rb_name(lcid).c_str(), cfg.t_poll_retx, cfg.poll_pdu, cfg.poll_byte, cfg.max_retx_thresh,
cfg.t_reordering, cfg.t_status_prohibit); cfg.t_reordering, cfg.t_status_prohibit);
return true;
} }
void rlc_am::empty_queue() { void rlc_am::empty_queue() {
// Drop all messages in TX SDU queue // Drop all messages in TX SDU queue
pthread_mutex_lock(&mutex);
byte_buffer_t *buf; byte_buffer_t *buf;
while(tx_sdu_queue.try_read(&buf)) { while(tx_sdu_queue.try_read(&buf)) {
pool->deallocate(buf); pool->deallocate(buf);
} }
tx_sdu_queue.reset(); tx_sdu_queue.reset();
pthread_mutex_unlock(&mutex);
} }
void rlc_am::reestablish() { void rlc_am::reestablish() {
@ -192,33 +199,26 @@ uint32_t rlc_am::get_bearer()
* PDCP interface * PDCP interface
***************************************************************************/ ***************************************************************************/
void rlc_am::write_sdu(byte_buffer_t *sdu) void rlc_am::write_sdu(byte_buffer_t *sdu, bool blocking)
{ {
if (!tx_enabled) { if (!tx_enabled) {
byte_buffer_pool::get_instance()->deallocate(sdu); byte_buffer_pool::get_instance()->deallocate(sdu);
return; return;
} }
if (sdu) { if (sdu) {
if (blocking) {
// block on write to queue
tx_sdu_queue.write(sdu); tx_sdu_queue.write(sdu);
log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", rrc->get_rb_name(lcid).c_str(), sdu->N_bytes, tx_sdu_queue.size()); log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", rrc->get_rb_name(lcid).c_str(), sdu->N_bytes, tx_sdu_queue.size());
} else { } else {
log->warning("NULL SDU pointer in write_sdu()\n"); // non-blocking write
}
}
void rlc_am::write_sdu_nb(byte_buffer_t *sdu)
{
if (!tx_enabled) {
byte_buffer_pool::get_instance()->deallocate(sdu);
return;
}
if (sdu) {
if (tx_sdu_queue.try_write(sdu)) { if (tx_sdu_queue.try_write(sdu)) {
log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", rrc->get_rb_name(lcid).c_str(), sdu->N_bytes, tx_sdu_queue.size()); log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", rrc->get_rb_name(lcid).c_str(), sdu->N_bytes, tx_sdu_queue.size());
} else { } else {
log->debug_hex(sdu->msg, sdu->N_bytes, "[Dropped SDU] %s Tx SDU (%d B, tx_sdu_queue_len=%d)", rrc->get_rb_name(lcid).c_str(), sdu->N_bytes, tx_sdu_queue.size()); log->debug_hex(sdu->msg, sdu->N_bytes, "[Dropped SDU] %s Tx SDU (%d B, tx_sdu_queue_len=%d)", rrc->get_rb_name(lcid).c_str(), sdu->N_bytes, tx_sdu_queue.size());
pool->deallocate(sdu); pool->deallocate(sdu);
} }
}
} else { } else {
log->warning("NULL SDU pointer in write_sdu()\n"); log->warning("NULL SDU pointer in write_sdu()\n");
} }
@ -363,6 +363,7 @@ unlock_and_return:
int rlc_am::read_pdu(uint8_t *payload, uint32_t nof_bytes) int rlc_am::read_pdu(uint8_t *payload, uint32_t nof_bytes)
{ {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
int pdu_size = 0;
log->debug("MAC opportunity - %d bytes\n", nof_bytes); log->debug("MAC opportunity - %d bytes\n", nof_bytes);
log->debug("tx_window size - %zu PDUs\n", tx_window.size()); log->debug("tx_window size - %zu PDUs\n", tx_window.size());
@ -370,7 +371,8 @@ int rlc_am::read_pdu(uint8_t *payload, uint32_t nof_bytes)
// Tx STATUS if requested // Tx STATUS if requested
if(do_status && !status_prohibited()) { if(do_status && !status_prohibited()) {
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return build_status_pdu(payload, nof_bytes); pdu_size = build_status_pdu(payload, nof_bytes);
goto unlock_and_exit;
} }
// if tx_window is full and retx_queue empty, retransmit next PDU to be ack'ed // if tx_window is full and retx_queue empty, retransmit next PDU to be ack'ed
@ -390,25 +392,27 @@ int rlc_am::read_pdu(uint8_t *payload, uint32_t nof_bytes)
// RETX if required // RETX if required
if(retx_queue.size() > 0) { if(retx_queue.size() > 0) {
int ret = build_retx_pdu(payload, nof_bytes); pdu_size = build_retx_pdu(payload, nof_bytes);
if (ret > 0) { if (pdu_size > 0) {
pthread_mutex_unlock(&mutex); goto unlock_and_exit;
return ret;
} }
} }
// Build a PDU from SDUs // Build a PDU from SDUs
int ret = build_data_pdu(payload, nof_bytes); pdu_size = build_data_pdu(payload, nof_bytes);
unlock_and_exit:
num_tx_bytes += pdu_size;
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return ret; return pdu_size;
} }
void rlc_am::write_pdu(uint8_t *payload, uint32_t nof_bytes) void rlc_am::write_pdu(uint8_t *payload, uint32_t nof_bytes)
{ {
if(nof_bytes < 1) if (nof_bytes < 1) return;
return;
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
num_rx_bytes += nof_bytes;
if(rlc_am_is_control_pdu(payload)) { if(rlc_am_is_control_pdu(payload)) {
handle_control_pdu(payload, nof_bytes); handle_control_pdu(payload, nof_bytes);
@ -424,6 +428,25 @@ void rlc_am::write_pdu(uint8_t *payload, uint32_t nof_bytes)
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
} }
uint32_t rlc_am::get_num_tx_bytes()
{
return num_tx_bytes;
}
uint32_t rlc_am::get_num_rx_bytes()
{
return num_rx_bytes;
}
void rlc_am::reset_metrics()
{
pthread_mutex_lock(&mutex);
num_rx_bytes = 0;
num_tx_bytes = 0;
pthread_mutex_unlock(&mutex);
}
/**************************************************************************** /****************************************************************************
* Timer checks * Timer checks
***************************************************************************/ ***************************************************************************/

@ -1,170 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 Software Radio Systems Limited
*
* \section LICENSE
*
* This file is part of the srsUE library.
*
* srsUE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsUE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include "srslte/upper/rlc_entity.h"
namespace srslte {
rlc_entity::rlc_entity()
:rlc(NULL)
{
}
void rlc_entity::init(rlc_mode_t mode_,
log *rlc_entity_log_,
uint32_t lcid_,
srsue::pdcp_interface_rlc *pdcp_,
srsue::rrc_interface_rlc *rrc_,
mac_interface_timers *mac_timers_,
int buffer_size)
{
if (buffer_size <= 0) {
buffer_size = rlc_common::RLC_BUFFER_NOF_PDU;
}
// Create the RLC instance the first time init() is called.
// If called to reestablished, the entity is stopped but not destroyed
// Next call to init() must use same mode
if (rlc == NULL) {
switch(mode_)
{
case RLC_MODE_TM:
rlc = new rlc_tm((uint32_t) buffer_size);
break;
case RLC_MODE_UM:
rlc = new rlc_um((uint32_t) buffer_size);
break;
case RLC_MODE_AM:
rlc = new rlc_am((uint32_t) buffer_size);
break;
default:
rlc_entity_log_->error("Invalid RLC mode - defaulting to TM\n");
rlc = new rlc_tm((uint32_t) buffer_size);
break;
}
lcid = lcid_;
mode = mode_;
} else {
if (lcid != lcid_) {
rlc_entity_log_->warning("Reestablishing RLC instance. LCID changed from %d to %d\n", lcid, lcid_);
lcid = lcid_;
}
if (mode != mode_) {
rlc_entity_log_->console("Error reestablishing RLC instance. Mode changed from %d to %d. \n", mode, mode_);
}
}
rlc->init(rlc_entity_log_, lcid_, pdcp_, rrc_, mac_timers_);
}
void rlc_entity::configure(srslte_rlc_config_t cnfg)
{
if(rlc)
rlc->configure(cnfg);
}
// Reestablishment stops the entity but does not destroy it. Mode will not change
void rlc_entity::reestablish() {
rlc->reestablish();
}
// A call to stop() stops the entity and clears deletes the instance. Next time this entity can be used for other mode.
void rlc_entity::stop()
{
rlc->stop();
delete rlc;
rlc = NULL;
}
void rlc_entity::empty_queue()
{
rlc->empty_queue();
}
bool rlc_entity::active()
{
return (rlc != NULL);
}
rlc_mode_t rlc_entity::get_mode()
{
if(rlc)
return rlc->get_mode();
else
return RLC_MODE_TM;
}
uint32_t rlc_entity::get_bearer()
{
if(rlc)
return rlc->get_bearer();
else
return 0;
}
// PDCP interface
void rlc_entity::write_sdu(byte_buffer_t *sdu)
{
if(rlc)
rlc->write_sdu(sdu);
}
void rlc_entity::write_sdu_nb(byte_buffer_t *sdu)
{
if(rlc)
rlc->write_sdu_nb(sdu);
}
// MAC interface
uint32_t rlc_entity::get_buffer_state()
{
if(rlc)
return rlc->get_buffer_state();
else
return 0;
}
uint32_t rlc_entity::get_total_buffer_state()
{
if(rlc)
return rlc->get_total_buffer_state();
else
return 0;
}
int rlc_entity::read_pdu(uint8_t *payload, uint32_t nof_bytes)
{
if(rlc)
return rlc->read_pdu(payload, nof_bytes);
else
return 0;
}
void rlc_entity::write_pdu(uint8_t *payload, uint32_t nof_bytes)
{
if(rlc)
rlc->write_pdu(payload, nof_bytes);
}
} // namespace srsue

@ -35,6 +35,8 @@ rlc_tm::rlc_tm(uint32_t queue_len) : ul_queue(queue_len)
pdcp = NULL; pdcp = NULL;
rrc = NULL; rrc = NULL;
lcid = 0; lcid = 0;
num_tx_bytes = 0;
num_rx_bytes = 0;
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
} }
@ -56,16 +58,17 @@ void rlc_tm::init(srslte::log *log_,
tx_enabled = true; tx_enabled = true;
} }
void rlc_tm::configure(srslte_rlc_config_t cnfg) bool rlc_tm::configure(srslte_rlc_config_t cnfg)
{ {
log->error("Attempted to configure TM RLC entity\n"); log->error("Attempted to configure TM RLC entity\n");
return true;
} }
void rlc_tm::empty_queue() void rlc_tm::empty_queue()
{ {
// Drop all messages in TX queue // Drop all messages in TX queue
byte_buffer_t *buf; byte_buffer_t *buf;
while(ul_queue.try_read(&buf)) { while (ul_queue.try_read(&buf)) {
pool->deallocate(buf); pool->deallocate(buf);
} }
ul_queue.reset(); ul_queue.reset();
@ -93,28 +96,18 @@ uint32_t rlc_tm::get_bearer()
} }
// PDCP interface // PDCP interface
void rlc_tm::write_sdu(byte_buffer_t *sdu) void rlc_tm::write_sdu(byte_buffer_t *sdu, bool blocking)
{ {
if (!tx_enabled) { if (!tx_enabled) {
byte_buffer_pool::get_instance()->deallocate(sdu); byte_buffer_pool::get_instance()->deallocate(sdu);
return; return;
} }
if (sdu) { if (sdu) {
if (blocking) {
ul_queue.write(sdu); ul_queue.write(sdu);
log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU, queue size=%d, bytes=%d", log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU, queue size=%d, bytes=%d",
rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes()); rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes());
} else { } else {
log->warning("NULL SDU pointer in write_sdu()\n");
}
}
void rlc_tm::write_sdu_nb(byte_buffer_t *sdu)
{
if (!tx_enabled) {
byte_buffer_pool::get_instance()->deallocate(sdu);
return;
}
if (sdu) {
if (ul_queue.try_write(sdu)) { if (ul_queue.try_write(sdu)) {
log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU, queue size=%d, bytes=%d", log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU, queue size=%d, bytes=%d",
rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes()); rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes());
@ -123,6 +116,7 @@ void rlc_tm::write_sdu_nb(byte_buffer_t *sdu)
rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes()); rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes());
pool->deallocate(sdu); pool->deallocate(sdu);
} }
}
} else { } else {
log->warning("NULL SDU pointer in write_sdu()\n"); log->warning("NULL SDU pointer in write_sdu()\n");
} }
@ -139,11 +133,26 @@ uint32_t rlc_tm::get_total_buffer_state()
return get_buffer_state(); return get_buffer_state();
} }
uint32_t rlc_tm::get_num_tx_bytes()
{
return num_tx_bytes;
}
uint32_t rlc_tm::get_num_rx_bytes()
{
return num_rx_bytes;
}
void rlc_tm::reset_metrics()
{
num_tx_bytes = 0;
num_rx_bytes = 0;
}
int rlc_tm::read_pdu(uint8_t *payload, uint32_t nof_bytes) int rlc_tm::read_pdu(uint8_t *payload, uint32_t nof_bytes)
{ {
uint32_t pdu_size = ul_queue.size_tail_bytes(); uint32_t pdu_size = ul_queue.size_tail_bytes();
if(pdu_size > nof_bytes) if (pdu_size > nof_bytes) {
{
log->error("TX %s PDU size larger than MAC opportunity\n", rrc->get_rb_name(lcid).c_str()); log->error("TX %s PDU size larger than MAC opportunity\n", rrc->get_rb_name(lcid).c_str());
return -1; return -1;
} }
@ -156,6 +165,8 @@ int rlc_tm::read_pdu(uint8_t *payload, uint32_t nof_bytes)
pool->deallocate(buf); pool->deallocate(buf);
log->info_hex(payload, pdu_size, "TX %s, %s PDU, queue size=%d, bytes=%d", log->info_hex(payload, pdu_size, "TX %s, %s PDU, queue size=%d, bytes=%d",
rrc->get_rb_name(lcid).c_str(), rlc_mode_text[RLC_MODE_TM], ul_queue.size(), ul_queue.size_bytes()); rrc->get_rb_name(lcid).c_str(), rlc_mode_text[RLC_MODE_TM], ul_queue.size(), ul_queue.size_bytes());
num_tx_bytes += pdu_size;
return pdu_size; return pdu_size;
} else { } else {
log->warning("Queue empty while trying to read\n"); log->warning("Queue empty while trying to read\n");
@ -174,6 +185,7 @@ void rlc_tm::write_pdu(uint8_t *payload, uint32_t nof_bytes)
memcpy(buf->msg, payload, nof_bytes); memcpy(buf->msg, payload, nof_bytes);
buf->N_bytes = nof_bytes; buf->N_bytes = nof_bytes;
buf->set_timestamp(); buf->set_timestamp();
num_rx_bytes += nof_bytes;
pdcp->write_pdu(lcid, buf); pdcp->write_pdu(lcid, buf);
} else { } else {
log->error("Fatal Error: Couldn't allocate buffer in rlc_tm::write_pdu().\n"); log->error("Fatal Error: Couldn't allocate buffer in rlc_tm::write_pdu().\n");

@ -37,6 +37,7 @@ rlc_um::rlc_um(uint32_t queue_len)
:lcid(0) :lcid(0)
,tx(queue_len) ,tx(queue_len)
,rrc(NULL) ,rrc(NULL)
,log(NULL)
{ {
bzero(&cfg, sizeof(srslte_rlc_um_config_t)); bzero(&cfg, sizeof(srslte_rlc_um_config_t));
} }
@ -57,48 +58,48 @@ void rlc_um::init(srslte::log *log_,
rx.init(log_, lcid_, pdcp_, rrc_, mac_timers_); rx.init(log_, lcid_, pdcp_, rrc_, mac_timers_);
lcid = lcid_; lcid = lcid_;
rrc = rrc_; // needed to determine bearer name during configuration rrc = rrc_; // needed to determine bearer name during configuration
log = log_;
} }
void rlc_um::configure(srslte_rlc_config_t cnfg_) bool rlc_um::configure(srslte_rlc_config_t cnfg_)
{ {
// determine bearer name and configure Rx/Tx objects // determine bearer name and configure Rx/Tx objects
rb_name = get_rb_name(rrc, lcid, cnfg_.um.is_mrb); rb_name = get_rb_name(rrc, lcid, cnfg_.um.is_mrb);
rx.configure(cnfg_, rb_name); if (not rx.configure(cnfg_, rb_name)) {
tx.configure(cnfg_, rb_name); return false;
}
if (not tx.configure(cnfg_, rb_name)) {
return false;
}
log->warning("%s configured in %s mode: t_reordering=%d ms, rx_sn_field_length=%u bits, tx_sn_field_length=%u bits\n",
rb_name.c_str(), rlc_mode_text[cnfg_.rlc_mode],
cfg.t_reordering, rlc_umd_sn_size_num[cfg.rx_sn_field_length], rlc_umd_sn_size_num[cfg.rx_sn_field_length]);
// store config // store config
cfg = cnfg_.um; cfg = cnfg_.um;
return true;
} }
void rlc_um::rlc_um_rx::configure(srslte_rlc_config_t cnfg_, std::string rb_name_) bool rlc_um::rlc_um_rx::configure(srslte_rlc_config_t cnfg_, std::string rb_name_)
{ {
cfg = cnfg_.um; cfg = cnfg_.um;
rb_name = rb_name_;
switch(cnfg_.rlc_mode) {
case LIBLTE_RRC_RLC_MODE_UM_BI:
log->warning("%s configured in %s mode: "
"t_reordering=%d ms, rx_sn_field_length=%u bits, tx_sn_field_length=%u bits\n",
get_rb_name(), liblte_rrc_rlc_mode_text[cnfg_.rlc_mode],
cfg.t_reordering, rlc_umd_sn_size_num[cfg.rx_sn_field_length], rlc_umd_sn_size_num[cfg.rx_sn_field_length]);
break;
case LIBLTE_RRC_RLC_MODE_UM_UNI_UL:
log->warning("%s configured in %s mode: tx_sn_field_length=%u bits\n",
get_rb_name(), liblte_rrc_rlc_mode_text[cnfg_.rlc_mode],
rlc_umd_sn_size_num[cfg.rx_sn_field_length]); if (cfg.rx_mod == 0) {
break; log->error("Error configuring %s RLC UM: rx_mod==0\n", get_rb_name());
case LIBLTE_RRC_RLC_MODE_UM_UNI_DL: return false;
log->warning("%s configured in %s mode: "
"t_reordering=%d ms, rx_sn_field_length=%u bits\n",
get_rb_name(), liblte_rrc_rlc_mode_text[cnfg_.rlc_mode],
cfg.t_reordering, rlc_umd_sn_size_num[cfg.rx_sn_field_length]);
break;
default:
log->error("RLC configuration mode not recognized\n");
} }
rb_name = rb_name_;
rx_enabled = true;
return true;
} }
@ -141,14 +142,14 @@ uint32_t rlc_um::get_bearer()
/**************************************************************************** /****************************************************************************
* PDCP interface * PDCP interface
***************************************************************************/ ***************************************************************************/
void rlc_um::write_sdu(byte_buffer_t *sdu) void rlc_um::write_sdu(byte_buffer_t *sdu, bool blocking)
{ {
if (blocking) {
tx.write_sdu(sdu); tx.write_sdu(sdu);
} } else {
void rlc_um::write_sdu_nb(byte_buffer_t *sdu)
{
tx.try_write_sdu(sdu); tx.try_write_sdu(sdu);
}
} }
/**************************************************************************** /****************************************************************************
@ -175,6 +176,22 @@ void rlc_um::write_pdu(uint8_t *payload, uint32_t nof_bytes)
rx.handle_data_pdu(payload, nof_bytes); rx.handle_data_pdu(payload, nof_bytes);
} }
uint32_t rlc_um::get_num_tx_bytes()
{
return tx.get_num_tx_bytes();
}
uint32_t rlc_um::get_num_rx_bytes()
{
return rx.get_num_rx_bytes();
}
void rlc_um::reset_metrics()
{
tx.reset_metrics();
rx.reset_metrics();
}
/**************************************************************************** /****************************************************************************
* Helper functions * Helper functions
@ -203,6 +220,7 @@ rlc_um::rlc_um_tx::rlc_um_tx(uint32_t queue_len)
,tx_sdu(NULL) ,tx_sdu(NULL)
,vt_us(0) ,vt_us(0)
,tx_enabled(false) ,tx_enabled(false)
,num_tx_bytes(0)
{ {
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
} }
@ -217,17 +235,26 @@ rlc_um::rlc_um_tx::~rlc_um_tx()
void rlc_um::rlc_um_tx::init(srslte::log *log_) void rlc_um::rlc_um_tx::init(srslte::log *log_)
{ {
log = log_; log = log_;
tx_enabled = true;
} }
void rlc_um::rlc_um_tx::configure(srslte_rlc_config_t cnfg_, std::string rb_name_) bool rlc_um::rlc_um_tx::configure(srslte_rlc_config_t cnfg_, std::string rb_name_)
{ {
cfg = cnfg_.um; cfg = cnfg_.um;
if (cfg.tx_mod == 0) {
log->error("Error configuring %s RLC UM: tx_mod==0\n", get_rb_name());
return false;
}
if(cfg.is_mrb){ if(cfg.is_mrb){
tx_sdu_queue.resize(512); tx_sdu_queue.resize(512);
} }
rb_name = rb_name_; rb_name = rb_name_;
tx_enabled = true;
return true;
} }
@ -266,6 +293,20 @@ void rlc_um::rlc_um_tx::empty_queue()
} }
uint32_t rlc_um::rlc_um_tx::get_num_tx_bytes()
{
return num_tx_bytes;
}
void rlc_um::rlc_um_tx::reset_metrics()
{
pthread_mutex_lock(&mutex);
num_tx_bytes = 0;
pthread_mutex_unlock(&mutex);
}
uint32_t rlc_um::rlc_um_tx::get_buffer_size_bytes() uint32_t rlc_um::rlc_um_tx::get_buffer_size_bytes()
{ {
// Bytes needed for tx SDUs // Bytes needed for tx SDUs
@ -434,6 +475,8 @@ int rlc_um::rlc_um_tx::build_data_pdu(uint8_t *payload, uint32_t nof_bytes)
debug_state(); debug_state();
num_tx_bytes += ret;
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return ret; return ret;
} }
@ -469,6 +512,8 @@ rlc_um::rlc_um_rx::rlc_um_rx()
,pdu_lost(false) ,pdu_lost(false)
,mac_timers(NULL) ,mac_timers(NULL)
,lcid(0) ,lcid(0)
,num_rx_bytes(0)
,rx_enabled(false)
{ {
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
} }
@ -508,6 +553,8 @@ void rlc_um::rlc_um_rx::stop()
vr_ux = 0; vr_ux = 0;
vr_uh = 0; vr_uh = 0;
pdu_lost = false; pdu_lost = false;
rx_enabled = false;
if(rx_sdu) { if(rx_sdu) {
pool->deallocate(rx_sdu); pool->deallocate(rx_sdu);
rx_sdu = NULL; rx_sdu = NULL;
@ -531,10 +578,18 @@ void rlc_um::rlc_um_rx::stop()
void rlc_um::rlc_um_rx::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes) void rlc_um::rlc_um_rx::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes)
{ {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
rlc_umd_pdu_t pdu; rlc_umd_pdu_t pdu;
int header_len = 0; int header_len = 0;
std::map<uint32_t, rlc_umd_pdu_t>::iterator it; std::map<uint32_t, rlc_umd_pdu_t>::iterator it;
rlc_umd_pdu_header_t header; rlc_umd_pdu_header_t header;
if (!rx_enabled) {
goto unlock_and_exit;
}
num_rx_bytes += nof_bytes;
rlc_um_read_data_pdu_header(payload, nof_bytes, cfg.rx_sn_field_length, &header); rlc_um_read_data_pdu_header(payload, nof_bytes, cfg.rx_sn_field_length, &header);
log->info_hex(payload, nof_bytes, "RX %s Rx data PDU SN: %d", get_rb_name(), header.sn); log->info_hex(payload, nof_bytes, "RX %s Rx data PDU SN: %d", get_rb_name(), header.sn);
@ -596,7 +651,7 @@ void rlc_um::rlc_um_rx::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes)
debug_state(); debug_state();
unlock_and_exit: unlock_and_exit:
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
} }
@ -814,6 +869,20 @@ bool rlc_um::rlc_um_rx::inside_reordering_window(uint16_t sn)
} }
uint32_t rlc_um::rlc_um_rx::get_num_rx_bytes()
{
return num_rx_bytes;
}
void rlc_um::rlc_um_rx::reset_metrics()
{
pthread_mutex_lock(&mutex);
num_rx_bytes = 0;
pthread_mutex_unlock(&mutex);
}
/**************************************************************************** /****************************************************************************
* Timeout callback interface * Timeout callback interface
***************************************************************************/ ***************************************************************************/

@ -169,6 +169,10 @@ void basic_test()
assert(tester.sdus[i]->N_bytes == 1); assert(tester.sdus[i]->N_bytes == 1);
assert(*(tester.sdus[i]->msg) == i); assert(*(tester.sdus[i]->msg) == i);
} }
// Check statistics
assert(rlc1.get_num_tx_bytes() == rlc2.get_num_rx_bytes());
assert(rlc2.get_num_tx_bytes() == rlc1.get_num_rx_bytes());
} }
void concat_test() void concat_test()
@ -234,6 +238,10 @@ void concat_test()
assert(tester.sdus[i]->N_bytes == 1); assert(tester.sdus[i]->N_bytes == 1);
assert(*(tester.sdus[i]->msg) == i); assert(*(tester.sdus[i]->msg) == i);
} }
// check statistics
assert(rlc1.get_num_tx_bytes() == rlc2.get_num_rx_bytes());
assert(rlc2.get_num_tx_bytes() == rlc1.get_num_rx_bytes());
} }
void segment_test() void segment_test()
@ -317,6 +325,9 @@ void segment_test()
for(int j=0;j<10;j++) for(int j=0;j<10;j++)
assert(tester.sdus[i]->msg[j] == j); assert(tester.sdus[i]->msg[j] == j);
} }
assert(rlc1.get_num_tx_bytes() == rlc2.get_num_rx_bytes());
assert(rlc2.get_num_tx_bytes() == rlc1.get_num_rx_bytes());
} }
void retx_test() void retx_test()

@ -325,7 +325,7 @@ void stress_test(stress_test_args_t args)
srslte_rlc_config_t cnfg_; srslte_rlc_config_t cnfg_;
if (args.mode == "AM") { if (args.mode == "AM") {
// config RLC AM bearer // config RLC AM bearer
cnfg_.rlc_mode = LIBLTE_RRC_RLC_MODE_AM; cnfg_.rlc_mode = RLC_MODE_AM;
cnfg_.am.max_retx_thresh = 4; cnfg_.am.max_retx_thresh = 4;
cnfg_.am.poll_byte = 25*1000; cnfg_.am.poll_byte = 25*1000;
cnfg_.am.poll_pdu = 4; cnfg_.am.poll_pdu = 4;
@ -334,7 +334,7 @@ void stress_test(stress_test_args_t args)
cnfg_.am.t_status_prohibit = 5; cnfg_.am.t_status_prohibit = 5;
} else if (args.mode == "UM") { } else if (args.mode == "UM") {
// config UM bearer // config UM bearer
cnfg_.rlc_mode = LIBLTE_RRC_RLC_MODE_UM_BI; cnfg_.rlc_mode = RLC_MODE_UM;
cnfg_.um.t_reordering = 5; cnfg_.um.t_reordering = 5;
cnfg_.um.rx_mod = 32; cnfg_.um.rx_mod = 32;
cnfg_.um.rx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; cnfg_.um.rx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS;
@ -388,15 +388,23 @@ void stress_test(stress_test_args_t args)
pcap.close(); pcap.close();
} }
printf("RLC1 received %d SDUs in %ds (%.2f PDU/s)\n", rlc_metrics_t metrics;
rlc1.get_metrics(metrics);
printf("RLC1 received %d SDUs in %ds (%.2f PDU/s), Throughput: DL=%4.2f Mbps, UL=%4.2f Mbps\n",
tester1.get_nof_rx_pdus(), tester1.get_nof_rx_pdus(),
args.test_duration_sec, args.test_duration_sec,
(float)tester1.get_nof_rx_pdus()/args.test_duration_sec); (float)tester1.get_nof_rx_pdus()/args.test_duration_sec,
metrics.dl_tput_mbps,
metrics.ul_tput_mbps);
printf("RLC2 received %d SDUs in %ds (%.2f PDU/s)\n", rlc2.get_metrics(metrics);
printf("RLC2 received %d SDUs in %ds (%.2f PDU/s), Throughput: DL=%4.2f Mbps, UL=%4.2f Mbps\n",
tester2.get_nof_rx_pdus(), tester2.get_nof_rx_pdus(),
args.test_duration_sec, args.test_duration_sec,
(float)tester2.get_nof_rx_pdus()/args.test_duration_sec); (float)tester2.get_nof_rx_pdus()/args.test_duration_sec,
metrics.dl_tput_mbps,
metrics.ul_tput_mbps);
} }

@ -130,8 +130,8 @@ void basic_test()
cnfg.dl_um_bi_rlc.sn_field_len = LIBLTE_RRC_SN_FIELD_LENGTH_SIZE10; cnfg.dl_um_bi_rlc.sn_field_len = LIBLTE_RRC_SN_FIELD_LENGTH_SIZE10;
cnfg.ul_um_bi_rlc.sn_field_len = LIBLTE_RRC_SN_FIELD_LENGTH_SIZE10; cnfg.ul_um_bi_rlc.sn_field_len = LIBLTE_RRC_SN_FIELD_LENGTH_SIZE10;
rlc1.configure(&cnfg); assert(rlc1.configure(&cnfg) == true);
rlc2.configure(&cnfg); assert(rlc2.configure(&cnfg) == true);
tester.set_expected_sdu_len(1); tester.set_expected_sdu_len(1);

@ -68,7 +68,7 @@ private:
uint16_t rnti; uint16_t rnti;
srsenb::rlc_interface_pdcp *rlc; srsenb::rlc_interface_pdcp *rlc;
// rlc_interface_pdcp // rlc_interface_pdcp
void write_sdu(uint32_t lcid, srslte::byte_buffer_t *sdu); void write_sdu(uint32_t lcid, srslte::byte_buffer_t *sdu, bool blocking);
bool rb_is_um(uint32_t lcid); bool rb_is_um(uint32_t lcid);
}; };

@ -154,9 +154,8 @@ void pdcp::user_interface_gtpu::write_pdu(uint32_t lcid, srslte::byte_buffer_t *
gtpu->write_pdu(rnti, lcid, pdu); gtpu->write_pdu(rnti, lcid, pdu);
} }
void pdcp::user_interface_rlc::write_sdu(uint32_t lcid, srslte::byte_buffer_t* sdu) void pdcp::user_interface_rlc::write_sdu(uint32_t lcid, srslte::byte_buffer_t* sdu, bool blocking)
{ {
rlc->write_sdu(rnti, lcid, sdu); rlc->write_sdu(rnti, lcid, sdu);
} }

@ -123,7 +123,7 @@ void rlc::add_bearer_mrb(uint16_t rnti, uint32_t lcid)
{ {
pthread_rwlock_rdlock(&rwlock); pthread_rwlock_rdlock(&rwlock);
if (users.count(rnti)) { if (users.count(rnti)) {
users[rnti].rlc->add_bearer_mrb_enb(lcid); users[rnti].rlc->add_bearer_mrb(lcid);
} }
pthread_rwlock_unlock(&rwlock); pthread_rwlock_unlock(&rwlock);
} }
@ -190,7 +190,7 @@ void rlc::write_sdu(uint16_t rnti, uint32_t lcid, srslte::byte_buffer_t* sdu)
pthread_rwlock_rdlock(&rwlock); pthread_rwlock_rdlock(&rwlock);
if (users.count(rnti)) { if (users.count(rnti)) {
if(rnti != SRSLTE_MRNTI){ if(rnti != SRSLTE_MRNTI){
users[rnti].rlc->write_sdu_nb(lcid, sdu); users[rnti].rlc->write_sdu(lcid, sdu, false);
tx_queue = users[rnti].rlc->get_total_buffer_state(lcid); tx_queue = users[rnti].rlc->get_total_buffer_state(lcid);
}else { }else {
users[rnti].rlc->write_sdu_mch(lcid, sdu); users[rnti].rlc->write_sdu_mch(lcid, sdu);

@ -326,10 +326,12 @@ private:
typedef struct { typedef struct {
enum { enum {
PDU,
PCCH, PCCH,
STOP STOP
} command; } command;
byte_buffer_t *pdu; byte_buffer_t *pdu;
uint16_t lcid;
} cmd_msg_t; } cmd_msg_t;
bool running; bool running;
@ -606,6 +608,7 @@ private:
void send_rrc_ue_cap_info(); void send_rrc_ue_cap_info();
// Parsers // Parsers
void process_pdu(uint32_t lcid, byte_buffer_t *pdu);
void parse_dl_ccch(byte_buffer_t *pdu); void parse_dl_ccch(byte_buffer_t *pdu);
void parse_dl_dcch(uint32_t lcid, byte_buffer_t *pdu); void parse_dl_dcch(uint32_t lcid, byte_buffer_t *pdu);
void parse_dl_info_transfer(uint32_t lcid, byte_buffer_t *pdu); void parse_dl_info_transfer(uint32_t lcid, byte_buffer_t *pdu);

@ -343,7 +343,7 @@ void gw::run_thread()
{ {
gw_log->info_hex(pdu->msg, pdu->N_bytes, "TX PDU"); gw_log->info_hex(pdu->msg, pdu->N_bytes, "TX PDU");
while(run_enable && !pdcp->is_drb_enabled(cfg.lcid) && attach_wait < ATTACH_WAIT_TOUT) { while(run_enable && !pdcp->is_lcid_enabled(cfg.lcid) && attach_wait < ATTACH_WAIT_TOUT) {
if (!attach_wait) { if (!attach_wait) {
gw_log->info("LCID=%d not active, requesting NAS attach (%d/%d)\n", cfg.lcid, attach_wait, ATTACH_WAIT_TOUT); gw_log->info("LCID=%d not active, requesting NAS attach (%d/%d)\n", cfg.lcid, attach_wait, ATTACH_WAIT_TOUT);
if (!nas->attach_request()) { if (!nas->attach_request()) {
@ -361,11 +361,10 @@ void gw::run_thread()
} }
// Send PDU directly to PDCP // Send PDU directly to PDCP
if (pdcp->is_drb_enabled(cfg.lcid)) { if (pdcp->is_lcid_enabled(cfg.lcid)) {
pdu->set_timestamp(); pdu->set_timestamp();
ul_tput_bytes += pdu->N_bytes; ul_tput_bytes += pdu->N_bytes;
pdcp->write_sdu(cfg.lcid, pdu); pdcp->write_sdu(cfg.lcid, pdu, false);
do { do {
pdu = pool_allocate; pdu = pool_allocate;
if (!pdu) { if (!pdu) {

@ -32,7 +32,7 @@
#include <time.h> #include <time.h>
#include <inttypes.h> // for printing uint64_t #include <inttypes.h> // for printing uint64_t
#include <srslte/asn1/liblte_rrc.h> #include <srslte/asn1/liblte_rrc.h>
#include "srsue/hdr/upper/rrc.h" #include <srsue/hdr/upper/rrc.h>
#include "srslte/asn1/liblte_rrc.h" #include "srslte/asn1/liblte_rrc.h"
#include "srslte/common/security.h" #include "srslte/common/security.h"
#include "srslte/common/bcd_helpers.h" #include "srslte/common/bcd_helpers.h"
@ -248,11 +248,14 @@ void rrc::run_thread() {
while(running) { while(running) {
cmd_msg_t msg = cmd_q.wait_pop(); cmd_msg_t msg = cmd_q.wait_pop();
switch(msg.command) { switch(msg.command) {
case cmd_msg_t::STOP: case cmd_msg_t::PDU:
return; process_pdu(msg.lcid, msg.pdu);
break;
case cmd_msg_t::PCCH: case cmd_msg_t::PCCH:
process_pcch(msg.pdu); process_pcch(msg.pdu);
break; break;
case cmd_msg_t::STOP:
return;
} }
} }
} }
@ -1939,6 +1942,16 @@ void rrc::write_sdu(uint32_t lcid, byte_buffer_t *sdu) {
void rrc::write_pdu(uint32_t lcid, byte_buffer_t *pdu) { void rrc::write_pdu(uint32_t lcid, byte_buffer_t *pdu) {
rrc_log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU", get_rb_name(lcid).c_str()); rrc_log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU", get_rb_name(lcid).c_str());
// add PDU to command queue
cmd_msg_t msg;
msg.pdu = pdu;
msg.command = cmd_msg_t::PDU;
msg.lcid = lcid;
cmd_q.push(msg);
}
void rrc::process_pdu(uint32_t lcid, byte_buffer_t *pdu)
{
switch (lcid) { switch (lcid) {
case RB_ID_SRB0: case RB_ID_SRB0:
parse_dl_ccch(pdu); parse_dl_ccch(pdu);

Loading…
Cancel
Save