rlc - usage of memory pool to allocate RLC bearers

master
Francisco 4 years ago committed by Francisco Paisana
parent 8fe27a72d0
commit 75e9700de0

@ -0,0 +1,27 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2021 Software Radio Systems Limited
*
* 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.
*
*/
#ifndef SRSRAN_BEARER_MEM_POOL_H
#define SRSRAN_BEARER_MEM_POOL_H
#include <cstddef>
namespace srsran {
// Allocation of objects in rnti-dedicated memory pool
void reserve_rlc_memblocks(size_t nof_blocks);
void* allocate_rlc_bearer(std::size_t size);
void deallocate_rlc_bearer(void* p);
} // namespace srsran
#endif // SRSRAN_BEARER_MEM_POOL_H

@ -15,6 +15,7 @@
#include "srsran/adt/circular_buffer.h" #include "srsran/adt/circular_buffer.h"
#include "srsran/interfaces/rlc_interface_types.h" #include "srsran/interfaces/rlc_interface_types.h"
#include "srsran/upper/bearer_mem_pool.h"
#include "srsran/upper/rlc_metrics.h" #include "srsran/upper/rlc_metrics.h"
#include <stdlib.h> #include <stdlib.h>
@ -270,6 +271,9 @@ public:
virtual void set_bsr_callback(bsr_callback_t callback) = 0; virtual void set_bsr_callback(bsr_callback_t callback) = 0;
void* operator new(size_t sz) { return allocate_rlc_bearer(sz); }
void operator delete(void* p) { return deallocate_rlc_bearer(p); }
private: private:
bool suspended = false; bool suspended = false;

@ -18,7 +18,8 @@ set(SOURCES gtpu.cc
rlc_am_lte.cc rlc_am_lte.cc
pdcp_entity_nr.cc pdcp_entity_nr.cc
rlc_um_nr.cc rlc_um_nr.cc
rlc_am_nr.cc) rlc_am_nr.cc
bearer_mem_pool.cc)
add_library(srsran_upper STATIC ${SOURCES}) add_library(srsran_upper STATIC ${SOURCES})
target_link_libraries(srsran_upper srsran_common srsran_asn1) target_link_libraries(srsran_upper srsran_common srsran_asn1)

@ -0,0 +1,44 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2021 Software Radio Systems Limited
*
* 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.
*
*/
#include "srsran/upper/bearer_mem_pool.h"
#include "srsran/adt/pool/batch_mem_pool.h"
#include "srsran/upper/rlc_am_lte.h"
#include "srsran/upper/rlc_um_lte.h"
#include "srsran/upper/rlc_um_nr.h"
namespace srsran {
srsran::background_mem_pool* get_bearer_pool()
{
static background_mem_pool pool(
4, std::max(std::max(sizeof(rlc_am_lte), sizeof(rlc_um_lte)), sizeof(rlc_um_nr)), 8, 8);
return &pool;
}
void reserve_rlc_memblocks(size_t nof_blocks)
{
srsran::background_mem_pool* pool = get_bearer_pool();
while (pool->cache_size() < nof_blocks) {
pool->allocate_batch();
}
}
void* allocate_rlc_bearer(std::size_t sz)
{
return get_bearer_pool()->allocate_node(sz);
}
void deallocate_rlc_bearer(void* p)
{
get_bearer_pool()->deallocate_node(p);
}
} // namespace srsran

@ -15,6 +15,7 @@
#include "srsenb/hdr/enb.h" #include "srsenb/hdr/enb.h"
#include "srsran/interfaces/enb_metrics_interface.h" #include "srsran/interfaces/enb_metrics_interface.h"
#include "srsran/srslog/event_trace.h" #include "srsran/srslog/event_trace.h"
#include "srsran/upper/bearer_mem_pool.h"
using namespace srsran; using namespace srsran;
@ -71,8 +72,10 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
args = args_; args = args_;
rrc_cfg = rrc_cfg_; rrc_cfg = rrc_cfg_;
// Init RNTI memory pool // Init RNTI and bearer memory pools
reserve_rnti_memblocks(args.mac.max_nof_ues); reserve_rnti_memblocks(args.mac.max_nof_ues);
uint32_t min_nof_bearers_per_ue = 4;
reserve_rlc_memblocks(args.mac.max_nof_ues * min_nof_bearers_per_ue);
// setup logging for each layer // setup logging for each layer
mac_logger.set_level(srslog::str_to_basic_level(args.log.mac_level)); mac_logger.set_level(srslog::str_to_basic_level(args.log.mac_level));

Loading…
Cancel
Save