2019-04-26 12:27:38 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2013-2019 Software Radio Systems Limited
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* This file is part of srsLTE.
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2017-05-18 03:52:29 -07:00
|
|
|
* 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.
|
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
2017-05-18 03:52:29 -07:00
|
|
|
* 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/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#ifndef SRSLTE_RLC_H
|
|
|
|
#define SRSLTE_RLC_H
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2017-05-31 14:39:17 -07:00
|
|
|
#include "srslte/common/buffer_pool.h"
|
|
|
|
#include "srslte/common/common.h"
|
2019-12-16 07:04:22 -08:00
|
|
|
#include "srslte/common/log.h"
|
2017-06-01 03:25:42 -07:00
|
|
|
#include "srslte/interfaces/ue_interfaces.h"
|
2017-07-04 07:29:33 -07:00
|
|
|
#include "srslte/upper/rlc_common.h"
|
2019-12-16 07:04:22 -08:00
|
|
|
#include "srslte/upper/rlc_metrics.h"
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2017-06-01 03:25:42 -07:00
|
|
|
namespace srslte {
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* RLC Layer
|
|
|
|
* Ref: 3GPP TS 36.322 v10.0.0
|
|
|
|
* Single interface for RLC layer - contains separate RLC entities for
|
|
|
|
* each bearer.
|
|
|
|
***************************************************************************/
|
2019-11-25 10:34:18 -08:00
|
|
|
class rlc : public srsue::rlc_interface_mac, public srsue::rlc_interface_pdcp, public srsue::rlc_interface_rrc
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
|
|
|
public:
|
2019-06-27 01:50:47 -07:00
|
|
|
rlc(log* rlc_log_);
|
2018-07-20 01:19:08 -07:00
|
|
|
virtual ~rlc();
|
2019-10-21 10:00:49 -07:00
|
|
|
void init(srsue::pdcp_interface_rlc* pdcp_,
|
|
|
|
srsue::rrc_interface_rlc* rrc_,
|
|
|
|
srslte::timer_handler* timers_,
|
|
|
|
uint32_t lcid_);
|
2017-05-18 03:52:29 -07:00
|
|
|
void stop();
|
|
|
|
|
2019-09-04 06:28:09 -07:00
|
|
|
void get_metrics(rlc_metrics_t& m);
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
// PDCP interface
|
2019-05-13 07:34:15 -07:00
|
|
|
void write_sdu(uint32_t lcid, unique_byte_buffer_t sdu, bool blocking = true);
|
|
|
|
void write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu);
|
2017-11-23 10:46:34 -08:00
|
|
|
bool rb_is_um(uint32_t lcid);
|
2019-11-25 10:34:18 -08:00
|
|
|
void discard_sdu(uint32_t lcid, uint32_t discard_sn);
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
// MAC interface
|
2018-11-30 03:26:37 -08:00
|
|
|
bool has_data(const uint32_t lcid);
|
2019-12-13 04:04:47 -08:00
|
|
|
bool is_suspended(const uint32_t lcid);
|
2018-11-30 03:26:37 -08:00
|
|
|
uint32_t get_buffer_state(const uint32_t lcid);
|
2018-05-15 07:57:23 -07:00
|
|
|
uint32_t get_total_mch_buffer_state(uint32_t lcid);
|
2019-12-16 07:04:22 -08:00
|
|
|
int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
|
|
|
|
int read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
|
2018-05-15 07:57:23 -07:00
|
|
|
int get_increment_sequence_num();
|
2019-12-16 07:04:22 -08:00
|
|
|
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_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);
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
// RRC interface
|
2017-11-23 10:46:34 -08:00
|
|
|
void reestablish();
|
2018-09-18 05:55:05 -07:00
|
|
|
void reestablish(uint32_t lcid);
|
2017-05-18 03:52:29 -07:00
|
|
|
void reset();
|
2017-08-22 06:06:51 -07:00
|
|
|
void empty_queue();
|
2019-07-04 09:15:40 -07:00
|
|
|
void add_bearer(uint32_t lcid, rlc_config_t cnfg);
|
2018-05-15 07:57:23 -07:00
|
|
|
void add_bearer_mrb(uint32_t lcid);
|
2018-08-03 07:28:06 -07:00
|
|
|
void del_bearer(uint32_t lcid);
|
2018-09-25 05:04:06 -07:00
|
|
|
void del_bearer_mrb(uint32_t lcid);
|
2019-07-09 13:54:04 -07:00
|
|
|
void suspend_bearer(uint32_t lcid);
|
2019-06-04 08:29:02 -07:00
|
|
|
void resume_bearer(uint32_t lcid);
|
2018-09-17 04:11:03 -07:00
|
|
|
void change_lcid(uint32_t old_lcid, uint32_t new_lcid);
|
2018-11-02 13:46:03 -07:00
|
|
|
bool has_bearer(uint32_t lcid);
|
2018-07-20 01:19:08 -07:00
|
|
|
|
2017-05-18 03:52:29 -07:00
|
|
|
private:
|
2019-06-27 01:50:47 -07:00
|
|
|
void reset_metrics();
|
|
|
|
|
2019-10-21 10:00:49 -07:00
|
|
|
byte_buffer_pool* pool = nullptr;
|
|
|
|
srslte::log* rlc_log = nullptr;
|
|
|
|
srsue::pdcp_interface_rlc* pdcp = nullptr;
|
|
|
|
srsue::rrc_interface_rlc* rrc = nullptr;
|
|
|
|
srslte::timer_handler* timers = nullptr;
|
2018-07-20 01:19:08 -07:00
|
|
|
|
2019-09-04 06:28:09 -07:00
|
|
|
typedef std::map<uint16_t, rlc_common*> rlc_map_t;
|
2018-07-20 01:19:08 -07:00
|
|
|
typedef std::pair<uint16_t, rlc_common*> rlc_map_pair_t;
|
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
rlc_map_t rlc_array, rlc_array_mrb;
|
2018-07-20 01:19:08 -07:00
|
|
|
pthread_rwlock_t rwlock;
|
|
|
|
|
2019-06-27 01:50:47 -07:00
|
|
|
uint32_t default_lcid = 0;
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2018-07-20 01:19:08 -07:00
|
|
|
// Timer needed for metrics calculation
|
2019-06-27 01:50:47 -07:00
|
|
|
struct timeval metrics_time[3] = {};
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
bool valid_lcid(uint32_t lcid);
|
2018-05-15 07:57:23 -07:00
|
|
|
bool valid_lcid_mrb(uint32_t lcid);
|
2017-05-18 03:52:29 -07:00
|
|
|
};
|
|
|
|
|
2019-08-07 05:32:14 -07:00
|
|
|
} // namespace srslte
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#endif // SRSLTE_RLC_H
|