2020-11-26 01:25:22 -08:00
|
|
|
/**
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* \section COPYRIGHT
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2021-03-19 03:45:56 -07:00
|
|
|
* Copyright 2013-2021 Software Radio Systems Limited
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* By using this file, you agree to the terms and conditions set
|
|
|
|
* forth in the LICENSE file which can be found at the top level of
|
|
|
|
* the distribution.
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
#include "srsran/upper/pdcp.h"
|
|
|
|
#include "srsran/upper/pdcp_entity_nr.h"
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
namespace srsran {
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
pdcp::pdcp(srsran::task_sched_handle task_sched_, const char* logname) :
|
2021-02-10 02:47:56 -08:00
|
|
|
task_sched(task_sched_), logger(srslog::fetch_basic_logger(logname))
|
|
|
|
{}
|
2018-07-16 12:17:01 -07:00
|
|
|
|
|
|
|
pdcp::~pdcp()
|
|
|
|
{
|
2020-03-23 06:31:33 -07:00
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> lock(cache_mutex);
|
|
|
|
valid_lcids_cached.clear();
|
|
|
|
}
|
2018-07-16 12:17:01 -07:00
|
|
|
// destroy all remaining entities
|
|
|
|
pdcp_array.clear();
|
2018-12-30 13:57:33 -08:00
|
|
|
pdcp_array_mrb.clear();
|
2018-01-31 07:48:50 -08:00
|
|
|
}
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2021-04-13 06:56:51 -07:00
|
|
|
void pdcp::init(srsue::rlc_interface_pdcp* rlc_,
|
|
|
|
srsue::rrc_interface_pdcp* rrc_,
|
|
|
|
srsue::rrc_interface_pdcp* rrc_nr_,
|
|
|
|
srsue::gw_interface_pdcp* gw_)
|
|
|
|
{
|
|
|
|
init(rlc_, rrc_, gw_);
|
|
|
|
rrc_nr = rrc_nr_;
|
|
|
|
}
|
|
|
|
|
2019-06-27 01:50:47 -07:00
|
|
|
void pdcp::init(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_)
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
2019-11-18 10:07:14 -08:00
|
|
|
rlc = rlc_;
|
|
|
|
rrc = rrc_;
|
|
|
|
gw = gw_;
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
2019-11-18 10:07:14 -08:00
|
|
|
void pdcp::stop() {}
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2019-11-18 10:07:14 -08:00
|
|
|
void pdcp::reestablish()
|
|
|
|
{
|
2020-04-09 10:37:22 -07:00
|
|
|
for (auto& lcid_it : pdcp_array) {
|
|
|
|
lcid_it.second->reestablish();
|
2017-11-23 10:46:34 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-04 08:31:50 -07:00
|
|
|
void pdcp::reestablish(uint32_t lcid)
|
|
|
|
{
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array.at(lcid)->reestablish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-18 03:52:29 -07:00
|
|
|
void pdcp::reset()
|
|
|
|
{
|
2020-03-23 06:31:33 -07:00
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> lock(cache_mutex);
|
|
|
|
valid_lcids_cached.clear();
|
|
|
|
}
|
2018-07-25 06:08:35 -07:00
|
|
|
// destroy all bearers
|
2020-04-09 10:37:22 -07:00
|
|
|
pdcp_array.clear();
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
RRC/GW interface
|
|
|
|
*******************************************************************************/
|
2020-03-23 06:31:33 -07:00
|
|
|
|
|
|
|
// NOTE: Called from separate thread
|
2018-07-25 06:09:19 -07:00
|
|
|
bool pdcp::is_lcid_enabled(uint32_t lcid)
|
2017-09-18 05:02:31 -07:00
|
|
|
{
|
2020-03-23 06:31:33 -07:00
|
|
|
std::lock_guard<std::mutex> lock(cache_mutex);
|
|
|
|
return valid_lcids_cached.count(lcid) > 0;
|
2017-09-18 05:02:31 -07:00
|
|
|
}
|
|
|
|
|
2021-02-11 10:01:14 -08:00
|
|
|
void pdcp::write_sdu(uint32_t lcid, unique_byte_buffer_t sdu, int sn)
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
2018-07-16 12:17:01 -07:00
|
|
|
if (valid_lcid(lcid)) {
|
2021-02-11 10:01:14 -08:00
|
|
|
pdcp_array.at(lcid)->write_sdu(std::move(sdu), sn);
|
2018-03-06 03:41:44 -08:00
|
|
|
} else {
|
2021-02-10 02:47:56 -08:00
|
|
|
logger.warning("Writing sdu: lcid=%d. Deallocating sdu", lcid);
|
2018-03-06 03:41:44 -08:00
|
|
|
}
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
2019-05-13 07:34:15 -07:00
|
|
|
void pdcp::write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu)
|
2018-05-15 07:57:23 -07:00
|
|
|
{
|
2019-11-18 10:07:14 -08:00
|
|
|
if (valid_mch_lcid(lcid)) {
|
2020-07-10 13:23:35 -07:00
|
|
|
pdcp_array_mrb.at(lcid)->write_sdu(std::move(sdu));
|
2018-05-15 07:57:23 -07:00
|
|
|
}
|
|
|
|
}
|
2018-08-03 07:28:06 -07:00
|
|
|
|
2019-07-25 09:31:04 -07:00
|
|
|
void pdcp::add_bearer(uint32_t lcid, pdcp_config_t cfg)
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
2018-07-16 12:17:01 -07:00
|
|
|
if (not valid_lcid(lcid)) {
|
2020-06-16 04:08:34 -07:00
|
|
|
std::unique_ptr<pdcp_entity_base> entity;
|
2021-02-25 06:17:05 -08:00
|
|
|
// For now we create an pdcp entity lte for nr due to it's maturity
|
2021-04-13 06:56:51 -07:00
|
|
|
if (cfg.rat == srsran::srsran_rat_t::lte) {
|
|
|
|
entity.reset(new pdcp_entity_lte{rlc, rrc, gw, task_sched, logger, lcid});
|
|
|
|
} else if (cfg.rat == srsran::srsran_rat_t::nr) {
|
|
|
|
if (rrc_nr == nullptr) {
|
|
|
|
logger.warning("Cannot add PDCP entity - missing rrc_nr parent pointer");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
entity.reset(new pdcp_entity_lte{rlc, rrc_nr, gw, task_sched, logger, lcid});
|
|
|
|
}
|
|
|
|
|
2021-04-08 03:09:25 -07:00
|
|
|
if (not entity->configure(cfg)) {
|
|
|
|
logger.error("Can not configure PDCP entity");
|
|
|
|
return;
|
|
|
|
}
|
2021-04-09 04:28:25 -07:00
|
|
|
|
2020-06-16 04:08:34 -07:00
|
|
|
if (not pdcp_array.insert(std::make_pair(lcid, std::move(entity))).second) {
|
2021-02-10 02:47:56 -08:00
|
|
|
logger.error("Error inserting PDCP entity in to array.");
|
2020-03-23 07:00:12 -07:00
|
|
|
return;
|
2018-07-16 12:17:01 -07:00
|
|
|
}
|
2021-04-09 04:28:25 -07:00
|
|
|
logger.info(
|
|
|
|
"Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)", rrc->get_rb_name(lcid), lcid, cfg.bearer_id, cfg.sn_len);
|
2020-03-23 06:31:33 -07:00
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> lock(cache_mutex);
|
|
|
|
valid_lcids_cached.insert(lcid);
|
|
|
|
}
|
2017-05-18 03:52:29 -07:00
|
|
|
} else {
|
2021-04-09 04:28:25 -07:00
|
|
|
logger.info("Bearer %s already configured.", rrc->get_rb_name(lcid));
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-25 09:31:04 -07:00
|
|
|
void pdcp::add_bearer_mrb(uint32_t lcid, pdcp_config_t cfg)
|
2018-05-15 07:57:23 -07:00
|
|
|
{
|
2018-07-16 12:17:01 -07:00
|
|
|
if (not valid_mch_lcid(lcid)) {
|
2021-04-08 03:09:25 -07:00
|
|
|
std::unique_ptr<pdcp_entity_lte> entity;
|
2021-04-09 04:28:25 -07:00
|
|
|
entity.reset(new pdcp_entity_lte{rlc, rrc, gw, task_sched, logger, lcid});
|
|
|
|
if (not entity->configure(cfg)) {
|
2021-04-08 03:09:25 -07:00
|
|
|
logger.error("Can not configure PDCP entity");
|
2021-04-09 04:28:25 -07:00
|
|
|
return;
|
2021-04-08 03:09:25 -07:00
|
|
|
}
|
|
|
|
|
2021-04-09 04:28:25 -07:00
|
|
|
if (not pdcp_array_mrb.insert(std::make_pair(lcid, std::move(entity))).second) {
|
2021-02-10 02:47:56 -08:00
|
|
|
logger.error("Error inserting PDCP entity in to array.");
|
2020-03-23 07:00:12 -07:00
|
|
|
return;
|
2018-07-16 12:17:01 -07:00
|
|
|
}
|
2021-04-09 04:28:25 -07:00
|
|
|
logger.info(
|
|
|
|
"Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)", rrc->get_rb_name(lcid), lcid, cfg.bearer_id, cfg.sn_len);
|
2018-05-15 07:57:23 -07:00
|
|
|
} else {
|
2021-04-09 04:28:25 -07:00
|
|
|
logger.warning("Bearer %s already configured. Reconfiguration not supported", rrc->get_rb_name(lcid));
|
2018-05-15 07:57:23 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-03 07:28:06 -07:00
|
|
|
void pdcp::del_bearer(uint32_t lcid)
|
|
|
|
{
|
2020-03-23 06:31:33 -07:00
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> lock(cache_mutex);
|
|
|
|
valid_lcids_cached.erase(lcid);
|
|
|
|
}
|
2018-08-03 07:28:06 -07:00
|
|
|
if (valid_lcid(lcid)) {
|
2020-04-09 10:47:17 -07:00
|
|
|
pdcp_array.erase(lcid);
|
2021-04-09 04:28:25 -07:00
|
|
|
logger.warning("Deleted PDCP bearer %s", rrc->get_rb_name(lcid));
|
2018-08-03 07:28:06 -07:00
|
|
|
} else {
|
2021-04-09 04:28:25 -07:00
|
|
|
logger.warning("Can't delete bearer %s. Bearer doesn't exist.", rrc->get_rb_name(lcid));
|
2018-08-03 07:28:06 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-17 04:10:44 -07:00
|
|
|
void pdcp::change_lcid(uint32_t old_lcid, uint32_t new_lcid)
|
|
|
|
{
|
|
|
|
// make sure old LCID exists and new LCID is still free
|
|
|
|
if (valid_lcid(old_lcid) && not valid_lcid(new_lcid)) {
|
|
|
|
// insert old PDCP entity into new LCID
|
2020-06-16 04:08:34 -07:00
|
|
|
std::lock_guard<std::mutex> lock(cache_mutex);
|
|
|
|
auto it = pdcp_array.find(old_lcid);
|
|
|
|
std::unique_ptr<pdcp_entity_base> pdcp_entity = std::move(it->second);
|
2020-04-09 10:37:22 -07:00
|
|
|
if (not pdcp_array.insert(std::make_pair(new_lcid, std::move(pdcp_entity))).second) {
|
2021-02-10 02:47:56 -08:00
|
|
|
logger.error("Error inserting PDCP entity into array.");
|
2020-03-23 07:00:12 -07:00
|
|
|
return;
|
2018-09-17 04:10:44 -07:00
|
|
|
}
|
|
|
|
// erase from old position
|
|
|
|
pdcp_array.erase(it);
|
2020-04-09 10:37:22 -07:00
|
|
|
valid_lcids_cached.erase(old_lcid);
|
|
|
|
valid_lcids_cached.insert(new_lcid);
|
2021-02-10 02:47:56 -08:00
|
|
|
logger.warning("Changed LCID of PDCP bearer from %d to %d", old_lcid, new_lcid);
|
2018-09-17 04:10:44 -07:00
|
|
|
} else {
|
2021-02-10 02:47:56 -08:00
|
|
|
logger.error("Can't change PDCP of bearer %s from %d to %d. Bearer doesn't exist or new LCID already occupied.",
|
2021-04-09 04:28:25 -07:00
|
|
|
rrc->get_rb_name(old_lcid),
|
2021-02-10 02:47:56 -08:00
|
|
|
old_lcid,
|
|
|
|
new_lcid);
|
2018-09-17 04:10:44 -07:00
|
|
|
}
|
|
|
|
}
|
2018-08-03 07:28:06 -07:00
|
|
|
|
2020-02-20 07:08:04 -08:00
|
|
|
void pdcp::config_security(uint32_t lcid, as_security_config_t sec_cfg)
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
2018-07-16 12:17:01 -07:00
|
|
|
if (valid_lcid(lcid)) {
|
2020-02-20 07:08:04 -08:00
|
|
|
pdcp_array.at(lcid)->config_security(sec_cfg);
|
2018-07-16 12:17:01 -07:00
|
|
|
}
|
2017-12-01 11:19:38 -08:00
|
|
|
}
|
|
|
|
|
2020-02-20 07:08:04 -08:00
|
|
|
void pdcp::config_security_all(as_security_config_t sec_cfg)
|
2017-12-02 13:43:35 -08:00
|
|
|
{
|
2020-04-09 10:37:22 -07:00
|
|
|
for (auto& it : pdcp_array) {
|
|
|
|
it.second->config_security(sec_cfg);
|
2017-12-02 13:43:35 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
void pdcp::enable_integrity(uint32_t lcid, srsran_direction_t direction)
|
2017-12-01 11:19:38 -08:00
|
|
|
{
|
2018-07-16 12:17:01 -07:00
|
|
|
if (valid_lcid(lcid)) {
|
2020-03-01 05:51:51 -08:00
|
|
|
pdcp_array.at(lcid)->enable_integrity(direction);
|
2018-07-16 12:17:01 -07:00
|
|
|
}
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
void pdcp::enable_encryption(uint32_t lcid, srsran_direction_t direction)
|
2017-11-30 09:09:12 -08:00
|
|
|
{
|
2018-07-16 12:17:01 -07:00
|
|
|
if (valid_lcid(lcid)) {
|
2020-03-01 05:51:51 -08:00
|
|
|
pdcp_array.at(lcid)->enable_encryption(direction);
|
2018-07-16 12:17:01 -07:00
|
|
|
}
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
void pdcp::enable_security_timed(uint32_t lcid, srsran_direction_t direction, uint32_t sn)
|
2020-04-08 11:53:46 -07:00
|
|
|
{
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array.at(lcid)->enable_security_timed(direction, sn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-18 10:33:19 -08:00
|
|
|
void pdcp::send_status_report()
|
|
|
|
{
|
|
|
|
for (auto& lcid_it : pdcp_array) {
|
|
|
|
lcid_it.second->send_status_report();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-12 10:05:48 -08:00
|
|
|
void pdcp::send_status_report(uint32_t lcid)
|
|
|
|
{
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array.at(lcid)->send_status_report();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
bool pdcp::get_bearer_state(uint32_t lcid, srsran::pdcp_lte_state_t* state)
|
2019-12-06 11:39:22 -08:00
|
|
|
{
|
|
|
|
if (not valid_lcid(lcid)) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-06-17 08:40:04 -07:00
|
|
|
pdcp_array[lcid]->get_bearer_state(state);
|
2019-12-06 11:39:22 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
bool pdcp::set_bearer_state(uint32_t lcid, const srsran::pdcp_lte_state_t& state)
|
2020-06-11 07:55:24 -07:00
|
|
|
{
|
|
|
|
if (not valid_lcid(lcid)) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-03-11 04:17:33 -08:00
|
|
|
pdcp_array[lcid]->set_bearer_state(state, true);
|
2020-06-12 07:23:55 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
std::map<uint32_t, srsran::unique_byte_buffer_t> pdcp::get_buffered_pdus(uint32_t lcid)
|
2021-01-28 09:22:19 -08:00
|
|
|
{
|
|
|
|
if (not valid_lcid(lcid)) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
return pdcp_array[lcid]->get_buffered_pdus();
|
|
|
|
}
|
|
|
|
|
2017-05-18 03:52:29 -07:00
|
|
|
/*******************************************************************************
|
|
|
|
RLC interface
|
|
|
|
*******************************************************************************/
|
2019-05-13 07:34:15 -07:00
|
|
|
void pdcp::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu)
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
2018-07-16 12:17:01 -07:00
|
|
|
if (valid_lcid(lcid)) {
|
2019-04-29 12:16:51 -07:00
|
|
|
pdcp_array.at(lcid)->write_pdu(std::move(pdu));
|
2018-03-06 03:41:44 -08:00
|
|
|
} else {
|
2021-02-10 02:47:56 -08:00
|
|
|
logger.warning("Writing pdu: lcid=%d. Deallocating pdu", lcid);
|
2018-03-06 03:41:44 -08:00
|
|
|
}
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
2019-05-13 07:34:15 -07:00
|
|
|
void pdcp::write_pdu_bcch_bch(unique_byte_buffer_t sdu)
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
2019-04-29 12:16:51 -07:00
|
|
|
rrc->write_pdu_bcch_bch(std::move(sdu));
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
2018-07-17 06:27:04 -07:00
|
|
|
|
2019-05-13 07:34:15 -07:00
|
|
|
void pdcp::write_pdu_bcch_dlsch(unique_byte_buffer_t sdu)
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
2019-04-29 12:16:51 -07:00
|
|
|
rrc->write_pdu_bcch_dlsch(std::move(sdu));
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
2019-05-13 07:34:15 -07:00
|
|
|
void pdcp::write_pdu_pcch(unique_byte_buffer_t sdu)
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
2019-04-29 12:16:51 -07:00
|
|
|
rrc->write_pdu_pcch(std::move(sdu));
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
2019-05-13 07:34:15 -07:00
|
|
|
void pdcp::write_pdu_mch(uint32_t lcid, unique_byte_buffer_t sdu)
|
2018-05-15 07:57:23 -07:00
|
|
|
{
|
2018-07-16 12:17:01 -07:00
|
|
|
if (0 == lcid) {
|
2019-04-29 12:16:51 -07:00
|
|
|
rrc->write_pdu_mch(lcid, std::move(sdu));
|
2018-05-15 07:57:23 -07:00
|
|
|
} else {
|
2019-04-29 12:16:51 -07:00
|
|
|
gw->write_pdu_mch(lcid, std::move(sdu));
|
2018-05-15 07:57:23 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-09 05:41:46 -08:00
|
|
|
void pdcp::notify_delivery(uint32_t lcid, const pdcp_sn_vector_t& pdcp_sns)
|
2020-09-15 04:21:39 -07:00
|
|
|
{
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array.at(lcid)->notify_delivery(pdcp_sns);
|
|
|
|
} else {
|
2021-02-10 02:47:56 -08:00
|
|
|
logger.warning("Could not notify delivery: lcid=%d, nof_sn=%ld.", lcid, pdcp_sns.size());
|
2020-09-15 04:21:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
void pdcp::notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns)
|
2021-02-22 02:36:14 -08:00
|
|
|
{
|
|
|
|
if (valid_lcid(lcid)) {
|
|
|
|
pdcp_array.at(lcid)->notify_failure(pdcp_sns);
|
|
|
|
} else {
|
|
|
|
logger.warning("Could not notify failure: lcid=%d, nof_sn=%ld.", lcid, pdcp_sns.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-18 03:52:29 -07:00
|
|
|
bool pdcp::valid_lcid(uint32_t lcid)
|
|
|
|
{
|
2021-03-19 03:45:56 -07:00
|
|
|
if (lcid >= SRSRAN_N_RADIO_BEARERS) {
|
|
|
|
logger.error("Radio bearer id must be in [0:%d] - %d", SRSRAN_N_RADIO_BEARERS, lcid);
|
2017-05-18 03:52:29 -07:00
|
|
|
return false;
|
|
|
|
}
|
2018-07-16 12:17:01 -07:00
|
|
|
|
2020-04-09 10:37:22 -07:00
|
|
|
return pdcp_array.find(lcid) != pdcp_array.end();
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
2018-05-15 07:57:23 -07:00
|
|
|
bool pdcp::valid_mch_lcid(uint32_t lcid)
|
|
|
|
{
|
2021-03-19 03:45:56 -07:00
|
|
|
if (lcid >= SRSRAN_N_MCH_LCIDS) {
|
|
|
|
logger.error("Radio bearer id must be in [0:%d] - %d", SRSRAN_N_RADIO_BEARERS, lcid);
|
2018-05-15 07:57:23 -07:00
|
|
|
return false;
|
|
|
|
}
|
2018-07-16 12:17:01 -07:00
|
|
|
|
2020-04-09 10:37:22 -07:00
|
|
|
return pdcp_array_mrb.find(lcid) != pdcp_array_mrb.end();
|
2018-05-15 07:57:23 -07:00
|
|
|
}
|
|
|
|
|
2021-02-15 05:20:44 -08:00
|
|
|
void pdcp::get_metrics(pdcp_metrics_t& m, const uint32_t nof_tti)
|
|
|
|
{
|
|
|
|
std::chrono::duration<double> secs = std::chrono::high_resolution_clock::now() - metrics_tp;
|
|
|
|
|
|
|
|
for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); ++it) {
|
|
|
|
pdcp_bearer_metrics_t metrics = it->second->get_metrics();
|
|
|
|
|
|
|
|
// Rx/Tx rate based on real time
|
|
|
|
double rx_rate_mbps_real_time = (metrics.num_rx_pdu_bytes * 8 / (double)1e6) / secs.count();
|
|
|
|
double tx_rate_mbps_real_time = (metrics.num_tx_pdu_bytes * 8 / (double)1e6) / secs.count();
|
|
|
|
|
|
|
|
// Rx/Tx rate based on number of TTIs
|
|
|
|
double rx_rate_mbps = (nof_tti > 0) ? ((metrics.num_rx_pdu_bytes * 8 / (double)1e6) / (nof_tti / 1000.0)) : 0.0;
|
|
|
|
double tx_rate_mbps = (nof_tti > 0) ? ((metrics.num_tx_pdu_bytes * 8 / (double)1e6) / (nof_tti / 1000.0)) : 0.0;
|
|
|
|
|
|
|
|
logger.info("lcid=%d, rx_rate_mbps=%4.2f (real=%4.2f), tx_rate_mbps=%4.2f (real=%4.2f)",
|
|
|
|
it->first,
|
|
|
|
rx_rate_mbps,
|
|
|
|
rx_rate_mbps_real_time,
|
|
|
|
tx_rate_mbps,
|
|
|
|
tx_rate_mbps_real_time);
|
|
|
|
m.bearer[it->first] = metrics;
|
|
|
|
}
|
|
|
|
|
|
|
|
reset_metrics();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pdcp::reset_metrics()
|
|
|
|
{
|
|
|
|
for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); ++it) {
|
|
|
|
it->second->reset_metrics();
|
|
|
|
}
|
|
|
|
|
|
|
|
metrics_tp = std::chrono::high_resolution_clock::now();
|
|
|
|
}
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
} // namespace srsran
|